diff options
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/networkd-link.c | 16 | ||||
-rw-r--r-- | src/network/networkd-route.c | 10 | ||||
-rw-r--r-- | src/network/networkd.h | 3 |
3 files changed, 17 insertions, 12 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 0a6f52408f..86d4b83d3b 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -415,7 +415,7 @@ static int link_set_dhcp_routes(Link *link) { for (i = 0; i < n; i++) { _cleanup_route_free_ Route *route = NULL; - r = route_new_dynamic(&route); + r = route_new_dynamic(&route, RTPROT_DHCP); if (r < 0) { log_error_link(link, "Could not allocate route: %s", strerror(-r)); @@ -481,7 +481,7 @@ static int link_enter_set_routes(Link *link) { } if (r != -ENOENT) { - r = route_new_dynamic(&route); + r = route_new_dynamic(&route, RTPROT_STATIC); if (r < 0) { log_error_link(link, "Could not allocate route: %s", strerror(-r)); @@ -517,14 +517,14 @@ static int link_enter_set_routes(Link *link) { } if (r >= 0) { - r = route_new_dynamic(&route); + r = route_new_dynamic(&route, RTPROT_DHCP); if (r < 0) { log_error_link(link, "Could not allocate route: %s", strerror(-r)); return r; } - r = route_new_dynamic(&route_gw); + r = route_new_dynamic(&route_gw, RTPROT_DHCP); if (r < 0) { log_error_link(link, "Could not allocate route: %s", strerror(-r)); @@ -969,7 +969,7 @@ static int dhcp_lease_lost(Link *link) { for (i = 0; i < n; i++) { _cleanup_route_free_ Route *route = NULL; - r = route_new_dynamic(&route); + r = route_new_dynamic(&route, RTPROT_UNSPEC); if (r >= 0) { route->family = AF_INET; route->in_addr.in = routes[i].gw_addr; @@ -989,7 +989,7 @@ static int dhcp_lease_lost(Link *link) { _cleanup_route_free_ Route *route_gw = NULL; _cleanup_route_free_ Route *route = NULL; - r = route_new_dynamic(&route_gw); + r = route_new_dynamic(&route_gw, RTPROT_UNSPEC); if (r >= 0) { route_gw->family = AF_INET; route_gw->dst_addr.in = gateway; @@ -999,7 +999,7 @@ static int dhcp_lease_lost(Link *link) { route_drop(route_gw, link, &route_drop_handler); } - r = route_new_dynamic(&route); + r = route_new_dynamic(&route, RTPROT_UNSPEC); if (r >= 0) { route->family = AF_INET; route->in_addr.in = gateway; @@ -1316,7 +1316,7 @@ static int ipv4ll_address_lost(Link *link) { address_drop(address, link, &address_drop_handler); - r = route_new_dynamic(&route); + r = route_new_dynamic(&route, RTPROT_UNSPEC); if (r < 0) { log_error_link(link, "Could not allocate route: %s", strerror(-r)); 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; diff --git a/src/network/networkd.h b/src/network/networkd.h index f1c7f204ea..7d291e5ea3 100644 --- a/src/network/networkd.h +++ b/src/network/networkd.h @@ -137,6 +137,7 @@ struct Route { unsigned char dst_prefixlen; unsigned char scope; uint32_t metrics; + unsigned char protocol; /* RTPROT_* */ union in_addr_union in_addr; union in_addr_union dst_addr; @@ -305,7 +306,7 @@ const struct ConfigPerfItem* network_network_gperf_lookup(const char *key, unsig /* Route */ int route_new_static(Network *network, unsigned section, Route **ret); -int route_new_dynamic(Route **ret); +int route_new_dynamic(Route **ret, unsigned char rtm_protocol); void route_free(Route *route); int route_configure(Route *route, Link *link, sd_rtnl_message_handler_t callback); int route_drop(Route *route, Link *link, sd_rtnl_message_handler_t callback); |