]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: display if FS entry is installed in PBR or not
authorPhilippe Guibert <philippe.guibert@6wind.com>
Fri, 20 Apr 2018 09:41:54 +0000 (11:41 +0200)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Thu, 31 May 2018 15:44:40 +0000 (17:44 +0200)
Once PBR rules installed, an information is printed in the main
show bgp ipv4 flowspec detail information.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
bgpd/bgp_flowspec_vty.c
bgpd/bgp_pbr.c
bgpd/bgp_pbr.h
bgpd/bgp_route.h
bgpd/bgp_zebra.c

index 7bf11f12aa1747919f9bbee5bd0a2f91bd0946d8..3ff45288953dc59df04ffbb8b9e13e24fb8641eb 100644 (file)
@@ -30,6 +30,7 @@
 #include "bgpd/bgp_flowspec_util.h"
 #include "bgpd/bgp_flowspec_private.h"
 #include "bgpd/bgp_debug.h"
+#include "bgpd/bgp_pbr.h"
 
 /* Local Structures and variables declarations
  * This code block hosts the struct declared that host the flowspec rules
@@ -318,16 +319,32 @@ void route_vty_out_flowspec(struct vty *vty, struct prefix *p,
                XFREE(MTYPE_ECOMMUNITY_STR, s);
        }
        peer_uptime(binfo->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL);
-       if (display == NLRI_STRING_FORMAT_LARGE)
-               vty_out(vty, "\tup for %8s\n", timebuf);
-       else if (json_paths) {
+       if (display == NLRI_STRING_FORMAT_LARGE) {
+               vty_out(vty, "\treceived for %8s\n", timebuf);
+       else if (json_paths) {
                json_time_path = json_object_new_object();
                json_object_string_add(json_time_path,
                                       "time", timebuf);
                if (display == NLRI_STRING_FORMAT_JSON)
                        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);
 
+               if (extra->bgp_fs_pbr) {
+                       struct bgp_pbr_match_entry *bpme;
+                       struct bgp_pbr_match *bpm;
+
+                       bpme = (struct bgp_pbr_match_entry *)extra->bgp_fs_pbr;
+                       bpm = bpme->backpointer;
+                       vty_out(vty, "\tinstalled in PBR");
+                       if (bpm)
+                               vty_out(vty, " (%s)\n", bpm->ipset_name);
+                       else
+                               vty_out(vty, "\n");
+               } else
+                       vty_out(vty, "\tnot installed in PBR\n");
+       }
 }
 
 int bgp_show_table_flowspec(struct vty *vty, struct bgp *bgp, afi_t afi,
index de94c0e03e551ba827582d262bcbe7de528c7f1a..646d58352e590c6be1b337d95a18e1f298db16c1 100644 (file)
@@ -867,6 +867,16 @@ static void bgp_pbr_flush_entry(struct bgp *bgp, struct bgp_pbr_action *bpa,
                bgp_send_pbr_ipset_entry_match(bpme, false);
                bpme->installed = false;
                bpme->backpointer = NULL;
+               if (bpme->bgp_info) {
+                       struct bgp_info *bgp_info;
+                       struct bgp_info_extra *extra;
+
+                       /* unlink bgp_info to bpme */
+                       bgp_info = (struct bgp_info *)bpme->bgp_info;
+                       extra = bgp_info_extra_get(bgp_info);
+                       extra->bgp_fs_pbr = NULL;
+                       bpme->bgp_info = NULL;
+               }
        }
        hash_release(bpm->entry_hash, bpme);
        if (hashcount(bpm->entry_hash) == 0) {
@@ -1133,6 +1143,8 @@ static void bgp_pbr_policyroute_add_to_zebra(struct bgp *bgp,
                bpme->backpointer = bpm;
                bpme->installed = false;
                bpme->install_in_progress = false;
+               /* link bgp info to bpme */
+               bpme->bgp_info = (void *)binfo;
        }
 
        /* BGP FS: append entry to zebra
index 212249295996183b0e7e932326b0d4c6b88f8662..e4117ffd05e0822ce0dda8a61768acb79192ba8a 100644 (file)
@@ -201,6 +201,8 @@ struct bgp_pbr_match_entry {
        uint16_t dst_port_max;
        uint8_t proto;
 
+       void *bgp_info;
+
        bool installed;
        bool install_in_progress;
 };
index 288b66fb85fa336aadfe6c3798dfef7eaaf1be1c..72923901b837cca1a3ea4f73a9d6b6871c0f9625 100644 (file)
@@ -146,6 +146,8 @@ struct bgp_info_extra {
         * Set nexthop_orig.family to 0 if not valid.
         */
        struct prefix nexthop_orig;
+       /* presence of FS pbr entry */
+       void *bgp_fs_pbr;
 };
 
 struct bgp_info {
index 0e1ff3303307679c2fbe75ef8e87923f491a230a..942c2d82fa05000200a827c4fa2c80f4a3ebef0a 100644 (file)
@@ -2064,11 +2064,20 @@ static int ipset_entry_notify_owner(int command, struct zclient *zclient,
                bgp_pbime->install_in_progress = false;
                break;
        case ZAPI_IPSET_ENTRY_INSTALLED:
-               bgp_pbime->installed = true;
-               bgp_pbime->install_in_progress = false;
-               if (BGP_DEBUG(zebra, ZEBRA))
-                       zlog_debug("%s: Received IPSET_ENTRY_INSTALLED",
-                                  __PRETTY_FUNCTION__);
+               {
+                       struct bgp_info *bgp_info;
+                       struct bgp_info_extra *extra;
+
+                       bgp_pbime->installed = true;
+                       bgp_pbime->install_in_progress = false;
+                       if (BGP_DEBUG(zebra, ZEBRA))
+                               zlog_debug("%s: Received IPSET_ENTRY_INSTALLED",
+                                          __PRETTY_FUNCTION__);
+                       /* link bgp_info to bpme */
+                       bgp_info = (struct bgp_info *)bgp_pbime->bgp_info;
+                       extra = bgp_info_extra_get(bgp_info);
+                       extra->bgp_fs_pbr = (void *)bgp_pbime;
+               }
                break;
        case ZAPI_IPSET_ENTRY_REMOVED:
                if (BGP_DEBUG(zebra, ZEBRA))