The branch main has been updated by kp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=013784c967f994058f701c1fd2a82a2cc0bd90b0

commit 013784c967f994058f701c1fd2a82a2cc0bd90b0
Author:     Kristof Provost <k...@freebsd.org>
AuthorDate: 2025-01-20 13:19:20 +0000
Commit:     Kristof Provost <k...@freebsd.org>
CommitDate: 2025-01-20 13:28:38 +0000

    netinet: virtualize net.link.ether.inet.garp_rexmit_count
    
    Turn garp_rexmit_count into a per-vnet variable.
    This immediate use case is to enable easier testing.
    
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 sys/netinet/if_ether.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c
index 81f4b901f21b..502261f5f2d9 100644
--- a/sys/netinet/if_ether.c
+++ b/sys/netinet/if_ether.c
@@ -155,11 +155,12 @@ SYSCTL_INT(_net_link_ether_inet, OID_AUTO, 
max_log_per_second,
  */
 #define MAX_GARP_RETRANSMITS 16
 static int sysctl_garp_rexmit(SYSCTL_HANDLER_ARGS);
-static int garp_rexmit_count = 0; /* GARP retransmission setting. */
+VNET_DEFINE_STATIC(int, garp_rexmit_count) = 0; /* GARP retransmission 
setting. */
+#define        V_garp_rexmit_count     VNET(garp_rexmit_count)
 
 SYSCTL_PROC(_net_link_ether_inet, OID_AUTO, garp_rexmit_count,
-    CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_MPSAFE,
-    &garp_rexmit_count, 0, sysctl_garp_rexmit, "I",
+    CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_MPSAFE|CTLFLAG_VNET,
+    &VNET_NAME(garp_rexmit_count), 0, sysctl_garp_rexmit, "I",
     "Number of times to retransmit GARP packets;"
     " 0 to disable, maximum of 16");
 
@@ -1377,7 +1378,7 @@ garp_rexmit(void *arg)
         * the callout to retransmit another GARP packet.
         */
        ++ia->ia_garp_count;
-       if (ia->ia_garp_count >= garp_rexmit_count) {
+       if (ia->ia_garp_count >= V_garp_rexmit_count) {
                ifa_free(&ia->ia_ifa);
        } else {
                int rescheduled;
@@ -1444,7 +1445,7 @@ arp_ifinit(struct ifnet *ifp, struct ifaddr *ifa)
        NET_EPOCH_ENTER(et);
        arp_announce_ifaddr(ifp, dst_in->sin_addr, IF_LLADDR(ifp));
        NET_EPOCH_EXIT(et);
-       if (garp_rexmit_count > 0) {
+       if (V_garp_rexmit_count > 0) {
                garp_timer_start(ifa);
        }
 

Reply via email to