Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Apr 2026 22:58:51 +0000
From:      Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 72043945c3c6 - main - nd6: Remove goto and unused condition in prelist_update
Message-ID:  <69e2bb2b.38d07.63bed8b7@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by pouria:

URL: https://cgit.FreeBSD.org/src/commit/?id=72043945c3c6e924ac57ace76ec0a4447d05d905

commit 72043945c3c6e924ac57ace76ec0a4447d05d905
Author:     Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
AuthorDate: 2026-04-17 16:57:47 +0000
Commit:     Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
CommitDate: 2026-04-17 22:52:23 +0000

    nd6: Remove goto and unused condition in prelist_update
    
    While here, style it.
    
    Reviewed by: markj, zlei
    Differential Revision: https://reviews.freebsd.org/D56136
---
 sys/netinet6/nd6_rtr.c | 41 +++++++++++++----------------------------
 1 file changed, 13 insertions(+), 28 deletions(-)

diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c
index e0ea36586985..637f00bef2c9 100644
--- a/sys/netinet6/nd6_rtr.c
+++ b/sys/netinet6/nd6_rtr.c
@@ -1746,38 +1746,26 @@ prelist_update(struct nd_prefixctl *new, struct nd_defrouter *dr,
 			ia6_match = ia6;
 	}
 
-	if (ia6_match == NULL && new->ndpr_vltime) {
+	/*
+	 * 5.5.3 (d) (continued)
+	 * If no address matched and the valid lifetime is non-zero,
+	 * create a new address.
+	 */
+	if (ia6_match == NULL && new->ndpr_vltime != 0) {
 		int ifidlen;
 
-		/*
-		 * 5.5.3 (d) (continued)
-		 * No address matched and the valid lifetime is non-zero.
-		 * Create a new address.
-		 */
-
 		/*
 		 * Prefix Length check:
 		 * If the sum of the prefix length and interface identifier
 		 * length does not equal 128 bits, the Prefix Information
 		 * option MUST be ignored.  The length of the interface
-		 * identifier is defined in a separate link-type specific
-		 * document.
+		 * identifier is defined in a separate link-type specific document.
 		 */
 		ifidlen = in6_if2idlen(ifp);
-		if (ifidlen < 0) {
-			/* this should not happen, so we always log it. */
-			log(LOG_ERR, "prelist_update: IFID undefined (%s)\n",
-			    if_name(ifp));
-			goto end;
-		}
 		if (ifidlen + pr->ndpr_plen != 128) {
-			nd6log((LOG_INFO,
-			    "%s: invalid prefixlen %d for %s, ignored\n",
+			nd6log((LOG_INFO, "%s: invalid prefixlen %d for %s, ignored\n",
 			    __func__, pr->ndpr_plen, if_name(ifp)));
-			goto end;
-		}
-
-		if ((ia6 = in6_ifadd(new, mcast)) != NULL) {
+		} else if ((ia6 = in6_ifadd(new, mcast)) != NULL) {
 			/*
 			 * note that we should use pr (not new) for reference.
 			 */
@@ -1789,8 +1777,7 @@ prelist_update(struct nd_prefixctl *new, struct nd_defrouter *dr,
 			 * When a new public address is created as described
 			 * in RFC2462, also create a new temporary address.
 			 *
-			 * RFC 3041 3.5.
-			 * When an interface connects to a new link, a new
+			 * 3.5: When an interface connects to a new link, a new
 			 * randomized interface identifier should be generated
 			 * immediately together with a new set of temporary
 			 * addresses.  Thus, we specifiy 1 as the 2nd arg of
@@ -1802,9 +1789,9 @@ prelist_update(struct nd_prefixctl *new, struct nd_defrouter *dr,
 			if (V_ip6_use_tempaddr && !has_temporary) {
 				int e;
 				if ((e = in6_tmpifadd(ia6, 1, 1)) != 0) {
-					nd6log((LOG_NOTICE, "%s: failed to "
-					    "create a temporary address "
-					    "(errno=%d)\n", __func__, e));
+					nd6log((LOG_NOTICE,
+					    "%s: failed to create a temporary address (errno=%d)\n",
+					    __func__, e));
 				}
 			}
 			ifa_free(&ia6->ia_ifa);
@@ -1818,9 +1805,7 @@ prelist_update(struct nd_prefixctl *new, struct nd_defrouter *dr,
 		}
 	}
 
-end:
 	nd6_prefix_rele(pr);
-	return;
 }
 
 /*


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69e2bb2b.38d07.63bed8b7>