]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_nexthop.c
Merge pull request #13455 from sri-mohan1/srib-ldpd
[mirror_frr.git] / bgpd / bgp_nexthop.c
index 00a0bc84023e91abf8ee4ed0d4bcd1f0255c8516..1c79d7d03be34ce8bea84cd64517500c71ec3c60 100644 (file)
@@ -6,7 +6,7 @@
 #include <zebra.h>
 
 #include "command.h"
-#include "thread.h"
+#include "frrevent.h"
 #include "prefix.h"
 #include "lib/json.h"
 #include "zclient.h"
@@ -166,11 +166,7 @@ void bgp_tip_hash_init(struct bgp *bgp)
 
 void bgp_tip_hash_destroy(struct bgp *bgp)
 {
-       if (bgp->tip_hash == NULL)
-               return;
-       hash_clean(bgp->tip_hash, bgp_tip_hash_free);
-       hash_free(bgp->tip_hash);
-       bgp->tip_hash = NULL;
+       hash_clean_and_free(&bgp->tip_hash, bgp_tip_hash_free);
 }
 
 /* Add/Update Tunnel-IP entry of bgp martian next-hop table.
@@ -305,11 +301,7 @@ void bgp_address_init(struct bgp *bgp)
 
 void bgp_address_destroy(struct bgp *bgp)
 {
-       if (bgp->address_hash == NULL)
-               return;
-       hash_clean(bgp->address_hash, bgp_address_hash_free);
-       hash_free(bgp->address_hash);
-       bgp->address_hash = NULL;
+       hash_clean_and_free(&bgp->address_hash, bgp_address_hash_free);
 }
 
 static void bgp_address_add(struct bgp *bgp, struct connected *ifc,
@@ -916,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",
@@ -934,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;