link->ipv4ll_route = true;
- if (link->ipv4ll_address == true)
- link_check_ready(link);
+ link_check_ready(link);
return 1;
}
+static int ipv4ll_route_configure(Link *link) {
+ _cleanup_(route_freep) Route *route = NULL;
+ int r;
+
+ r = route_new(&route);
+ if (r < 0)
+ return r;
+
+ route->family = AF_INET;
+ route->scope = RT_SCOPE_LINK;
+ route->protocol = RTPROT_STATIC;
+ route->priority = IPV4LL_ROUTE_METRIC;
+ route->table = link_get_vrf_table(link);
+
+ return route_configure(route, link, ipv4ll_route_handler);
+}
+
static int ipv4ll_address_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
int r;
link->ipv4ll_address = true;
- if (link->ipv4ll_route)
- link_check_ready(link);
+ r = ipv4ll_route_configure(link);
+ if (r < 0) {
+ log_link_error_errno(link, r, "Failed to configure ipv4ll route: %m");
+ link_enter_failed(link);
+ }
return 1;
}
static int ipv4ll_address_claimed(sd_ipv4ll *ll, Link *link) {
_cleanup_(address_freep) Address *ll_addr = NULL;
- _cleanup_(route_freep) Route *route = NULL;
struct in_addr address;
int r;
assert(ll);
assert(link);
+ link->ipv4ll_address = false;
+ link->ipv4ll_route = false;
+
r = sd_ipv4ll_get_address(ll, &address);
if (r == -ENOENT)
return 0;
if (r < 0)
return r;
- link->ipv4ll_address = false;
-
- r = route_new(&route);
- if (r < 0)
- return r;
-
- route->family = AF_INET;
- route->scope = RT_SCOPE_LINK;
- route->protocol = RTPROT_STATIC;
- route->priority = IPV4LL_ROUTE_METRIC;
-
- r = route_configure(route, link, ipv4ll_route_handler);
- if (r < 0)
- return r;
-
- link->ipv4ll_route = false;
-
return 0;
}
case SD_IPV4LL_EVENT_BIND:
r = ipv4ll_address_claimed(ll, link);
if (r < 0) {
+ log_link_error(link, "Failed to configure ipv4ll address: %m");
link_enter_failed(link);
return;
}