summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2023-04-21 10:49:02 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2023-04-21 10:49:02 +0000
commit0301a86ed03f62062c8583edf459c80dde10dbb8 (patch)
tree509ffb43f2186c301a0999fcfc87ccafc12b6577 /usr.sbin/bgpd
parent534eeb35fa9409d4b9d162fd46cade30893b225e (diff)
Adjust ext community handling to support the generic transitive communities
introduced with flowspec. OK tb@
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r--usr.sbin/bgpd/parse.y10
-rw-r--r--usr.sbin/bgpd/printconf.c8
2 files changed, 15 insertions, 3 deletions
diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y
index 516c19c07cb..3c3e31044ce 100644
--- a/usr.sbin/bgpd/parse.y
+++ b/usr.sbin/bgpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.451 2023/04/21 10:47:07 claudio Exp $ */
+/* $OpenBSD: parse.y,v 1.452 2023/04/21 10:48:33 claudio Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -4441,7 +4441,7 @@ parseextvalue(int type, char *s, uint32_t *v, uint32_t *flag)
type = EXT_COMMUNITY_TRANS_IPV4;
}
- switch (type) {
+ switch (type & EXT_COMMUNITY_VALUE) {
case EXT_COMMUNITY_TRANS_TWO_AS:
uval = strtonum(s, 0, USHRT_MAX, &errstr);
if (errstr) {
@@ -4510,6 +4510,9 @@ parseextcommunity(struct community *c, char *t, char *s)
case EXT_COMMUNITY_TRANS_TWO_AS:
case EXT_COMMUNITY_TRANS_FOUR_AS:
case EXT_COMMUNITY_TRANS_IPV4:
+ case EXT_COMMUNITY_GEN_TWO_AS:
+ case EXT_COMMUNITY_GEN_FOUR_AS:
+ case EXT_COMMUNITY_GEN_IPV4:
case -1:
if (strcmp(s, "*") == 0) {
dflag1 = COMMUNITY_ANY;
@@ -4525,11 +4528,14 @@ parseextcommunity(struct community *c, char *t, char *s)
switch (type) {
case EXT_COMMUNITY_TRANS_TWO_AS:
+ case EXT_COMMUNITY_GEN_TWO_AS:
if (getcommunity(p, 1, &uval2, &dflag2) == -1)
return (-1);
break;
case EXT_COMMUNITY_TRANS_IPV4:
case EXT_COMMUNITY_TRANS_FOUR_AS:
+ case EXT_COMMUNITY_GEN_IPV4:
+ case EXT_COMMUNITY_GEN_FOUR_AS:
if (getcommunity(p, 0, &uval2, &dflag2) == -1)
return (-1);
break;
diff --git a/usr.sbin/bgpd/printconf.c b/usr.sbin/bgpd/printconf.c
index 137dd77c1b1..75fa425e73d 100644
--- a/usr.sbin/bgpd/printconf.c
+++ b/usr.sbin/bgpd/printconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: printconf.c,v 1.165 2023/04/18 14:11:54 claudio Exp $ */
+/* $OpenBSD: printconf.c,v 1.166 2023/04/21 10:48:33 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -219,6 +219,8 @@ print_community(struct community *c)
switch (type) {
case EXT_COMMUNITY_TRANS_TWO_AS:
case EXT_COMMUNITY_TRANS_FOUR_AS:
+ case EXT_COMMUNITY_GEN_TWO_AS:
+ case EXT_COMMUNITY_GEN_FOUR_AS:
if ((c->flags >> 8 & 0xff) == COMMUNITY_NEIGHBOR_AS)
printf("neighbor-as:");
else if ((c->flags >> 8 & 0xff) == COMMUNITY_LOCAL_AS)
@@ -227,6 +229,7 @@ print_community(struct community *c)
printf("%s:", log_as(c->data1));
break;
case EXT_COMMUNITY_TRANS_IPV4:
+ case EXT_COMMUNITY_GEN_IPV4:
addr.s_addr = htonl(c->data1);
printf("%s:", inet_ntoa(addr));
break;
@@ -236,6 +239,9 @@ print_community(struct community *c)
case EXT_COMMUNITY_TRANS_TWO_AS:
case EXT_COMMUNITY_TRANS_FOUR_AS:
case EXT_COMMUNITY_TRANS_IPV4:
+ case EXT_COMMUNITY_GEN_TWO_AS:
+ case EXT_COMMUNITY_GEN_FOUR_AS:
+ case EXT_COMMUNITY_GEN_IPV4:
if ((c->flags >> 16 & 0xff) == COMMUNITY_ANY)
printf("* ");
else if ((c->flags >> 16 & 0xff) ==