]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_flowspec_vty.c
bgpd: Adding BGP GR Global & Per Neighbour FSM changes
[mirror_frr.git] / bgpd / bgp_flowspec_vty.c
index faa88f98506712aa4052299ff27fd2001d06bda7..80384c12c628bd0a50545a0b3c242a134c6ae7f2 100644 (file)
@@ -253,8 +253,8 @@ void bgp_fs_nlri_get_string(unsigned char *nlri_content, size_t len,
 }
 
 void route_vty_out_flowspec(struct vty *vty, struct prefix *p,
-                           struct bgp_info *binfo,
-                           int display, json_object *json_paths)
+                           struct bgp_path_info *path, int display,
+                           json_object *json_paths)
 {
        struct attr *attr;
        char return_string[BGP_FLOWSPEC_STRING_DISPLAY_MAX];
@@ -274,9 +274,9 @@ void route_vty_out_flowspec(struct vty *vty, struct prefix *p,
                        else
                                json_nlri_path = json_paths;
                }
-               if (display == NLRI_STRING_FORMAT_LARGE && binfo)
+               if (display == NLRI_STRING_FORMAT_LARGE && path)
                        vty_out(vty, "BGP flowspec entry: (flags 0x%x)\n",
-                               binfo->flags);
+                               path->flags);
                bgp_fs_nlri_get_string((unsigned char *)
                                       p->u.prefix_flowspec.ptr,
                                       p->u.prefix_flowspec.prefixlen,
@@ -292,11 +292,11 @@ void route_vty_out_flowspec(struct vty *vty, struct prefix *p,
                else if (json_paths && display == NLRI_STRING_FORMAT_JSON)
                        json_object_array_add(json_paths, json_nlri_path);
        }
-       if (!binfo)
+       if (!path)
                return;
-       if (binfo->attr && binfo->attr->ecommunity) {
+       if (path->attr->ecommunity) {
                /* Print attribute */
-               attr = binfo->attr;
+               attr = path->attr;
                s = ecommunity_ecom2str(attr->ecommunity,
                                        ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
                if (!s)
@@ -315,10 +315,11 @@ void route_vty_out_flowspec(struct vty *vty, struct prefix *p,
                }
                if (attr->nexthop.s_addr != 0 &&
                    display == NLRI_STRING_FORMAT_LARGE)
-                       vty_out(vty, "\tNH %-16s\n", inet_ntoa(attr->nexthop));
+                       vty_out(vty, "\tNLRI NH %-16s\n",
+                               inet_ntoa(attr->nexthop));
                XFREE(MTYPE_ECOMMUNITY_STR, s);
        }
-       peer_uptime(binfo->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL);
+       peer_uptime(path->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL);
        if (display == NLRI_STRING_FORMAT_LARGE) {
                vty_out(vty, "\treceived for %8s\n", timebuf);
        } else if (json_paths) {
@@ -329,18 +330,18 @@ void route_vty_out_flowspec(struct vty *vty, struct prefix *p,
                        json_object_array_add(json_paths, json_time_path);
        }
        if (display == NLRI_STRING_FORMAT_LARGE) {
-               struct bgp_info_extra *extra = bgp_info_extra_get(binfo);
+               struct bgp_path_info_extra *extra =
+                       bgp_path_info_extra_get(path);
+               bool list_began = false;
 
-               if (extra->bgp_fs_pbr) {
+               if (extra->bgp_fs_pbr && listcount(extra->bgp_fs_pbr)) {
                        struct listnode *node;
                        struct bgp_pbr_match_entry *bpme;
                        struct bgp_pbr_match *bpm;
-                       bool list_began = false;
                        struct list *list_bpm;
 
                        list_bpm = list_new();
-                       if (listcount(extra->bgp_fs_pbr))
-                               vty_out(vty, "\tinstalled in PBR");
+                       vty_out(vty, "\tinstalled in PBR");
                        for (ALL_LIST_ELEMENTS_RO(extra->bgp_fs_pbr,
                                                  node, bpme)) {
                                bpm = bpme->backpointer;
@@ -354,11 +355,32 @@ void route_vty_out_flowspec(struct vty *vty, struct prefix *p,
                                        vty_out(vty, ", ");
                                vty_out(vty, "%s", bpm->ipset_name);
                        }
+                       list_delete(&list_bpm);
+               }
+               if (extra->bgp_fs_iprule && listcount(extra->bgp_fs_iprule)) {
+                       struct listnode *node;
+                       struct bgp_pbr_rule *bpr;
+
+                       if (!list_began)
+                               vty_out(vty, "\tinstalled in PBR");
+                       for (ALL_LIST_ELEMENTS_RO(extra->bgp_fs_iprule,
+                                                 node, bpr)) {
+                               if (!bpr->action)
+                                       continue;
+                               if (!list_began) {
+                                       vty_out(vty, " (");
+                                       list_began = true;
+                               } else
+                                       vty_out(vty, ", ");
+                               vty_out(vty, "-ipv4-rule %d action lookup %u-",
+                                       bpr->priority,
+                                       bpr->action->table_id);
+                       }
                        if (list_began)
                                vty_out(vty, ")");
                        vty_out(vty, "\n");
-                       list_delete_and_null(&list_bpm);
-               } else
+               }
+               if (!list_began)
                        vty_out(vty, "\tnot installed in PBR\n");
        }
 }
@@ -368,7 +390,7 @@ int bgp_show_table_flowspec(struct vty *vty, struct bgp *bgp, afi_t afi,
                            void *output_arg, bool use_json, int is_last,
                            unsigned long *output_cum, unsigned long *total_cum)
 {
-       struct bgp_info *ri;
+       struct bgp_path_info *pi;
        struct bgp_node *rn;
        unsigned long total_count = 0;
        json_object *json_paths = NULL;
@@ -378,18 +400,17 @@ int bgp_show_table_flowspec(struct vty *vty, struct bgp *bgp, afi_t afi,
                return CMD_SUCCESS;
 
        for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
-               if (rn->info == NULL)
+               pi = bgp_node_get_bgp_path_info(rn);
+               if (pi == NULL)
                        continue;
                if (use_json) {
                        json_paths = json_object_new_array();
                        display = NLRI_STRING_FORMAT_JSON;
                }
-               for (ri = rn->info; ri; ri = ri->next) {
+               for (; pi; pi = pi->next) {
                        total_count++;
-                       route_vty_out_flowspec(vty, &rn->p,
-                                              ri, display,
+                       route_vty_out_flowspec(vty, &rn->p, pi, display,
                                               json_paths);
-
                }
                if (use_json) {
                        vty_out(vty, "%s\n",
@@ -543,11 +564,11 @@ extern int bgp_flowspec_display_match_per_ip(afi_t afi, struct bgp_table *rib,
                        continue;
 
                if (bgp_flowspec_contains_prefix(prefix, match, prefix_check)) {
-                       route_vty_out_flowspec(vty, &rn->p,
-                                              rn->info, use_json ?
-                                              NLRI_STRING_FORMAT_JSON :
-                                              NLRI_STRING_FORMAT_LARGE,
-                                              json_paths);
+                       route_vty_out_flowspec(
+                               vty, &rn->p, bgp_node_get_bgp_path_info(rn),
+                               use_json ? NLRI_STRING_FORMAT_JSON
+                                        : NLRI_STRING_FORMAT_LARGE,
+                               json_paths);
                        display++;
                }
        }