]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network,udev: move TransmitQueues=/ReceiveQueues= from .network to .link 18319/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 20 Jan 2021 06:50:01 +0000 (15:50 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 3 Feb 2021 05:44:51 +0000 (14:44 +0900)
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

13 files changed:
man/systemd.link.xml
man/systemd.network.xml
src/libsystemd/sd-netlink/netlink-util.c
src/libsystemd/sd-netlink/netlink-util.h
src/network/networkd-link.c
src/network/networkd-network-gperf.gperf
src/network/networkd-network.c
src/network/networkd-network.h
src/udev/net/link-config-gperf.gperf
src/udev/net/link-config.c
src/udev/net/link-config.h
test/fuzz/fuzz-link-parser/directives.link
test/fuzz/fuzz-network-parser/directives.network

index 9fefb0c372c91fb228a1d7b9e9f139c4db674ebe..93f7191b3321109aad8f875d0280e3fb9d8abce9 100644 (file)
           be ignored.</para>
         </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>
index 8e7b190638ab06a3d5a6b75c0e70c23b20680442..606a2dd5dbbf637f9b3a7af9e13616c25fffdfda 100644 (file)
           integer in the range 0…4294967294. Defaults to unset.</para>
         </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>
index a0bc44e7fbbf14503098d50dede031d5dc5d78e3..448c50d4ab44e0b9e5c2124ae6eecc5f04d4df60 100644 (file)
@@ -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)
index acf5b668a293fbcb83ecde6b7a4d66f7418d3ef7..a3a3951ff7942e79908b0899aeb9cfec55da07a1 100644 (file)
@@ -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);
index fe6d3bd927c87832f3ab27b50a97e05b4956669d..ccefb46cbc60974eeaf5b8790379cbbda9f14398 100644 (file)
@@ -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;
index f1344c0fcc6ed2cd5a3aab291d94f7c84aa9e748..7f0de7660c31a040dd54dff2c240f02fe35bde84 100644 (file)
@@ -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)
index 62e3ff0cc623dd9cbec113392c769e76197dae67..84ab1d5e18d673981ddcef3c7b7fc150ad293874 100644 (file)
@@ -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");
 
index b1db17f7b72be444594b24c634cb71c32c1c2ff5..baa806fca6cbc2f26c3a7c02cd4bf073b761eb45 100644 (file)
@@ -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);
index e7abd2d436929a80257c7ce8d3c0ea35f2d749be..70c5525b57724f4bb1a95004d11180847aefa4b2 100644 (file)
@@ -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)
index baad48b43b5f89e371288fdef3cd4ecf402fbf35..0653ae7a9cd1bfbf46614d1a837b06ba8cb198bc 100644 (file)
@@ -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,
index 059c48c8af4b9b19ea51a27437d511bc189f5e66..721f822f85a87900e71b384661fae99dfeed2006 100644 (file)
@@ -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);
index de11d08ea1f51db1452e245bff23b778dbed322b..112a81930f7ff434405e28c9409e2c47616bb25e 100644 (file)
@@ -20,6 +20,8 @@ Name=
 AlternativeNamesPolicy=
 AlternativeName=
 Alias=
+TransmitQueues=
+ReceiveQueues=
 TransmitQueueLength=
 MTUBytes=
 BitsPerSecond=
index e6fb9f6a80b4cc43424b3630a11772a535187c61..1c4f338ad0954a51a602ef3b3ca8b0391380090a 100644 (file)
@@ -40,8 +40,6 @@ Multicast=
 MACAddress=
 Group=
 Promiscuous=
-TransmitQueues=
-ReceiveQueues=
 [SR-IOV]
 VirtualFunction=
 MACSpoofCheck=