Download raw body.
remove ip6_divert.h header file
Hi,
All redundant code for IPv6 divert has been removed or merged into
ip_divert.c. What remains is the ip6_divert.h header file. Sysctl
does not exists anymore, the leftover is #ifdef _KERNEL. The few
IPv6 specific declatation can easily be moved into ip_divert.h and
the header deleted.
ok?
bluhm
Index: net/pf.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/net/pf.c,v
diff -u -p -r1.1213 pf.c
--- net/pf.c 9 Jun 2025 20:34:08 -0000 1.1213
+++ net/pf.c 21 Jun 2025 22:18:26 -0000
@@ -84,7 +84,6 @@
#include <netinet6/ip6_var.h>
#include <netinet/icmp6.h>
#include <netinet6/nd6.h>
-#include <netinet6/ip6_divert.h>
#endif /* INET6 */
#include <net/pfvar.h>
Index: netinet/ip_divert.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_divert.c,v
diff -u -p -r1.105 ip_divert.c
--- netinet/ip_divert.c 6 Jun 2025 13:13:37 -0000 1.105
+++ netinet/ip_divert.c 21 Jun 2025 22:21:29 -0000
@@ -313,8 +313,7 @@ divert_send(struct socket *so, struct mb
}
int
-divert_sysctl_divstat(struct cpumem *cpucounters, void *oldp, size_t *oldlenp,
- void *newp)
+divert_sysctl_divstat(void *oldp, size_t *oldlenp, void *newp)
{
uint64_t counters[divs_ncounters];
struct divstat divstat;
@@ -323,7 +322,7 @@ divert_sysctl_divstat(struct cpumem *cpu
CTASSERT(sizeof(divstat) == (nitems(counters) * sizeof(u_long)));
memset(&divstat, 0, sizeof divstat);
- counters_read(cpucounters, counters, nitems(counters), NULL);
+ counters_read(divcounters, counters, nitems(counters), NULL);
for (i = 0; i < nitems(counters); i++)
words[i] = (u_long)counters[i];
@@ -345,8 +344,7 @@ divert_sysctl(int *name, u_int namelen,
switch (name[0]) {
case DIVERTCTL_STATS:
- return (divert_sysctl_divstat(divcounters, oldp, oldlenp,
- newp));
+ return (divert_sysctl_divstat(oldp, oldlenp, newp));
default:
return (sysctl_bounded_arr(divertctl_vars,
nitems(divertctl_vars), name, namelen, oldp, oldlenp,
Index: netinet/ip_divert.h
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_divert.h,v
diff -u -p -r1.29 ip_divert.h
--- netinet/ip_divert.h 18 Jun 2025 17:45:07 -0000 1.29
+++ netinet/ip_divert.h 21 Jun 2025 22:21:43 -0000
@@ -69,18 +69,25 @@ divstat_inc(enum divstat_counters c)
extern u_int divert_sendspace;
extern u_int divert_recvspace;
-extern struct inpcbtable divbtable;
-extern const struct pr_usrreqs divert_usrreqs;
+extern struct inpcbtable divbtable, divb6table;
+extern const struct pr_usrreqs divert_usrreqs, divert6_usrreqs;
void divert_init(void);
void divert_packet(struct mbuf *, int, u_int16_t);
int divert_sysctl(int *, u_int, void *, size_t *, void *, size_t);
-int divert_sysctl_divstat(struct cpumem *, void *, size_t *, void *);
+int divert_sysctl_divstat(void *, size_t *, void *);
int divert_attach(struct socket *, int, int);
int divert_detach(struct socket *);
int divert_bind(struct socket *, struct mbuf *, struct proc *);
int divert_shutdown(struct socket *);
int divert_send(struct socket *, struct mbuf *, struct mbuf *,
struct mbuf *);
+
+void divert6_init(void);
+void divert6_packet(struct mbuf *, int, u_int16_t);
+int divert6_attach(struct socket *, int, int);
+int divert6_send(struct socket *, struct mbuf *, struct mbuf *,
+ struct mbuf *);
+
#endif /* _KERNEL */
#endif /* _IP_DIVERT_H_ */
Index: netinet6/in6_proto.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/in6_proto.c,v
diff -u -p -r1.131 in6_proto.c
--- netinet6/in6_proto.c 21 Jun 2025 22:08:44 -0000 1.131
+++ netinet6/in6_proto.c 21 Jun 2025 22:18:54 -0000
@@ -106,7 +106,7 @@
#include "pf.h"
#if NPF > 0
-#include <netinet6/ip6_divert.h>
+#include <netinet/ip_divert.h>
#endif
#include "etherip.h"
Index: netinet6/ip6_divert.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/ip6_divert.c,v
diff -u -p -r1.106 ip6_divert.c
--- netinet6/ip6_divert.c 21 Jun 2025 22:08:44 -0000 1.106
+++ netinet6/ip6_divert.c 21 Jun 2025 22:19:00 -0000
@@ -37,7 +37,6 @@
#include <netinet6/ip6_var.h>
#include <netinet/in_pcb.h>
#include <netinet/ip_divert.h>
-#include <netinet6/ip6_divert.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <netinet/icmp6.h>
Index: netinet6/ip6_divert.h
===================================================================
RCS file: netinet6/ip6_divert.h
diff -N netinet6/ip6_divert.h
--- netinet6/ip6_divert.h 21 Jun 2025 22:08:44 -0000 1.26
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,53 +0,0 @@
-/* $OpenBSD: ip6_divert.h,v 1.26 2025/06/21 22:08:44 bluhm Exp $ */
-
-/*
- * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef _IP6_DIVERT_H_
-#define _IP6_DIVERT_H_
-
-/*
- * Names for divert sysctl objects
- */
-#define DIVERT6CTL_RECVSPACE 1 /* receive buffer space */
-#define DIVERT6CTL_SENDSPACE 2 /* send buffer space */
-#define DIVERT6CTL_STATS 3 /* divert statistics */
-#define DIVERT6CTL_MAXID 4
-
-#define DIVERT6CTL_NAMES { \
- { 0, 0 }, \
- { NULL, 0 }, \
- { NULL, 0 }, \
- { NULL, 0 } \
-}
-
-#ifdef _KERNEL
-
-#include <sys/percpu.h>
-#include <netinet/ip_divert.h>
-
-extern struct inpcbtable divb6table;
-
-extern const struct pr_usrreqs divert6_usrreqs;
-
-void divert6_init(void);
-void divert6_packet(struct mbuf *, int, u_int16_t);
-int divert6_attach(struct socket *, int, int);
-int divert6_send(struct socket *, struct mbuf *, struct mbuf *,
- struct mbuf *);
-#endif /* _KERNEL */
-
-#endif /* _IP6_DIVERT_H_ */
remove ip6_divert.h header file