]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_evpn_vty.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / bgpd / bgp_evpn_vty.c
index e1f735f2b65b10df6ed36d622f7f815411503a26..e28a8c8057ed1dc3c847fcd1257066ca84aafe85 100644 (file)
@@ -1,21 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /* Ethernet-VPN Packet and vty Processing File
  * Copyright (C) 2017 6WIND
  *
  * This file is part of FRRouting
- *
- * FRRouting is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * FRRouting is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <zebra.h>
@@ -2506,7 +2493,7 @@ static void evpn_show_route_vni_multicast(struct vty *vty, struct bgp *bgp,
 
        /* Prefix and num paths displayed once per prefix. */
        route_vty_out_detail_header(vty, bgp, dest, bgp_dest_get_prefix(dest),
-                                   NULL, afi, safi, json);
+                                   NULL, afi, safi, json, false);
 
        /* Display each path for this prefix. */
        for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) {
@@ -2608,7 +2595,7 @@ static void evpn_show_route_vni_macip(struct vty *vty, struct bgp *bgp,
 
        /* Prefix and num paths displayed once per prefix. */
        route_vty_out_detail_header(vty, bgp, dest, (struct prefix *)&p, NULL,
-                                   afi, safi, json);
+                                   afi, safi, json, false);
 
        evp = (const struct prefix_evpn *)bgp_dest_get_prefix(dest);
 
@@ -2743,7 +2730,7 @@ static void evpn_show_route_rd_macip(struct vty *vty, struct bgp *bgp,
 
        /* Prefix and num paths displayed once per prefix. */
        route_vty_out_detail_header(vty, bgp, dest, bgp_dest_get_prefix(dest),
-                                   prd, afi, safi, json);
+                                   prd, afi, safi, json, false);
 
        if (json)
                json_paths = json_object_new_array();
@@ -2852,7 +2839,7 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp,
                        /* Prefix and num paths displayed once per prefix. */
                        route_vty_out_detail_header(
                                vty, bgp, dest, bgp_dest_get_prefix(dest), prd,
-                               afi, safi, json_prefix);
+                               afi, safi, json_prefix, false);
 
                        prefix_cnt++;
                }
@@ -2989,7 +2976,7 @@ static void evpn_show_route_rd_all_macip(struct vty *vty, struct bgp *bgp,
                        /* Prefix and num paths displayed once per prefix. */
                        route_vty_out_detail_header(
                                vty, bgp, dest, p, (struct prefix_rd *)rd_destp,
-                               AFI_L2VPN, SAFI_EVPN, json_prefix);
+                               AFI_L2VPN, SAFI_EVPN, json_prefix, false);
 
                /* For EVPN, the prefix is displayed for each path (to
                 * fit in with code that already exists).
@@ -3047,7 +3034,7 @@ static void evpn_show_route_rd_all_macip(struct vty *vty, struct bgp *bgp,
  * If 'type' is non-zero, only routes matching that type are shown.
  */
 static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
-                                json_object *json, int detail)
+                                json_object *json, int detail, bool self_orig)
 {
        struct bgp_dest *rd_dest;
        struct bgp_table *table;
@@ -3105,6 +3092,9 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
 
                        pi = bgp_dest_get_bgp_path_info(dest);
                        if (pi) {
+                               if (self_orig && (pi->peer != bgp->peer_self))
+                                       continue;
+
                                /* Overall header/legend displayed once. */
                                if (header) {
                                        bgp_evpn_show_route_header(vty, bgp,
@@ -3143,7 +3133,7 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
                                        vty, bgp, dest,
                                        bgp_dest_get_prefix(dest),
                                        (struct prefix_rd *)rd_destp, AFI_L2VPN,
-                                       SAFI_EVPN, json_prefix);
+                                       SAFI_EVPN, json_prefix, false);
 
                        /* For EVPN, the prefix is displayed for each path (to
                         * fit in
@@ -3224,7 +3214,7 @@ int bgp_evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
        if (use_json)
                json = json_object_new_object();
 
-       evpn_show_all_routes(vty, bgp, type, json, detail);
+       evpn_show_all_routes(vty, bgp, type, json, detail, false);
 
        if (use_json)
                vty_json(vty, json);
@@ -4797,7 +4787,7 @@ int bgp_evpn_cli_parse_type(int *type, struct cmd_token **argv, int argc)
  */
 DEFUN(show_bgp_l2vpn_evpn_route,
       show_bgp_l2vpn_evpn_route_cmd,
-      "show bgp l2vpn evpn route [detail] [type "EVPN_TYPE_ALL_LIST"] [json]",
+      "show bgp l2vpn evpn route [detail] [type "EVPN_TYPE_ALL_LIST"] ["BGP_SELF_ORIG_CMD_STR"] [json]",
       SHOW_STR
       BGP_STR
       L2VPN_HELP_STR
@@ -4806,12 +4796,15 @@ DEFUN(show_bgp_l2vpn_evpn_route,
       "Display Detailed Information\n"
       EVPN_TYPE_HELP_STR
       EVPN_TYPE_ALL_LIST_HELP_STR
+      BGP_SELF_ORIG_HELP_STR
       JSON_STR)
 {
        struct bgp *bgp;
        int detail = 0;
        int type = 0;
        bool uj = false;
+       int arg_idx = 0;
+       bool self_orig = false;
        json_object *json = NULL;
 
        uj = use_json(argc, argv);
@@ -4829,7 +4822,10 @@ DEFUN(show_bgp_l2vpn_evpn_route,
        if (argv_find(argv, argc, "detail", &detail))
                detail = 1;
 
-       evpn_show_all_routes(vty, bgp, type, json, detail);
+       if (argv_find(argv, argc, BGP_SELF_ORIG_CMD_STR, &arg_idx))
+               self_orig = true;
+
+       evpn_show_all_routes(vty, bgp, type, json, detail, self_orig);
 
        /*
         * This is an extremely expensive operation at scale
@@ -4895,7 +4891,7 @@ DEFUN(show_bgp_l2vpn_evpn_route_rd,
                return CMD_WARNING;
 
        if (rd_all)
-               evpn_show_all_routes(vty, bgp, type, json, 1);
+               evpn_show_all_routes(vty, bgp, type, json, 1, false);
        else
                evpn_show_route_rd(vty, bgp, &prd, type, json);