diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2020-06-22 19:26:31 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2020-07-01 13:51:35 +0900 |
commit | e64b31c84867d9a9c07166ec9cedf6776b93b1be (patch) | |
tree | 1ed5c12831c51cc4e33d4eb393c4d76596710e97 /src/network/networkd-sriov.c | |
parent | 518cd6b52700b1206ea2b268602b7da7073f160f (diff) | |
download | systemd-e64b31c84867d9a9c07166ec9cedf6776b93b1be.tar.gz |
network: add VLANProtocol= setting in [SR-IOV] section
Diffstat (limited to 'src/network/networkd-sriov.c')
-rw-r--r-- | src/network/networkd-sriov.c | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/network/networkd-sriov.c b/src/network/networkd-sriov.c index 63d0d1443d..62a6fc9c22 100644 --- a/src/network/networkd-sriov.c +++ b/src/network/networkd-sriov.c @@ -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, |