summaryrefslogtreecommitdiff
path: root/bgpd/bgp_nexthop.c
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2023-04-24 22:33:15 +0200
committerPhilippe Guibert <philippe.guibert@6wind.com>2023-04-27 17:04:20 +0200
commit20d072d3ecce99a5e163c61524952797886b65a7 (patch)
tree5b569bf2279abb211b412870435d36a3a1d033b3 /bgpd/bgp_nexthop.c
parent34a8441fe8bb5777c9c450d2ba0dfc6bd33fd2c9 (diff)
bgpd: keep interface index on bgp nexthop tracking
The following BGP configuration does not show that the resolved next-hop to 192.0.2.1 has a defined interface. > router bgp 65500 > bgp router-id 192.0.2.2 > neighbor 192.0.2.1 remote-as 65500 > neighbor 192.0.2.1 update-source loop1 > neighbor 192.168.0.1 remote-as 65500 > ! > address-family ipv4 unicast > network 192.0.2.2/32 > no neighbor 192.168.0.1 activate > exit-address-family > ! > address-family ipv4 labeled-unicast > neighbor 192.168.0.1 activate > exit-address-family > ! > address-family ipv4 vpn > neighbor 192.0.2.1 activate > exit-address-family The 'show bgp nexthop' dump does not output the interface whereas the zebra rnh has the information. > dut-vm# show bgp nexthop > [..] > Current BGP nexthop cache: > 192.0.2.1 valid [IGP metric 0], #paths 1, peer 192.0.2.1 > gate 192.168.0.1 > Last update: Mon Apr 24 22:10:07 2023 > > dut-vm# show ip nht > 192.0.2.1 > resolved via bgp > via 192.168.0.1, r2-eth0 > Client list: bgp(fd 33) Modify the display of BGP nexthop tracking to also dump the interface used: > dut-vm# show bgp nexthop > [..] > Current BGP nexthop cache: > 192.0.2.1 valid [IGP metric 0], #paths 1, peer 192.0.2.1 > gate 192.168.0.1, r2-eth0 > Last update: Mon Apr 24 22:10:07 2023 Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'bgpd/bgp_nexthop.c')
-rw-r--r--bgpd/bgp_nexthop.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c
index c4b832ee59..1c79d7d03b 100644
--- a/bgpd/bgp_nexthop.c
+++ b/bgpd/bgp_nexthop.c
@@ -908,17 +908,34 @@ static void bgp_show_nexthops_detail(struct vty *vty, struct bgp *bgp,
}
switch (nexthop->type) {
case NEXTHOP_TYPE_IPV6:
- vty_out(vty, " gate %pI6\n", &nexthop->gate.ipv6);
- break;
case NEXTHOP_TYPE_IPV6_IFINDEX:
- vty_out(vty, " gate %pI6, if %s\n",
- &nexthop->gate.ipv6,
- ifindex2ifname(bnc->ifindex ? bnc->ifindex
- : nexthop->ifindex,
- bgp->vrf_id));
+ vty_out(vty, " gate %pI6", &nexthop->gate.ipv6);
+ if (nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX &&
+ bnc->ifindex)
+ vty_out(vty, ", if %s\n",
+ ifindex2ifname(bnc->ifindex,
+ bgp->vrf_id));
+ else if (nexthop->ifindex)
+ vty_out(vty, ", if %s\n",
+ ifindex2ifname(nexthop->ifindex,
+ bgp->vrf_id));
+ else
+ vty_out(vty, "\n");
break;
case NEXTHOP_TYPE_IPV4:
- vty_out(vty, " gate %pI4\n", &nexthop->gate.ipv4);
+ case NEXTHOP_TYPE_IPV4_IFINDEX:
+ vty_out(vty, " gate %pI4", &nexthop->gate.ipv4);
+ if (nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX &&
+ bnc->ifindex)
+ vty_out(vty, ", if %s\n",
+ ifindex2ifname(bnc->ifindex,
+ bgp->vrf_id));
+ else if (nexthop->ifindex)
+ vty_out(vty, ", if %s\n",
+ ifindex2ifname(nexthop->ifindex,
+ bgp->vrf_id));
+ else
+ vty_out(vty, "\n");
break;
case NEXTHOP_TYPE_IFINDEX:
vty_out(vty, " if %s\n",
@@ -926,13 +943,6 @@ static void bgp_show_nexthops_detail(struct vty *vty, struct bgp *bgp,
: nexthop->ifindex,
bgp->vrf_id));
break;
- case NEXTHOP_TYPE_IPV4_IFINDEX:
- vty_out(vty, " gate %pI4, if %s\n",
- &nexthop->gate.ipv4,
- ifindex2ifname(bnc->ifindex ? bnc->ifindex
- : nexthop->ifindex,
- bgp->vrf_id));
- break;
case NEXTHOP_TYPE_BLACKHOLE:
vty_out(vty, " blackhole\n");
break;