From: Yu Watanabe Date: Tue, 5 Apr 2022 15:45:52 +0000 (+0900) Subject: network: drop support for old kernels which cannot set prefix route with non-main... X-Git-Tag: v252-rc1~950 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=93a72170bd8a7001abde8c85b65cf0f456c8022e;p=thirdparty%2Fsystemd.git network: drop support for old kernels which cannot set prefix route with non-main route table 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. --- diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c index d3fd2571e0d..5770b48767e 100644 --- a/src/network/networkd-dhcp4.c +++ b/src/network/networkd-dhcp4.c @@ -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) { diff --git a/src/network/networkd-link.h b/src/network/networkd-link.h index d6740010424..5174127413f 100644 --- a/src/network/networkd-link.h +++ b/src/network/networkd-link.h @@ -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; diff --git a/src/network/networkd-manager.h b/src/network/networkd-manager.h index fab2cfaf111..2191d0d9557 100644 --- a/src/network/networkd-manager.h +++ b/src/network/networkd-manager.h @@ -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; diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 989020e0c6c..51f379f26a1 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -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')