Download raw body.
simplify divert defines
On Wed, Jun 04, 2025 at 06:33:45PM +0200, Alexander Bluhm wrote:
> Hi,
>
> I doubt that anyone wants to override these IP divert defines via
> compiler options. Let's move them simply to ip_divert.h header
> file.
>
> ok?
If at all I would make DIVERTHASHSIZE adjustable via sysctl.
So OK on this diff.
> bluhm
>
> Index: netinet/ip_divert.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_divert.c,v
> diff -u -p -r1.104 ip_divert.c
> --- netinet/ip_divert.c 4 Jun 2025 12:37:00 -0000 1.104
> +++ netinet/ip_divert.c 4 Jun 2025 16:29:07 -0000
> @@ -49,19 +49,9 @@
> struct inpcbtable divbtable;
> struct cpumem *divcounters;
>
> -#ifndef DIVERT_SENDSPACE
> -#define DIVERT_SENDSPACE (65536 + 100)
> -#endif
> u_int divert_sendspace = DIVERT_SENDSPACE; /* [a] */
> -#ifndef DIVERT_RECVSPACE
> -#define DIVERT_RECVSPACE (65536 + 100)
> -#endif
> u_int divert_recvspace = DIVERT_RECVSPACE; /* [a] */
>
> -#ifndef DIVERTHASHSIZE
> -#define DIVERTHASHSIZE 128
> -#endif
> -
> const struct sysctl_bounded_args divertctl_vars[] = {
> { DIVERTCTL_RECVSPACE, &divert_recvspace, 0, SB_MAX },
> { DIVERTCTL_SENDSPACE, &divert_sendspace, 0, SB_MAX },
> @@ -78,14 +68,12 @@ const struct pr_usrreqs divert_usrreqs =
> .pru_peeraddr = in_peeraddr,
> };
>
> -int divbhashsize = DIVERTHASHSIZE;
> -
> int divert_output(struct inpcb *, struct mbuf *, struct mbuf *,
> struct mbuf *);
> void
> divert_init(void)
> {
> - in_pcbinit(&divbtable, divbhashsize);
> + in_pcbinit(&divbtable, DIVERT_HASHSIZE);
> divcounters = counters_alloc(divs_ncounters);
> }
>
> Index: netinet/ip_divert.h
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_divert.h,v
> diff -u -p -r1.27 ip_divert.h
> --- netinet/ip_divert.h 4 Jun 2025 12:37:00 -0000 1.27
> +++ netinet/ip_divert.h 4 Jun 2025 16:29:07 -0000
> @@ -46,6 +46,10 @@ struct divstat {
>
> #include <sys/percpu.h>
>
> +#define DIVERT_SENDSPACE (65536 + 100)
> +#define DIVERT_RECVSPACE (65536 + 100)
> +#define DIVERT_HASHSIZE 128
> +
> enum divstat_counters {
> divs_ipackets,
> divs_noport,
> Index: netinet6/ip6_divert.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/ip6_divert.c,v
> diff -u -p -r1.103 ip6_divert.c
> --- netinet6/ip6_divert.c 4 Jun 2025 12:37:00 -0000 1.103
> +++ netinet6/ip6_divert.c 4 Jun 2025 16:29:07 -0000
> @@ -52,19 +52,9 @@
> struct inpcbtable divb6table;
> struct cpumem *div6counters;
>
> -#ifndef DIVERT_SENDSPACE
> -#define DIVERT_SENDSPACE (65536 + 100)
> -#endif
> u_int divert6_sendspace = DIVERT_SENDSPACE; /* [a] */
> -#ifndef DIVERT_RECVSPACE
> -#define DIVERT_RECVSPACE (65536 + 100)
> -#endif
> u_int divert6_recvspace = DIVERT_RECVSPACE; /* [a] */
>
> -#ifndef DIVERTHASHSIZE
> -#define DIVERTHASHSIZE 128
> -#endif
> -
> const struct sysctl_bounded_args divert6ctl_vars[] = {
> { DIVERT6CTL_RECVSPACE, &divert6_recvspace, 0, SB_MAX },
> { DIVERT6CTL_SENDSPACE, &divert6_sendspace, 0, SB_MAX },
> @@ -81,15 +71,13 @@ const struct pr_usrreqs divert6_usrreqs
> .pru_peeraddr = in6_peeraddr,
> };
>
> -int divb6hashsize = DIVERTHASHSIZE;
> -
> int divert6_output(struct inpcb *, struct mbuf *, struct mbuf *,
> struct mbuf *);
>
> void
> divert6_init(void)
> {
> - in_pcbinit(&divb6table, divb6hashsize);
> + in_pcbinit(&divb6table, DIVERT_HASHSIZE);
> div6counters = counters_alloc(divs_ncounters);
> }
>
>
--
:wq Claudio
simplify divert defines