inet6: Prevent excessive IPI from draining IPv6 fragments.
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 2 Aug 2017 09:13:21 +0000 (17:13 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 2 Aug 2017 09:17:03 +0000 (17:17 +0800)
sys/netinet6/frag6.c

index dffca09..4c5efa9 100644 (file)
@@ -86,6 +86,7 @@ MALLOC_DEFINE(M_FTABLE, "fragment", "fragment reassembly header");
 static struct callout          frag6_slowtimo_ch;
 static struct netmsg_base      frag6_slowtimo_nmsg;
 static struct netmsg_base      frag6_drain_nmsg;
+static volatile int            frag6_draining;
 
 /*
  * Initialise reassembly queue and fragment identifier.
@@ -711,6 +712,7 @@ frag6_drain_dispatch(netmsg_t nmsg)
        crit_exit();
 
        frag6_drain_oncpu();
+       frag6_draining = 0;
 }
 
 static void
@@ -735,6 +737,12 @@ frag6_drain(void)
                return;
        }
 
+       if (!frag6_nfrags || frag6_draining) {
+               /* No fragments or is draining; done. */
+               return;
+       }
+       frag6_draining = 1;
+
        /* Target cpu0. */
        lwkt_send_ipiq_bycpu(0, frag6_drain_ipi, NULL);
 }