]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: Changes to BGP show json commands
authorAmeya Dharkar <adharkar@vmware.com>
Thu, 19 Jul 2018 20:46:46 +0000 (13:46 -0700)
committerAmeya Dharkar <adharkar@vmware.com>
Thu, 19 Jul 2018 20:46:46 +0000 (13:46 -0700)
Added localRouterID to "show bgp neighbor json"
Added json O/P to "show bgp [AFI] community <community>"

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
bgpd/bgp_route.c
bgpd/bgp_vty.c

index 795bd15613a0c41376c2b291f5903d33f2948331..f10f7425c6a6a6a79de38e1f94db50077bb32bf9 100644 (file)
@@ -8163,7 +8163,7 @@ static int bgp_show_regexp(struct vty *vty, struct bgp *bgp, const char *regstr,
                           afi_t afi, safi_t safi, enum bgp_show_type type);
 static int bgp_show_community(struct vty *vty, struct bgp *bgp,
                              const char *comstr, int exact, afi_t afi,
-                             safi_t safi);
+                             safi_t safi, uint8_t use_json);
 
 
 static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi,
@@ -9038,7 +9038,6 @@ DEFUN (show_ip_bgp,
            |prefix-list WORD\
            |filter-list WORD\
            |statistics\
-           |community <AA:NN|local-AS|no-advertise|no-export|graceful-shutdown> [exact-match]\
            |community-list <(1-500)|WORD> [exact-match]\
            |A.B.C.D/M longer-prefixes\
            |X:X::X:X/M longer-prefixes\
@@ -9058,13 +9057,6 @@ DEFUN (show_ip_bgp,
        "Display routes conforming to the filter-list\n"
        "Regular expression access list name\n"
        "BGP RIB advertisement statistics\n"
-       "Display routes matching the communities\n"
-       COMMUNITY_AANN_STR
-       "Do not send outside local AS (well-known community)\n"
-       "Do not advertise to any peer (well-known community)\n"
-       "Do not export to next AS (well-known community)\n"
-       "Graceful shutdown (well-known community)\n"
-       "Exact match of the communities\n"
        "Display routes matching the community-list\n"
        "community-list number\n"
        "community-list name\n"
@@ -9079,7 +9071,6 @@ DEFUN (show_ip_bgp,
        int exact_match = 0;
        struct bgp *bgp = NULL;
        int idx = 0;
-       int idx_community_type = 0;
 
        bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi,
                                            &bgp);
@@ -9106,24 +9097,6 @@ DEFUN (show_ip_bgp,
                return bgp_show_route_map(vty, bgp, argv[idx + 1]->arg, afi,
                                          safi, bgp_show_type_route_map);
 
-       if (argv_find(argv, argc, "community", &idx)) {
-               /* show a specific community */
-               if (argv_find(argv, argc, "local-AS", &idx_community_type)
-                   || argv_find(argv, argc, "no-advertise",
-                                &idx_community_type)
-                   || argv_find(argv, argc, "no-export", &idx_community_type)
-                   || argv_find(argv, argc, "graceful-shutdown",
-                                &idx_community_type)
-                   || argv_find(argv, argc, "AA:NN", &idx_community_type)) {
-
-                       if (argv_find(argv, argc, "exact-match", &idx))
-                               exact_match = 1;
-                       return bgp_show_community(vty, bgp,
-                                                 argv[idx_community_type]->arg,
-                                                 exact_match, afi, safi);
-               }
-       }
-
        if (argv_find(argv, argc, "community-list", &idx)) {
                const char *clist_number_or_name = argv[++idx]->arg;
                if (++idx < argc && strmatch(argv[idx]->text, "exact-match"))
@@ -9148,7 +9121,7 @@ DEFUN (show_ip_bgp_json,
           [<\
              cidr-only\
              |dampening <flap-statistics|dampened-paths>\
-             |community \
+             |community [<AA:NN|local-AS|no-advertise|no-export|graceful-shutdown>] [exact-match]\
           >] [json]",
        SHOW_STR
        IP_STR
@@ -9161,6 +9134,12 @@ DEFUN (show_ip_bgp_json,
        "Display flap statistics of routes\n"
        "Display paths suppressed due to dampening\n"
        "Display routes matching the communities\n"
+       COMMUNITY_AANN_STR
+       "Do not send outside local AS (well-known community)\n"
+       "Do not advertise to any peer (well-known community)\n"
+       "Do not export to next AS (well-known community)\n"
+       "Graceful shutdown (well-known community)\n"
+       "Exact match of the communities\n"
        JSON_STR)
 {
        afi_t afi = AFI_IP6;
@@ -9168,6 +9147,8 @@ DEFUN (show_ip_bgp_json,
        enum bgp_show_type sh_type = bgp_show_type_normal;
        struct bgp *bgp = NULL;
        int idx = 0;
+       int idx_community_type = 0;
+       int exact_match = 0;
 
        bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi,
                                            &bgp);
@@ -9193,10 +9174,31 @@ DEFUN (show_ip_bgp_json,
        }
 
        if (argv_find(argv, argc, "community", &idx)) {
-               /* show all communities */
-               return bgp_show(vty, bgp, afi, safi,
-                               bgp_show_type_community_all, NULL, uj);
+
+               /* show a specific community */
+               if (argv_find(argv, argc, "local-AS", &idx_community_type) ||
+                       argv_find(argv, argc, "no-advertise",
+                                       &idx_community_type) ||
+                       argv_find(argv, argc, "no-export",
+                                       &idx_community_type) ||
+                       argv_find(argv, argc, "graceful-shutdown",
+                                       &idx_community_type) ||
+                       argv_find(argv, argc, "AA:NN", &idx_community_type)) {
+                       if (argv_find(argv, argc, "exact-match", &idx))
+                               exact_match = 1;
+
+                       return (bgp_show_community(vty, bgp,
+                                               argv[idx_community_type]->arg,
+                                               exact_match, afi, safi, uj));
+               } else {
+
+                       /* show all communities */
+                       return (bgp_show(vty, bgp, afi, safi,
+                                       bgp_show_type_community_all, NULL,
+                                       uj));
+               }
        }
+
        return bgp_show(vty, bgp, afi, safi, sh_type, NULL, uj);
 }
 
@@ -9403,7 +9405,7 @@ static int bgp_show_route_map(struct vty *vty, struct bgp *bgp,
 
 static int bgp_show_community(struct vty *vty, struct bgp *bgp,
                              const char *comstr, int exact, afi_t afi,
-                             safi_t safi)
+                             safi_t safi, uint8_t use_json)
 {
        struct community *com;
        int ret = 0;
@@ -9417,7 +9419,7 @@ static int bgp_show_community(struct vty *vty, struct bgp *bgp,
        ret = bgp_show(vty, bgp, afi, safi,
                       (exact ? bgp_show_type_community_exact
                              : bgp_show_type_community),
-                      com, 0);
+                      com, use_json);
        community_free(com);
 
        return ret;
index e9d9a846af810490248a7494ac75ec2a48400b74..2acf39a69961a95a9cfc9d0cc2942f1283be4e33 100644 (file)
@@ -9115,6 +9115,10 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, uint8_t use_json,
                json_object_string_add(
                        json_neigh, "remoteRouterId",
                        inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1)));
+               json_object_string_add(
+                       json_neigh, "localRouterId",
+                       inet_ntop(AF_INET, &bgp->router_id, buf1,
+                                       sizeof(buf1)));
 
                /* Confederation */
                if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)