summaryrefslogtreecommitdiff
path: root/zebra/if_netlink.c
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2021-10-13 15:06:38 +0300
committerIgor Ryzhov <iryzhov@nfware.com>2021-10-19 15:29:51 +0300
commitf60a11883cb426f574dbe5abeff8254148e7c371 (patch)
tree2b489718f0d61ed4c5b043959bcbe3e18035d874 /zebra/if_netlink.c
parente9f7b2b597ad8c6947ce3b7238e89391e4f9f863 (diff)
lib: allow to create interfaces in non-existing VRFs
It allows FRR to read the interface config even when the necessary VRFs are not yet created and interfaces are in "wrong" VRFs. Currently, such config is rejected. For VRF-lite backend, we don't care at all about the VRF of the inactive interface. When the interface is created in the OS and becomes active, we always use its actual VRF instead of the configured one. So there's no need to reject the config. For netns backend, we may have multiple interfaces with the same name in different VRFs. So we care about the VRF of inactive interfaces. And we must allow to preconfigure the interface in a VRF even before it is moved to the corresponding netns. From now on, we allow to create multiple configs for the same interface name in different VRFs and the necessary config is applied once the OS interface is moved to the corresponding netns. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'zebra/if_netlink.c')
-rw-r--r--zebra/if_netlink.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c
index fa3aabb195..187cd10e9c 100644
--- a/zebra/if_netlink.c
+++ b/zebra/if_netlink.c
@@ -972,17 +972,9 @@ static int netlink_interface(struct nlmsghdr *h, ns_id_t ns_id, int startup)
link_nsid = ns_id_get_absolute(ns_id, link_nsid);
}
- /* Add interface.
- * We add by index first because in some cases such as the master
- * interface, we have the index before we have the name. Fixing
- * back references on the slave interfaces is painful if not done
- * this way, i.e. by creating by ifindex.
- */
- ifp = if_get_by_ifindex(ifi->ifi_index, vrf_id);
+ ifp = if_get_by_name(name, vrf_id, NULL);
set_ifindex(ifp, ifi->ifi_index, zns); /* add it to ns struct */
- if_set_name(ifp, name);
-
ifp->flags = ifi->ifi_flags & 0x0000fffff;
ifp->mtu6 = ifp->mtu = *(uint32_t *)RTA_DATA(tb[IFLA_MTU]);
ifp->metric = 0;
@@ -1814,7 +1806,7 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
if (ifp == NULL) {
/* unknown interface */
- ifp = if_get_by_name(name, vrf_id);
+ ifp = if_get_by_name(name, vrf_id, NULL);
} else {
/* pre-configured interface, learnt now */
if (ifp->vrf_id != vrf_id)