]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
netdev/macvlan: allow to set the broadcast queueing threshold
authorSusant Sahani <ssahani@vmware.com>
Tue, 20 Feb 2024 13:12:20 +0000 (18:42 +0530)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 22 Feb 2024 00:36:19 +0000 (09:36 +0900)
Allow to set the broadcast queueing threshold
on macvlan devices. This controls which multicast packets will be
processed in a workqueue instead of inline.

man/systemd.netdev.xml
src/libsystemd/sd-netlink/netlink-types-rtnl.c
src/network/netdev/macvlan.c
src/network/netdev/macvlan.h
src/network/netdev/netdev-gperf.gperf

index 08da75f06fcc637b77cb1f09c424f8a8f34839cd..e941a39eb89508770794ed5e8a5f8880e18a50cf 100644 (file)
           <xi:include href="version-info.xml" xpointer="v248"/>
         </listitem>
       </varlistentry>
+
+      <varlistentry>
+        <term><varname>BroadcastQueueThreshold=</varname></term>
+        <listitem>
+          <para>Controls the threshold for broadcast queueing of the macvlan device. Takes the special value
+          <literal>no</literal>, or an integer in the range 0…2147483647. When <literal>no</literal> is
+          specified, the broadcast queueing is disabled altogether. When an integer is specified, a multicast
+          address will be queued as broadcast if the number of devices using it is greater than the given
+          value. Defaults to unset, and the kernel default will be used.</para>
+
+          <xi:include href="version-info.xml" xpointer="v256"/>
+        </listitem>
+      </varlistentry>
     </variablelist>
   </refsect1>
 
index 1fa88b1ca58e9edf73fac6d541b427129ca7092b..e39a75cfe475abd08fc61946c3697b01b3fc31c2 100644 (file)
@@ -308,6 +308,7 @@ static const NLAPolicy rtnl_link_info_data_macvlan_policies[] = {
         [IFLA_MACVLAN_MACADDR_COUNT]     = BUILD_POLICY(U32),
         [IFLA_MACVLAN_BC_QUEUE_LEN]      = BUILD_POLICY(U32),
         [IFLA_MACVLAN_BC_QUEUE_LEN_USED] = BUILD_POLICY(U32),
+        [IFLA_MACVLAN_BC_CUTOFF]         = BUILD_POLICY(S32),
 };
 
 static const NLAPolicy rtnl_link_info_data_tun_policies[] = {
index 203807e3a566112c4add57ae8c1f6446ee8f3138..85011e11de40a3da85a8c3c972b44042e84ef237 100644 (file)
 #include "networkd-network.h"
 #include "parse-util.h"
 
+typedef enum BCQueueThreshold {
+        BC_QUEUE_THRESHOLD_UNDEF   = INT32_MIN,
+        BC_QUEUE_THRESHOLD_DISABLE = -1,
+} BCQueueThreshold;
+
 DEFINE_CONFIG_PARSE_ENUM(config_parse_macvlan_mode, macvlan_mode, MacVlanMode, "Failed to parse macvlan mode");
 
 static int netdev_macvlan_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *req) {
@@ -62,6 +67,12 @@ static int netdev_macvlan_fill_message_create(NetDev *netdev, Link *link, sd_net
                         return r;
         }
 
+        if (m->bc_queue_threshold != BC_QUEUE_THRESHOLD_UNDEF) {
+                r = sd_netlink_message_append_s32(req, IFLA_MACVLAN_BC_CUTOFF, m->bc_queue_threshold);
+                if (r < 0)
+                        return r;
+        }
+
         return 0;
 }
 
@@ -96,6 +107,53 @@ int config_parse_macvlan_broadcast_queue_size(
                         &m->bc_queue_length);
 }
 
+int config_parse_macvlan_broadcast_queue_threshold(
+                const char *unit,
+                const char *filename,
+                unsigned line,
+                const char *section,
+                unsigned section_line,
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
+
+        assert(filename);
+        assert(lvalue);
+        assert(rvalue);
+
+        int32_t v, *threshold = ASSERT_PTR(data);
+        int r;
+
+        if (isempty(rvalue)) {
+                *threshold = BC_QUEUE_THRESHOLD_UNDEF;
+                return 0;
+        }
+
+        if (streq(rvalue, "no")) {
+                *threshold = BC_QUEUE_THRESHOLD_DISABLE;
+                return 0;
+        }
+
+        r = safe_atoi32(rvalue, &v);
+        if (r < 0) {
+                log_syntax(unit, LOG_WARNING, filename, line, r,
+                           "Failed to parse %s=, ignoring assignment: %s",
+                           lvalue, rvalue);
+                return 0;
+        }
+        if (v < 0) {
+                log_syntax(unit, LOG_WARNING, filename, line, 0,
+                           "Invalid %s= value specified, ignoring assignment: %s",
+                           lvalue, rvalue);
+                return 0;
+        }
+
+        *threshold = v;
+        return 0;
+}
+
 static void macvlan_done(NetDev *netdev) {
         MacVlan *m = ASSERT_PTR(netdev)->kind == NETDEV_KIND_MACVLAN ? MACVLAN(netdev) : MACVTAP(netdev);
 
@@ -107,6 +165,7 @@ static void macvlan_init(NetDev *netdev) {
 
         m->mode = _NETDEV_MACVLAN_MODE_INVALID;
         m->bc_queue_length = UINT32_MAX;
+        m->bc_queue_threshold = BC_QUEUE_THRESHOLD_UNDEF;
 }
 
 const NetDevVTable macvtap_vtable = {
index c45fc4fd33925bafe06c031ee7dc6cae557862e6..76b53a62eae3bf13e41797d090b5b28ca507f074 100644 (file)
@@ -14,6 +14,7 @@ struct MacVlan {
         Set *match_source_mac;
 
         uint32_t bc_queue_length;
+        int32_t bc_queue_threshold;
 };
 
 DEFINE_NETDEV_CAST(MACVLAN, MacVlan);
@@ -23,3 +24,4 @@ extern const NetDevVTable macvtap_vtable;
 
 CONFIG_PARSER_PROTOTYPE(config_parse_macvlan_mode);
 CONFIG_PARSER_PROTOTYPE(config_parse_macvlan_broadcast_queue_size);
+CONFIG_PARSER_PROTOTYPE(config_parse_macvlan_broadcast_queue_threshold);
index eb28b9be5404c3b2b6158dc9e80d789a1de57bf0..1bac0c227d09c9f89883ca99761bfcab00e80916 100644 (file)
@@ -64,6 +64,7 @@ VLAN.IngressQOSMaps,                      config_parse_vlan_qos_maps,
 MACVLAN.Mode,                             config_parse_macvlan_mode,                 0,                             offsetof(MacVlan, mode)
 MACVLAN.SourceMACAddress,                 config_parse_ether_addrs,                  0,                             offsetof(MacVlan, match_source_mac)
 MACVLAN.BroadcastMulticastQueueLength,    config_parse_macvlan_broadcast_queue_size, 0,                             offsetof(MacVlan, bc_queue_length)
+MACVLAN.BroadcastQueueThreshold,          config_parse_macvlan_broadcast_queue_threshold, 0,                        offsetof(MacVlan, bc_queue_threshold)
 MACVTAP.Mode,                             config_parse_macvlan_mode,                 0,                             offsetof(MacVlan, mode)
 MACVTAP.SourceMACAddress,                 config_parse_ether_addrs,                  0,                             offsetof(MacVlan, match_source_mac)
 IPVLAN.Mode,                              config_parse_ipvlan_mode,                  0,                             offsetof(IPVlan, mode)