teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame 34251.patch

15d25f
From 3f14557ce01cc9012991a602851b03f0a4205fc2 Mon Sep 17 00:00:00 2001
15d25f
From: Daan De Meyer <daan.j.demeyer@gmail.com>
15d25f
Date: Wed, 4 Sep 2024 12:19:49 +0200
15d25f
Subject: [PATCH 1/2] network: Add support for multiq qdisc
15d25f
15d25f
---
15d25f
 man/systemd.network.xml                       | 10 ++++++++++
15d25f
 src/network/meson.build                       |  1 +
15d25f
 src/network/networkd-network-gperf.gperf      |  2 ++
15d25f
 src/network/networkd-network.c                |  1 +
15d25f
 src/network/tc/multiq.c                       | 19 +++++++++++++++++++
15d25f
 src/network/tc/multiq.h                       | 11 +++++++++++
15d25f
 src/network/tc/qdisc.c                        |  1 +
15d25f
 src/network/tc/qdisc.h                        |  2 ++
15d25f
 .../test-network/conf/25-qdisc-multiq.network | 12 ++++++++++++
15d25f
 test/test-network/systemd-networkd-tests.py   | 10 ++++++++++
15d25f
 10 files changed, 69 insertions(+)
15d25f
 create mode 100644 src/network/tc/multiq.c
15d25f
 create mode 100644 src/network/tc/multiq.h
15d25f
 create mode 100644 test/test-network/conf/25-qdisc-multiq.network
15d25f
15d25f
diff --git a/man/systemd.network.xml b/man/systemd.network.xml
15d25f
index 734a4f7c0b21b..cc6a31484f20c 100644
15d25f
--- a/man/systemd.network.xml
15d25f
+++ b/man/systemd.network.xml
15d25f
@@ -6064,6 +6064,16 @@ ServerAddress=192.168.0.1/24</programlisting>
15d25f
     </variablelist>
15d25f
   </refsect1>
15d25f
 
15d25f
+  <refsect1>
15d25f
+    <title>[BandMultiQueueing] Section Options</title>
15d25f
+    <para>The [BandMultiQueueing] section manages the queueing discipline (qdisc) of Band Multi Queueing (multiq).</para>
15d25f
+
15d25f
+    <variablelist class='network-directives'>
15d25f
+      <xi:include href="tc.xml" xpointer="qdisc-parent" />
15d25f
+      <xi:include href="tc.xml" xpointer="qdisc-handle" />
15d25f
+    </variablelist>
15d25f
+  </refsect1>
15d25f
+
15d25f
   <refsect1>
15d25f
     <title>[HeavyHitterFilter] Section Options</title>
15d25f
     <para>The [HeavyHitterFilter] section manages the queueing discipline (qdisc) of Heavy Hitter Filter
