]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #12441 from ssahani/bridge-fdb
authorChris Down <chris@chrisdown.name>
Fri, 3 May 2019 13:50:47 +0000 (09:50 -0400)
committerGitHub <noreply@github.com>
Fri, 3 May 2019 13:50:47 +0000 (09:50 -0400)
networkd: add support for bridge fdb destination address.

man/systemd.network.xml
src/network/networkd-fdb.c
src/network/networkd-fdb.h
src/network/networkd-network-gperf.gperf
test/fuzz/fuzz-network-parser/directives.network
test/test-network/conf/vxlan-test1.network [new file with mode: 0644]
test/test-network/conf/vxlan.network
test/test-network/systemd-networkd-tests.py

index 4381090d34eef8495f480110baa965facdbf117a..604eea4c18dc5151d2bb6aee1c5617bdbced3c22 100644 (file)
             key is mandatory.</para>
           </listitem>
         </varlistentry>
+        <varlistentry>
+          <term><varname>Destination=</varname></term>
+          <listitem>
+            <para>Takes an IP address of the destination VXLAN tunnel endpoint.</para>
+          </listitem>
+        </varlistentry>
         <varlistentry>
           <term><varname>VLANId=</varname></term>
           <listitem>
index fa13949538134612996322df53e83d0d93c3a2e6..6ebc45267fcc1a4077e282be10448f7cf240035b 100644 (file)
@@ -139,12 +139,18 @@ int fdb_entry_configure(Link *link, FdbEntry *fdb_entry) {
                 return rtnl_log_create_error(r);
 
         /* VLAN Id is optional. We'll add VLAN Id only if it's specified. */
-        if (0 != fdb_entry->vlan_id) {
+        if (fdb_entry->vlan_id > 0) {
                 r = sd_netlink_message_append_u16(req, NDA_VLAN, fdb_entry->vlan_id);
                 if (r < 0)
                         return rtnl_log_create_error(r);
         }
 
+        if (!in_addr_is_null(fdb_entry->family, &fdb_entry->destination_addr)) {
+                r = netlink_message_append_in_addr_union(req, NDA_DST, fdb_entry->family, &fdb_entry->destination_addr);
+                if (r < 0)
+                        return log_link_error_errno(link, r, "Could not append NDA_DST attribute: %m");
+        }
+
         /* send message to the kernel to update its internal static MAC table. */
         r = netlink_call_async(rtnl, NULL, req, set_fdb_handler,
                                link_netlink_destroy_callback, link);
@@ -258,3 +264,40 @@ int config_parse_fdb_vlan_id(
 
         return 0;
 }
+
+int config_parse_fdb_destination(
+                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_(fdb_entry_free_or_set_invalidp) FdbEntry *fdb_entry = NULL;
+        Network *network = userdata;
+        int r;
+
+        assert(filename);
+        assert(section);
+        assert(lvalue);
+        assert(rvalue);
+        assert(data);
+
+        r = fdb_entry_new_static(network, filename, section_line, &fdb_entry);
+        if (r < 0)
+                return log_oom();
+
+        r = in_addr_from_string_auto(rvalue, &fdb_entry->family, &fdb_entry->destination_addr);
+        if (r < 0)
+                return log_syntax(unit, LOG_ERR, filename, line, r,
+                                  "FDB destination IP address is invalid, ignoring assignment: %s",
+                                  rvalue);
+
+        fdb_entry = NULL;
+
+        return 0;
+}
index 6b7da2e7413598d399fd508a40e4452baa33f7b1..e3c45acd72d0406550fd3a281e2731485ccf73f0 100644 (file)
@@ -19,9 +19,12 @@ struct FdbEntry {
         Network *network;
         NetworkConfigSection *section;
 
-        struct ether_addr *mac_addr;
+        int family;
         uint16_t vlan_id;
 
+        struct ether_addr *mac_addr;
+        union in_addr_union destination_addr;
+
         LIST_FIELDS(FdbEntry, static_fdb_entries);
 };
 
@@ -32,3 +35,4 @@ DEFINE_NETWORK_SECTION_FUNCTIONS(FdbEntry, fdb_entry_free);
 
 CONFIG_PARSER_PROTOTYPE(config_parse_fdb_hwaddr);
 CONFIG_PARSER_PROTOTYPE(config_parse_fdb_vlan_id);
+CONFIG_PARSER_PROTOTYPE(config_parse_fdb_destination);
index 0db59473ffd2932bba7c2f76554ab2b89542cc2f..653da83c9f791967c5bb33f22ea2e0504e31fafd 100644 (file)
@@ -179,6 +179,7 @@ Bridge.Learning,                        config_parse_tristate,
 Bridge.Priority,                        config_parse_bridge_port_priority,               0,                             offsetof(Network, priority)
 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
 BridgeVLAN.PVID,                        config_parse_brvlan_pvid,                        0,                             0
 BridgeVLAN.VLAN,                        config_parse_brvlan_vlan,                        0,                             0
 BridgeVLAN.EgressUntagged,              config_parse_brvlan_untagged,                    0,                             0
index cd2031150f3a23cc5777df3fab838d99d94a2fde..fd3256e78406bee26abf9be6fc5a7c39251ee725 100644 (file)
@@ -32,6 +32,7 @@ MACAddress=
 [BridgeFDB]
 VLANId=
 MACAddress=
+Destination=
 [DHCP]
 UseDomains=
 UseRoutes=
diff --git a/test/test-network/conf/vxlan-test1.network b/test/test-network/conf/vxlan-test1.network
new file mode 100644 (file)
index 0000000..3288087
--- /dev/null
@@ -0,0 +1,6 @@
+[Match]
+Name=test1
+
+[Network]
+IPv6AcceptRA=false
+VXLAN=vxlan99
index 80b405574c6bc21a97dcae640b1f5083f6c5ebb9..1b63785d153d1d41542256158b24af2a1d7d6f61 100644 (file)
@@ -1,5 +1,17 @@
 [Match]
-Name=test1
+Name=vxlan99
 
 [Network]
-VXLAN=vxlan99
+IPv6AcceptRA=no
+
+[BridgeFDB]
+MACAddress=00:11:22:33:44:55
+Destination=10.0.0.5
+
+[BridgeFDB]
+MACAddress=00:11:22:33:44:66
+Destination=10.0.0.6
+
+[BridgeFDB]
+MACAddress=00:11:22:33:44:77
+Destination=10.0.0.7
index 806f860eb73331712a9570e337ff3d5822d2d97d..73c0edb38e44d3d4c847e664365349ecf5595456 100755 (executable)
@@ -331,6 +331,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
         'sit.network',
         'vti6.network',
         'vti.network',
+        'vxlan-test1.network',
         'vxlan.network']
 
     def setUp(self):
@@ -861,14 +862,15 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
         subprocess.call(['ip', 'fou', 'del', 'port', '55556'])
 
     def test_vxlan(self):
-        self.copy_unit_to_networkd_unit_path('25-vxlan.netdev', 'vxlan.network', '11-dummy.netdev')
-        self.start_networkd()
+        self.copy_unit_to_networkd_unit_path('25-vxlan.netdev', 'vxlan.network',
+                                             '11-dummy.netdev', 'vxlan-test1.network')
+        self.start_networkd(0)
 
-        self.assertTrue(self.link_exits('vxlan99'))
+        self.wait_online(['test1:degraded', 'vxlan99:degraded'])
 
         output = subprocess.check_output(['ip', '-d', 'link', 'show', 'vxlan99']).rstrip().decode('utf-8')
         print(output)
-        self.assertRegex(output, "999")
+        self.assertRegex(output, '999')
         self.assertRegex(output, '5555')
         self.assertRegex(output, 'l2miss')
         self.assertRegex(output, 'l3miss')
@@ -879,6 +881,12 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
         self.assertRegex(output, 'remcsumrx')
         self.assertRegex(output, 'gbp')
 
+        output = subprocess.check_output(['bridge', 'fdb', 'show', 'dev', 'vxlan99']).rstrip().decode('utf-8')
+        print(output)
+        self.assertRegex(output, '00:11:22:33:44:55 dst 10.0.0.5 self permanent')
+        self.assertRegex(output, '00:11:22:33:44:66 dst 10.0.0.6 self permanent')
+        self.assertRegex(output, '00:11:22:33:44:77 dst 10.0.0.7 self permanent')
+
     def test_macsec(self):
         self.copy_unit_to_networkd_unit_path('25-macsec.netdev', '25-macsec.network', '25-macsec.key',
                                              'macsec.network', '12-dummy.netdev')