Re: bgpd draft-ietf-idr-large-community

2016-10-14 Thread Sebastian Benoit

forgot to look at bgpctl in my first reply, sry

Peter Hessler(phess...@openbsd.org) on 2016.10.13 17:34:28 +0200:
> On 2016 Oct 11 (Tue) at 00:00:53 +0200 (+0200), Peter Hessler wrote:
> :Here is an initial implementation of draft-ietf-idr-large-community for
> :OpenBGPD.  I can connect and exchange routes with these attributes
> :against exabgp.
> :
> :Normal communities are two 16bit numbers.  With the addition of
> :32bit ASNs, those will not work if you wish to control one of
> :them.
> :
> :Large Communities are 32bit:32bit:32bit.  It seems the convention will be
> :::, with  and  being locally
> :defined.
> :
> :RFC status: currently accepted by the IDR-WG, is at version -02, the
> :wire format is set, the attribute codepoint is assigned by IANA, and it
> :seems that only trivial details need to be addressed.  Very likely to be
> :accepted.
> :
> :This was based on a partial implementation from Job Snijders, many
> :thanks!
> :
> :Comments?  OK?
> :
> 
> Updated diff:
>  - assert copyright for the non-trivial changes
>  - since the magic ASN matching canaries use valid bits, seperate the
> filter storage and a wire storage
>  - clean up warnings
>  - fix a few printing issues
> 
> OK?
> 
> 
> Index: usr.sbin/bgpctl/bgpctl.8
> ===
> RCS file: /cvs/openbsd/src/usr.sbin/bgpctl/bgpctl.8,v
> retrieving revision 1.69
> diff -u -p -u -p -r1.69 bgpctl.8
> --- usr.sbin/bgpctl/bgpctl.8  25 May 2016 14:15:59 -  1.69
> +++ usr.sbin/bgpctl/bgpctl.8  5 Sep 2016 13:41:29 -
> @@ -300,6 +300,9 @@ anywhere in the AS path.
>  .It Cm community Ar community
>  Show all entries with community
>  .Ar community .
> +.It Cm large-community Ar large-community
> +Show all entries with large-community
> +.Ar large-community .
>  .It Cm empty-as
>  Show all entries that are internal routes with no AS's in the AS path.
>  .It Cm memory
> Index: usr.sbin/bgpctl/bgpctl.c
> ===
> RCS file: /cvs/openbsd/src/usr.sbin/bgpctl/bgpctl.c,v
> retrieving revision 1.188
> diff -u -p -u -p -r1.188 bgpctl.c
> --- usr.sbin/bgpctl/bgpctl.c  3 Jun 2016 17:36:37 -   1.188
> +++ usr.sbin/bgpctl/bgpctl.c  13 Oct 2016 15:32:30 -
> @@ -2,6 +2,8 @@
>  
>  /*
>   * Copyright (c) 2003 Henning Brauer 
> + * Copyright (c) 2016 Job Snijders 
> + * Copyright (c) 2016 Peter Hessler 
>   *
>   * Permission to use, copy, modify, and distribute this software for any
>   * purpose with or without fee is hereby granted, provided that the above
> @@ -82,6 +84,7 @@ void show_rib_brief(struct ctl_show_ri
>  void  show_rib_detail(struct ctl_show_rib *, u_char *, int);
>  void  show_attr(void *, u_int16_t);
>  void  show_community(u_char *, u_int16_t);
> +void  show_large_community(u_char *, u_int16_t);
>  void  show_ext_community(u_char *, u_int16_t);
>  char *fmt_mem(int64_t);
>  int   show_rib_memory_msg(struct imsg *);
> @@ -254,6 +257,13 @@ main(int argc, char *argv[])
>   sizeof(res->community));
>   type = IMSG_CTL_SHOW_RIB_COMMUNITY;
>   }
> + if (res->large_community.as != COMMUNITY_UNSET &&
> + res->large_community.ld1 != COMMUNITY_UNSET &&
> + res->large_community.ld2 != COMMUNITY_UNSET) {
> + memcpy(_community, >large_community,
> + sizeof(res->large_community));
> + type = IMSG_CTL_SHOW_RIB_LARGECOMMUNITY;
> + }
>   memcpy(, , sizeof(ribreq.neighbor));
>   strlcpy(ribreq.rib, res->rib, sizeof(ribreq.rib));
>   ribreq.aid = res->aid;
> @@ -275,6 +285,11 @@ main(int argc, char *argv[])
>   res->community.type != COMMUNITY_UNSET)
>   memcpy(, >community,
>   sizeof(res->community));
> + if (res->large_community.as != COMMUNITY_UNSET &&
> + res->large_community.ld1 != COMMUNITY_UNSET &&
> + res->large_community.ld2 != COMMUNITY_UNSET)
> + memcpy(_community, >large_community,
> + sizeof(res->large_community));
>   memcpy(, , sizeof(ribreq.neighbor));
>   ribreq.aid = res->aid;
>   ribreq.flags = res->flags;
> @@ -377,6 +392,11 @@ main(int argc, char *argv[])
>   res->community.type != COMMUNITY_UNSET)
>   memcpy(, >community,
>   sizeof(res->community));
> + if (res->large_community.as != COMMUNITY_UNSET &&
> + res->large_community.ld1 != COMMUNITY_UNSET &&
> + res->large_community.ld2 != COMMUNITY_UNSET)
> + memcpy(_community, >large_community,
> +

Re: bgpd draft-ietf-idr-large-community

2016-10-14 Thread Sebastian Benoit
Peter Hessler(phess...@openbsd.org) on 2016.10.13 17:34:28 +0200:
> On 2016 Oct 11 (Tue) at 00:00:53 +0200 (+0200), Peter Hessler wrote:
> :Here is an initial implementation of draft-ietf-idr-large-community for
> :OpenBGPD.  I can connect and exchange routes with these attributes
> :against exabgp.
> :
> :Normal communities are two 16bit numbers.  With the addition of
> :32bit ASNs, those will not work if you wish to control one of
> :them.
> :
> :Large Communities are 32bit:32bit:32bit.  It seems the convention will be
> :::, with  and  being locally
> :defined.
> :
> :RFC status: currently accepted by the IDR-WG, is at version -02, the
> :wire format is set, the attribute codepoint is assigned by IANA, and it
> :seems that only trivial details need to be addressed.  Very likely to be
> :accepted.
> :
> :This was based on a partial implementation from Job Snijders, many
> :thanks!
> :
> :Comments?  OK?
> :
> 
> Updated diff:
>  - assert copyright for the non-trivial changes
>  - since the magic ASN matching canaries use valid bits, seperate the
> filter storage and a wire storage
>  - clean up warnings
>  - fix a few printing issues
> 
> OK?

nice, just a few questions below 

> Index: usr.sbin/bgpctl/bgpctl.8
> ===
> RCS file: /cvs/openbsd/src/usr.sbin/bgpctl/bgpctl.8,v
> retrieving revision 1.69
> diff -u -p -u -p -r1.69 bgpctl.8
> --- usr.sbin/bgpctl/bgpctl.8  25 May 2016 14:15:59 -  1.69
> +++ usr.sbin/bgpctl/bgpctl.8  5 Sep 2016 13:41:29 -
> @@ -300,6 +300,9 @@ anywhere in the AS path.
>  .It Cm community Ar community
>  Show all entries with community
>  .Ar community .
> +.It Cm large-community Ar large-community
> +Show all entries with large-community
> +.Ar large-community .
>  .It Cm empty-as
>  Show all entries that are internal routes with no AS's in the AS path.
>  .It Cm memory
> Index: usr.sbin/bgpctl/bgpctl.c
> ===
> RCS file: /cvs/openbsd/src/usr.sbin/bgpctl/bgpctl.c,v
> retrieving revision 1.188
> diff -u -p -u -p -r1.188 bgpctl.c
> --- usr.sbin/bgpctl/bgpctl.c  3 Jun 2016 17:36:37 -   1.188
> +++ usr.sbin/bgpctl/bgpctl.c  13 Oct 2016 15:32:30 -
> @@ -2,6 +2,8 @@
>  
>  /*
>   * Copyright (c) 2003 Henning Brauer 
> + * Copyright (c) 2016 Job Snijders 
> + * Copyright (c) 2016 Peter Hessler 
>   *
>   * Permission to use, copy, modify, and distribute this software for any
>   * purpose with or without fee is hereby granted, provided that the above
> @@ -82,6 +84,7 @@ void show_rib_brief(struct ctl_show_ri
>  void  show_rib_detail(struct ctl_show_rib *, u_char *, int);
>  void  show_attr(void *, u_int16_t);
>  void  show_community(u_char *, u_int16_t);
> +void  show_large_community(u_char *, u_int16_t);
>  void  show_ext_community(u_char *, u_int16_t);
>  char *fmt_mem(int64_t);
>  int   show_rib_memory_msg(struct imsg *);
> @@ -254,6 +257,13 @@ main(int argc, char *argv[])
>   sizeof(res->community));
>   type = IMSG_CTL_SHOW_RIB_COMMUNITY;
>   }
> + if (res->large_community.as != COMMUNITY_UNSET &&
> + res->large_community.ld1 != COMMUNITY_UNSET &&
> + res->large_community.ld2 != COMMUNITY_UNSET) {
> + memcpy(_community, >large_community,
> + sizeof(res->large_community));
> + type = IMSG_CTL_SHOW_RIB_LARGECOMMUNITY;
> + }
>   memcpy(, , sizeof(ribreq.neighbor));
>   strlcpy(ribreq.rib, res->rib, sizeof(ribreq.rib));
>   ribreq.aid = res->aid;
> @@ -275,6 +285,11 @@ main(int argc, char *argv[])
>   res->community.type != COMMUNITY_UNSET)
>   memcpy(, >community,
>   sizeof(res->community));
> + if (res->large_community.as != COMMUNITY_UNSET &&
> + res->large_community.ld1 != COMMUNITY_UNSET &&
> + res->large_community.ld2 != COMMUNITY_UNSET)
> + memcpy(_community, >large_community,
> + sizeof(res->large_community));
>   memcpy(, , sizeof(ribreq.neighbor));
>   ribreq.aid = res->aid;
>   ribreq.flags = res->flags;
> @@ -377,6 +392,11 @@ main(int argc, char *argv[])
>   res->community.type != COMMUNITY_UNSET)
>   memcpy(, >community,
>   sizeof(res->community));
> + if (res->large_community.as != COMMUNITY_UNSET &&
> + res->large_community.ld1 != COMMUNITY_UNSET &&
> + res->large_community.ld2 != COMMUNITY_UNSET)
> + memcpy(_community, >large_community,
> + 

Re: bgpd draft-ietf-idr-large-community

2016-10-13 Thread Peter Hessler
On 2016 Oct 11 (Tue) at 00:00:53 +0200 (+0200), Peter Hessler wrote:
:Here is an initial implementation of draft-ietf-idr-large-community for
:OpenBGPD.  I can connect and exchange routes with these attributes
:against exabgp.
:
:Normal communities are two 16bit numbers.  With the addition of
:32bit ASNs, those will not work if you wish to control one of
:them.
:
:Large Communities are 32bit:32bit:32bit.  It seems the convention will be
:::, with  and  being locally
:defined.
:
:RFC status: currently accepted by the IDR-WG, is at version -02, the
:wire format is set, the attribute codepoint is assigned by IANA, and it
:seems that only trivial details need to be addressed.  Very likely to be
:accepted.
:
:This was based on a partial implementation from Job Snijders, many
:thanks!
:
:Comments?  OK?
:

Updated diff:
 - assert copyright for the non-trivial changes
 - since the magic ASN matching canaries use valid bits, seperate the
filter storage and a wire storage
 - clean up warnings
 - fix a few printing issues

OK?


Index: usr.sbin/bgpctl/bgpctl.8
===
RCS file: /cvs/openbsd/src/usr.sbin/bgpctl/bgpctl.8,v
retrieving revision 1.69
diff -u -p -u -p -r1.69 bgpctl.8
--- usr.sbin/bgpctl/bgpctl.825 May 2016 14:15:59 -  1.69
+++ usr.sbin/bgpctl/bgpctl.85 Sep 2016 13:41:29 -
@@ -300,6 +300,9 @@ anywhere in the AS path.
 .It Cm community Ar community
 Show all entries with community
 .Ar community .
+.It Cm large-community Ar large-community
+Show all entries with large-community
+.Ar large-community .
 .It Cm empty-as
 Show all entries that are internal routes with no AS's in the AS path.
 .It Cm memory
Index: usr.sbin/bgpctl/bgpctl.c
===
RCS file: /cvs/openbsd/src/usr.sbin/bgpctl/bgpctl.c,v
retrieving revision 1.188
diff -u -p -u -p -r1.188 bgpctl.c
--- usr.sbin/bgpctl/bgpctl.c3 Jun 2016 17:36:37 -   1.188
+++ usr.sbin/bgpctl/bgpctl.c13 Oct 2016 15:32:30 -
@@ -2,6 +2,8 @@
 
 /*
  * Copyright (c) 2003 Henning Brauer 
+ * Copyright (c) 2016 Job Snijders 
+ * Copyright (c) 2016 Peter Hessler 
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -82,6 +84,7 @@ void   show_rib_brief(struct ctl_show_ri
 voidshow_rib_detail(struct ctl_show_rib *, u_char *, int);
 voidshow_attr(void *, u_int16_t);
 voidshow_community(u_char *, u_int16_t);
+voidshow_large_community(u_char *, u_int16_t);
 voidshow_ext_community(u_char *, u_int16_t);
 char   *fmt_mem(int64_t);
 int show_rib_memory_msg(struct imsg *);
@@ -254,6 +257,13 @@ main(int argc, char *argv[])
sizeof(res->community));
type = IMSG_CTL_SHOW_RIB_COMMUNITY;
}
+   if (res->large_community.as != COMMUNITY_UNSET &&
+   res->large_community.ld1 != COMMUNITY_UNSET &&
+   res->large_community.ld2 != COMMUNITY_UNSET) {
+   memcpy(_community, >large_community,
+   sizeof(res->large_community));
+   type = IMSG_CTL_SHOW_RIB_LARGECOMMUNITY;
+   }
memcpy(, , sizeof(ribreq.neighbor));
strlcpy(ribreq.rib, res->rib, sizeof(ribreq.rib));
ribreq.aid = res->aid;
@@ -275,6 +285,11 @@ main(int argc, char *argv[])
res->community.type != COMMUNITY_UNSET)
memcpy(, >community,
sizeof(res->community));
+   if (res->large_community.as != COMMUNITY_UNSET &&
+   res->large_community.ld1 != COMMUNITY_UNSET &&
+   res->large_community.ld2 != COMMUNITY_UNSET)
+   memcpy(_community, >large_community,
+   sizeof(res->large_community));
memcpy(, , sizeof(ribreq.neighbor));
ribreq.aid = res->aid;
ribreq.flags = res->flags;
@@ -377,6 +392,11 @@ main(int argc, char *argv[])
res->community.type != COMMUNITY_UNSET)
memcpy(, >community,
sizeof(res->community));
+   if (res->large_community.as != COMMUNITY_UNSET &&
+   res->large_community.ld1 != COMMUNITY_UNSET &&
+   res->large_community.ld2 != COMMUNITY_UNSET)
+   memcpy(_community, >large_community,
+   sizeof(res->large_community));
memcpy(, , sizeof(ribreq.neighbor));
ribreq.aid = res->aid;
ribreq.flags = res->flags;
@@ -1424,6 +1444,11 @@ show_attr(void *b, u_int16_t len)

bgpd draft-ietf-idr-large-community

2016-10-10 Thread Peter Hessler
Here is an initial implementation of draft-ietf-idr-large-community for
OpenBGPD.  I can connect and exchange routes with these attributes
against exabgp.

Normal communities are two 16bit numbers.  With the addition of
32bit ASNs, those will not work if you wish to control one of
them.

Large Communities are 32bit:32bit:32bit.  It seems the convention will be
::, with  and  being locally
defined.

RFC status: currently accepted by the IDR-WG, is at version -02, the
wire format is set, the attribute codepoint is assigned by IANA, and it
seems that only trivial details need to be addressed.  Very likely to be
accepted.

This was based on a partial implementation from Job Snijders, many
thanks!

Comments?  OK?



Index: usr.sbin/bgpd.large-communities//bgpd.8
===
RCS file: /cvs/openbsd/src/usr.sbin/bgpd/bgpd.8,v
retrieving revision 1.48
diff -u -p -u -p -r1.48 bgpd.8
--- usr.sbin/bgpd.large-communities//bgpd.8 14 Aug 2013 06:32:36 -  
1.48
+++ usr.sbin/bgpd.large-communities//bgpd.8 2 Oct 2016 13:39:54 -
@@ -238,6 +238,17 @@ control socket
 .Re
 .Pp
 .Rs
+.%A J. Snijders
+.%A J. Heitz
+.%A K. Patel
+.%A I. Bagdonas
+.%A A. Simpson
+.%D September 2016
+.%R draft-ietf-idr-large-community
+.%T Large BGP Communities Attribute
+.Re
+.Pp
+.Rs
 .%A A. Heffernan
 .%D August 1998
 .%R RFC 2385
Index: usr.sbin/bgpd.large-communities//bgpd.conf.5
===
RCS file: /cvs/openbsd/src/usr.sbin/bgpd/bgpd.conf.5,v
retrieving revision 1.147
diff -u -p -u -p -r1.147 bgpd.conf.5
--- usr.sbin/bgpd.large-communities//bgpd.conf.55 Oct 2016 07:38:06 
-   1.147
+++ usr.sbin/bgpd.large-communities//bgpd.conf.510 Oct 2016 20:05:40 
-
@@ -1143,6 +1143,39 @@ may be set to
 which is expanded to the current neighbor remote AS number.
 .Pp
 .It Xo
+.Ic large-community
+.Ar as-number : Ns Ar local : Ns Ar local
+.Xc
+.It Ic large-community Ar name
+This rule applies only to
+.Em UPDATES
+where the
+.Ic Large community
+path attribute is present and matches.
+Communities are specified as
+.Ar as-number : Ns Ar local : Ns Ar local ,
+where
+.Ar as-number
+is an AS number and
+.Ar local
+is a locally significant number between zero and
+.Li 4294967295.
+Both
+.Ar as-number
+and
+.Ar local
+may be set to
+.Sq *
+to do wildcard matching.
+Both
+.Ar as-number
+and
+.Ar local
+may be set to
+.Ic neighbor-as ,
+which is expanded to the current neighbor remote AS number.
+.Pp
+.It Xo
 .Ic ext-community
 .Ar subtype Ar as-number : Ns Ar local
 .Xc
@@ -1364,6 +1397,35 @@ Alternately, well-known communities may 
 .Ic NO_EXPORT_SUBCONFED ,
 or
 .Ic NO_PEER .
+For
+.Cm delete ,
+both
+.Ar as-number
+and
+.Ar local
+may be set to
+.Sq *
+to do wildcard matching.
+.Pp
+.It Xo
+.Ic large-community Op Ar delete
+.Ar as-number : Ns Ar local : Ns Ar local
+.Xc
+.It Xo
+.Ic large-community Op Ar delete
+.Ar name
+.Xc
+Set or delete the
+.Em Large Communities
+path attribute.
+Communities are specified as
+.Ar as-number : Ns Ar local : Ns Ar local ,
+where
+.Ar as-number
+is an AS number and
+.Ar local
+is a locally-significant number between zero and
+.Li 4294967295 .
 For
 .Cm delete ,
 both
Index: usr.sbin/bgpd.large-communities//bgpd.h
===
RCS file: /cvs/openbsd/src/usr.sbin/bgpd/bgpd.h,v
retrieving revision 1.296
diff -u -p -u -p -r1.296 bgpd.h
--- usr.sbin/bgpd.large-communities//bgpd.h 5 Oct 2016 07:38:06 -   
1.296
+++ usr.sbin/bgpd.large-communities//bgpd.h 10 Oct 2016 19:14:41 -
@@ -377,6 +377,7 @@ enum imsg_type {
IMSG_CTL_SHOW_RIB_PREFIX,
IMSG_CTL_SHOW_RIB_ATTR,
IMSG_CTL_SHOW_RIB_COMMUNITY,
+   IMSG_CTL_SHOW_RIB_LARGECOMMUNITY,
IMSG_CTL_SHOW_NETWORK,
IMSG_CTL_SHOW_RIB_MEM,
IMSG_CTL_SHOW_TERSE,
@@ -648,6 +649,12 @@ struct filter_community {
int type;
 };
 
+struct filter_largecommunity {
+   uint32_tas;
+   uint32_tld1;
+   uint32_tld2;
+};
+
 struct filter_extcommunity {
u_int16_t   flags;
u_int8_ttype;
@@ -675,6 +682,7 @@ struct ctl_show_rib_request {
struct bgpd_addrprefix;
struct filter_asas;
struct filter_community community;
+   struct filter_largecommunity large_community;
u_int32_t   peerid;
pid_t   pid;
u_int16_t   flags;
@@ -793,6 +801,7 @@ struct filter_match {
struct filter_asas;
struct filter_aslen aslen;
struct filter_community community;
+   struct filter_largecommunitylarge_community;
struct filter_extcommunity  ext_community;
 };
 
@@ -834,6 +843,8 @@ enum action_types {
ACTION_SET_NEXTHOP_SELF,
ACTION_SET_COMMUNITY,
ACTION_DEL_COMMUNITY,
+