diff options
author | Emil Renner Berthing <systemd@esmil.dk> | 2014-09-05 11:56:02 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-09-08 15:08:27 +0200 |
commit | 46b0c76e2c355c0d0cc4792abb98cde07b28bc53 (patch) | |
tree | c5a3a16ed64d3d3470852f415293380361f6bfa8 /src/network/networkd-route.c | |
parent | 4bd5ace3e78ec0ca4c174bc875e3d9f6e1ae7405 (diff) |
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]
Diffstat (limited to 'src/network/networkd-route.c')
-rw-r--r-- | src/network/networkd-route.c | 22 |
1 files changed, 22 insertions, 0 deletions
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)); |