Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Apr 2026 22:58:46 +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: ced1de238fbe - main - nd6: Break pfxrtr_add out of nd6_prelist_add
Message-ID:  <69e2bb26.39112.75e65f90@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=ced1de238fbe620e2b110c34561d63656bd2043c

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

    nd6: Break pfxrtr_add out of nd6_prelist_add
    
    Updating defrouter only required by `prelist_update()`.
    since `nd6_prelist_add()` is a public function, exclude unsed
    dr logic from it.
    
    Reviewed by: markj
    Differential Revision: https://reviews.freebsd.org/D56131
---
 sys/netinet6/in6.c          |  2 +-
 sys/netinet6/in6_ifattach.c |  2 +-
 sys/netinet6/nd6.h          |  3 +--
 sys/netinet6/nd6_rtr.c      | 15 ++++++---------
 4 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c
index cf2720cac036..feb63bd0eaa4 100644
--- a/sys/netinet6/in6.c
+++ b/sys/netinet6/in6.c
@@ -1319,7 +1319,7 @@ in6_addifaddr(struct ifnet *ifp, struct in6_aliasreq *ifra, struct in6_ifaddr *i
 		 * nd6_prelist_add will install the corresponding
 		 * interface route.
 		 */
-		if ((error = nd6_prelist_add(&pr0, NULL, &pr)) != 0) {
+		if ((error = nd6_prelist_add(&pr0, &pr)) != 0) {
 			if (carp_attached)
 				(*carp_detach_p)(&ia->ia_ifa, false);
 			goto out;
diff --git a/sys/netinet6/in6_ifattach.c b/sys/netinet6/in6_ifattach.c
index 237fb7ecfd44..2f59b791a259 100644
--- a/sys/netinet6/in6_ifattach.c
+++ b/sys/netinet6/in6_ifattach.c
@@ -625,7 +625,7 @@ in6_ifattach_linklocal(struct ifnet *ifp, struct ifnet *altifp)
 	 * valid with referring to the old link-local address.
 	 */
 	if ((pr = nd6_prefix_lookup(&pr0)) == NULL) {
-		if ((error = nd6_prelist_add(&pr0, NULL, &pr)) != 0)
+		if ((error = nd6_prelist_add(&pr0, &pr)) != 0)
 			return (error);
 		/* Reference prefix */
 		ia->ia6_ndpr = pr;
diff --git a/sys/netinet6/nd6.h b/sys/netinet6/nd6.h
index 8dc27aef5e12..92b776b008b9 100644
--- a/sys/netinet6/nd6.h
+++ b/sys/netinet6/nd6.h
@@ -402,8 +402,7 @@ void nd6_defrouter_flush_all(void);
 void nd6_defrouter_purge(struct ifnet *);
 void nd6_defrouter_timer(void);
 void nd6_defrouter_init(void);
-int nd6_prelist_add(struct nd_prefixctl *, struct nd_defrouter *,
-    struct nd_prefix **);
+int nd6_prelist_add(struct nd_prefixctl *, struct nd_prefix **);
 void nd6_prefix_unlink(struct nd_prefix *, struct nd_prhead *);
 void nd6_prefix_del(struct nd_prefix *);
 void nd6_prefix_ref(struct nd_prefix *);
diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c
index 7b7db1b95e31..5833bf487c23 100644
--- a/sys/netinet6/nd6_rtr.c
+++ b/sys/netinet6/nd6_rtr.c
@@ -1400,8 +1400,7 @@ nd6_prefix_rele(struct nd_prefix *pr)
 }
 
 int
-nd6_prelist_add(struct nd_prefixctl *pr, struct nd_defrouter *dr,
-    struct nd_prefix **newp)
+nd6_prelist_add(struct nd_prefixctl *pr, struct nd_prefix **newp)
 {
 	struct nd_prefix *new;
 	char ip6buf[INET6_ADDRSTRLEN];
@@ -1448,8 +1447,6 @@ nd6_prelist_add(struct nd_prefixctl *pr, struct nd_defrouter *dr,
 		ND6_ONLINK_UNLOCK();
 	}
 
-	if (dr != NULL)
-		pfxrtr_add(new, dr);
 	if (newp != NULL)
 		*newp = new;
 	return (0);
@@ -1571,17 +1568,15 @@ 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) {
+	if ((pr = nd6_prefix_lookup(new)) != NULL)
 		nd6_prefix_update(new, pr);
-		if (dr != NULL)
-			pfxrtr_add(pr, dr);
-	} else {
+	else {
 		if (new->ndpr_vltime == 0)
 			goto end;
 		if (new->ndpr_raf_onlink == 0 && new->ndpr_raf_auto == 0)
 			goto end;
 
-		error = nd6_prelist_add(new, dr, &pr);
+		error = nd6_prelist_add(new, &pr);
 		if (error != 0) {
 			nd6log((LOG_NOTICE, "%s: nd6_prelist_add() failed for "
 			    "the prefix %s/%d on %s (errno=%d)\n", __func__,
@@ -1603,6 +1598,8 @@ prelist_update(struct nd_prefixctl *new, struct nd_defrouter *dr,
 			in6_init_prefix_ltimes(pr);
 		}
 	}
+	if (dr != NULL)
+		pfxrtr_add(pr, dr);
 
 	/*
 	 * Address autoconfiguration based on Section 5.5.3 of RFC 2462.


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69e2bb26.39112.75e65f90>