git: 0c891822310c - main - netinet6: Remove ndpr_raf_ra_derived flag
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 12 Jun 2025 18:47:47 UTC
The branch main has been updated by hrs:
URL: https://cgit.FreeBSD.org/src/commit/?id=0c891822310cebd11c22bb59391f85bc53c94fa3
commit 0c891822310cebd11c22bb59391f85bc53c94fa3
Author: Hiroki Sato <hrs@FreeBSD.org>
AuthorDate: 2025-06-12 18:46:46 +0000
Commit: Hiroki Sato <hrs@FreeBSD.org>
CommitDate: 2025-06-12 18:47:06 +0000
netinet6: Remove ndpr_raf_ra_derived flag
This flag was introduced at 8036234c72c9361711e867cc1a0c6a7fe0babd84
to prevent the SIOCSPFXFLUSH_IN6 ioctl from removing manually-added
entries. However, this flag did actually not work due to an
incomplete implementation making prelist_update() not handle it before
calling nd6_prelist_add().
This patch removes the flag because a prefix is derived from an RA
always has an entry in the ndpr_advrtrs member in the struct
nd_prefix. Having a separate flag is not a good idea because it can
cause a mismatch between the flag and the ndpr_advrtrs entry. Testing
using LIST_EMPTY() is simpler for the origial goal.
This also removes in a prefix check in the ICMPV6CTL_ND6_PRLIST sysctl
to exclude manually-added entries. This ioctl is designed to list all
entries, and there is no relationship to SIOCSPFXFLUSH_IN6.
Differential Revision: https://reviews.freebsd.org/D46441
---
sys/netinet6/in6_var.h | 4 +---
sys/netinet6/nd6.c | 8 +++-----
sys/netinet6/nd6.h | 1 -
sys/netinet6/nd6_rtr.c | 1 -
4 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/sys/netinet6/in6_var.h b/sys/netinet6/in6_var.h
index 918a3abe426e..e5ab83e6a2a1 100644
--- a/sys/netinet6/in6_var.h
+++ b/sys/netinet6/in6_var.h
@@ -323,8 +323,7 @@ struct in6_prflags {
struct prf_ra {
u_char onlink : 1;
u_char autonomous : 1;
- u_char ra_derived: 1;
- u_char reserved : 5;
+ u_char reserved : 6;
} prf_ra;
u_char prf_reserved1;
u_short prf_reserved2;
@@ -355,7 +354,6 @@ struct in6_prefixreq {
#define ipr_raf_onlink ipr_flags.prf_ra.onlink
#define ipr_raf_auto ipr_flags.prf_ra.autonomous
-#define ipr_raf_ra_derived ipr_flags.prf_ra.ra_derived
#define ipr_statef_onlink ipr_flags.prf_state.onlink
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c
index 6ec5a8b54cf4..8480e7fc90e3 100644
--- a/sys/netinet6/nd6.c
+++ b/sys/netinet6/nd6.c
@@ -84,11 +84,11 @@
#include <security/mac/mac_framework.h>
+#define ND6_PREFIX_WITH_ROUTER(pr) !LIST_EMPTY(&(pr)->ndpr_advrtrs)
+
#define ND6_SLOWTIMER_INTERVAL (60 * 60) /* 1 hour */
#define ND6_RECALC_REACHTM_INTERVAL (60 * 120) /* 2 hours */
-#define SIN6(s) ((const struct sockaddr_in6 *)(s))
-
MALLOC_DEFINE(M_IP6NDP, "ip6ndp", "IPv6 Neighbor Discovery");
VNET_DEFINE_STATIC(int, nd6_prune) = 1;
@@ -1796,7 +1796,7 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp)
ND6_WLOCK();
LIST_FOREACH_SAFE(pr, &V_nd_prefix, ndpr_entry, next) {
- if (pr->ndpr_raf_ra_derived)
+ if (ND6_PREFIX_WITH_ROUTER(pr))
nd6_prefix_unlink(pr, &prl);
}
ND6_WUNLOCK();
@@ -2675,8 +2675,6 @@ nd6_sysctl_prlist(SYSCTL_HANDLER_ARGS)
ND6_RLOCK();
LIST_FOREACH(pr, &V_nd_prefix, ndpr_entry) {
- if (!pr->ndpr_raf_ra_derived)
- continue;
p.prefix = pr->ndpr_prefix;
if (sa6_recoverscope(&p.prefix)) {
log(LOG_ERR, "scope error in prefix list (%s)\n",
diff --git a/sys/netinet6/nd6.h b/sys/netinet6/nd6.h
index 1db1b666c60b..d0cbacff29d2 100644
--- a/sys/netinet6/nd6.h
+++ b/sys/netinet6/nd6.h
@@ -242,7 +242,6 @@ struct nd_prefix {
#define ndpr_raf ndpr_flags
#define ndpr_raf_onlink ndpr_flags.onlink
#define ndpr_raf_auto ndpr_flags.autonomous
-#define ndpr_raf_ra_derived ndpr_flags.ra_derived
#define ndpr_raf_router ndpr_flags.router
struct nd_pfxrouter {
diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c
index c145af7d3ffc..927c7895305a 100644
--- a/sys/netinet6/nd6_rtr.c
+++ b/sys/netinet6/nd6_rtr.c
@@ -520,7 +520,6 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len)
ND_OPT_PI_FLAG_ONLINK) ? 1 : 0;
pr.ndpr_raf_auto = (pi->nd_opt_pi_flags_reserved &
ND_OPT_PI_FLAG_AUTO) ? 1 : 0;
- pr.ndpr_raf_ra_derived = 1;
pr.ndpr_plen = pi->nd_opt_pi_prefix_len;
pr.ndpr_vltime = ntohl(pi->nd_opt_pi_valid_time);
pr.ndpr_pltime = ntohl(pi->nd_opt_pi_preferred_time);