diff options
| author | Philippe Guibert <philippe.guibert@6wind.com> | 2018-02-20 10:58:42 +0100 | 
|---|---|---|
| committer | Philippe Guibert <philippe.guibert@6wind.com> | 2018-03-30 14:01:06 +0200 | 
| commit | 268e1b9b924ed1068bcdf1a5e49ce830f4cc7914 (patch) | |
| tree | 9452365cea5053b7ef33b245f061be62dea958ee /bgpd/bgp_flowspec.c | |
| parent | dba3c1d3fbf563aab505aebeed0ece7480e895a4 (diff) | |
bgpd: introduce [no] debug bgp flowspec
It is possible to enhance debug bgp flowspec feature by using vty
command. This command, if enabled, will dump the match/set couple of
information received on NLRI.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'bgpd/bgp_flowspec.c')
| -rw-r--r-- | bgpd/bgp_flowspec.c | 31 | 
1 files changed, 31 insertions, 0 deletions
diff --git a/bgpd/bgp_flowspec.c b/bgpd/bgp_flowspec.c index ebfa7dae66..d53271e851 100644 --- a/bgpd/bgp_flowspec.c +++ b/bgpd/bgp_flowspec.c @@ -28,6 +28,8 @@  #include "bgpd/bgp_flowspec.h"  #include "bgpd/bgp_flowspec_util.h"  #include "bgpd/bgp_flowspec_private.h" +#include "bgpd/bgp_ecommunity.h" +#include "bgpd/bgp_debug.h"  static int bgp_fs_nlri_validate(uint8_t *nlri_content, uint32_t len)  { @@ -143,6 +145,35 @@ int bgp_nlri_parse_flowspec(struct peer *peer, struct attr *attr,  		temp = XCALLOC(MTYPE_TMP, psize);  		memcpy(temp, pnt, psize);  		p.u.prefix_flowspec.ptr = (uintptr_t) temp; + +		if (BGP_DEBUG(flowspec, FLOWSPEC)) { +			char return_string[BGP_FLOWSPEC_NLRI_STRING_MAX]; +			char local_string[BGP_FLOWSPEC_NLRI_STRING_MAX]; +			char ec_string[BGP_FLOWSPEC_NLRI_STRING_MAX]; +			char *s = NULL; + +			bgp_fs_nlri_get_string((unsigned char *) +					       p.u.prefix_flowspec.ptr, +					       p.u.prefix_flowspec.prefixlen, +					       return_string, +					       NLRI_STRING_FORMAT_MIN); +			snprintf(ec_string, BGP_FLOWSPEC_NLRI_STRING_MAX, +				 "EC{none}"); +			if (attr && attr->ecommunity) { +				s = ecommunity_ecom2str(attr->ecommunity, +						ECOMMUNITY_FORMAT_ROUTE_MAP, 0); +				snprintf(ec_string, +					 BGP_FLOWSPEC_NLRI_STRING_MAX, +					 "EC{%s}", +					s == NULL ? "none" : s); +			} +			snprintf(local_string, BGP_FLOWSPEC_NLRI_STRING_MAX, +				 "FS Rx %s %s %s %s", withdraw ? +				 "Withdraw":"Update", +				 afi2str(afi), return_string, +				 attr != NULL ? ec_string : ""); +			zlog_info("%s", local_string); +		}  		/* Process the route. */  		if (!withdraw)  			ret = bgp_update(peer, &p, 0, attr,  | 
