[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openbsd-tech
Subject:    Re: tcpdump: decode Large BGP Communities
From:       Stuart Henderson <stu () spacehopper ! org>
Date:       2016-10-12 16:54:10
Message-ID: 20161012165410.ngtpkhp6ggvkpmwb () symphytum ! spacehopper ! org
[Download RAW message or body]

On 2016/10/12 18:44, Job Snijders wrote:
> This patch adds support to tcpdump(8) to decode Large BGP
> Communities in human readable form.
> 
> Example:
> 
> 	[ snip ] BGP (UPDATE: (Path attributes: (ORIGIN[T] IGP)
> 		(AS_PATH[T] 65000)
> 		(NEXT_HOP[T] pxtr-2.meerval.net)
> 		(COMMUNITIES[OT] 666:666 2914:0)
> 		(LARGE_COMMUNITIES[OT] 2914:0:666 2914:4294927296:123))
> 		(NLRI: 9.9.9.10/32)) (DF) (ttl 63, id 2806, len 138)
> 
> Kind regards,
> 
> Job

OK sthen@.


> 
> Index: src/usr.sbin/tcpdump/print-bgp.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/tcpdump/print-bgp.c,v
> retrieving revision 1.18
> diff -u -p -u -r1.18 print-bgp.c
> --- src/usr.sbin/tcpdump/print-bgp.c	20 Oct 2015 11:29:07 -0000	1.18
> +++ src/usr.sbin/tcpdump/print-bgp.c	12 Oct 2016 16:09:51 -0000
> @@ -134,6 +134,7 @@ struct bgp_attr {
>  #define BGPTYPE_EXTD_COMMUNITIES	16	/* RFC4360 */
>  #define BGPTYPE_AS4_PATH		17	/* RFC4893 */
>  #define BGPTYPE_AGGREGATOR4		18	/* RFC4893 */
> +#define BGPTYPE_LARGE_COMMUNITIES	30	/* draft-ietf-idr-large-community */
>  
>  #define BGP_AS_SET             1
>  #define BGP_AS_SEQUENCE        2
> @@ -265,7 +266,8 @@ static const char *bgpattr_type[] = {
>  	"MULTI_EXIT_DISC", "LOCAL_PREF", "ATOMIC_AGGREGATE", "AGGREGATOR",
>  	"COMMUNITIES", "ORIGINATOR_ID", "CLUSTER_LIST", "DPA",
>  	"ADVERTISERS", "RCID_PATH", "MP_REACH_NLRI", "MP_UNREACH_NLRI",
> -	"EXTD_COMMUNITIES", "AS4_PATH", "AGGREGATOR4",
> +	"EXTD_COMMUNITIES", "AS4_PATH", "AGGREGATOR4", NULL, NULL, NULL,
> +	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "LARGE_COMMUNITIES",
>  };
>  #define bgp_attr_type(x) \
>  	num_or_str(bgpattr_type, \
> @@ -544,6 +546,21 @@ bgp_attr_print(const struct bgp_attr *at
>  			}
>  			tlen -= 4;
>  			p += 4;
> +		}
> +		break;
> +	case BGPTYPE_LARGE_COMMUNITIES:
> +		if (len == 0 || len % 12) {
> +			printf(" invalid len");
> +			break;
> +		}
> +		while (tlen>0) {
> +			TCHECK2(p[0], 12);
> +			printf(" %u:%u:%u",
> +			EXTRACT_32BITS(p),
> +			EXTRACT_32BITS(p + 4),
> +			EXTRACT_32BITS(p + 8));
> +			tlen -= 12;
> +			p += 12;
>  		}
>  		break;
>  	case BGPTYPE_ORIGINATOR_ID:
> 

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic