From 46b0c76e2c355c0d0cc4792abb98cde07b28bc53 Mon Sep 17 00:00:00 2001 From: Emil Renner Berthing Date: Fri, 5 Sep 2014 11:56:02 +0200 Subject: networkd: add preferred source to dhcp4 gateway route This makes DHCPv4 and IPv4LL coexist peacefully. [tomegun: apply to both the dhcp routes, use in_addr_is_null() rather than a separate variable to indicate when prefsrc should be applied] --- src/network/networkd-route.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/network/networkd-route.c') diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index aead4fbb9e..10d8cd902a 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -144,6 +144,17 @@ int route_drop(Route *route, Link *link, } } + if (!in_addr_is_null(route->family, &route->prefsrc_addr)) { + if (route->family == AF_INET) + r = sd_rtnl_message_append_in_addr(req, RTA_PREFSRC, &route->prefsrc_addr.in); + else if (route->family == AF_INET6) + r = sd_rtnl_message_append_in6_addr(req, RTA_PREFSRC, &route->prefsrc_addr.in6); + if (r < 0) { + log_error("Could not append RTA_PREFSRC attribute: %s", strerror(-r)); + return r; + } + } + r = sd_rtnl_message_route_set_scope(req, route->scope); if (r < 0) { log_error("Could not set scope: %s", strerror(-r)); @@ -218,6 +229,17 @@ int route_configure(Route *route, Link *link, } } + if (!in_addr_is_null(route->family, &route->prefsrc_addr)) { + if (route->family == AF_INET) + r = sd_rtnl_message_append_in_addr(req, RTA_PREFSRC, &route->prefsrc_addr.in); + else if (route->family == AF_INET6) + r = sd_rtnl_message_append_in6_addr(req, RTA_PREFSRC, &route->prefsrc_addr.in6); + if (r < 0) { + log_error("Could not append RTA_PREFSRC attribute: %s", strerror(-r)); + return r; + } + } + r = sd_rtnl_message_route_set_scope(req, route->scope); if (r < 0) { log_error("Could not set scope: %s", strerror(-r)); -- cgit v1.2.3-54-g00ecf