Hi,

ARP has a sysctl to show the number of packets waiting for the arp
response.  ND6 should have the same 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.  That does not
change much as int reads are always atomic, but it makes clear that
we don't need a lock around sysctl_rdint().

ok?

bluhm

Index: netinet/icmp6.h
===================================================================
RCS file: /cvs/src/sys/netinet/icmp6.h,v
retrieving revision 1.51
diff -u -p -r1.51 icmp6.h
--- netinet/icmp6.h     11 Jan 2021 13:28:53 -0000      1.51
+++ netinet/icmp6.h     5 Apr 2023 19:38:25 -0000
@@ -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 }, \
Index: netinet/if_ether.c
===================================================================
RCS file: /cvs/src/sys/netinet/if_ether.c,v
retrieving revision 1.259
diff -u -p -r1.259 if_ether.c
--- netinet/if_ether.c  5 Apr 2023 19:35:23 -0000       1.259
+++ netinet/if_ether.c  5 Apr 2023 19:38:25 -0000
@@ -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 */
Index: netinet/ip_input.c
===================================================================
RCS file: /cvs/src/sys/netinet/ip_input.c,v
retrieving revision 1.382
diff -u -p -r1.382 ip_input.c
--- netinet/ip_input.c  8 Mar 2023 23:17:02 -0000       1.382
+++ netinet/ip_input.c  5 Apr 2023 19:38:26 -0000
@@ -1698,7 +1698,8 @@ ip_sysctl(int *name, u_int namelen, void
                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
Index: netinet/ip_var.h
===================================================================
RCS file: /cvs/src/sys/netinet/ip_var.h,v
retrieving revision 1.108
diff -u -p -r1.108 ip_var.h
--- netinet/ip_var.h    17 Nov 2022 18:05:43 -0000      1.108
+++ netinet/ip_var.h    5 Apr 2023 19:38:26 -0000
@@ -217,7 +217,7 @@ extern int ipforwarding;            /* enable IP f
 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;
 
Index: netinet6/icmp6.c
===================================================================
RCS file: /cvs/src/sys/netinet6/icmp6.c,v
retrieving revision 1.247
diff -u -p -r1.247 icmp6.c
--- netinet6/icmp6.c    10 Dec 2022 23:45:51 -0000      1.247
+++ netinet6/icmp6.c    5 Apr 2023 19:38:26 -0000
@@ -1902,6 +1902,11 @@ icmp6_sysctl(int *name, u_int namelen, v
                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,
Index: netinet6/nd6.c
===================================================================
RCS file: /cvs/src/sys/netinet6/nd6.c,v
retrieving revision 1.270
diff -u -p -r1.270 nd6.c
--- netinet6/nd6.c      5 Apr 2023 19:35:23 -0000       1.270
+++ netinet6/nd6.c      5 Apr 2023 19:38:26 -0000
@@ -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 *);
Index: netinet6/nd6.h
===================================================================
RCS file: /cvs/src/sys/netinet6/nd6.h,v
retrieving revision 1.96
diff -u -p -r1.96 nd6.h
--- netinet6/nd6.h      5 Apr 2023 19:35:23 -0000       1.96
+++ netinet6/nd6.h      5 Apr 2023 19:38:26 -0000
@@ -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)
 

Reply via email to