summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorTuetuopay <tuetuopay@me.com>2023-01-27 15:10:49 +0100
committerLuca Boccassi <luca.boccassi@gmail.com>2023-01-31 23:58:34 +0000
commit1d84a3c7792a8910b05904937c703307ca19740f (patch)
treecdc59166ce5884cd57c63196b764620d8c85aa34 /src/network
parent9c45bfb2ac10b343cd27aa30f8f37f4d476d92ca (diff)
downloadsystemd-1d84a3c7792a8910b05904937c703307ca19740f.tar.gz
network/dhcp4: accept local subnet routes from DHCP
RFC3442 specifies option 121 (Classless Static Routes) that allow a DHCP server to push arbitrary routes to a client. It has a Local Subnet Routes section expliciting the behavior of routes with a null (0.0.0.0) gateway. Such routes are to be installed on the interface with a Link scope, to mark them as directly available on the link without any gateway. Networkd currently drops those routes, which is against the RFC, as Linux has proper support for such routes. Fixes: 7f20627 ("network: dhcp4: ignore gateway in static routes if destination is link-local or in the same network")
Diffstat (limited to 'src/network')
-rw-r--r--src/network/networkd-dhcp4.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c
index 1d5e2975a8..d4b4942173 100644
--- a/src/network/networkd-dhcp4.c
+++ b/src/network/networkd-dhcp4.c
@@ -337,15 +337,18 @@ static int dhcp4_request_route_auto(
route->gw = IN_ADDR_NULL;
route->prefsrc.in = address;
- } else {
- if (in4_addr_is_null(gw)) {
- log_link_debug(link, "DHCP: requested route destination "IPV4_ADDRESS_FMT_STR"/%u is not in the assigned network "
- IPV4_ADDRESS_FMT_STR"/%u, but no gateway is specified, ignoring.",
- IPV4_ADDRESS_FMT_VAL(route->dst.in), route->dst_prefixlen,
- IPV4_ADDRESS_FMT_VAL(prefix), prefixlen);
- return 0;
- }
+ } else if (in4_addr_is_null(gw)) {
+ log_link_debug(link, "DHCP: requested route destination "IPV4_ADDRESS_FMT_STR"/%u is not in the assigned network "
+ IPV4_ADDRESS_FMT_STR"/%u, but no gateway is specified, using 'link' scope.",
+ IPV4_ADDRESS_FMT_VAL(route->dst.in), route->dst_prefixlen,
+ IPV4_ADDRESS_FMT_VAL(prefix), prefixlen);
+ route->scope = RT_SCOPE_LINK;
+ route->gw_family = AF_UNSPEC;
+ route->gw = IN_ADDR_NULL;
+ route->prefsrc.in = address;
+
+ } else {
r = dhcp4_request_route_to_gateway(link, gw);
if (r < 0)
return r;