summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-01-20 15:50:01 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-02-03 14:44:51 +0900
commitface9fcc165809bc621933794a919e3fde5afbbe (patch)
tree43fbe35f25772d1ada7253b19487513807cff6df
parent1f8dc96c06ead4f9bd88e82a8e91ecdeaec4ae04 (diff)
downloadsystemd-face9fcc165809bc621933794a919e3fde5afbbe.tar.gz
network,udev: move TransmitQueues=/ReceiveQueues= from .network to .link
As the settings are mostly hardware setup, and merely see from network layer. See also discussions in https://github.com/systemd/systemd/pull/18170#issuecomment-758807497 https://github.com/orgs/systemd/teams/systemd/discussions/1
-rw-r--r--man/systemd.link.xml14
-rw-r--r--man/systemd.network.xml14
-rw-r--r--src/libsystemd/sd-netlink/netlink-util.c28
-rw-r--r--src/libsystemd/sd-netlink/netlink-util.h13
-rw-r--r--src/network/networkd-link.c59
-rw-r--r--src/network/networkd-network-gperf.gperf2
-rw-r--r--src/network/networkd-network.c34
-rw-r--r--src/network/networkd-network.h3
-rw-r--r--src/udev/net/link-config-gperf.gperf2
-rw-r--r--src/udev/net/link-config.c46
-rw-r--r--src/udev/net/link-config.h3
-rw-r--r--test/fuzz/fuzz-link-parser/directives.link2
-rw-r--r--test/fuzz/fuzz-network-parser/directives.network2
13 files changed, 99 insertions, 123 deletions
diff --git a/man/systemd.link.xml b/man/systemd.link.xml
index 9fefb0c372..93f7191b33 100644
--- a/man/systemd.link.xml
+++ b/man/systemd.link.xml
@@ -410,6 +410,20 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term><varname>TransmitQueues=</varname></term>
+ <listitem>
+ <para>Specifies the device's number of transmit queues. An integer in the range 1…4096.
+ When unset, the kernel's default will be used.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><varname>ReceiveQueues=</varname></term>
+ <listitem>
+ <para>Specifies the device's number of receive queues. An integer in the range 1…4096.
+ When unset, the kernel's default will be used.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term><varname>TransmitQueueLength=</varname></term>
<listitem>
<para>Specifies the transmit queue length of the device in number of packets. An unsigned integer
diff --git a/man/systemd.network.xml b/man/systemd.network.xml
index 8e7b190638..606a2dd5db 100644
--- a/man/systemd.network.xml
+++ b/man/systemd.network.xml
@@ -216,20 +216,6 @@
</listitem>
</varlistentry>
<varlistentry>
- <term><varname>TransmitQueues=</varname></term>
- <listitem>
- <para>Specifies the devices's number of transmit queues. An integer in the range 1…4096.
- When unset, the kernel's default will be used.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><varname>ReceiveQueues=</varname></term>
- <listitem>
- <para>Specifies the devices's number of receive queues. An integer in the range 1…4096.
- When unset, the kernel's default will be used.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
<term><varname>RequiredForOnline=</varname></term>
<listitem>
<para>Takes a boolean or a minimum operational state and an optional maximum operational state.
diff --git a/src/libsystemd/sd-netlink/netlink-util.c b/src/libsystemd/sd-netlink/netlink-util.c
index a0bc44e7fb..448c50d4ab 100644
--- a/src/libsystemd/sd-netlink/netlink-util.c
+++ b/src/libsystemd/sd-netlink/netlink-util.c
@@ -57,15 +57,25 @@ int rtnl_set_link_name(sd_netlink **rtnl, int ifindex, const char *name) {
return 0;
}
-int rtnl_set_link_properties(sd_netlink **rtnl, int ifindex, const char *alias, const struct ether_addr *mac,
- uint32_t txqueuelen, uint32_t mtu, uint32_t gso_max_size, size_t gso_max_segments) {
+int rtnl_set_link_properties(
+ sd_netlink **rtnl,
+ int ifindex,
+ const char *alias,
+ const struct ether_addr *mac,
+ uint32_t txqueues,
+ uint32_t rxqueues,
+ uint32_t txqueuelen,
+ 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 && txqueuelen == UINT32_MAX && mtu == 0 && gso_max_size == 0 && gso_max_segments == 0)
+ if (!alias && !mac && txqueues == 0 && rxqueues == 0 && txqueuelen == UINT32_MAX && mtu == 0 &&
+ gso_max_size == 0 && gso_max_segments == 0)
return 0;
if (!*rtnl) {
@@ -90,6 +100,18 @@ int rtnl_set_link_properties(sd_netlink **rtnl, int ifindex, const char *alias,
return r;
}
+ if (txqueues > 0) {
+ r = sd_netlink_message_append_u32(message, IFLA_NUM_TX_QUEUES, txqueues);
+ if (r < 0)
+ return r;
+ }
+
+ if (rxqueues > 0) {
+ r = sd_netlink_message_append_u32(message, IFLA_NUM_RX_QUEUES, rxqueues);
+ if (r < 0)
+ return r;
+ }
+
if (txqueuelen < UINT32_MAX) {
r = sd_netlink_message_append_u32(message, IFLA_TXQLEN, txqueuelen);
if (r < 0)
diff --git a/src/libsystemd/sd-netlink/netlink-util.h b/src/libsystemd/sd-netlink/netlink-util.h
index acf5b668a2..a3a3951ff7 100644
--- a/src/libsystemd/sd-netlink/netlink-util.h
+++ b/src/libsystemd/sd-netlink/netlink-util.h
@@ -70,8 +70,17 @@ 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 txqueuelen, uint32_t mtu, uint32_t gso_max_size, size_t gso_max_segments);
+int rtnl_set_link_properties(
+ sd_netlink **rtnl,
+ int ifindex,
+ const char *alias,
+ const struct ether_addr *mac,
+ uint32_t txqueues,
+ uint32_t rxqueues,
+ uint32_t txqueuelen,
+ 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/network/networkd-link.c b/src/network/networkd-link.c
index fe6d3bd927..ccefb46cbc 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1479,61 +1479,6 @@ static int link_set_group(Link *link) {
return 0;
}
-static int link_tx_rx_queues_hadler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
- int r;
-
- assert(link);
-
- if (IN_SET(link->state, LINK_STATE_FAILED, LINK_STATE_LINGER))
- return 1;
-
- r = sd_netlink_message_get_errno(m);
- if (r < 0)
- log_link_message_warning_errno(link, m, r, "Could not set transmit / receive queues for the interface");
-
- return 1;
-}
-
-static int link_set_tx_rx_queues(Link *link) {
- _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
- int r;
-
- assert(link);
- assert(link->network);
- assert(link->manager);
- assert(link->manager->rtnl);
-
- if (link->network->txqueues == 0 && link->network->rxqueues == 0)
- return 0;
-
- log_link_debug(link, "Setting transmit / receive queues");
-
- r = sd_rtnl_message_new_link(link->manager->rtnl, &req, RTM_SETLINK, link->ifindex);
- if (r < 0)
- return log_link_error_errno(link, r, "Could not allocate RTM_SETLINK message: %m");
-
- if (link->network->txqueues > 0) {
- r = sd_netlink_message_append_u32(req, IFLA_NUM_TX_QUEUES, link->network->txqueues);
- if (r < 0)
- return log_link_error_errno(link, r, "Could not set link transmit queues: %m");
- }
-
- if (link->network->rxqueues > 0) {
- r = sd_netlink_message_append_u32(req, IFLA_NUM_RX_QUEUES, link->network->rxqueues);
- if (r < 0)
- return log_link_error_errno(link, r, "Could not set link receive queues: %m");
- }
-
- r = netlink_call_async(link->manager->rtnl, NULL, req, link_tx_rx_queues_hadler,
- link_netlink_destroy_callback, link);
- if (r < 0)
- return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
-
- link_ref(link);
-
- return 0;
-}
-
static int link_handle_bound_to_list(Link *link) {
Link *l;
int r;
@@ -2111,10 +2056,6 @@ int link_configure(Link *link) {
if (r < 0)
return r;
- r = link_set_tx_rx_queues(link);
- if (r < 0)
- return r;
-
r = ipv4ll_configure(link);
if (r < 0)
return r;
diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf
index f1344c0fcc..7f0de7660c 100644
--- a/src/network/networkd-network-gperf.gperf
+++ b/src/network/networkd-network-gperf.gperf
@@ -60,8 +60,6 @@ Match.Architecture, config_parse_net_condition,
Link.MACAddress, config_parse_hwaddr, 0, offsetof(Network, mac)
Link.MTUBytes, config_parse_mtu, AF_UNSPEC, offsetof(Network, mtu)
Link.Group, config_parse_uint32, 0, offsetof(Network, group)
-Link.TransmitQueues, config_parse_rx_tx_queues, 0, offsetof(Network, txqueues)
-Link.ReceiveQueues, config_parse_rx_tx_queues, 0, offsetof(Network, rxqueues)
Link.ARP, config_parse_tristate, 0, offsetof(Network, arp)
Link.Multicast, config_parse_tristate, 0, offsetof(Network, multicast)
Link.AllMulticast, config_parse_tristate, 0, offsetof(Network, allmulticast)
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index 62e3ff0cc6..84ab1d5e18 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -1198,40 +1198,6 @@ int config_parse_required_for_online(
return 0;
}
-int config_parse_rx_tx_queues(
- 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) {
-
- uint32_t k, *v = data;
- int r;
-
- if (isempty(rvalue)) {
- *v = 0;
- return 0;
- }
-
- r = safe_atou32(rvalue, &k);
- if (r < 0) {
- log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse %s=, ignoring assignment: %s.", lvalue, rvalue);
- return 0;
- }
- if (k == 0 || k > 4096) {
- log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid %s=, ignoring assignment: %s.", lvalue, rvalue);
- return 0;
- }
-
- *v = k;
- return 0;
-}
-
DEFINE_CONFIG_PARSE_ENUM(config_parse_keep_configuration, keep_configuration, KeepConfiguration,
"Failed to parse KeepConfiguration= setting");
diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h
index b1db17f7b7..baa806fca6 100644
--- a/src/network/networkd-network.h
+++ b/src/network/networkd-network.h
@@ -95,8 +95,6 @@ struct Network {
struct ether_addr *mac;
uint32_t mtu;
uint32_t group;
- uint32_t txqueues;
- uint32_t rxqueues;
int arp;
int multicast;
int allmulticast;
@@ -344,7 +342,6 @@ CONFIG_PARSER_PROTOTYPE(config_parse_ntp);
CONFIG_PARSER_PROTOTYPE(config_parse_required_for_online);
CONFIG_PARSER_PROTOTYPE(config_parse_keep_configuration);
CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_link_local_address_gen_mode);
-CONFIG_PARSER_PROTOTYPE(config_parse_rx_tx_queues);
CONFIG_PARSER_PROTOTYPE(config_parse_activation_policy);
const struct ConfigPerfItem* network_network_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
diff --git a/src/udev/net/link-config-gperf.gperf b/src/udev/net/link-config-gperf.gperf
index e7abd2d436..70c5525b57 100644
--- a/src/udev/net/link-config-gperf.gperf
+++ b/src/udev/net/link-config-gperf.gperf
@@ -41,6 +41,8 @@ Link.Name, config_parse_ifname, 0,
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.TransmitQueues, config_parse_rx_tx_queues, 0, offsetof(link_config, txqueues)
+Link.ReceiveQueues, config_parse_rx_tx_queues, 0, offsetof(link_config, rxqueues)
Link.TransmitQueueLength, config_parse_txqueuelen, 0, offsetof(link_config, txqueuelen)
Link.MTUBytes, config_parse_mtu, AF_UNSPEC, offsetof(link_config, mtu)
Link.BitsPerSecond, config_parse_si_uint64, 0, offsetof(link_config, speed)
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
index baad48b43b..0653ae7a9c 100644
--- a/src/udev/net/link-config.c
+++ b/src/udev/net/link-config.c
@@ -427,11 +427,15 @@ 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->txqueuelen, config->mtu,
- config->gso_max_size, config->gso_max_segments);
+ r = rtnl_set_link_properties(rtnl, ifindex, config->alias, mac,
+ config->txqueues, config->rxqueues, config->txqueuelen,
+ config->mtu, config->gso_max_size, config->gso_max_segments);
if (r < 0)
- log_device_warning_errno(device, r, "Could not set Alias=, MACAddress=, TransmitQueueLength=, MTU=, "
- "GenericSegmentOffloadMaxBytes= or GenericSegmentOffloadMaxSegments=, ignoring: %m");
+ log_device_warning_errno(device, r,
+ "Could not set Alias=, MACAddress=, "
+ "TransmitQueues=, ReceiveQueues=, TransmitQueueLength=, MTU=, "
+ "GenericSegmentOffloadMaxBytes= or GenericSegmentOffloadMaxSegments=, "
+ "ignoring: %m");
return 0;
}
@@ -704,6 +708,40 @@ int config_parse_ifalias(
return 0;
}
+int config_parse_rx_tx_queues(
+ 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) {
+
+ uint32_t k, *v = data;
+ int r;
+
+ if (isempty(rvalue)) {
+ *v = 0;
+ return 0;
+ }
+
+ r = safe_atou32(rvalue, &k);
+ if (r < 0) {
+ log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse %s=, ignoring assignment: %s.", lvalue, rvalue);
+ return 0;
+ }
+ if (k == 0 || k > 4096) {
+ log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid %s=, ignoring assignment: %s.", lvalue, rvalue);
+ return 0;
+ }
+
+ *v = k;
+ return 0;
+}
+
int config_parse_txqueuelen(
const char *unit,
const char *filename,
diff --git a/src/udev/net/link-config.h b/src/udev/net/link-config.h
index 059c48c8af..721f822f85 100644
--- a/src/udev/net/link-config.h
+++ b/src/udev/net/link-config.h
@@ -46,6 +46,8 @@ struct link_config {
char *name;
char **alternative_names;
char *alias;
+ uint32_t txqueues;
+ uint32_t rxqueues;
uint32_t txqueuelen;
uint32_t mtu;
uint32_t gso_max_segments;
@@ -91,6 +93,7 @@ MACAddressPolicy mac_address_policy_from_string(const char *p) _pure_;
const struct ConfigPerfItem* link_config_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
CONFIG_PARSER_PROTOTYPE(config_parse_ifalias);
+CONFIG_PARSER_PROTOTYPE(config_parse_rx_tx_queues);
CONFIG_PARSER_PROTOTYPE(config_parse_txqueuelen);
CONFIG_PARSER_PROTOTYPE(config_parse_mac_address_policy);
CONFIG_PARSER_PROTOTYPE(config_parse_name_policy);
diff --git a/test/fuzz/fuzz-link-parser/directives.link b/test/fuzz/fuzz-link-parser/directives.link
index de11d08ea1..112a81930f 100644
--- a/test/fuzz/fuzz-link-parser/directives.link
+++ b/test/fuzz/fuzz-link-parser/directives.link
@@ -20,6 +20,8 @@ Name=
AlternativeNamesPolicy=
AlternativeName=
Alias=
+TransmitQueues=
+ReceiveQueues=
TransmitQueueLength=
MTUBytes=
BitsPerSecond=
diff --git a/test/fuzz/fuzz-network-parser/directives.network b/test/fuzz/fuzz-network-parser/directives.network
index e6fb9f6a80..1c4f338ad0 100644
--- a/test/fuzz/fuzz-network-parser/directives.network
+++ b/test/fuzz/fuzz-network-parser/directives.network
@@ -40,8 +40,6 @@ Multicast=
MACAddress=
Group=
Promiscuous=
-TransmitQueues=
-ReceiveQueues=
[SR-IOV]
VirtualFunction=
MACSpoofCheck=