]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/network/networkd-link.c
Merge pull request #11681 from yuwata/network-link-enslaved-operstate
[thirdparty/systemd.git] / src / network / networkd-link.c
index acb4943b843b510c697d7a7fc24852d3a566bd22..0cff3cf62729c090690ca4e55e86a3d5c539f95d 100644 (file)
@@ -14,6 +14,7 @@
 #include "fd-util.h"
 #include "fileio.h"
 #include "missing_network.h"
+#include "netdev/vrf.h"
 #include "netlink-util.h"
 #include "network-internal.h"
 #include "networkd-ipv6-proxy-ndp.h"
 #include "util.h"
 #include "virt.h"
 
+uint32_t link_get_vrf_table(Link *link) {
+        return link->network->vrf ? VRF(link->network->vrf)->table : RT_TABLE_MAIN;
+}
+
+uint32_t link_get_dhcp_route_table(Link *link) {
+        /* When the interface is part of an VRF use the VRFs routing table, unless
+         * another table is explicitly specified. */
+        if (link->network->dhcp_route_table_set)
+                return link->network->dhcp_route_table;
+        return link_get_vrf_table(link);
+}
+
+uint32_t link_get_ipv6_accept_ra_route_table(Link *link) {
+        if (link->network->ipv6_accept_ra_route_table_set)
+                return link->network->ipv6_accept_ra_route_table;
+        return link_get_vrf_table(link);
+}
+
 DUID* link_get_duid(Link *link) {
         if (link->network->duid.type != _DUID_TYPE_INVALID)
                 return &link->network->duid;
@@ -96,7 +115,7 @@ static bool link_ipv4ll_enabled(Link *link) {
         if (!link->network)
                 return false;
 
-        if (streq_ptr(link->kind, "wireguard"))
+        if (STRPTR_IN_SET(link->kind, "vrf", "wireguard"))
                 return false;
 
         if (link->network->bond)
@@ -117,7 +136,7 @@ static bool link_ipv6ll_enabled(Link *link) {
         if (!link->network)
                 return false;
 
-        if (streq_ptr(link->kind, "wireguard"))
+        if (STRPTR_IN_SET(link->kind, "vrf", "wireguard"))
                 return false;
 
         if (link->network->bond)
@@ -3656,7 +3675,7 @@ static int link_carrier_lost(Link *link) {
 
         assert(link);
 
-        if (link->network->ignore_carrier_loss)
+        if (link->network && link->network->ignore_carrier_loss)
                 return 0;
 
         /* Some devices reset itself while setting the MTU. This causes the DHCP client fall into a loop.