Index | Thread | Search

From:
Alexander Bluhm <bluhm@openbsd.org>
Subject:
divert6 remove recv and send space sysctl
To:
tech@openbsd.org
Date:
Tue, 17 Jun 2025 00:42:15 +0200

Download raw body.

Thread
Hi,

UDP has a common sysctl for recv and send space, but divert has a
special knob for inet6.

net.inet.udp.recvspace=41600
net.inet.udp.sendspace=9216
net.inet.divert.recvspace=65636
net.inet.divert.sendspace=65636
net.inet6.divert.recvspace=65636
net.inet6.divert.sendspace=65636

Use the divert instead of divert6 space.  Remove net.inet6.divert.recvspace
and net.inet6.divert.sendspace sysctl.  Goal is to kill all redundant
code in ip6_divert.c.

ok?

bluhm

Index: netinet/ip_divert.h
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_divert.h,v
diff -u -p -r1.28 ip_divert.h
--- netinet/ip_divert.h	6 Jun 2025 13:13:37 -0000	1.28
+++ netinet/ip_divert.h	16 Jun 2025 22:15:23 -0000
@@ -67,8 +67,9 @@ divstat_inc(enum divstat_counters c)
 	counters_inc(divcounters, c);
 }
 
-extern struct	inpcbtable	divbtable;
-
+extern u_int divert_sendspace;
+extern u_int divert_recvspace;
+extern struct inpcbtable divbtable;
 extern const struct pr_usrreqs divert_usrreqs;
 
 void	 divert_init(void);
Index: netinet6/ip6_divert.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/ip6_divert.c,v
diff -u -p -r1.104 ip6_divert.c
--- netinet6/ip6_divert.c	6 Jun 2025 13:13:37 -0000	1.104
+++ netinet6/ip6_divert.c	16 Jun 2025 22:11:53 -0000
@@ -52,14 +52,6 @@
 struct	inpcbtable	divb6table;
 struct	cpumem		*div6counters;
 
-u_int   divert6_sendspace = DIVERT_SENDSPACE;	/* [a] */
-u_int   divert6_recvspace = DIVERT_RECVSPACE;	/* [a] */
-
-const struct sysctl_bounded_args divert6ctl_vars[] = {
-	{ DIVERT6CTL_RECVSPACE, &divert6_recvspace, 0, SB_MAX },
-	{ DIVERT6CTL_SENDSPACE, &divert6_sendspace, 0, SB_MAX },
-};
-
 const struct pr_usrreqs divert6_usrreqs = {
 	.pru_attach	= divert6_attach,
 	.pru_detach	= divert_detach,
@@ -267,8 +259,8 @@ divert6_attach(struct socket *so, int pr
 	if ((so->so_state & SS_PRIV) == 0)
 		return EACCES;
 
-	error = soreserve(so, atomic_load_int(&divert6_sendspace),
-	    atomic_load_int(&divert6_recvspace));
+	error = soreserve(so, atomic_load_int(&divert_sendspace),
+	    atomic_load_int(&divert_recvspace));
 	if (error)
 		return (error);
 	error = in_pcballoc(so, &divb6table, wait);
@@ -304,9 +296,7 @@ divert6_sysctl(int *name, u_int namelen,
 		return (divert_sysctl_divstat(div6counters, oldp, oldlenp,
 		    newp));
 	default:
-		return (sysctl_bounded_arr(divert6ctl_vars,
-		    nitems(divert6ctl_vars), name, namelen, oldp, oldlenp,
-		    newp, newlen));
+		return (EOPNOTSUPP);
 	}
 	/* NOTREACHED */
 }
Index: netinet6/ip6_divert.h
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/ip6_divert.h,v
diff -u -p -r1.24 ip6_divert.h
--- netinet6/ip6_divert.h	4 Jun 2025 12:37:00 -0000	1.24
+++ netinet6/ip6_divert.h	16 Jun 2025 22:19:47 -0000
@@ -29,8 +29,8 @@
 
 #define	DIVERT6CTL_NAMES { \
 	{ 0, 0 }, \
-	{ "recvspace",	CTLTYPE_INT }, \
-	{ "sendspace",	CTLTYPE_INT }, \
+	{ NULL,	0 }, \
+	{ NULL,	0 }, \
 	{ "stats",	CTLTYPE_STRUCT } \
 }