From: phessler Date: Mon, 26 Jun 2017 10:05:57 +0000 (+0000) Subject: add support for the "graceful shutdown" well-known community as described X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=1540651089022fc021f3c66076e0a458f3d94ccd;p=openbsd add support for the "graceful shutdown" well-known community as described in draft-ietf-grow-bgp-gshut from Job Snijders ok phessler@ benno@ --- diff --git a/usr.sbin/bgpctl/bgpctl.c b/usr.sbin/bgpctl/bgpctl.c index 4d9701da35b..55a5312e8f9 100644 --- a/usr.sbin/bgpctl/bgpctl.c +++ b/usr.sbin/bgpctl/bgpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpctl.c,v 1.195 2017/05/31 10:48:06 claudio Exp $ */ +/* $OpenBSD: bgpctl.c,v 1.196 2017/06/26 10:05:57 phessler Exp $ */ /* * Copyright (c) 2003 Henning Brauer @@ -1532,6 +1532,9 @@ show_community(u_char *data, u_int16_t len) v = ntohs(v); if (a == COMMUNITY_WELLKNOWN) switch (v) { + case COMMUNITY_GRACEFUL_SHUTDOWN: + printf("GRACEFUL_SHUTDOWN"); + break; case COMMUNITY_NO_EXPORT: printf("NO_EXPORT"); break; diff --git a/usr.sbin/bgpctl/parser.c b/usr.sbin/bgpctl/parser.c index 85300d1cd32..1020afeb6ff 100644 --- a/usr.sbin/bgpctl/parser.c +++ b/usr.sbin/bgpctl/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.77 2017/02/14 13:13:23 benno Exp $ */ +/* $OpenBSD: parser.c,v 1.78 2017/06/26 10:05:57 phessler Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -950,7 +950,11 @@ parse_community(const char *word, struct parse_result *r) int as, type; /* Well-known communities */ - if (strcasecmp(word, "NO_EXPORT") == 0) { + if (strcasecmp(word, "GRACEFUL_SHUTDOWN") == 0) { + as = COMMUNITY_WELLKNOWN; + type = COMMUNITY_GRACEFUL_SHUTDOWN; + goto done; + } else if (strcasecmp(word, "NO_EXPORT") == 0) { as = COMMUNITY_WELLKNOWN; type = COMMUNITY_NO_EXPORT; goto done; @@ -988,6 +992,7 @@ done: } if (as == COMMUNITY_WELLKNOWN) switch (type) { + case COMMUNITY_GRACEFUL_SHUTDOWN: case COMMUNITY_NO_EXPORT: case COMMUNITY_NO_ADVERTISE: case COMMUNITY_NO_EXPSUBCONFED: diff --git a/usr.sbin/bgpd/bgpd.conf.5 b/usr.sbin/bgpd/bgpd.conf.5 index 6cecd7a5a80..d7945b810c3 100644 --- a/usr.sbin/bgpd/bgpd.conf.5 +++ b/usr.sbin/bgpd/bgpd.conf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: bgpd.conf.5,v 1.160 2017/05/31 10:49:10 claudio Exp $ +.\" $OpenBSD: bgpd.conf.5,v 1.161 2017/06/26 10:05:57 phessler Exp $ .\" .\" Copyright (c) 2004 Claudio Jeker .\" Copyright (c) 2003, 2004 Henning Brauer @@ -16,7 +16,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: May 31 2017 $ +.Dd $Mdocdate: June 26 2017 $ .Dt BGPD.CONF 5 .Os .Sh NAME @@ -1173,6 +1173,7 @@ to do wildcard matching. Alternatively, well-known communities may be given by name instead and include .Ic BLACKHOLE , +.Ic GRACEFUL_SHUTDOWN , .Ic NO_EXPORT , .Ic NO_ADVERTISE , .Ic NO_EXPORT_SUBCONFED , @@ -1444,6 +1445,7 @@ is an AS number and is a locally-significant number between zero and .Li 65535 . Alternately, well-known communities may be specified by name: +.Ic GRACEFUL_SHUTDOWN , .Ic NO_EXPORT , .Ic NO_ADVERTISE , .Ic NO_EXPORT_SUBCONFED , diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index db52f858241..ed248775699 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.308 2017/05/31 10:44:00 claudio Exp $ */ +/* $OpenBSD: bgpd.h,v 1.309 2017/06/26 10:05:57 phessler Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -750,6 +750,7 @@ struct filter_peers { #define COMMUNITY_LOCAL_AS -4 #define COMMUNITY_UNSET -5 #define COMMUNITY_WELLKNOWN 0xffff +#define COMMUNITY_GRACEFUL_SHUTDOWN 0x0000 /* draft-ietf-grow-bgp-gshut */ #define COMMUNITY_BLACKHOLE 0x029A /* RFC 7999 */ #define COMMUNITY_NO_EXPORT 0xff01 #define COMMUNITY_NO_ADVERTISE 0xff02 diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y index ce06f4d7d0d..606f84603d5 100644 --- a/usr.sbin/bgpd/parse.y +++ b/usr.sbin/bgpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.310 2017/06/26 10:04:21 phessler Exp $ */ +/* $OpenBSD: parse.y,v 1.311 2017/06/26 10:05:57 phessler Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer @@ -2989,7 +2989,11 @@ parsecommunity(struct filter_community *c, char *s) int i, as; /* Well-known communities */ - if (strcasecmp(s, "NO_EXPORT") == 0) { + if (strcasecmp(s, "GRACEFUL_SHUTDOWN") == 0) { + c->as = COMMUNITY_WELLKNOWN; + c->type = COMMUNITY_GRACEFUL_SHUTDOWN; + return (0); + } else if (strcasecmp(s, "NO_EXPORT") == 0) { c->as = COMMUNITY_WELLKNOWN; c->type = COMMUNITY_NO_EXPORT; return (0);