]> git.proxmox.com Git - systemd.git/blobdiff - src/network/networkd-ipv4ll.c
New upstream version 242
[systemd.git] / src / network / networkd-ipv4ll.c
index 3562e90535ddce1f5ea1736060a109d8581e06e3..829dc48a0a16e37ccb46c988c63831e4d86b060d 100644 (file)
@@ -65,12 +65,28 @@ static int ipv4ll_route_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *l
 
         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;
 
@@ -86,21 +102,26 @@ static int ipv4ll_address_handler(sd_netlink *rtnl, sd_netlink_message *m, Link
 
         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;
@@ -124,23 +145,6 @@ static int ipv4ll_address_claimed(sd_ipv4ll *ll, Link *link) {
         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;
 }
 
@@ -176,6 +180,7 @@ static void ipv4ll_handler(sd_ipv4ll *ll, int event, void *userdata) {
                 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;
                         }