]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: introduce network_adjust_bridge_vlan()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 25 May 2021 08:08:27 +0000 (17:08 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 7 Jun 2021 21:33:27 +0000 (06:33 +0900)
src/network/networkd-bridge-vlan.c
src/network/networkd-bridge-vlan.h
src/network/networkd-network.c

index 797c5c69d55481dfcc31dd5c8c6fbbe89029576a..c4c25eaff4d1322644a5a9708069fd2a52238519 100644 (file)
@@ -161,10 +161,6 @@ int link_set_bridge_vlan(Link *link) {
         if (!link->network->bridge && !streq_ptr(link->kind, "bridge"))
                 return 0;
 
-        /* pvid might not be in br_vid_bitmap yet */
-        if (link->network->pvid)
-                set_bit(link->network->pvid, link->network->br_vid_bitmap);
-
         /* create new RTM message */
         r = sd_rtnl_message_new_link(link->manager->rtnl, &req, RTM_SETLINK, link->ifindex);
         if (r < 0)
@@ -206,6 +202,17 @@ int link_set_bridge_vlan(Link *link) {
         return 0;
 }
 
+void network_adjust_bridge_vlan(Network *network) {
+        assert(network);
+
+        if (!network->use_br_vlan)
+                return;
+
+        /* pvid might not be in br_vid_bitmap yet */
+        if (network->pvid)
+                set_bit(network->pvid, network->br_vid_bitmap);
+}
+
 int config_parse_brvlan_pvid(
                 const char *unit,
                 const char *filename,
index 938b7901f19a73603bb157dbcb2f1e421cd1712f..22f886f1b46fbe3945342d9b9c1c725b1600ac98 100644 (file)
@@ -11,6 +11,9 @@
 #define BRIDGE_VLAN_BITMAP_LEN (BRIDGE_VLAN_BITMAP_MAX / 32)
 
 typedef struct Link Link;
+typedef struct Network Network;
+
+void network_adjust_bridge_vlan(Network *network);
 
 int link_set_bridge_vlan(Link *link);
 
index 9cb6551d8ae97111ab07c227b2f81c7a898f2932..4e4ae7b76be037afa2c9bc4dd7ffd08fc694756e 100644 (file)
@@ -182,6 +182,7 @@ int network_verify(Network *network) {
         network_adjust_ipv6_accept_ra(network);
         network_adjust_dhcp(network);
         network_adjust_radv(network);
+        network_adjust_bridge_vlan(network);
 
         if (network->mtu > 0 && network->dhcp_use_mtu) {
                 log_warning("%s: MTUBytes= in [Link] section and UseMTU= in [DHCP] section are set. "