diff options
-rw-r--r-- | man/systemd.link.xml | 16 | ||||
-rw-r--r-- | src/libsystemd/sd-netlink/netlink-types.c | 2 | ||||
-rw-r--r-- | src/libsystemd/sd-netlink/netlink-util.c | 17 | ||||
-rw-r--r-- | src/libsystemd/sd-netlink/netlink-util.h | 3 | ||||
-rw-r--r-- | src/udev/net/link-config-gperf.gperf | 94 | ||||
-rw-r--r-- | src/udev/net/link-config.c | 2 | ||||
-rw-r--r-- | src/udev/net/link-config.h | 2 | ||||
-rw-r--r-- | test/fuzz/fuzz-link-parser/directives.link | 2 |
8 files changed, 88 insertions, 50 deletions
diff --git a/man/systemd.link.xml b/man/systemd.link.xml index 24271ea65a..e6b4b54668 100644 --- a/man/systemd.link.xml +++ b/man/systemd.link.xml @@ -743,6 +743,22 @@ PAUSE configuration. When unset, the kernel's default will be used.</para> </listitem> </varlistentry> + <varlistentry> + <term><varname>GenericSegmentOffloadMaxBytes=</varname></term> + <listitem> + <para>Specifies the maximum size of a Generic Segment Offload (GSO) packet the + device should accept. The usual suffixes K, M, G, are supported and are + understood to the base of 1024. An unsigned integer in the range 1—65536. + Defaults to unset.</para> + </listitem> + </varlistentry> + <varlistentry> + <term><varname>GenericSegmentOffloadMaxSegments=</varname></term> + <listitem> + <para>Specifies the maximum number of a Generic Segment Offload (GSO) segments the device should accept. + An unsigned integer in the range 1—65535. Defaults to unset.</para> + </listitem> + </varlistentry> </variablelist> </refsect1> diff --git a/src/libsystemd/sd-netlink/netlink-types.c b/src/libsystemd/sd-netlink/netlink-types.c index f5e5fdf3af..15db32fd1b 100644 --- a/src/libsystemd/sd-netlink/netlink-types.c +++ b/src/libsystemd/sd-netlink/netlink-types.c @@ -642,6 +642,8 @@ static const NLType rtnl_link_types[] = { [IFLA_PROMISCUITY] = { .type = NETLINK_TYPE_U32 }, [IFLA_NUM_TX_QUEUES] = { .type = NETLINK_TYPE_U32 }, [IFLA_NUM_RX_QUEUES] = { .type = NETLINK_TYPE_U32 }, + [IFLA_GSO_MAX_SEGS] = { .type = NETLINK_TYPE_U32 }, + [IFLA_GSO_MAX_SIZE] = { .type = NETLINK_TYPE_U32 }, [IFLA_CARRIER] = { .type = NETLINK_TYPE_U8 }, /* [IFLA_PHYS_PORT_ID] = { .type = NETLINK_TYPE_BINARY, .len = MAX_PHYS_PORT_ID_LEN }, diff --git a/src/libsystemd/sd-netlink/netlink-util.c b/src/libsystemd/sd-netlink/netlink-util.c index 09e2158c9e..56cde0ffb0 100644 --- a/src/libsystemd/sd-netlink/netlink-util.c +++ b/src/libsystemd/sd-netlink/netlink-util.c @@ -58,14 +58,15 @@ int rtnl_set_link_name(sd_netlink **rtnl, int ifindex, const char *name) { } int rtnl_set_link_properties(sd_netlink **rtnl, int ifindex, const char *alias, - const struct ether_addr *mac, uint32_t mtu) { + const struct ether_addr *mac, uint32_t mtu, + uint32_t gso_max_size, size_t gso_max_segments) { _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *message = NULL; int r; assert(rtnl); assert(ifindex > 0); - if (!alias && !mac && mtu == 0) + if (!alias && !mac && mtu == 0 && gso_max_size == 0 && gso_max_segments == 0) return 0; if (!*rtnl) { @@ -96,6 +97,18 @@ int rtnl_set_link_properties(sd_netlink **rtnl, int ifindex, const char *alias, return r; } + if (gso_max_size > 0) { + r = sd_netlink_message_append_u32(message, IFLA_GSO_MAX_SIZE, gso_max_size); + if (r < 0) + return r; + } + + if (gso_max_segments > 0) { + r = sd_netlink_message_append_u32(message, IFLA_GSO_MAX_SEGS, gso_max_segments); + if (r < 0) + return r; + } + r = sd_netlink_call(*rtnl, message, 0, NULL); if (r < 0) return r; diff --git a/src/libsystemd/sd-netlink/netlink-util.h b/src/libsystemd/sd-netlink/netlink-util.h index d28d07a9f5..08b273b5e8 100644 --- a/src/libsystemd/sd-netlink/netlink-util.h +++ b/src/libsystemd/sd-netlink/netlink-util.h @@ -70,7 +70,8 @@ static inline bool rtnl_message_type_is_mdb(uint16_t type) { } int rtnl_set_link_name(sd_netlink **rtnl, int ifindex, const char *name); -int rtnl_set_link_properties(sd_netlink **rtnl, int ifindex, const char *alias, const struct ether_addr *mac, uint32_t mtu); +int rtnl_set_link_properties(sd_netlink **rtnl, int ifindex, const char *alias, const struct ether_addr *mac, uint32_t mtu, + uint32_t gso_max_size, size_t gso_max_segments); int rtnl_get_link_alternative_names(sd_netlink **rtnl, int ifindex, char ***ret); int rtnl_set_link_alternative_names(sd_netlink **rtnl, int ifindex, char * const *alternative_names); int rtnl_set_link_alternative_names_by_ifname(sd_netlink **rtnl, const char *ifname, char * const *alternative_names); diff --git a/src/udev/net/link-config-gperf.gperf b/src/udev/net/link-config-gperf.gperf index dc107170cc..9d66cb284d 100644 --- a/src/udev/net/link-config-gperf.gperf +++ b/src/udev/net/link-config-gperf.gperf @@ -20,49 +20,51 @@ struct ConfigPerfItem; %struct-type %includes %% -Match.MACAddress, config_parse_hwaddrs, 0, offsetof(link_config, match.mac) -Match.PermanentMACAddress, config_parse_hwaddrs, 0, offsetof(link_config, match.permanent_mac) -Match.OriginalName, config_parse_match_ifnames, 0, offsetof(link_config, match.ifname) -Match.Path, config_parse_match_strv, 0, offsetof(link_config, match.path) -Match.Driver, config_parse_match_strv, 0, offsetof(link_config, match.driver) -Match.Type, config_parse_match_strv, 0, offsetof(link_config, match.iftype) -Match.Property, config_parse_match_property, 0, offsetof(link_config, match.property) -Match.Host, config_parse_net_condition, CONDITION_HOST, offsetof(link_config, conditions) -Match.Virtualization, config_parse_net_condition, CONDITION_VIRTUALIZATION, offsetof(link_config, conditions) -Match.KernelCommandLine, config_parse_net_condition, CONDITION_KERNEL_COMMAND_LINE, offsetof(link_config, conditions) -Match.KernelVersion, config_parse_net_condition, CONDITION_KERNEL_VERSION, offsetof(link_config, conditions) -Match.Architecture, config_parse_net_condition, CONDITION_ARCHITECTURE, offsetof(link_config, conditions) -Link.Description, config_parse_string, 0, offsetof(link_config, description) -Link.MACAddressPolicy, config_parse_mac_address_policy, 0, offsetof(link_config, mac_address_policy) -Link.MACAddress, config_parse_hwaddr, 0, offsetof(link_config, mac) -Link.NamePolicy, config_parse_name_policy, 0, offsetof(link_config, name_policy) -Link.Name, config_parse_ifname, 0, offsetof(link_config, name) -Link.AlternativeName, config_parse_ifnames, IFNAME_VALID_ALTERNATIVE, offsetof(link_config, alternative_names) -Link.AlternativeNamesPolicy, config_parse_alternative_names_policy, 0, offsetof(link_config, alternative_names_policy) -Link.Alias, config_parse_ifalias, 0, offsetof(link_config, alias) -Link.MTUBytes, config_parse_mtu, AF_UNSPEC, offsetof(link_config, mtu) -Link.BitsPerSecond, config_parse_si_uint64, 0, offsetof(link_config, speed) -Link.Duplex, config_parse_duplex, 0, offsetof(link_config, duplex) -Link.AutoNegotiation, config_parse_tristate, 0, offsetof(link_config, autonegotiation) -Link.WakeOnLan, config_parse_wol, 0, offsetof(link_config, wol) -Link.Port, config_parse_port, 0, offsetof(link_config, port) -Link.ReceiveChecksumOffload, config_parse_tristate, 0, offsetof(link_config, features[NET_DEV_FEAT_RX]) -Link.TransmitChecksumOffload, config_parse_tristate, 0, offsetof(link_config, features[NET_DEV_FEAT_TX]) -Link.GenericSegmentationOffload, config_parse_tristate, 0, offsetof(link_config, features[NET_DEV_FEAT_GSO]) -Link.TCPSegmentationOffload, config_parse_tristate, 0, offsetof(link_config, features[NET_DEV_FEAT_TSO]) -Link.TCP6SegmentationOffload, config_parse_tristate, 0, offsetof(link_config, features[NET_DEV_FEAT_TSO6]) -Link.UDPSegmentationOffload, config_parse_warn_compat, DISABLED_LEGACY, 0 -Link.GenericReceiveOffload, config_parse_tristate, 0, offsetof(link_config, features[NET_DEV_FEAT_GRO]) -Link.LargeReceiveOffload, config_parse_tristate, 0, offsetof(link_config, features[NET_DEV_FEAT_LRO]) -Link.RxChannels, config_parse_channel, 0, offsetof(link_config, channels) -Link.TxChannels, config_parse_channel, 0, offsetof(link_config, channels) -Link.OtherChannels, config_parse_channel, 0, offsetof(link_config, channels) -Link.CombinedChannels, config_parse_channel, 0, offsetof(link_config, channels) -Link.Advertise, config_parse_advertise, 0, offsetof(link_config, advertise) -Link.RxBufferSize, config_parse_nic_buffer_size, 0, offsetof(link_config, ring) -Link.RxMiniBufferSize, config_parse_nic_buffer_size, 0, offsetof(link_config, ring) -Link.RxJumboBufferSize, config_parse_nic_buffer_size, 0, offsetof(link_config, ring) -Link.TxBufferSize, config_parse_nic_buffer_size, 0, offsetof(link_config, ring) -Link.RxFlowControl, config_parse_tristate, 0, offsetof(link_config, rx_flow_control) -Link.TxFlowControl, config_parse_tristate, 0, offsetof(link_config, tx_flow_control) -Link.AutoNegotiationFlowControl, config_parse_tristate, 0, offsetof(link_config, autoneg_flow_control) +Match.MACAddress, config_parse_hwaddrs, 0, offsetof(link_config, match.mac) +Match.PermanentMACAddress, config_parse_hwaddrs, 0, offsetof(link_config, match.permanent_mac) +Match.OriginalName, config_parse_match_ifnames, 0, offsetof(link_config, match.ifname) +Match.Path, config_parse_match_strv, 0, offsetof(link_config, match.path) +Match.Driver, config_parse_match_strv, 0, offsetof(link_config, match.driver) +Match.Type, config_parse_match_strv, 0, offsetof(link_config, match.iftype) +Match.Property, config_parse_match_property, 0, offsetof(link_config, match.property) +Match.Host, config_parse_net_condition, CONDITION_HOST, offsetof(link_config, conditions) +Match.Virtualization, config_parse_net_condition, CONDITION_VIRTUALIZATION, offsetof(link_config, conditions) +Match.KernelCommandLine, config_parse_net_condition, CONDITION_KERNEL_COMMAND_LINE, offsetof(link_config, conditions) +Match.KernelVersion, config_parse_net_condition, CONDITION_KERNEL_VERSION, offsetof(link_config, conditions) +Match.Architecture, config_parse_net_condition, CONDITION_ARCHITECTURE, offsetof(link_config, conditions) +Link.Description, config_parse_string, 0, offsetof(link_config, description) +Link.MACAddressPolicy, config_parse_mac_address_policy, 0, offsetof(link_config, mac_address_policy) +Link.MACAddress, config_parse_hwaddr, 0, offsetof(link_config, mac) +Link.NamePolicy, config_parse_name_policy, 0, offsetof(link_config, name_policy) +Link.Name, config_parse_ifname, 0, offsetof(link_config, name) +Link.AlternativeName, config_parse_ifnames, IFNAME_VALID_ALTERNATIVE, offsetof(link_config, alternative_names) +Link.AlternativeNamesPolicy, config_parse_alternative_names_policy, 0, offsetof(link_config, alternative_names_policy) +Link.Alias, config_parse_ifalias, 0, offsetof(link_config, alias) +Link.MTUBytes, config_parse_mtu, AF_UNSPEC, offsetof(link_config, mtu) +Link.BitsPerSecond, config_parse_si_uint64, 0, offsetof(link_config, speed) +Link.Duplex, config_parse_duplex, 0, offsetof(link_config, duplex) +Link.AutoNegotiation, config_parse_tristate, 0, offsetof(link_config, autonegotiation) +Link.WakeOnLan, config_parse_wol, 0, offsetof(link_config, wol) +Link.Port, config_parse_port, 0, offsetof(link_config, port) +Link.ReceiveChecksumOffload, config_parse_tristate, 0, offsetof(link_config, features[NET_DEV_FEAT_RX]) +Link.TransmitChecksumOffload, config_parse_tristate, 0, offsetof(link_config, features[NET_DEV_FEAT_TX]) +Link.GenericSegmentationOffload, config_parse_tristate, 0, offsetof(link_config, features[NET_DEV_FEAT_GSO]) +Link.TCPSegmentationOffload, config_parse_tristate, 0, offsetof(link_config, features[NET_DEV_FEAT_TSO]) +Link.TCP6SegmentationOffload, config_parse_tristate, 0, offsetof(link_config, features[NET_DEV_FEAT_TSO6]) +Link.UDPSegmentationOffload, config_parse_warn_compat, DISABLED_LEGACY, 0 +Link.GenericReceiveOffload, config_parse_tristate, 0, offsetof(link_config, features[NET_DEV_FEAT_GRO]) +Link.LargeReceiveOffload, config_parse_tristate, 0, offsetof(link_config, features[NET_DEV_FEAT_LRO]) +Link.RxChannels, config_parse_channel, 0, offsetof(link_config, channels) +Link.TxChannels, config_parse_channel, 0, offsetof(link_config, channels) +Link.OtherChannels, config_parse_channel, 0, offsetof(link_config, channels) +Link.CombinedChannels, config_parse_channel, 0, offsetof(link_config, channels) +Link.Advertise, config_parse_advertise, 0, offsetof(link_config, advertise) +Link.RxBufferSize, config_parse_nic_buffer_size, 0, offsetof(link_config, ring) +Link.RxMiniBufferSize, config_parse_nic_buffer_size, 0, offsetof(link_config, ring) +Link.RxJumboBufferSize, config_parse_nic_buffer_size, 0, offsetof(link_config, ring) +Link.TxBufferSize, config_parse_nic_buffer_size, 0, offsetof(link_config, ring) +Link.RxFlowControl, config_parse_tristate, 0, offsetof(link_config, rx_flow_control) +Link.TxFlowControl, config_parse_tristate, 0, offsetof(link_config, tx_flow_control) +Link.AutoNegotiationFlowControl, config_parse_tristate, 0, offsetof(link_config, autoneg_flow_control) +Link.GenericSegmentOffloadMaxBytes, config_parse_iec_size, 0, offsetof(link_config, gso_max_size) +Link.GenericSegmentOffloadMaxSegments, config_parse_uint32, 0, offsetof(link_config, gso_max_segments) diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c index cbeaad9ccc..95d4564050 100644 --- a/src/udev/net/link-config.c +++ b/src/udev/net/link-config.c @@ -426,7 +426,7 @@ static int link_config_apply_rtnl_settings(sd_netlink **rtnl, const link_config } else mac = config->mac; - r = rtnl_set_link_properties(rtnl, ifindex, config->alias, mac, config->mtu); + r = rtnl_set_link_properties(rtnl, ifindex, config->alias, mac, config->mtu, config->gso_max_size, config->gso_max_segments); if (r < 0) log_device_warning_errno(device, r, "Could not set Alias=, MACAddress= or MTU=, ignoring: %m"); diff --git a/src/udev/net/link-config.h b/src/udev/net/link-config.h index 1beecb10ea..c563717448 100644 --- a/src/udev/net/link-config.h +++ b/src/udev/net/link-config.h @@ -47,6 +47,8 @@ struct link_config { char **alternative_names; char *alias; uint32_t mtu; + uint32_t gso_max_segments; + size_t gso_max_size; uint64_t speed; Duplex duplex; int autonegotiation; diff --git a/test/fuzz/fuzz-link-parser/directives.link b/test/fuzz/fuzz-link-parser/directives.link index 7d23a9ecf8..f1067568fa 100644 --- a/test/fuzz/fuzz-link-parser/directives.link +++ b/test/fuzz/fuzz-link-parser/directives.link @@ -46,3 +46,5 @@ TxBufferSize= RxFlowControl= TxFlowControl= AutoNegotiationFlowControl= +GenericSegmentOffloadMaxBytes= +GenericSegmentOffloadMaxSegments= |