]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
networkd: add support for setting vlan_tunnel on bridge ports
authorErik Larsson <who+github@cnackers.org>
Sat, 22 Mar 2025 14:40:35 +0000 (15:40 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 24 Mar 2025 08:15:19 +0000 (17:15 +0900)
man/systemd.network.xml
src/network/networkd-network-gperf.gperf
src/network/networkd-network.c
src/network/networkd-network.h
src/network/networkd-setlink.c
test/test-network/conf/14-dummy.netdev [new file with mode: 0644]
test/test-network/conf/26-bridge-vlan-tunnel.network [new file with mode: 0644]
test/test-network/systemd-networkd-tests.py

index 52194c4fc0c2bb8a3c7227d7c015db30832e5c1f..ba10b7cd9d12225fcb1867f5e7cdd447b4465dae 100644 (file)
@@ -4644,6 +4644,15 @@ ServerAddress=192.168.0.1/24</programlisting>
           clearing the locked flag. Requires Learning to be enabled. When unset, the kernel's default will be
           used.</para>
 
+          <xi:include href="version-info.xml" xpointer="v258"/>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>VLANTunnel=</varname></term>
+        <listitem>
+          <para>Takes a boolean. Configures whether vlan tunnel mode is to be enabled on this port.
+          When unset, the kernel's default will be used.</para>
+
           <xi:include href="version-info.xml" xpointer="v258"/>
         </listitem>
       </varlistentry>
index 8e99a059c1b978a78bf6f136595f50e92e51a0fb..c1aff5c02d272200c59ae49cc18810034078f3e8 100644 (file)
@@ -386,6 +386,7 @@ Bridge.Priority,                             config_parse_bridge_port_priority,
 Bridge.MulticastRouter,                      config_parse_multicast_router,                            0,                             offsetof(Network, multicast_router)
 Bridge.Locked,                               config_parse_tristate,                                    0,                             offsetof(Network, bridge_locked)
 Bridge.MACAuthenticationBypass,              config_parse_tristate,                                    0,                             offsetof(Network, bridge_mac_authentication_bypass)
+Bridge.VLANTunnel,                           config_parse_tristate,                                    0,                             offsetof(Network, bridge_vlan_tunnel)
 BridgeFDB.MACAddress,                        config_parse_fdb_hwaddr,                                  0,                             0
 BridgeFDB.VLANId,                            config_parse_fdb_vlan_id,                                 0,                             0
 BridgeFDB.Destination,                       config_parse_fdb_destination,                             0,                             0
index 080e184ae144215f4061740772fb113cc46ee18c..00851243b5ac7176ee159d6298191fba53014de2 100644 (file)
@@ -458,6 +458,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
                 .multicast_router = _MULTICAST_ROUTER_INVALID,
                 .bridge_locked = -1,
                 .bridge_mac_authentication_bypass = -1,
+                .bridge_vlan_tunnel = -1,
 
                 .bridge_vlan_pvid = BRIDGE_VLAN_KEEP_PVID,
 
index cec5f98d5bb07f3cb94dcba2d21ea1ba19c6bab7..c83281441e8b3d65c8aa8022e9448bb685f666c6 100644 (file)
@@ -299,6 +299,7 @@ struct Network {
         MulticastRouter multicast_router;
         int bridge_locked;
         int bridge_mac_authentication_bypass;
+        int bridge_vlan_tunnel;
 
         /* Bridge VLAN */
         uint16_t bridge_vlan_pvid;
index 17c2b4b10eb3c5718abac40583dfaf2f81e60e42..c0c1da1b16a6f3095920b4a3bd4ae5ae767dfbcd 100644 (file)
@@ -332,6 +332,12 @@ static int link_configure_fill_message(
                                 return r;
                 }
 
+                if (link->network->bridge_vlan_tunnel >= 0) {
+                        r = sd_netlink_message_append_u8(req, IFLA_BRPORT_VLAN_TUNNEL, link->network->bridge_vlan_tunnel);
+                        if (r < 0)
+                                return r;
+                }
+
                 r = sd_netlink_message_close_container(req);
                 if (r < 0)
                         return r;
diff --git a/test/test-network/conf/14-dummy.netdev b/test/test-network/conf/14-dummy.netdev
new file mode 100644 (file)
index 0000000..2420ab7
--- /dev/null
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+[NetDev]
+Name=dummy97
+Kind=dummy
diff --git a/test/test-network/conf/26-bridge-vlan-tunnel.network b/test/test-network/conf/26-bridge-vlan-tunnel.network
new file mode 100644 (file)
index 0000000..93be9cc
--- /dev/null
@@ -0,0 +1,11 @@
+[Match]
+Name=dummy97
+
+[Link]
+MTUBytes=9000
+
+[Network]
+Bridge=bridge99
+
+[Bridge]
+VLANTunnel=true
index 71ae689156195739f5972e69a9eac408b9b56b0c..a91d45e99521eae65cc0586c23e99ee898bcfb1f 100755 (executable)
@@ -6027,7 +6027,7 @@ class NetworkdBridgeTests(unittest.TestCase, Utilities):
     def test_bridge_property(self):
         copy_network_unit('11-dummy.netdev', '12-dummy.netdev', '26-bridge.netdev',
                           '26-bridge-slave-interface-1.network', '26-bridge-slave-interface-2.network',
-                          '25-bridge99.network')
+                          '25-bridge99.network', '14-dummy.netdev', '26-bridge-vlan-tunnel.network')
         start_networkd()
         self.check_bridge_property()
 
@@ -6038,6 +6038,7 @@ class NetworkdBridgeTests(unittest.TestCase, Utilities):
             '26-bridge.netdev',
             '26-bridge-slave-interface-1.network',
             '26-bridge-slave-interface-2.network',
+            '26-bridge-vlan-tunnel.network',
             '25-bridge99.network')
         networkctl_reload()
         self.check_bridge_property()
@@ -6066,7 +6067,11 @@ class NetworkdBridgeTests(unittest.TestCase, Utilities):
         self.assertIn('bridge_slave', output)
         self.assertIn('mtu 9000 ', output)
 
+        output = check_output('ip -d link show dummy97')
+        self.assertIn('vlan_tunnel on ', output)
+
         remove_link('dummy98')
+        remove_link('dummy97')
         self.wait_operstate('bridge99', 'no-carrier')
 
         output = check_output('ip -d link show bridge99')