mirror of
https://github.com/systemd/systemd.git
synced 2025-02-02 13:47:27 +03:00
network/ndisc: do not set per-route MTU and hop limit
Setting MTU announced in RA message to routes is problematic, as the value may be larger than the device MTU (IFLA_MTU), and in such case the route cannot be used. These two properties are now set per-interface, and gracefully handled such invalid cases. Hence not necessary to set them to each route. Follow-up for #32195.
This commit is contained in:
parent
3ec49af973
commit
2e73aa507b
@ -179,8 +179,6 @@ static void ndisc_set_route_priority(Link *link, Route *route) {
|
||||
|
||||
static int ndisc_request_route(Route *route, Link *link, sd_ndisc_router *rt) {
|
||||
struct in6_addr router;
|
||||
uint8_t hop_limit = 0;
|
||||
uint32_t mtu = 0;
|
||||
bool is_new;
|
||||
int r;
|
||||
|
||||
@ -194,30 +192,13 @@ static int ndisc_request_route(Route *route, Link *link, sd_ndisc_router *rt) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (link->network->ndisc_use_mtu) {
|
||||
r = sd_ndisc_router_get_mtu(rt, &mtu);
|
||||
if (r < 0 && r != -ENODATA)
|
||||
return log_link_warning_errno(link, r, "Failed to get MTU from RA: %m");
|
||||
}
|
||||
|
||||
if (link->network->ndisc_use_hop_limit) {
|
||||
r = sd_ndisc_router_get_hop_limit(rt, &hop_limit);
|
||||
if (r < 0 && r != -ENODATA)
|
||||
return log_link_warning_errno(link, r, "Failed to get hop limit from RA: %m");
|
||||
}
|
||||
|
||||
route->source = NETWORK_CONFIG_SOURCE_NDISC;
|
||||
route->provider.in6 = router;
|
||||
if (!route->table_set)
|
||||
route->table = link_get_ndisc_route_table(link);
|
||||
if (!route->protocol_set)
|
||||
route->protocol = RTPROT_RA;
|
||||
r = route_metric_set(&route->metric, RTAX_MTU, mtu);
|
||||
if (r < 0)
|
||||
return r;
|
||||
r = route_metric_set(&route->metric, RTAX_HOPLIMIT, hop_limit);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = route_metric_set(&route->metric, RTAX_QUICKACK, link->network->ndisc_quickack);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
@ -5668,15 +5668,6 @@ class NetworkdRATests(unittest.TestCase, Utilities):
|
||||
self.assertIn('2002:da8:1:0:b47e:7975:fc7a:7d6e', output)
|
||||
self.assertIn('2002:da8:2:0:f689:561a:8eda:7443', output)
|
||||
|
||||
def check_router_hop_limit(self, hop_limit):
|
||||
self.wait_route('client', rf'default via fe80::1034:56ff:fe78:9a99 proto ra .* hoplimit {hop_limit}', ipv='-6', timeout_sec=10)
|
||||
|
||||
output = check_output('ip -6 route show dev client default via fe80::1034:56ff:fe78:9a99')
|
||||
print(output)
|
||||
self.assertIn(f'hoplimit {hop_limit}', output)
|
||||
|
||||
self.check_ipv6_sysctl_attr('client', 'hop_limit', f'{hop_limit}')
|
||||
|
||||
def test_router_hop_limit(self):
|
||||
copy_network_unit('25-veth-client.netdev',
|
||||
'25-veth-router.netdev',
|
||||
@ -5686,18 +5677,24 @@ class NetworkdRATests(unittest.TestCase, Utilities):
|
||||
'25-veth-router-hop-limit.network',
|
||||
'25-bridge99.network')
|
||||
start_networkd()
|
||||
self.wait_online('client-p:enslaved',
|
||||
self.wait_online('client:routable', 'client-p:enslaved',
|
||||
'router:degraded', 'router-p:enslaved',
|
||||
'bridge99:routable')
|
||||
|
||||
self.check_router_hop_limit(42)
|
||||
self.check_ipv6_sysctl_attr('client', 'hop_limit', '42')
|
||||
|
||||
with open(os.path.join(network_unit_dir, '25-veth-router-hop-limit.network'), mode='a', encoding='utf-8') as f:
|
||||
f.write('\n[IPv6SendRA]\nHopLimit=43\n')
|
||||
|
||||
networkctl_reload()
|
||||
|
||||
self.check_router_hop_limit(43)
|
||||
for _ in range(20):
|
||||
output = read_ipv6_sysctl_attr('client', 'hop_limit')
|
||||
if output == '43':
|
||||
break
|
||||
time.sleep(0.5)
|
||||
|
||||
self.check_ipv6_sysctl_attr('client', 'hop_limit', '43')
|
||||
|
||||
def test_router_preference(self):
|
||||
copy_network_unit('25-veth-client.netdev',
|
||||
|
Loading…
x
Reference in New Issue
Block a user