15d25f
diff --git a/src/network/meson.build b/src/network/meson.build
15d25f
index 275542daa27f5..3edcd48c83e63 100644
15d25f
--- a/src/network/meson.build
15d25f
+++ b/src/network/meson.build
15d25f
@@ -93,6 +93,7 @@ sources = files(
15d25f
         'tc/gred.c',
15d25f
         'tc/hhf.c',
15d25f
         'tc/htb.c',
15d25f
+        'tc/multiq.c',
15d25f
         'tc/netem.c',
15d25f
         'tc/pie.c',
15d25f
         'tc/qdisc.c',
15d25f
diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf
15d25f
index 0957eeef6ed8b..95fe0275a9be4 100644
15d25f
--- a/src/network/networkd-network-gperf.gperf
15d25f
+++ b/src/network/networkd-network-gperf.gperf
15d25f
@@ -552,6 +552,8 @@ HierarchyTokenBucketClass.Rate,              config_parse_hierarchy_token_bucket
15d25f
 HierarchyTokenBucketClass.CeilRate,          config_parse_hierarchy_token_bucket_class_rate,           TCLASS_KIND_HTB,               0
15d25f
 HierarchyTokenBucketClass.BufferBytes,       config_parse_hierarchy_token_bucket_class_size,           TCLASS_KIND_HTB,               0
15d25f
 HierarchyTokenBucketClass.CeilBufferBytes,   config_parse_hierarchy_token_bucket_class_size,           TCLASS_KIND_HTB,               0
15d25f
+BandMultiQueueing.Parent,                    config_parse_qdisc_parent,                                QDISC_KIND_MULTIQ,             0
15d25f
+BandMultiQueueing.Handle,                    config_parse_qdisc_handle,                                QDISC_KIND_MULTIQ,             0
15d25f
 NetworkEmulator.Parent,                      config_parse_qdisc_parent,                                QDISC_KIND_NETEM,              0
15d25f
 NetworkEmulator.Handle,                      config_parse_qdisc_handle,                                QDISC_KIND_NETEM,              0
15d25f
 NetworkEmulator.DelaySec,                    config_parse_network_emulator_delay,                      QDISC_KIND_NETEM,              0
15d25f
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
15d25f
index ecd54a3829d49..2c2f8ad939064 100644
15d25f
--- a/src/network/networkd-network.c
15d25f
+++ b/src/network/networkd-network.c
15d25f
@@ -551,6 +551,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
15d25f
                         "HeavyHitterFilter\0"
15d25f
                         "HierarchyTokenBucket\0"
15d25f
                         "HierarchyTokenBucketClass\0"
15d25f
+                        "BandMultiQueueing\0"
15d25f
                         "NetworkEmulator\0"
15d25f
                         "PFIFO\0"
15d25f
                         "PFIFOFast\0"
15d25f
diff --git a/src/network/tc/multiq.c b/src/network/tc/multiq.c
15d25f
new file mode 100644
15d25f
index 0000000000000..c70d8c59061e3
15d25f
--- /dev/null
15d25f
+++ b/src/network/tc/multiq.c
15d25f
@@ -0,0 +1,19 @@
15d25f
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
15d25f
+
15d25f
+#include "multiq.h"
15d25f
+
15d25f
+static int multi_queueing_fill_message(Link *link, QDisc *qdisc, sd_netlink_message *req) {
15d25f
+        struct tc_multiq_qopt opt = {};
15d25f
+
15d25f
+        assert(req);
15d25f
+
15d25f
+        /* It looks weird, but the multiq qdisc initialization wants to receive a tc_multiq_qopt attr even
15d25f
+         * though it doesn't do anything with it. */
15d25f
+        return sd_netlink_message_append_data(req, TCA_OPTIONS, &opt, sizeof(opt));
15d25f
+}
15d25f
+
15d25f
+const QDiscVTable multiq_vtable = {
15d25f
+        .object_size = sizeof(BandMultiQueueing),
15d25f
+        .tca_kind = "multiq",
15d25f
+        .fill_message = multi_queueing_fill_message,
15d25f
+};
15d25f
diff --git a/src/network/tc/multiq.h b/src/network/tc/multiq.h
15d25f
new file mode 100644
15d25f
index 0000000000000..e53ed57c716ab
15d25f
--- /dev/null
15d25f
+++ b/src/network/tc/multiq.h
15d25f
@@ -0,0 +1,11 @@
15d25f
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
15d25f
+#pragma once
15d25f
+
15d25f
+#include "qdisc.h"
15d25f
+
15d25f
+typedef struct BandMultiQueueing {
15d25f
+        QDisc meta;
15d25f
+} BandMultiQueueing;
15d25f
+
15d25f
+DEFINE_QDISC_CAST(MULTIQ, BandMultiQueueing);
15d25f
+extern const QDiscVTable multiq_vtable;
15d25f
diff --git a/src/network/tc/qdisc.c b/src/network/tc/qdisc.c
15d25f
index 0f89d844f585a..5e8f97a785100 100644
15d25f
--- a/src/network/tc/qdisc.c
15d25f
+++ b/src/network/tc/qdisc.c
15d25f
@@ -30,6 +30,7 @@ const QDiscVTable * const qdisc_vtable[_QDISC_KIND_MAX] = {
15d25f
         [QDISC_KIND_GRED]            = &gred_vtable,
15d25f
         [QDISC_KIND_HHF]             = &hhf_vtable,
15d25f
         [QDISC_KIND_HTB]             = &htb_vtable,
15d25f
+        [QDISC_KIND_MULTIQ]          = &multiq_vtable,
15d25f
         [QDISC_KIND_NETEM]           = &netem_vtable,
15d25f
         [QDISC_KIND_PIE]             = &pie_vtable,
15d25f
         [QDISC_KIND_QFQ]             = &qfq_vtable,
15d25f
diff --git a/src/network/tc/qdisc.h b/src/network/tc/qdisc.h
15d25f
index 50a8f4ead1951..83853dcaa742c 100644
15d25f
--- a/src/network/tc/qdisc.h
15d25f
+++ b/src/network/tc/qdisc.h
15d25f
@@ -21,6 +21,7 @@ typedef enum QDiscKind {
15d25f
         QDISC_KIND_GRED,
15d25f
         QDISC_KIND_HHF,
15d25f
         QDISC_KIND_HTB,
15d25f
+        QDISC_KIND_MULTIQ,
15d25f
         QDISC_KIND_NETEM,
15d25f
         QDISC_KIND_PFIFO,
15d25f
         QDISC_KIND_PFIFO_FAST,
15d25f
@@ -106,6 +107,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_qdisc_handle);
15d25f
 #include "gred.h"
15d25f
 #include "hhf.h"
15d25f
 #include "htb.h"
15d25f
+#include "multiq.h"
15d25f
 #include "pie.h"
15d25f
 #include "qfq.h"
15d25f
 #include "netem.h"
15d25f
diff --git a/test/test-network/conf/25-qdisc-multiq.network b/test/test-network/conf/25-qdisc-multiq.network
15d25f
new file mode 100644
15d25f
index 0000000000000..a805c77124d0c
15d25f
--- /dev/null
15d25f
+++ b/test/test-network/conf/25-qdisc-multiq.network
15d25f
@@ -0,0 +1,12 @@
15d25f
+# SPDX-License-Identifier: LGPL-2.1-or-later
15d25f
+[Match]
15d25f
+Name=testtun99
15d25f
+Name=testtap99
15d25f
+
15d25f
+[Network]
15d25f
+LinkLocalAddressing=yes
15d25f
+IPv6AcceptRA=no
15d25f
+
15d25f
+[BandMultiQueueing]
15d25f
+Parent=root
15d25f
+Handle=0002
15d25f
diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py
15d25f
index 1b61038d09e08..a2b4eb40b239d 100755
15d25f
--- a/test/test-network/systemd-networkd-tests.py
15d25f
+++ b/test/test-network/systemd-networkd-tests.py
15d25f
@@ -4648,6 +4648,16 @@ def test_qdisc_ingress(self):
15d25f
         print(output)
15d25f
         self.assertRegex(output, 'qdisc ingress')
15d25f
 
15d25f
+    @expectedFailureIfModuleIsNotAvailable('sch_multiq')
15d25f
+    def test_qdisc_multiq(self):
15d25f
+        copy_network_unit('25-tun.netdev', '25-tap.netdev', '25-qdisc-multiq.network')
15d25f
+        start_networkd()
15d25f
+        self.wait_online('testtun99:degraded', 'testtap99:degraded')
15d25f
+
15d25f
+        output = check_output('tc qdisc show dev testtun99')
15d25f
+        print(output)
15d25f
+        self.assertIn('qdisc multiq 2: root', output)
15d25f
+
15d25f
     @expectedFailureIfModuleIsNotAvailable('sch_netem')
15d25f
     def test_qdisc_netem(self):
15d25f
         copy_network_unit('25-qdisc-netem.network', '12-dummy.netdev',
15d25f
15d25f
From 2b9ced9072a280a2cb0c2c7783a288788a3a6771 Mon Sep 17 00:00:00 2001
15d25f
From: Daan De Meyer <daan.j.demeyer@gmail.com>
15d25f
Date: Wed, 4 Sep 2024 13:32:32 +0200
15d25f
Subject: [PATCH 2/2] network: Add support for mq qdisc
15d25f
15d25f
---
15d25f
 man/systemd.network.xml                     | 10 ++++++++++
15d25f
 src/network/meson.build                     |  1 +
15d25f
 src/network/networkd-network-gperf.gperf    |  2 ++
15d25f
 src/network/networkd-network.c              |  1 +
15d25f
 src/network/tc/mq.c                         |  8 ++++++++
15d25f
 src/network/tc/mq.h                         | 11 +++++++++++
15d25f
 src/network/tc/qdisc.c                      |  1 +
15d25f
 src/network/tc/qdisc.h                      |  2 ++
15d25f
 test/test-network/conf/25-qdisc-mq.network  | 12 ++++++++++++
15d25f
 test/test-network/systemd-networkd-tests.py |  9 +++++++++
15d25f
 10 files changed, 57 insertions(+)
15d25f
 create mode 100644 src/network/tc/mq.c
15d25f
 create mode 100644 src/network/tc/mq.h
15d25f
 create mode 100644 test/test-network/conf/25-qdisc-mq.network
15d25f
15d25f
diff --git a/man/systemd.network.xml b/man/systemd.network.xml
15d25f
index cc6a31484f20c..89484c449f31d 100644
15d25f
--- a/man/systemd.network.xml
15d25f
+++ b/man/systemd.network.xml
15d25f
@@ -6064,6 +6064,16 @@ ServerAddress=192.168.0.1/24</programlisting>
15d25f
     </variablelist>
15d25f
   </refsect1>
15d25f
 
15d25f
+  <refsect1>
15d25f
+    <title>[ClassfulMultiQueueing] Section Options</title>
15d25f
+    <para>The [ClassfulMultiQueueing] section manages the queueing discipline (qdisc) of Classful Multi Queueing (mq).</para>
15d25f
+
15d25f
+    <variablelist class='network-directives'>
15d25f
+      <xi:include href="tc.xml" xpointer="qdisc-parent" />
15d25f
+      <xi:include href="tc.xml" xpointer="qdisc-handle" />
15d25f
+    </variablelist>
15d25f
+  </refsect1>
15d25f
+
15d25f
   <refsect1>
15d25f
     <title>[BandMultiQueueing] Section Options</title>
15d25f
     <para>The [BandMultiQueueing] section manages the queueing discipline (qdisc) of Band Multi Queueing (multiq).</para>
15d25f
diff --git a/src/network/meson.build b/src/network/meson.build
15d25f
index 3edcd48c83e63..54cf694aeb47e 100644
15d25f
--- a/src/network/meson.build
15d25f
+++ b/src/network/meson.build
15d25f
@@ -93,6 +93,7 @@ sources = files(
15d25f
         'tc/gred.c',
15d25f
         'tc/hhf.c',
15d25f
         'tc/htb.c',
15d25f
+        'tc/mq.c',
15d25f
         'tc/multiq.c',
15d25f
         'tc/netem.c',
15d25f
         'tc/pie.c',
15d25f
diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf
15d25f
index 95fe0275a9be4..a84de4ca7fca9 100644
15d25f
--- a/src/network/networkd-network-gperf.gperf
15d25f
+++ b/src/network/networkd-network-gperf.gperf
15d25f
@@ -552,6 +552,8 @@ HierarchyTokenBucketClass.Rate,              config_parse_hierarchy_token_bucket
15d25f
 HierarchyTokenBucketClass.CeilRate,          config_parse_hierarchy_token_bucket_class_rate,           TCLASS_KIND_HTB,               0
15d25f
 HierarchyTokenBucketClass.BufferBytes,       config_parse_hierarchy_token_bucket_class_size,           TCLASS_KIND_HTB,               0
15d25f
 HierarchyTokenBucketClass.CeilBufferBytes,   config_parse_hierarchy_token_bucket_class_size,           TCLASS_KIND_HTB,               0
15d25f
+ClassfulMultiQueueing.Parent,                config_parse_qdisc_parent,                                QDISC_KIND_MQ,                 0
15d25f
+ClassfulMultiQueueing.Handle,                config_parse_qdisc_handle,                                QDISC_KIND_MQ,                 0
15d25f
 BandMultiQueueing.Parent,                    config_parse_qdisc_parent,                                QDISC_KIND_MULTIQ,             0
15d25f
 BandMultiQueueing.Handle,                    config_parse_qdisc_handle,                                QDISC_KIND_MULTIQ,             0
15d25f
 NetworkEmulator.Parent,                      config_parse_qdisc_parent,                                QDISC_KIND_NETEM,              0
15d25f
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
15d25f
index 2c2f8ad939064..8ccf215a71e84 100644
15d25f
--- a/src/network/networkd-network.c
15d25f
+++ b/src/network/networkd-network.c
15d25f
@@ -551,6 +551,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
15d25f
                         "HeavyHitterFilter\0"
15d25f
                         "HierarchyTokenBucket\0"
15d25f
                         "HierarchyTokenBucketClass\0"
15d25f
+                        "ClassfulMultiQueueing\0"
15d25f
                         "BandMultiQueueing\0"
15d25f
                         "NetworkEmulator\0"
15d25f
                         "PFIFO\0"
15d25f
diff --git a/src/network/tc/mq.c b/src/network/tc/mq.c
15d25f
new file mode 100644
15d25f
index 0000000000000..1435ed1fda0fa
15d25f
--- /dev/null
15d25f
+++ b/src/network/tc/mq.c
15d25f
@@ -0,0 +1,8 @@
15d25f
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
15d25f
+
15d25f
+#include "mq.h"
15d25f
+
15d25f
+const QDiscVTable mq_vtable = {
15d25f
+        .object_size = sizeof(ClassfulMultiQueueing),
15d25f
+        .tca_kind = "mq",
15d25f
+};
15d25f
diff --git a/src/network/tc/mq.h b/src/network/tc/mq.h
15d25f
new file mode 100644
15d25f
index 0000000000000..88f0049670cf1
15d25f
--- /dev/null
15d25f
+++ b/src/network/tc/mq.h
15d25f
@@ -0,0 +1,11 @@
15d25f
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
15d25f
+#pragma once
15d25f
+
15d25f
+#include "qdisc.h"
15d25f
+
15d25f
+typedef struct ClassfulMultiQueueing {
15d25f
+        QDisc meta;
15d25f
+} ClassfulMultiQueueing;
15d25f
+
15d25f
+DEFINE_QDISC_CAST(MQ, ClassfulMultiQueueing);
15d25f
+extern const QDiscVTable mq_vtable;
15d25f
diff --git a/src/network/tc/qdisc.c b/src/network/tc/qdisc.c
15d25f
index 5e8f97a785100..3bcc3930662f4 100644
15d25f
--- a/src/network/tc/qdisc.c
15d25f
+++ b/src/network/tc/qdisc.c
15d25f
@@ -30,6 +30,7 @@ const QDiscVTable * const qdisc_vtable[_QDISC_KIND_MAX] = {
15d25f
         [QDISC_KIND_GRED]            = &gred_vtable,
15d25f
         [QDISC_KIND_HHF]             = &hhf_vtable,
15d25f
         [QDISC_KIND_HTB]             = &htb_vtable,
15d25f
+        [QDISC_KIND_MQ]              = &mq_vtable,
15d25f
         [QDISC_KIND_MULTIQ]          = &multiq_vtable,
15d25f
         [QDISC_KIND_NETEM]           = &netem_vtable,
15d25f
         [QDISC_KIND_PIE]             = &pie_vtable,
15d25f
diff --git a/src/network/tc/qdisc.h b/src/network/tc/qdisc.h
15d25f
index 83853dcaa742c..80b95c2aab4fc 100644
15d25f
--- a/src/network/tc/qdisc.h
15d25f
+++ b/src/network/tc/qdisc.h
15d25f
@@ -21,6 +21,7 @@ typedef enum QDiscKind {
15d25f
         QDISC_KIND_GRED,
15d25f
         QDISC_KIND_HHF,
15d25f
         QDISC_KIND_HTB,
15d25f
+        QDISC_KIND_MQ,
15d25f
         QDISC_KIND_MULTIQ,
15d25f
         QDISC_KIND_NETEM,
15d25f
         QDISC_KIND_PFIFO,
15d25f
@@ -107,6 +108,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_qdisc_handle);
15d25f
 #include "gred.h"
15d25f
 #include "hhf.h"
15d25f
 #include "htb.h"
15d25f
+#include "mq.h"
15d25f
 #include "multiq.h"
15d25f
 #include "pie.h"
15d25f
 #include "qfq.h"
15d25f
diff --git a/test/test-network/conf/25-qdisc-mq.network b/test/test-network/conf/25-qdisc-mq.network
15d25f
new file mode 100644
15d25f
index 0000000000000..32366d05dabed
15d25f
--- /dev/null
15d25f
+++ b/test/test-network/conf/25-qdisc-mq.network
15d25f
@@ -0,0 +1,12 @@
15d25f
+# SPDX-License-Identifier: LGPL-2.1-or-later
15d25f
+[Match]
15d25f
+Name=testtun99
15d25f
+Name=testtap99
15d25f
+
15d25f
+[Network]
15d25f
+LinkLocalAddressing=yes
15d25f
+IPv6AcceptRA=no
15d25f
+
15d25f
+[ClassfulMultiQueueing]
15d25f
+Parent=root
15d25f
+Handle=0002
15d25f
diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py
15d25f
index a2b4eb40b239d..3989fc04014d1 100755
15d25f
--- a/test/test-network/systemd-networkd-tests.py
15d25f
+++ b/test/test-network/systemd-networkd-tests.py
15d25f
@@ -4648,6 +4648,15 @@ def test_qdisc_ingress(self):
15d25f
         print(output)
15d25f
         self.assertRegex(output, 'qdisc ingress')
15d25f
 
15d25f
+    def test_qdisc_mq(self):
15d25f
+        copy_network_unit('25-tun.netdev', '25-tap.netdev', '25-qdisc-mq.network')
15d25f
+        start_networkd()
15d25f
+        self.wait_online('testtun99:degraded', 'testtap99:degraded')
15d25f
+
15d25f
+        output = check_output('tc qdisc show dev testtun99')
15d25f
+        print(output)
15d25f
+        self.assertIn('qdisc mq 2: root', output)
15d25f
+
15d25f
     @expectedFailureIfModuleIsNotAvailable('sch_multiq')
15d25f
     def test_qdisc_multiq(self):
15d25f
         copy_network_unit('25-tun.netdev', '25-tap.netdev', '25-qdisc-multiq.network')