Index | Thread | Search

From:
Vitaliy Makkoveev <mvs@openbsd.org>
Subject:
Unlock IPV6CTL_AUTO_FLOWLABEL case of ip6_sysctl()
To:
Alexander Bluhm <bluhm@openbsd.org>, tech@openbsd.org
Date:
Thu, 24 Jul 2025 12:17:15 +0300

Download raw body.

Thread
in6_pcbconnect() and in6_pcbset_addr()/syn_cache_get() are different
paths of connecting and listening sockets respectively. Not used in
ramdisk.

Index: sys/netinet6/in6_pcb.c
===================================================================
RCS file: /cvs/src/sys/netinet6/in6_pcb.c,v
diff -u -p -r1.150 in6_pcb.c
--- sys/netinet6/in6_pcb.c	8 Jul 2025 00:47:41 -0000	1.150
+++ sys/netinet6/in6_pcb.c	24 Jul 2025 08:55:17 -0000
@@ -334,7 +334,7 @@ in6_pcbconnect(struct inpcb *inp, struct
 	mtx_leave(&table->inpt_mtx);
 
 	inp->inp_flowinfo &= ~IPV6_FLOWLABEL_MASK;
-	if (ip6_auto_flowlabel) {
+	if (atomic_load_int(&ip6_auto_flowlabel)) {
 		inp->inp_flowinfo |=
 		    (htonl(ip6_randomflowlabel()) & IPV6_FLOWLABEL_MASK);
 	}
@@ -730,7 +730,7 @@ in6_pcbset_addr(struct inpcb *inp, const
 	mtx_leave(&table->inpt_mtx);
 
 	inp->inp_flowinfo &= ~IPV6_FLOWLABEL_MASK;
-	if (ip6_auto_flowlabel) {
+	if (atomic_load_int(&ip6_auto_flowlabel)) {
 		inp->inp_flowinfo |=
 		    (htonl(ip6_randomflowlabel()) & IPV6_FLOWLABEL_MASK);
 	}
Index: sys/netinet6/in6_proto.c
===================================================================
RCS file: /cvs/src/sys/netinet6/in6_proto.c,v
diff -u -p -r1.140 in6_proto.c
--- sys/netinet6/in6_proto.c	23 Jul 2025 22:32:49 -0000	1.140
+++ sys/netinet6/in6_proto.c	24 Jul 2025 08:55:17 -0000
@@ -360,7 +360,7 @@ int	ip6_log_interval = 5;	/* [a] */
 int	ip6_hdrnestlimit = 10;	/* [a] appropriate? */
 int	ip6_dad_count = 1;	/* [a] DupAddrDetectionTransmits */
 int	ip6_dad_pending;	/* number of currently running DADs */
-int	ip6_auto_flowlabel = 1;
+int	ip6_auto_flowlabel = 1;	/* [a] */
 int	ip6_use_deprecated = 1;	/* allow deprecated addr (RFC2462 5.5.4) */
 int	ip6_mcast_pmtu = 0;	/* enable pMTU discovery for multicast? */
 int	ip6_neighborgcthresh = 2048; /* Threshold # of NDP entries for GC */
Index: sys/netinet6/ip6_input.c
===================================================================
RCS file: /cvs/src/sys/netinet6/ip6_input.c,v
diff -u -p -r1.284 ip6_input.c
--- sys/netinet6/ip6_input.c	23 Jul 2025 22:32:49 -0000	1.284
+++ sys/netinet6/ip6_input.c	24 Jul 2025 08:55:17 -0000
@@ -1451,10 +1451,10 @@ const struct sysctl_bounded_args ipv6ctl
 	{ IPV6CTL_LOG_INTERVAL, &ip6_log_interval, 0, INT_MAX },
 	{ IPV6CTL_HDRNESTLIMIT, &ip6_hdrnestlimit, 0, 100 },
 	{ IPV6CTL_DAD_COUNT, &ip6_dad_count, 0, 10 },
+	{ IPV6CTL_AUTO_FLOWLABEL, &ip6_auto_flowlabel, 0, 1 },
 };
 
 const struct sysctl_bounded_args ipv6ctl_vars[] = {
-	{ IPV6CTL_AUTO_FLOWLABEL, &ip6_auto_flowlabel, 0, 1 },
 	{ IPV6CTL_DEFMCASTHLIM, &ip6_defmcasthlim, 0, 255 },
 	{ IPV6CTL_USE_DEPRECATED, &ip6_use_deprecated, 0, 1 },
 	{ IPV6CTL_MAXFRAGS, &ip6_maxfrags, 0, 1000 },
@@ -1574,6 +1574,7 @@ ip6_sysctl(int *name, u_int namelen, voi
 	case IPV6CTL_LOG_INTERVAL:
 	case IPV6CTL_HDRNESTLIMIT:
 	case IPV6CTL_DAD_COUNT:
+	case IPV6CTL_AUTO_FLOWLABEL:
 		return (sysctl_bounded_arr(
 		    ipv6ctl_vars_unlocked, nitems(ipv6ctl_vars_unlocked),
 		    name, namelen, oldp, oldlenp, newp, newlen));