From: Philippe Guibert Date: Fri, 20 Apr 2018 09:41:54 +0000 (+0200) Subject: bgpd: display if FS entry is installed in PBR or not X-Git-Tag: frr-6.1-dev~395^2~15 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=b588b642ce3d933394240f77879eb41f36959311;p=matthieu%2Ffrr.git bgpd: display if FS entry is installed in PBR or not Once PBR rules installed, an information is printed in the main show bgp ipv4 flowspec detail information. Signed-off-by: Philippe Guibert --- diff --git a/bgpd/bgp_flowspec_vty.c b/bgpd/bgp_flowspec_vty.c index 7bf11f12aa..3ff4528895 100644 --- a/bgpd/bgp_flowspec_vty.c +++ b/bgpd/bgp_flowspec_vty.c @@ -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, diff --git a/bgpd/bgp_pbr.c b/bgpd/bgp_pbr.c index de94c0e03e..646d58352e 100644 --- a/bgpd/bgp_pbr.c +++ b/bgpd/bgp_pbr.c @@ -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 diff --git a/bgpd/bgp_pbr.h b/bgpd/bgp_pbr.h index 2122492959..e4117ffd05 100644 --- a/bgpd/bgp_pbr.h +++ b/bgpd/bgp_pbr.h @@ -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; }; diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h index 00e5677fe0..250298f0de 100644 --- a/bgpd/bgp_route.h +++ b/bgpd/bgp_route.h @@ -140,6 +140,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 { diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index ecc6d1ee34..84a8155808 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -2050,11 +2050,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))