From 86f07f44c12cfc29924041f0f84158f6d3035472 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Thu, 5 Jul 2018 10:04:48 +0200 Subject: [PATCH] zebra: mpls entry interface lookup adaptation for vrf backend The search algorithm for interface based on ifindex only is adapted to vrf netns based too. Only the default netns will be used to search the interface index. Signed-off-by: Philippe Guibert --- zebra/zebra_mpls.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index fe0837a63a..cfe208d35b 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -38,6 +38,7 @@ #include "zebra/rib.h" #include "zebra/rt.h" +#include "zebra/interface.h" #include "zebra/zserv.h" #include "zebra/redistribute.h" #include "zebra/debug.h" @@ -704,6 +705,7 @@ static int nhlfe_nexthop_active(zebra_nhlfe_t *nhlfe) { struct nexthop *nexthop; struct interface *ifp; + struct zebra_ns *zns; nexthop = nhlfe->nexthop; if (!nexthop) // unexpected @@ -721,7 +723,8 @@ static int nhlfe_nexthop_active(zebra_nhlfe_t *nhlfe) * which will not be in the default * VRF. So let's look in all of them */ - ifp = if_lookup_by_index(nexthop->ifindex, VRF_UNKNOWN); + zns = zebra_ns_lookup(NS_DEFAULT); + ifp = if_lookup_by_index_per_ns(zns, nexthop->ifindex); if (ifp && if_is_operative(ifp)) SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE); else @@ -2752,10 +2755,13 @@ void zebra_mpls_print_lsp_table(struct vty *vty, struct zebra_vrf *zvrf, switch (nexthop->type) { case NEXTHOP_TYPE_IFINDEX: { + struct zebra_ns *zns; struct interface *ifp; - ifp = if_lookup_by_index( - nexthop->ifindex, VRF_UNKNOWN); + zns = zebra_ns_lookup(NS_DEFAULT); + ifp = if_lookup_by_index_per_ns( + zns, + nexthop->ifindex); vty_out(vty, "%15s", ifp->name); break; } -- 2.39.5