]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: allow setting VLAN protocol on bridges
authorRubens Figueiredo <rubens.figueiredo@bisdn.de>
Fri, 20 Mar 2020 15:09:36 +0000 (16:09 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 14 May 2020 15:59:57 +0000 (17:59 +0200)
Signed-off-by: Rubens Figueiredo <rubens.figueiredo@bisdn.de>
man/systemd.netdev.xml
src/network/netdev/bridge.c
src/network/netdev/bridge.h
src/network/netdev/netdev-gperf.gperf
src/shared/conf-parser.c
src/shared/conf-parser.h
test/fuzz/fuzz-netdev-parser/directives.netdev

index 6ad1dc9e73714598fa1bdec079bbec7d5a9969e2..026fae089f24a248185ef90fd02fb0297187956e 100644 (file)
           </para>
         </listitem>
       </varlistentry>
+      <varlistentry>
+        <term><varname>VLANProtocol=</varname></term>
+        <listitem>
+          <para>Allows setting the protocol used for VLAN filtering. Takes
+          <option>802.1q</option> or,
+          <option>802.1ad</option>, and defaults to unset and kernel's default is used.
+          </para>
+        </listitem>
+      </varlistentry>
       <varlistentry>
         <term><varname>STP=</varname></term>
         <listitem>
index 6b8f9944612ea39765f4a3ead0ceee9813d6099f..de492c5eeb2a66ed1e65b7e4f97f47b3492ed8af 100644 (file)
@@ -126,6 +126,12 @@ static int netdev_bridge_post_create(NetDev *netdev, Link *link, sd_netlink_mess
                         return log_netdev_error_errno(netdev, r, "Could not append IFLA_BR_VLAN_FILTERING attribute: %m");
         }
 
+        if (b->vlan_protocol >= 0) {
+                r = sd_netlink_message_append_u16(req, IFLA_BR_VLAN_PROTOCOL, b->vlan_protocol);
+                if (r < 0)
+                        return log_netdev_error_errno(netdev, r, "Could not append IFLA_BR_VLAN_PROTOCOL attribute: %m");
+        }
+
         if (b->stp >= 0) {
                 r = sd_netlink_message_append_u32(req, IFLA_BR_STP_STATE, b->stp);
                 if (r < 0)
@@ -346,6 +352,7 @@ static void bridge_init(NetDev *n) {
         b->mcast_querier = -1;
         b->mcast_snooping = -1;
         b->vlan_filtering = -1;
+        b->vlan_protocol = -1;
         b->stp = -1;
         b->default_pvid = VLANID_INVALID;
         b->forward_delay = USEC_INFINITY;
index b0a728e5a40df76fab3c2e94c87e1fbd6ced4ac1..ed4f484c946457966dc010fc862e1543bfb18e84 100644 (file)
@@ -13,6 +13,7 @@ typedef struct Bridge {
         int mcast_querier;
         int mcast_snooping;
         int vlan_filtering;
+        int vlan_protocol;
         int stp;
         uint16_t priority;
         uint16_t group_fwd_mask;
index 09a5f4822e03dc39b32e7fe8072ecaf89bc2cc04..b14835c313eb74f05a1a5a0b6a66f035a4c28084 100644 (file)
@@ -206,6 +206,7 @@ Bridge.DefaultPVID,                       config_parse_default_port_vlanid,
 Bridge.MulticastQuerier,                  config_parse_tristate,                     0,                             offsetof(Bridge, mcast_querier)
 Bridge.MulticastSnooping,                 config_parse_tristate,                     0,                             offsetof(Bridge, mcast_snooping)
 Bridge.VLANFiltering,                     config_parse_tristate,                     0,                             offsetof(Bridge, vlan_filtering)
+Bridge.VLANProtocol,                      config_parse_vlanprotocol,                 0,                             offsetof(Bridge, vlan_protocol)
 Bridge.STP,                               config_parse_tristate,                     0,                             offsetof(Bridge, stp)
 Bridge.MulticastIGMPVersion,              config_parse_uint8,                        0,                             offsetof(Bridge, igmp_version)
 VRF.TableId,                              config_parse_uint32,                       0,                             offsetof(Vrf, table) /* deprecated */
index 3ba33606fbcdfaaa3676404a6f33bd7428d5d351..23cb3b65b67678c84727a1c680d1a194d70ae72e 100644 (file)
@@ -1187,3 +1187,35 @@ int config_parse_permille(const char* unit,
 
         return 0;
 }
+
+int config_parse_vlanprotocol(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) {
+        int *vlan_protocol = data;
+        assert(filename);
+        assert(lvalue);
+
+        if (isempty(rvalue)) {
+                *vlan_protocol = -1;
+                return 0;
+        }
+
+        if (STR_IN_SET(rvalue, "802.1ad", "802.1AD"))
+                *vlan_protocol = ETH_P_8021AD;
+        else if (STR_IN_SET(rvalue, "802.1q", "802.1Q"))
+                *vlan_protocol = ETH_P_8021Q;
+        else {
+                log_syntax(unit, LOG_ERR, filename, line, 0,
+                           "Failed to parse VLAN protocol value, ignoring: %s", rvalue);
+                return 0;
+        }
+
+        return 0;
+}
index 2f3cb4217d01ebda574db82f7de8cdf3450c3933..59e74590cabff84870530ee816a5c1817b03c180 100644 (file)
@@ -142,6 +142,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_ifnames);
 CONFIG_PARSER_PROTOTYPE(config_parse_ip_port);
 CONFIG_PARSER_PROTOTYPE(config_parse_mtu);
 CONFIG_PARSER_PROTOTYPE(config_parse_rlimit);
+CONFIG_PARSER_PROTOTYPE(config_parse_vlanprotocol);
 
 typedef enum Disabled {
         DISABLED_CONFIGURATION,
index e8391dab780cfad2385a3a6f641d09a08f2b43b1..d69ac09f1fb81900e01c5fef97452a318370a43e 100644 (file)
@@ -45,6 +45,7 @@ AgeingTimeSec=
 Priority=
 GroupForwardMask=
 VLANFiltering=
+VLANProtocol=
 MulticastIGMPVersion=
 [VRF]
 TableId=