Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Apr 2026 22:58:45 +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: d96e8cb4e728 - main - nd6: Break nd6_prefix_update out of prelist_update
Message-ID:  <69e2bb25.39818.171c71b0@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=d96e8cb4e72847ac545423460af122fa14b2b1f1

commit d96e8cb4e72847ac545423460af122fa14b2b1f1
Author:     Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
AuthorDate: 2026-04-16 22:18:02 +0000
Commit:     Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
CommitDate: 2026-04-17 22:52:13 +0000

    nd6: Break nd6_prefix_update out of prelist_update
    
    if PI exists, call prefix_update, instead of doing it inside
    the prelist_update.
    no functional change intended.
    
    Reviewed by: markj
    Differential Revision: https://reviews.freebsd.org/D56130
---
 sys/netinet6/nd6_rtr.c | 78 ++++++++++++++++++++++++++------------------------
 1 file changed, 41 insertions(+), 37 deletions(-)

diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c
index 623bfd60918e..7b7db1b95e31 100644
--- a/sys/netinet6/nd6_rtr.c
+++ b/sys/netinet6/nd6_rtr.c
@@ -1516,6 +1516,45 @@ nd6_prefix_del(struct nd_prefix *pr)
 	pfxlist_onlink_check();
 }
 
+static void
+nd6_prefix_update(struct nd_prefixctl *new, struct nd_prefix *pr)
+{
+	int error;
+	char ip6buf[INET6_ADDRSTRLEN];
+
+	/*
+	 * Update prefix information.  Note that the on-link (L) bit
+	 * and the autonomous (A) bit should NOT be changed from 1
+	 * to 0.
+	 */
+	if (new->ndpr_raf_onlink == 1)
+		pr->ndpr_raf_onlink = 1;
+	if (new->ndpr_raf_auto == 1)
+		pr->ndpr_raf_auto = 1;
+	if (new->ndpr_raf_onlink != 0) {
+		pr->ndpr_vltime = new->ndpr_vltime;
+		pr->ndpr_pltime = new->ndpr_pltime;
+		in6_init_prefix_ltimes(pr);
+		pr->ndpr_lastupdate = time_uptime;
+	}
+
+	if (new->ndpr_raf_onlink != 0 &&
+	    (pr->ndpr_stateflags & NDPRF_ONLINK) == 0) {
+		ND6_ONLINK_LOCK();
+		if ((error = nd6_prefix_onlink(pr)) != 0) {
+			nd6log((LOG_ERR,
+			    "%s: failed to make the prefix %s/%d "
+			    "on-link on %s (errno=%d)\n", __func__,
+			    ip6_sprintf(ip6buf,
+			        &pr->ndpr_prefix.sin6_addr),
+			    pr->ndpr_plen, if_name(pr->ndpr_ifp),
+			    error));
+			/* proceed anyway. XXX: is it correct? */
+		}
+		ND6_ONLINK_UNLOCK();
+	}
+}
+
 static int
 prelist_update(struct nd_prefixctl *new, struct nd_defrouter *dr,
     bool auth, int mcast)
@@ -1531,44 +1570,9 @@ prelist_update(struct nd_prefixctl *new, struct nd_defrouter *dr,
 
 	NET_EPOCH_ASSERT();
 
+	/* check if prefix already exists on the same interface */
 	if ((pr = nd6_prefix_lookup(new)) != NULL) {
-		/*
-		 * nd6_prefix_lookup() ensures that pr and new have the same
-		 * prefix on a same interface.
-		 */
-
-		/*
-		 * Update prefix information.  Note that the on-link (L) bit
-		 * and the autonomous (A) bit should NOT be changed from 1
-		 * to 0.
-		 */
-		if (new->ndpr_raf_onlink == 1)
-			pr->ndpr_raf_onlink = 1;
-		if (new->ndpr_raf_auto == 1)
-			pr->ndpr_raf_auto = 1;
-		if (new->ndpr_raf_onlink) {
-			pr->ndpr_vltime = new->ndpr_vltime;
-			pr->ndpr_pltime = new->ndpr_pltime;
-			in6_init_prefix_ltimes(pr);
-			pr->ndpr_lastupdate = time_uptime;
-		}
-
-		if (new->ndpr_raf_onlink &&
-		    (pr->ndpr_stateflags & NDPRF_ONLINK) == 0) {
-			ND6_ONLINK_LOCK();
-			if ((error = nd6_prefix_onlink(pr)) != 0) {
-				nd6log((LOG_ERR,
-				    "%s: failed to make the prefix %s/%d "
-				    "on-link on %s (errno=%d)\n", __func__,
-				    ip6_sprintf(ip6buf,
-				        &pr->ndpr_prefix.sin6_addr),
-				    pr->ndpr_plen, if_name(pr->ndpr_ifp),
-				    error));
-				/* proceed anyway. XXX: is it correct? */
-			}
-			ND6_ONLINK_UNLOCK();
-		}
-
+		nd6_prefix_update(new, pr);
 		if (dr != NULL)
 			pfxrtr_add(pr, dr);
 	} else {


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69e2bb25.39818.171c71b0>