]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: drop support for old kernels which cannot set prefix route with non-main...
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 5 Apr 2022 15:45:52 +0000 (00:45 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Sat, 21 May 2022 14:09:53 +0000 (15:09 +0100)
Not sure when the issue was fixed.
- kernel-3.10 on CentOS 7 has the issue,
- kernel-4.18 on CentOS 8 works fine.

Note, the workaround dropped by the commit is not incomplete:
with an old kernel which has the issue, all non-prefix routes are
configured on the specified route table, but the prefix route is
configured on the main table. That should not work for most cases,
hence, the workaround is mostly meaningless.

src/network/networkd-dhcp4.c
src/network/networkd-link.h
src/network/networkd-manager.h
test/test-network/systemd-networkd-tests.py

index d3fd2571e0db29c70f950817a1ea301c7d43ce7c..5770b48767e9ba626e714041af205d8d5771e466 100644 (file)
@@ -27,8 +27,6 @@
 #include "strv.h"
 #include "sysctl-util.h"
 
-static int dhcp4_request_address_and_routes(Link *link, bool announce);
-
 void network_adjust_dhcp4(Network *network) {
         assert(network);
 
@@ -157,26 +155,6 @@ int dhcp4_check_ready(Link *link) {
         return 0;
 }
 
-static int dhcp4_retry(Link *link) {
-        int r;
-
-        assert(link);
-
-        r = dhcp4_remove_address_and_routes(link, /* only_marked = */ false);
-        if (r < 0)
-                return r;
-
-        r = link_request_static_nexthops(link, true);
-        if (r < 0)
-                return r;
-
-        r = link_request_static_routes(link, true);
-        if (r < 0)
-                return r;
-
-        return dhcp4_request_address_and_routes(link, false);
-}
-
 static int dhcp4_route_handler(sd_netlink *rtnl, sd_netlink_message *m, Request *req, Link *link, Route *route) {
         int r;
 
@@ -184,31 +162,12 @@ static int dhcp4_route_handler(sd_netlink *rtnl, sd_netlink_message *m, Request
         assert(link);
 
         r = sd_netlink_message_get_errno(m);
-        if (r == -ENETUNREACH && !link->dhcp4_route_retrying) {
-
-                /* It seems kernel does not support that the prefix route cannot be configured with
-                 * route table. Let's once drop the config and reconfigure them later. */
-
-                log_link_message_debug_errno(link, m, r, "Could not set DHCPv4 route, retrying later");
-                link->dhcp4_route_failed = true;
-                link->manager->dhcp4_prefix_root_cannot_set_table = true;
-        } else if (r < 0 && r != -EEXIST) {
+        if (r < 0 && r != -EEXIST) {
                 log_link_message_warning_errno(link, m, r, "Could not set DHCPv4 route");
                 link_enter_failed(link);
                 return 1;
         }
 
-        if (link->dhcp4_messages == 0 && link->dhcp4_route_failed) {
-                link->dhcp4_route_failed = false;
-                link->dhcp4_route_retrying = true;
-
-                r = dhcp4_retry(link);
-                if (r < 0)
-                        link_enter_failed(link);
-
-                return 1;
-        }
-
         r = dhcp4_check_ready(link);
         if (r < 0)
                 link_enter_failed(link);
@@ -253,8 +212,7 @@ static int dhcp4_request_route(Route *in, Link *link) {
 
 static bool link_prefixroute(Link *link) {
         return !link->network->dhcp_route_table_set ||
-                link->network->dhcp_route_table == RT_TABLE_MAIN ||
-                link->manager->dhcp4_prefix_root_cannot_set_table;
+                link->network->dhcp_route_table == RT_TABLE_MAIN;
 }
 
 static int dhcp4_request_prefix_route(Link *link) {
index d67400104249f643aed30a5ce8c4c5fcee99464a..5174127413f02ff7353909e3d300c6ce1ea51b59 100644 (file)
@@ -120,8 +120,6 @@ typedef struct Link {
         sd_dhcp_lease *dhcp_lease;
         char *lease_file;
         unsigned dhcp4_messages;
-        bool dhcp4_route_failed:1;
-        bool dhcp4_route_retrying:1;
         bool dhcp4_configured:1;
         char *dhcp4_6rd_tunnel_name;
 
index fab2cfaf111cbc72dce980779dc36559399e03f0..2191d0d9557340a7dbea70309b162d598a270fda 100644 (file)
@@ -95,7 +95,6 @@ struct Manager {
         usec_t speed_meter_usec_new;
         usec_t speed_meter_usec_old;
 
-        bool dhcp4_prefix_root_cannot_set_table;
         bool bridge_mdb_on_master_not_supported;
 
         FirewallContext *fw_ctx;
index 989020e0c6cf876e20df47b6ddb9600e674ba3c4..51f379f26a1d34f7e0bea2c7639928b2d8197863 100755 (executable)
@@ -4638,17 +4638,13 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
         print('## ip route show table main dev veth99')
         output = check_output('ip route show table main dev veth99')
         print(output)
-        # See issue #8726
-        main_table_is_empty = output == ''
-        if not main_table_is_empty:
-            self.assertNotRegex(output, 'proto dhcp')
+        self.assertNotRegex(output, 'proto dhcp')
 
         print('## ip route show table 211 dev veth99')
         output = check_output('ip route show table 211 dev veth99')
         print(output)
         self.assertRegex(output, 'default via 192.168.5.1 proto dhcp')
-        if main_table_is_empty:
-            self.assertRegex(output, '192.168.5.0/24 proto dhcp')
+        self.assertRegex(output, '192.168.5.0/24 proto dhcp')
         self.assertRegex(output, '192.168.5.1 proto dhcp scope link')
 
         print('## dnsmasq log')