]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: add 'show bgp mplsvpn-nh-label-bind' command
authorLouis Scalbert <louis.scalbert@6wind.com>
Tue, 2 May 2023 15:23:58 +0000 (17:23 +0200)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Fri, 16 Jun 2023 08:54:58 +0000 (10:54 +0200)
There is no 'show command' to use for troubleshooting
purposes.
Add a new show command to dump the cache entry of the
MPLS VPN nexthop label bind cache table.
> show bgp [vrf NAME] mplsvpn-nh-label-bind [detail]

The below command illustrates its output:
> dut# show bgp mplsvpn-nh-label-bind  detail
> Current BGP mpls-vpn nexthop label bind cache, VRF default
>  192.168.1.3, label 102, local label 18 #paths 3
>   interface r2-eth1
>   Last update: Mon May 22 14:39:42 2023
>   Paths:
>     1/3 172.31.3.0/24 VRF default flags 0x418
>     1/3 172.31.2.0/24 VRF default flags 0x418
>     1/3 172.31.1.0/24 VRF default flags 0x418
>  192.0.2.1, label 101, local label 19 #paths 1
>   interface r2-eth0
>   Last update: Mon May 22 14:39:43 2023
>   Paths:
>     1/3 172.31.0.0/24 VRF default flags 0x418

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
bgpd/bgp_mplsvpn.c
bgpd/bgp_mplsvpn.h
bgpd/bgpd.c

index 48d7cb0f71ef1a018d64b7189494b7b8e91e68dd..a439790fd7125b24c196c920e556ea6c17af7e47 100644 (file)
@@ -4161,3 +4161,85 @@ void bgp_mplsvpn_nh_label_bind_register_local_label(struct bgp *bgp,
                                bmnc, ZEBRA_MPLS_LABELS_REPLACE);
        }
 }
+
+static void show_bgp_mplsvpn_nh_label_bind_internal(struct vty *vty,
+                                                   struct bgp *bgp,
+                                                   bool detail)
+{
+       struct bgp_mplsvpn_nh_label_bind_cache_head *tree;
+       struct bgp_mplsvpn_nh_label_bind_cache *iter;
+       afi_t afi;
+       safi_t safi;
+       struct bgp_dest *dest;
+       struct bgp_path_info *path;
+       struct bgp *bgp_path;
+       struct bgp_table *table;
+       time_t tbuf;
+
+       vty_out(vty, "Current BGP mpls-vpn nexthop label bind cache, %s\n",
+               bgp->name_pretty);
+
+       tree = &bgp->mplsvpn_nh_label_bind;
+       frr_each (bgp_mplsvpn_nh_label_bind_cache, tree, iter) {
+               if (iter->nexthop.family == AF_INET)
+                       vty_out(vty, " %pI4", &iter->nexthop.u.prefix4);
+               else
+                       vty_out(vty, " %pI6", &iter->nexthop.u.prefix6);
+               vty_out(vty, ", label %u, local label %u #paths %u\n",
+                       iter->orig_label, iter->new_label, iter->path_count);
+               if (iter->nh)
+                       vty_out(vty, "  interface %s\n",
+                               ifindex2ifname(iter->nh->ifindex,
+                                              iter->nh->vrf_id));
+               tbuf = time(NULL) - (monotime(NULL) - iter->last_update);
+               vty_out(vty, "  Last update: %s", ctime(&tbuf));
+               if (!detail)
+                       continue;
+               vty_out(vty, "  Paths:\n");
+               LIST_FOREACH (path, &(iter->paths),
+                             mplsvpn.bmnc.nh_label_bind_thread) {
+                       dest = path->net;
+                       table = bgp_dest_table(dest);
+                       assert(dest && table);
+                       afi = family2afi(bgp_dest_get_prefix(dest)->family);
+                       safi = table->safi;
+                       bgp_path = table->bgp;
+
+                       vty_out(vty, "    %d/%d %pBD %s flags 0x%x\n", afi,
+                               safi, dest, bgp_path->name_pretty, path->flags);
+               }
+       }
+}
+
+
+DEFUN(show_bgp_mplsvpn_nh_label_bind, show_bgp_mplsvpn_nh_label_bind_cmd,
+      "show bgp [<view|vrf> VIEWVRFNAME] mplsvpn-nh-label-bind [detail]",
+      SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
+      "BGP mplsvpn nexthop label binding entries\n"
+      "Show detailed information\n")
+{
+       int idx = 0;
+       char *vrf = NULL;
+       struct bgp *bgp;
+       bool detail = false;
+
+       if (argv_find(argv, argc, "vrf", &idx)) {
+               vrf = argv[++idx]->arg;
+               bgp = bgp_lookup_by_name(vrf);
+       } else
+               bgp = bgp_get_default();
+
+       if (!bgp)
+               return CMD_SUCCESS;
+
+       if (argv_find(argv, argc, "detail", &idx))
+               detail = true;
+
+       show_bgp_mplsvpn_nh_label_bind_internal(vty, bgp, detail);
+       return CMD_SUCCESS;
+}
+
+void bgp_mplsvpn_nexthop_init(void)
+{
+       install_element(VIEW_NODE, &show_bgp_mplsvpn_nh_label_bind_cmd);
+}
index aeea4598e3cd3217f73ec126b98d5cf8a16f276e..894094fdad346b74c1c66719587044dcb936be92 100644 (file)
@@ -390,5 +390,6 @@ bgp_mplsvpn_nh_label_bind_new(struct bgp_mplsvpn_nh_label_bind_cache_head *tree,
 struct bgp_mplsvpn_nh_label_bind_cache *bgp_mplsvpn_nh_label_bind_find(
        struct bgp_mplsvpn_nh_label_bind_cache_head *tree, struct prefix *p,
        mpls_label_t orig_label);
+void bgp_mplsvpn_nexthop_init(void);
 
 #endif /* _QUAGGA_BGP_MPLSVPN_H */
index d4f42128e6a69fe0712f744028f5f1d57f4e629c..49ce6462364ef4da11fde01fd8ee70166374f4b1 100644 (file)
@@ -8268,6 +8268,7 @@ void bgp_init(unsigned short instance)
        bgp_lp_vty_init();
 
        bgp_label_per_nexthop_init();
+       bgp_mplsvpn_nexthop_init();
 
        cmd_variable_handler_register(bgp_viewvrf_var_handlers);
 }