summaryrefslogtreecommitdiff
path: root/src/network/networkd-dhcp4.c
diff options
context:
space:
mode:
authorDan Streetman <ddstreet@canonical.com>2019-07-05 16:42:38 -0400
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-07-06 07:36:31 +0900
commitac2dce5f36bb8b1a877ff765e6a4dfde6bfb2d49 (patch)
tree3d9ccc1d2a4823e6b154412a649b035cd1673621 /src/network/networkd-dhcp4.c
parent1ccbb359a1ad63efb5e44d943b7747989b6166ab (diff)
downloadsystemd-ac2dce5f36bb8b1a877ff765e6a4dfde6bfb2d49.tar.gz
systemd-ac2dce5f36bb8b1a877ff765e6a4dfde6bfb2d49.tar.bz2
systemd-ac2dce5f36bb8b1a877ff765e6a4dfde6bfb2d49.zip
src/network/networkd-dhcp4.c: set prefsrc for classless or static routes
When a DHCP server provides only a gateway, the networkd-dhcp4 code adds a default route using that gateway, and sets the just-provided address as the route's prefsrc; this was added in commit 46b0c76e2c355c0d0cc4792abb98cde07b28bc53 However, if the DHCP server has also provided classless route(s), these are used instead of a default route using the provided gateway; the networkd-dhcp4 code sets up the classless routes, but does not use the just-provided dhcp address as the prefsrc of the route(s). Note that it also doesn't set the prefsrc for static routes, though it should. If the interface has only the dhcp-provided address, this is not usually a problem, but if it has another address (e.g. a static address), then traffic sent through the dhcp-provided gateway might not use the dhcp-provided source address. If the gateway router only will route traffic from the dhcp-provided address, then the dhcp client system's networking through the router will not work. Fixes: #12969
Diffstat (limited to 'src/network/networkd-dhcp4.c')
-rw-r--r--src/network/networkd-dhcp4.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c
index 3e384a47c0..c0d776f464 100644
--- a/src/network/networkd-dhcp4.c
+++ b/src/network/networkd-dhcp4.c
@@ -147,6 +147,8 @@ static int link_set_dhcp_routes(Link *link) {
route->priority = link->network->dhcp_route_metric;
route->table = table;
route->scope = route_scope_from_address(route, &address);
+ if (IN_SET(route->scope, RT_SCOPE_LINK, RT_SCOPE_UNIVERSE))
+ route->prefsrc.in = address;
r = route_configure(route, link, dhcp4_route_handler);
if (r < 0)
@@ -277,6 +279,8 @@ static int dhcp_remove_routes(Link *link, sd_dhcp_lease *lease, sd_dhcp_lease *n
route->priority = link->network->dhcp_route_metric;
route->table = table;
route->scope = route_scope_from_address(route, address);
+ if (IN_SET(route->scope, RT_SCOPE_LINK, RT_SCOPE_UNIVERSE))
+ route->prefsrc.in = *address;
if (route_present_in_routes(route, new_routes, m))
continue;