]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: tc/cake: introduce MPUBytes= setting
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 3 Nov 2021 19:16:20 +0000 (04:16 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 9 Nov 2021 01:58:44 +0000 (10:58 +0900)
man/systemd.network.xml
src/network/networkd-network-gperf.gperf
src/network/tc/cake.c
src/network/tc/cake.h
test/fuzz/fuzz-network-parser/directives.network

index 13eb06fdca5d8ee1be7be4ad6f5504fad92d57cb..b82efd4394ca5846097f2aa50365b7c90e841a89 100644 (file)
@@ -3491,6 +3491,14 @@ Token=prefixstable:2002:da8:1::</programlisting></para>
         </listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term><varname>MPUBytes=</varname></term>
+        <listitem>
+          <para>Rounds each packet (including overhead) up to the specified bytes. Takes an integer in
+          the range 1…256. Defaults to unset and kernel's default is used.</para>
+        </listitem>
+      </varlistentry>
+
       <varlistentry>
         <term><varname>CompensationMode=</varname></term>
         <listitem>
index 1fe4b72b5ffd3dcfdce36c63b827a7a2d800e9ba..1c09f300bd63fd2e0dbe973811ef961fe36a12e0 100644 (file)
@@ -388,6 +388,7 @@ CAKE.Handle,                                 config_parse_qdisc_handle,
 CAKE.Bandwidth,                              config_parse_cake_bandwidth,                              QDISC_KIND_CAKE,               0
 CAKE.AutoRateIngress,                        config_parse_cake_tristate,                               QDISC_KIND_CAKE,               0
 CAKE.OverheadBytes,                          config_parse_cake_overhead,                               QDISC_KIND_CAKE,               0
+CAKE.MPUBytes,                               config_parse_cake_mpu,                                    QDISC_KIND_CAKE,               0
 CAKE.CompensationMode,                       config_parse_cake_compensation_mode,                      QDISC_KIND_CAKE,               0
 CAKE.FlowIsolationMode,                      config_parse_cake_flow_isolation_mode,                    QDISC_KIND_CAKE,               0
 CAKE.NAT,                                    config_parse_cake_tristate,                               QDISC_KIND_CAKE,               0
index 27395918ea9491839f57f1f341b2ded2ad3590bd..7641574fd8f9e0b5c14e97080f8f181fdba6c8fc 100644 (file)
@@ -59,6 +59,12 @@ static int cake_fill_message(Link *link, QDisc *qdisc, sd_netlink_message *req)
                         return log_link_error_errno(link, r, "Could not append TCA_CAKE_OVERHEAD attribute: %m");
         }
 
+        if (c->mpu > 0) {
+                r = sd_netlink_message_append_u32(req, TCA_CAKE_MPU, c->mpu);
+                if (r < 0)
+                        return log_link_error_errno(link, r, "Could not append TCA_CAKE_MPU attribute: %m");
+        }
+
         if (c->compensation_mode >= 0) {
                 r = sd_netlink_message_append_u32(req, TCA_CAKE_ATM, c->compensation_mode);
                 if (r < 0)
@@ -199,6 +205,65 @@ int config_parse_cake_overhead(
         return 0;
 }
 
+int config_parse_cake_mpu(
+                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) {
+
+        _cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
+        CommonApplicationsKeptEnhanced *c;
+        Network *network = data;
+        uint32_t v;
+        int r;
+
+        assert(filename);
+        assert(lvalue);
+        assert(rvalue);
+        assert(data);
+
+        r = qdisc_new_static(QDISC_KIND_CAKE, network, filename, section_line, &qdisc);
+        if (r == -ENOMEM)
+                return log_oom();
+        if (r < 0) {
+                log_syntax(unit, LOG_WARNING, filename, line, r,
+                           "More than one kind of queueing discipline, ignoring assignment: %m");
+                return 0;
+        }
+
+        c = CAKE(qdisc);
+
+        if (isempty(rvalue)) {
+                c->mpu = 0;
+                TAKE_PTR(qdisc);
+                return 0;
+        }
+
+        r = safe_atou32(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 || v > 256) {
+                log_syntax(unit, LOG_WARNING, filename, line, 0,
+                           "Invalid '%s=', ignoring assignment: %s",
+                           lvalue, rvalue);
+                return 0;
+        }
+
+        c->mpu = v;
+        TAKE_PTR(qdisc);
+        return 0;
+}
+
 int config_parse_cake_tristate(
                 const char *unit,
                 const char *filename,
index 1be8cacbe9a22a0e5aef4dcf81390c59c771de10..c8defb505eb71f90e712715a357260e858b44ff3 100644 (file)
@@ -38,6 +38,7 @@ typedef struct CommonApplicationsKeptEnhanced {
         /* Overhead compensation parameters */
         bool overhead_set;
         int overhead;
+        uint32_t mpu;
         CakeCompensationMode compensation_mode;
 
         /* Flow isolation parameters */
@@ -51,6 +52,7 @@ extern const QDiscVTable cake_vtable;
 
 CONFIG_PARSER_PROTOTYPE(config_parse_cake_bandwidth);
 CONFIG_PARSER_PROTOTYPE(config_parse_cake_overhead);
+CONFIG_PARSER_PROTOTYPE(config_parse_cake_mpu);
 CONFIG_PARSER_PROTOTYPE(config_parse_cake_tristate);
 CONFIG_PARSER_PROTOTYPE(config_parse_cake_compensation_mode);
 CONFIG_PARSER_PROTOTYPE(config_parse_cake_flow_isolation_mode);
index 5d0d0968e7a9ba70e5aa7a0fb98a63549d161269..de6d460eb1f1ed680b067524214ef6eb1d621b75 100644 (file)
@@ -470,6 +470,7 @@ Handle=
 Bandwidth=
 AutoRateIngress=
 OverheadBytes=
+MPUBytes=
 CompensationMode=
 FlowIsolationMode=
 NAT=