assert(link->manager);
assert(link->network);
- route->source = NETWORK_CONFIG_SOURCE_NDISC;
-
- if (!route->table_set)
- route->table = link_get_ndisc_route_table(link);
-
r = route_metric_set(&route->metric, RTAX_QUICKACK, link->network->ndisc_quickack);
if (r < 0)
return r;
return 0;
}
+static void ndisc_route_prepare(Route *route, Link *link) {
+ assert(route);
+ assert(link);
+
+ route->source = NETWORK_CONFIG_SOURCE_NDISC;
+
+ if (!route->table_set)
+ route->table = link_get_ndisc_route_table(link);
+}
+
+static int ndisc_router_route_prepare(Route *route, Link *link, sd_ndisc_router *rt) {
+ assert(route);
+ assert(link);
+ assert(rt);
+
+ ndisc_route_prepare(route, link);
+
+ if (!route->protocol_set)
+ route->protocol = RTPROT_RA;
+
+ return sd_ndisc_router_get_sender_address(rt, &route->provider.in6);
+}
+
static int ndisc_request_router_route(Route *route, Link *link, sd_ndisc_router *rt) {
int r;
assert(link);
assert(rt);
- r = sd_ndisc_router_get_sender_address(rt, &route->provider.in6);
+ r = ndisc_router_route_prepare(route, link, rt);
if (r < 0)
return r;
- if (!route->protocol_set)
- route->protocol = RTPROT_RA;
-
return ndisc_request_route(route, link);
}
assert(link);
assert(link->manager);
- if (!route->table_set)
- route->table = link_get_ndisc_route_table(link);
-
r = route_adjust_nexthops(route, link);
if (r < 0)
return r;
return ret;
}
+static int ndisc_remove_router_route(Route *route, Link *link, sd_ndisc_router *rt) {
+ int r;
+
+ assert(route);
+ assert(link);
+ assert(rt);
+
+ r = ndisc_router_route_prepare(route, link, rt);
+ if (r < 0)
+ return r;
+
+ return ndisc_remove_route(route, link);
+}
+
static int ndisc_address_handler(sd_netlink *rtnl, sd_netlink_message *m, Request *req, Link *link, Address *address) {
int r;
if (r < 0)
return r;
+ ndisc_route_prepare(route, link);
+
return ndisc_remove_route(route, link);
}
if (r < 0)
return r;
+ ndisc_route_prepare(route, link);
+
return ndisc_request_route(route, link);
}
route->nexthop.family = AF_INET6;
route->nexthop.gw.in6 = gateway;
- r = ndisc_remove_route(route, link);
+ r = ndisc_remove_router_route(route, link, rt);
if (r < 0)
return log_link_warning_errno(link, r, "Failed to remove the default gateway configured by RA: %m");
tmp->nexthop.gw.in6 = gateway;
- r = ndisc_remove_route(tmp, link);
+ r = ndisc_remove_router_route(tmp, link, rt);
if (r < 0)
return log_link_warning_errno(link, r, "Could not remove semi-static gateway: %m");
}
* received advertisement, reset its invalidation timer to the Valid Lifetime value in the Prefix
* Information option. If the new Lifetime value is zero, timeout the prefix immediately. */
if (lifetime_usec == 0) {
- r = ndisc_remove_route(route, link);
+ r = ndisc_remove_router_route(route, link, rt);
if (r < 0)
return log_link_warning_errno(link, r, "Failed to remove prefix route: %m");
} else {
if (r < 0)
return log_link_warning_errno(link, r, "Could not request additional route: %m");
} else {
- r = ndisc_remove_route(route, link);
+ r = ndisc_remove_router_route(route, link, rt);
if (r < 0)
return log_link_warning_errno(link, r, "Could not remove additional route with zero lifetime: %m");
}