From: Susant Sahani Date: Tue, 12 Jan 2021 10:02:12 +0000 (+0100) Subject: network: Allow to configure VLan egress qos maps X-Git-Tag: v248-rc1~362^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ea0708628593846dfb8301349fb1ddc42f55e0c4;p=thirdparty%2Fsystemd.git network: Allow to configure VLan egress qos maps --- diff --git a/man/systemd.netdev.xml b/man/systemd.netdev.xml index 7add69ca8da..9bb7491a6ea 100644 --- a/man/systemd.netdev.xml +++ b/man/systemd.netdev.xml @@ -502,6 +502,17 @@ + + IngressQOSMaps= + + Defines a mapping of Linux internal packet priority (SO_PRIORITY) to VLAN header + PCP field for incoming frames. Takes a whitespace-separated list of unsigned integer pairs in the format + from-to, e.g., 21-7 45-5 ranges 1–4294967294. + Note that from must be greater than or equal to to. When unset, + the kernel's default will be used. + + + diff --git a/src/network/netdev/netdev-gperf.gperf b/src/network/netdev/netdev-gperf.gperf index 2c94065bf55..720bacc7f55 100644 --- a/src/network/netdev/netdev-gperf.gperf +++ b/src/network/netdev/netdev-gperf.gperf @@ -54,6 +54,7 @@ VLAN.MVRP, config_parse_tristate, VLAN.LooseBinding, config_parse_tristate, 0, offsetof(VLan, loose_binding) VLAN.ReorderHeader, config_parse_tristate, 0, offsetof(VLan, reorder_hdr) VLAN.EgressQOSMaps, config_parse_vlan_qos_maps, 0, offsetof(VLan, egress_qos_maps) +VLAN.IngressQOSMaps, config_parse_vlan_qos_maps, 0, offsetof(VLan, ingress_qos_maps) MACVLAN.Mode, config_parse_macvlan_mode, 0, offsetof(MacVlan, mode) MACVLAN.SourceMACAddress, config_parse_hwaddrs, 0, offsetof(MacVlan, match_source_mac) MACVTAP.Mode, config_parse_macvlan_mode, 0, offsetof(MacVlan, mode) diff --git a/src/network/netdev/vlan.c b/src/network/netdev/vlan.c index f9fcea8898a..de3eb721e9b 100644 --- a/src/network/netdev/vlan.c +++ b/src/network/netdev/vlan.c @@ -73,6 +73,24 @@ static int netdev_vlan_fill_message_create(NetDev *netdev, Link *link, sd_netlin return log_netdev_error_errno(netdev, r, "Could not close container IFLA_VLAN_EGRESS_QOS: %m"); } + if (!set_isempty(v->ingress_qos_maps)) { + struct ifla_vlan_qos_mapping *m; + + r = sd_netlink_message_open_container(req, IFLA_VLAN_INGRESS_QOS); + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not open container IFLA_VLAN_INGRESS_QOS: %m"); + + SET_FOREACH(m, v->ingress_qos_maps) { + r = sd_netlink_message_append_data(req, IFLA_VLAN_QOS_MAPPING, m, sizeof(struct ifla_vlan_qos_mapping)); + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_VLAN_QOS_MAPPING attribute: %m"); + } + + r = sd_netlink_message_close_container(req); + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not close container IFLA_VLAN_INGRESS_QOS: %m"); + } + return 0; } @@ -186,6 +204,7 @@ static void vlan_done(NetDev *n) { assert(v); set_free(v->egress_qos_maps); + set_free(v->ingress_qos_maps); } static void vlan_init(NetDev *netdev) { diff --git a/src/network/netdev/vlan.h b/src/network/netdev/vlan.h index 376024d4fd3..1e5e5904fcd 100644 --- a/src/network/netdev/vlan.h +++ b/src/network/netdev/vlan.h @@ -18,6 +18,7 @@ struct VLan { int reorder_hdr; Set *egress_qos_maps; + Set *ingress_qos_maps; }; DEFINE_NETDEV_CAST(VLAN, VLan); diff --git a/test/fuzz/fuzz-netdev-parser/directives.netdev b/test/fuzz/fuzz-netdev-parser/directives.netdev index d038b21a634..8c36e31a0e7 100644 --- a/test/fuzz/fuzz-netdev-parser/directives.netdev +++ b/test/fuzz/fuzz-netdev-parser/directives.netdev @@ -6,6 +6,7 @@ Id= GVRP= Protocol= EgressQOSMaps= +IngressQOSMaps= [MACVLAN] Mode= SourceMACAddress=