From 14fcc65cbbcd3d1684b879a10a0d8564c238e0e6 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 5 Jan 2018 09:21:55 -0500 Subject: lib: Allow interface lookup by VRF_UNKNOWN Modify if_lookup_by_index to accept a VRF_UNKNOWN as a vrf_id. This will cause it to look in all vrf's for the interface pointer. Subsequently all if_XXXX functions that call this function will also get this behavior. VRF_UNKNOWN *should* not be used for interface creation as that this will break some core assumptions. This work is part of allowing vrf route leaking. Currently it is possible to create a route in the linux kernel that has a nexthop across vrf boundaries. Signed-off-by: Donald Sharp --- lib/if.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/if.c') diff --git a/lib/if.c b/lib/if.c index 8e6a9a6968..fdcd563a5d 100644 --- a/lib/if.c +++ b/lib/if.c @@ -219,6 +219,18 @@ struct interface *if_lookup_by_index(ifindex_t ifindex, vrf_id_t vrf_id) struct vrf *vrf; struct interface if_tmp; + if (vrf_id == VRF_UNKNOWN) { + struct interface *ifp; + + RB_FOREACH(vrf, vrf_id_head, &vrfs_by_id) { + ifp = if_lookup_by_index(ifindex, vrf->vrf_id); + if (ifp) + return ifp; + } + + return NULL; + } + vrf = vrf_lookup_by_id(vrf_id); if (!vrf) return NULL; -- cgit v1.2.3 From c7974c0f1a7acedd1d5c4d9dff73ae8b42595c56 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 29 Jan 2018 15:38:03 -0500 Subject: lib: When we shutdown we would leak interface description Signed-off-by: Donald Sharp desc) + XFREE(MTYPE_TMP, ifp->desc); + XFREE(MTYPE_IF, ifp); } -- cgit v1.2.3