]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: add VLANProtocol= setting in [SR-IOV] section
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 22 Jun 2020 10:26:31 +0000 (19:26 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 1 Jul 2020 04:51:35 +0000 (13:51 +0900)
man/systemd.network.xml
src/network/networkd-network-gperf.gperf
src/network/networkd-sriov.c
src/network/networkd-sriov.h
test/fuzz/fuzz-network-parser/directives.network

index 5968c16b2119248ccb2345cb4ccd45e492d4ae2f..7c31f345ab872579da46e1f872e4773b5708cf28 100644 (file)
           </listitem>
         </varlistentry>
 
+        <varlistentry>
+          <term><varname>VLANProtocol=</varname></term>
+          <listitem>
+            <para>Specifies VLAN protocol of the virtual function. Takes <literal>802.1Q</literal> or
+            <literal>802.1ad</literal>.</para>
+          </listitem>
+        </varlistentry>
+
         <varlistentry>
           <term><varname>MACSpoofCheck=</varname></term>
           <listitem>
index fe640bd2b0e5b2b41487d0d16ad7c622568247fe..f1937ac251f87bd4bfa5686b93bf687ead95ba1e 100644 (file)
@@ -57,6 +57,7 @@ Link.RequiredForOnline,                      config_parse_required_for_online,
 SR-IOV.VirtualFunction,                      config_parse_sr_iov_uint32,                               0,                             0
 SR-IOV.VLANId,                               config_parse_sr_iov_uint32,                               0,                             0
 SR-IOV.QualityOfService,                     config_parse_sr_iov_uint32,                               0,                             0
+SR-IOV.VLANProtocol,                         config_parse_sr_iov_vlan_proto,                           0,                             0
 SR-IOV.MACSpoofCheck,                        config_parse_sr_iov_boolean,                              0,                             0
 SR-IOV.QueryReceiveSideScaling,              config_parse_sr_iov_boolean,                              0,                             0
 SR-IOV.Trust,                                config_parse_sr_iov_boolean,                              0,                             0
index 63d0d1443dca81b611443c500f71ba7812f6d8d2..62a6fc9c225119cd3563e3625519994ea08dbc51 100644 (file)
@@ -18,6 +18,7 @@ static int sr_iov_new(SRIOV **ret) {
 
         *sr_iov = (SRIOV) {
                   .vf = (uint32_t) -1,
+                  .vlan_proto = ETH_P_8021Q,
                   .vf_spoof_check_setting = -1,
                   .trust = -1,
                   .query_rss = -1,
@@ -180,7 +181,7 @@ int sr_iov_configure(Link *link, SRIOV *sr_iov) {
                 ivvi.vf = sr_iov->vf;
                 ivvi.vlan = sr_iov->vlan;
                 ivvi.qos = sr_iov->qos;
-                ivvi.vlan_proto = htobe16(ETH_P_8021Q);
+                ivvi.vlan_proto = htobe16(sr_iov->vlan_proto);
 
                 r = sd_netlink_message_open_container(req, IFLA_VF_VLAN_LIST);
                 if (r < 0)
@@ -297,6 +298,45 @@ int config_parse_sr_iov_uint32(
         return 0;
 }
 
+int config_parse_sr_iov_vlan_proto(
+                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_(sr_iov_free_or_set_invalidp) SRIOV *sr_iov = NULL;
+        Network *network = data;
+        int r;
+
+        assert(filename);
+        assert(lvalue);
+        assert(rvalue);
+        assert(data);
+
+        r = sr_iov_new_static(network, filename, section_line, &sr_iov);
+        if (r < 0)
+                return r;
+
+        if (isempty(rvalue) || streq(rvalue, "802.1Q"))
+                sr_iov->vlan_proto = ETH_P_8021Q;
+        else if (streq(rvalue, "802.1ad"))
+                sr_iov->vlan_proto = ETH_P_8021AD;
+        else {
+                log_syntax(unit, LOG_ERR, filename, line, 0,
+                           "Invalid SR-IOV '%s=', ignoring assignment: %s", lvalue, rvalue);
+                return 0;
+        }
+
+        TAKE_PTR(sr_iov);
+        return 0;
+}
+
 int config_parse_sr_iov_link_state(
                 const char *unit,
                 const char *filename,
index d9668d7b65fd975b39a41d0a7e77395932df9c53..65ad3266b3d7699afc411e2888566801f8a365fb 100644 (file)
@@ -24,6 +24,7 @@ typedef struct SRIOV {
         uint32_t vf;   /* 0 - 2147483646 */
         uint32_t vlan; /* 0 - 4095, 0 disables VLAN filter */
         uint32_t qos;
+        uint16_t vlan_proto; /* ETH_P_8021Q or ETH_P_8021AD */
         int vf_spoof_check_setting;
         int query_rss;
         int trust;
@@ -40,3 +41,4 @@ DEFINE_NETWORK_SECTION_FUNCTIONS(SRIOV, sr_iov_free);
 CONFIG_PARSER_PROTOTYPE(config_parse_sr_iov_uint32);
 CONFIG_PARSER_PROTOTYPE(config_parse_sr_iov_boolean);
 CONFIG_PARSER_PROTOTYPE(config_parse_sr_iov_link_state);
+CONFIG_PARSER_PROTOTYPE(config_parse_sr_iov_vlan_proto);
index 0066cbda18d9eb5d6866bce4e2b88b1798029d20..c5bab2abf8320e3cd2eb161f9ed97cd183db29a4 100644 (file)
@@ -42,6 +42,7 @@ Group=
 VirtualFunction=
 MACSpoofCheck=
 VLANId=
+VLANProtocol=
 QualityOfService=
 QueryReceiveSideScaling=
 Trust=