summaryrefslogtreecommitdiff
path: root/zebra/interface.h
diff options
context:
space:
mode:
authorXiao Liang <shaw.leon@gmail.com>2023-02-21 14:00:36 +0800
committerXiao Liang <shaw.leon@gmail.com>2023-03-08 09:57:18 +0800
commitaf19624b005452dbaf25215ba371e35f61835e03 (patch)
tree349d054feabed05f52018b29e13cbfeb5c3d6f10 /zebra/interface.h
parente618cc7b21608c493ec321caf2377771c6c4baba (diff)
zebra: Add link_nsid to zebra interface
Create VRF and interfaces: ip netns add vrf1 ip link add veth1 index 100 type veth ip link add link veth1 veth1.200 type vlan id 200 ip link set veth1.200 netns vrf1 ip -n vrf1 link add veth2 index 100 type veth After reloading zebra, "show interface veth1.200" shows wrong parent interface: test# show interface veth1.200 Interface veth1.200 is down ... Parent interface: veth2 This is because veth1.200 and veth1 are in different netns, and veth2 happens to have the same ifindex as veth1, in the same netns of veth1.200. When looking for parent, link-ifindex 100 should be looked up within link-netns, rather than that of the child interface. Add link_nsid to zebra interface, so that the <link_nsid, link_ifindex> pair can uniquely identify the link interface. Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
Diffstat (limited to 'zebra/interface.h')
-rw-r--r--zebra/interface.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/zebra/interface.h b/zebra/interface.h
index c8ae906c91..09df42bc53 100644
--- a/zebra/interface.h
+++ b/zebra/interface.h
@@ -195,6 +195,7 @@ struct zebra_if {
struct list *mac_list;
/* Link fields - for sub-interfaces. */
+ ns_id_t link_nsid;
ifindex_t link_ifindex;
struct interface *link;
@@ -259,6 +260,8 @@ extern struct interface *if_lookup_by_index_per_ns(struct zebra_ns *, uint32_t);
extern struct interface *if_lookup_by_name_per_ns(struct zebra_ns *,
const char *);
extern struct interface *if_link_per_ns(struct zebra_ns *, struct interface *);
+extern struct interface *if_lookup_by_index_per_nsid(ns_id_t nsid,
+ uint32_t ifindex);
extern const char *ifindex2ifname_per_ns(struct zebra_ns *, unsigned int);
extern void if_unlink_per_ns(struct interface *);