summaryrefslogtreecommitdiff
path: root/src/network/networkd-route.c
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2014-07-22 16:54:47 -0500
committerTom Gundersen <teg@jklm.no>2014-07-23 09:19:32 +0200
commit28cc555d8504c9429776aedbbe1fee7101258578 (patch)
tree9b681a3243156df7113eaf82ad5811c8a6138a1f /src/network/networkd-route.c
parent82eb1e7efbe3ca8620d2b183af37c4fd34bf8bb3 (diff)
networkd: set route protocol
All routes added by networkd are currently set RTPROT_BOOT, which according to the kernel means "Route installed during boot" (rtnetlink.h). But this is not always the case as networkd changes routing after boot too. Since the kernel gives more detailed protocols, use them. With this patch, user-configured static routes now use RTPROT_STATIC (which they are) and DHCP routes use RTPROT_DHCP. There is no define for IPv4LL yet, so those are installed as RTPROT_STATIC (though perhaps RTPROT_RA is better?). [tomegun: fixup src/network/networkd-link.c:972:33: error: too few arguments to function 'route_new_dynamic']
Diffstat (limited to 'src/network/networkd-route.c')
-rw-r--r--src/network/networkd-route.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c
index 8949299409..00fd9528c4 100644
--- a/src/network/networkd-route.c
+++ b/src/network/networkd-route.c
@@ -49,6 +49,7 @@ int route_new_static(Network *network, unsigned section, Route **ret) {
route->family = AF_UNSPEC;
route->scope = RT_SCOPE_UNIVERSE;
+ route->protocol = RTPROT_STATIC;
route->network = network;
@@ -65,7 +66,7 @@ int route_new_static(Network *network, unsigned section, Route **ret) {
return 0;
}
-int route_new_dynamic(Route **ret) {
+int route_new_dynamic(Route **ret, unsigned char rtm_protocol) {
_cleanup_route_free_ Route *route = NULL;
route = new0(Route, 1);
@@ -74,6 +75,7 @@ int route_new_dynamic(Route **ret) {
route->family = AF_UNSPEC;
route->scope = RT_SCOPE_UNIVERSE;
+ route->protocol = rtm_protocol;
*ret = route;
route = NULL;
@@ -108,7 +110,8 @@ int route_drop(Route *route, Link *link,
assert(route->family == AF_INET || route->family == AF_INET6);
r = sd_rtnl_message_new_route(link->manager->rtnl, &req,
- RTM_DELROUTE, route->family);
+ RTM_DELROUTE, route->family,
+ route->protocol);
if (r < 0) {
log_error("Could not create RTM_DELROUTE message: %s", strerror(-r));
return r;
@@ -181,7 +184,8 @@ int route_configure(Route *route, Link *link,
assert(route->family == AF_INET || route->family == AF_INET6);
r = sd_rtnl_message_new_route(link->manager->rtnl, &req,
- RTM_NEWROUTE, route->family);
+ RTM_NEWROUTE, route->family,
+ route->protocol);
if (r < 0) {
log_error("Could not create RTM_NEWROUTE message: %s", strerror(-r));
return r;