From: bluhm Date: Wed, 5 Apr 2023 21:51:47 +0000 (+0000) Subject: ARP has a sysctl to show the number of packets waiting for an arp X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e2c3420425c610cd82369970f9c34d0a370ebcdd;p=openbsd ARP has a sysctl to show the number of packets waiting for an arp response. Implement analog sysctl net.inet6.icmp6.nd6_queued for ND6 to reduce places where mbufs can hide within the kernel. Atomic operations operate on unsigned int. Make the type of total hold queue length consistent. Use atomic load to read the value for the sysctl. This clarifies why no lock around sysctl_rdint() is needed. OK mvs@ kn@ --- diff --git a/sys/netinet/icmp6.h b/sys/netinet/icmp6.h index ef7df8dfdde..210c6191fd8 100644 --- a/sys/netinet/icmp6.h +++ b/sys/netinet/icmp6.h @@ -1,4 +1,4 @@ -/* $OpenBSD: icmp6.h,v 1.51 2021/01/11 13:28:53 bluhm Exp $ */ +/* $OpenBSD: icmp6.h,v 1.52 2023/04/05 21:51:47 bluhm Exp $ */ /* $KAME: icmp6.h,v 1.84 2003/04/23 10:26:51 itojun Exp $ */ /* @@ -504,7 +504,8 @@ struct icmp6stat { #define ICMPV6CTL_REDIRTIMEOUT 3 /* redirect cache time */ #define ICMPV6CTL_ND6_DELAY 8 #define ICMPV6CTL_ND6_UMAXTRIES 9 -#define ICMPV6CTL_ND6_MMAXTRIES 10 +#define ICMPV6CTL_ND6_MMAXTRIES 10 +#define ICMPV6CTL_ND6_QUEUED 11 #define ICMPV6CTL_NODEINFO 13 #define ICMPV6CTL_ERRPPSLIMIT 14 /* ICMPv6 error pps limitation */ #define ICMPV6CTL_ND6_MAXNUDHINT 15 @@ -525,7 +526,7 @@ struct icmp6stat { { "nd6_delay", CTLTYPE_INT }, \ { "nd6_umaxtries", CTLTYPE_INT }, \ { "nd6_mmaxtries", CTLTYPE_INT }, \ - { 0, 0 }, \ + { "nd6_queued", CTLTYPE_INT }, \ { 0, 0 }, \ { 0, 0 }, \ { "errppslimit", CTLTYPE_INT }, \ diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index b1268d3fa00..46aa3c26acb 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ether.c,v 1.259 2023/04/05 19:35:23 bluhm Exp $ */ +/* $OpenBSD: if_ether.c,v 1.260 2023/04/05 21:51:47 bluhm Exp $ */ /* $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $ */ /* @@ -109,7 +109,7 @@ LIST_HEAD(, llinfo_arp) arp_list = LIST_HEAD_INITIALIZER(arp_list); /* [mN] list of llinfo_arp structures */ struct pool arp_pool; /* [I] pool for llinfo_arp structures */ int arp_maxtries = 5; /* [I] arp requests before set to rejected */ -int la_hold_total; /* [a] packets currently in the arp queue */ +unsigned int la_hold_total; /* [a] packets currently in the arp queue */ #ifdef NFSCLIENT /* revarp state */ diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 07dde2897c5..42c1c72d78d 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_input.c,v 1.382 2023/03/08 23:17:02 bluhm Exp $ */ +/* $OpenBSD: ip_input.c,v 1.383 2023/04/05 21:51:47 bluhm Exp $ */ /* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */ /* @@ -1698,7 +1698,8 @@ ip_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, return (sysctl_niq(name + 1, namelen - 1, oldp, oldlenp, newp, newlen, &arpinq)); case IPCTL_ARPQUEUED: - return (sysctl_rdint(oldp, oldlenp, newp, la_hold_total)); + return (sysctl_rdint(oldp, oldlenp, newp, + atomic_load_int(&la_hold_total))); case IPCTL_STATS: return (ip_sysctl_ipstat(oldp, oldlenp, newp)); #ifdef MROUTING diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h index e4ba27bc65c..b93b27ca337 100644 --- a/sys/netinet/ip_var.h +++ b/sys/netinet/ip_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_var.h,v 1.108 2022/11/17 18:05:43 mvs Exp $ */ +/* $OpenBSD: ip_var.h,v 1.109 2023/04/05 21:51:47 bluhm Exp $ */ /* $NetBSD: ip_var.h,v 1.16 1996/02/13 23:43:20 christos Exp $ */ /* @@ -217,7 +217,7 @@ extern int ipforwarding; /* enable IP forwarding */ extern int ipmforwarding; /* enable multicast forwarding */ #endif extern int ipmultipath; /* enable multipath routing */ -extern int la_hold_total; +extern unsigned int la_hold_total; extern const struct pr_usrreqs rip_usrreqs; diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c index a1174a1bac5..9173b5292a1 100644 --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: icmp6.c,v 1.247 2022/12/10 23:45:51 kn Exp $ */ +/* $OpenBSD: icmp6.c,v 1.248 2023/04/05 21:51:47 bluhm Exp $ */ /* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */ /* @@ -1902,6 +1902,11 @@ icmp6_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, error = icmp6_sysctl_icmp6stat(oldp, oldlenp, newp); break; + case ICMPV6CTL_ND6_QUEUED: + error = sysctl_rdint(oldp, oldlenp, newp, + atomic_load_int(&ln_hold_total)); + break; + default: NET_LOCK(); error = sysctl_bounded_arr(icmpv6ctl_vars, diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index c937040f420..591a4688b37 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6.c,v 1.270 2023/04/05 19:35:23 bluhm Exp $ */ +/* $OpenBSD: nd6.c,v 1.271 2023/04/05 21:51:47 bluhm Exp $ */ /* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */ /* @@ -87,7 +87,7 @@ int nd6_debug = 0; TAILQ_HEAD(llinfo_nd6_head, llinfo_nd6) nd6_list; struct pool nd6_pool; /* pool for llinfo_nd6 structures */ int nd6_inuse; -int ln_hold_total; /* [a] packets currently in the nd6 queue */ +unsigned int ln_hold_total; /* [a] packets currently in the nd6 queue */ void nd6_timer(void *); void nd6_slowtimo(void *); diff --git a/sys/netinet6/nd6.h b/sys/netinet6/nd6.h index b3c2be97bcb..8e6a722637c 100644 --- a/sys/netinet6/nd6.h +++ b/sys/netinet6/nd6.h @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6.h,v 1.96 2023/04/05 19:35:23 bluhm Exp $ */ +/* $OpenBSD: nd6.h,v 1.97 2023/04/05 21:51:47 bluhm Exp $ */ /* $KAME: nd6.h,v 1.95 2002/06/08 11:31:06 itojun Exp $ */ /* @@ -91,7 +91,7 @@ struct llinfo_nd6 { #define LN_HOLD_QUEUE 10 #define LN_HOLD_TOTAL 100 -extern int ln_hold_total; +extern unsigned int ln_hold_total; #define ND6_LLINFO_PERMANENT(n) ((n)->ln_rt->rt_expire == 0)