From fab64b600a6d9a4feb636e346eecf97dee110cfe Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Thu, 2 Mar 2023 10:46:31 +0100 Subject: [PATCH] zebra: mpls nexthop entry displays also interface when available The 'show mpls table json' command displays the outgoing interface name only when the nexthop type is either NEXTHOP_TYPE_IFINDEX or NEXTHOP_TYPE_IPV6_IFINDEX. add the interface name for the nexthop type NEXTHOP_TYPE_IPV4_IFINDEX. Fixes: ("b78b820d46d6") MPLS: Display enhancements and JSON support Signed-off-by: Philippe Guibert --- zebra/zebra_mpls.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index 38a76a2998..47d5b64a3f 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -1525,6 +1525,10 @@ static json_object *nhlfe_json(struct zebra_nhlfe *nhlfe) case NEXTHOP_TYPE_IPV4_IFINDEX: json_object_string_addf(json_nhlfe, "nexthop", "%pI4", &nexthop->gate.ipv4); + if (nexthop->ifindex) + json_object_string_add(json_nhlfe, "interface", + ifindex2ifname(nexthop->ifindex, + nexthop->vrf_id)); break; case NEXTHOP_TYPE_IPV6: case NEXTHOP_TYPE_IPV6_IFINDEX: