mirror of
https://github.com/systemd/systemd
synced 2024-07-21 18:24:38 +00:00
Merge pull request #28286 from yuwata/network-dhcp4-classless-static-routes
network,dhcp4: do not ignore gateway in classless static routes option
This commit is contained in:
commit
d859cf15eb
|
@ -278,7 +278,8 @@ static int dhcp4_request_route_to_gateway(Link *link, const struct in_addr *gw)
|
|||
static int dhcp4_request_route_auto(
|
||||
Route *in,
|
||||
Link *link,
|
||||
const struct in_addr *gw) {
|
||||
const struct in_addr *gw,
|
||||
bool force_use_gw) {
|
||||
|
||||
_cleanup_(route_freep) Route *route = in;
|
||||
struct in_addr address, netmask, prefix;
|
||||
|
@ -323,7 +324,8 @@ static int dhcp4_request_route_auto(
|
|||
route->gw = IN_ADDR_NULL;
|
||||
route->prefsrc.in = address;
|
||||
|
||||
} else if (route->dst_prefixlen >= prefixlen &&
|
||||
} else if (!force_use_gw &&
|
||||
route->dst_prefixlen >= prefixlen &&
|
||||
(route->dst.in.s_addr & netmask.s_addr) == prefix.s_addr) {
|
||||
if (in4_addr_is_set(gw))
|
||||
log_link_debug(link, "DHCP: requested route destination "IPV4_ADDRESS_FMT_STR"/%u is in the assigned network "
|
||||
|
@ -473,7 +475,9 @@ static int dhcp4_request_static_routes(Link *link, struct in_addr *ret_default_g
|
|||
in4_addr_is_null(&default_gw))
|
||||
default_gw = gw;
|
||||
|
||||
r = dhcp4_request_route_auto(TAKE_PTR(route), link, &gw);
|
||||
/* Do not ignore the gateway given by the classless route option even if the destination is
|
||||
* in the same network. See issue #28280. */
|
||||
r = dhcp4_request_route_auto(TAKE_PTR(route), link, &gw, /* force_use_gw = */ n_classless_routes > 0);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
@ -609,7 +613,7 @@ static int dhcp4_request_routes_to_servers(
|
|||
route->dst.in = servers[i];
|
||||
route->dst_prefixlen = 32;
|
||||
|
||||
r = dhcp4_request_route_auto(TAKE_PTR(route), link, gw);
|
||||
r = dhcp4_request_route_auto(TAKE_PTR(route), link, gw, /* force_use_gw = */ false);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -4829,7 +4829,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
|
|||
]
|
||||
if classless:
|
||||
additional_options += [
|
||||
'--dhcp-option=option:classless-static-route,0.0.0.0/0,192.168.5.4,8.0.0.0/8,192.168.5.5'
|
||||
'--dhcp-option=option:classless-static-route,0.0.0.0/0,192.168.5.4,8.0.0.0/8,192.168.5.5,192.168.5.64/26,192.168.5.5'
|
||||
]
|
||||
start_dnsmasq(*additional_options)
|
||||
self.wait_online(['veth99:routable', 'veth-peer:routable'])
|
||||
|
@ -4842,6 +4842,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
|
|||
if classless:
|
||||
self.assertRegex(output, r'default via 192.168.5.4 proto dhcp src 192.168.5.[0-9]* metric 1024')
|
||||
self.assertRegex(output, r'8.0.0.0/8 via 192.168.5.5 proto dhcp src 192.168.5.[0-9]* metric 1024')
|
||||
self.assertRegex(output, r'192.168.5.64/26 via 192.168.5.5 proto dhcp src 192.168.5.[0-9]* metric 1024')
|
||||
self.assertRegex(output, r'192.168.5.4 proto dhcp scope link src 192.168.5.[0-9]* metric 1024')
|
||||
self.assertRegex(output, r'192.168.5.5 proto dhcp scope link src 192.168.5.[0-9]* metric 1024')
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue