add support for the "graceful shutdown" well-known community as described
authorphessler <phessler@openbsd.org>
Mon, 26 Jun 2017 10:05:57 +0000 (10:05 +0000)
committerphessler <phessler@openbsd.org>
Mon, 26 Jun 2017 10:05:57 +0000 (10:05 +0000)
in draft-ietf-grow-bgp-gshut

from Job Snijders
ok phessler@ benno@

usr.sbin/bgpctl/bgpctl.c
usr.sbin/bgpctl/parser.c
usr.sbin/bgpd/bgpd.conf.5
usr.sbin/bgpd/bgpd.h
usr.sbin/bgpd/parse.y

index 4d9701d..55a5312 100644 (file)
@@ -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 <henning@openbsd.org>
@@ -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;
index 85300d1..1020afe 100644 (file)
@@ -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 <henning@openbsd.org>
@@ -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:
index 6cecd7a..d7945b8 100644 (file)
@@ -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 <claudio@openbsd.org>
 .\" Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -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 ,
index db52f85..ed24877 100644 (file)
@@ -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 <henning@openbsd.org>
@@ -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
index ce06f4d..606f846 100644 (file)
@@ -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 <henning@openbsd.org>
@@ -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);