diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bgpctl/bgpctl.c | 40 | ||||
-rw-r--r-- | usr.sbin/bgpctl/output.c | 5 | ||||
-rw-r--r-- | usr.sbin/bgpctl/output_json.c | 5 | ||||
-rw-r--r-- | usr.sbin/bgpctl/parser.c | 12 | ||||
-rw-r--r-- | usr.sbin/bgpd/parse.y | 10 | ||||
-rw-r--r-- | usr.sbin/bgpd/printconf.c | 8 |
6 files changed, 53 insertions, 27 deletions
diff --git a/usr.sbin/bgpctl/bgpctl.c b/usr.sbin/bgpctl/bgpctl.c index 91387b0ab01..e1304a9e4bb 100644 --- a/usr.sbin/bgpctl/bgpctl.c +++ b/usr.sbin/bgpctl/bgpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpctl.c,v 1.292 2023/04/21 09:12:41 claudio Exp $ */ +/* $OpenBSD: bgpctl.c,v 1.293 2023/04/21 10:49:01 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -1051,6 +1051,7 @@ fmt_ext_community(uint8_t *data) switch (type) { case EXT_COMMUNITY_TRANS_TWO_AS: + case EXT_COMMUNITY_GEN_TWO_AS: memcpy(&as2, data + 2, sizeof(as2)); memcpy(&u32, data + 4, sizeof(u32)); snprintf(buf, sizeof(buf), "%s %s:%u", @@ -1058,6 +1059,7 @@ fmt_ext_community(uint8_t *data) log_as(ntohs(as2)), ntohl(u32)); return buf; case EXT_COMMUNITY_TRANS_IPV4: + case EXT_COMMUNITY_GEN_IPV4: memcpy(&ip, data + 2, sizeof(ip)); memcpy(&u16, data + 6, sizeof(u16)); snprintf(buf, sizeof(buf), "%s %s:%hu", @@ -1065,6 +1067,7 @@ fmt_ext_community(uint8_t *data) inet_ntoa(ip), ntohs(u16)); return buf; case EXT_COMMUNITY_TRANS_FOUR_AS: + case EXT_COMMUNITY_GEN_FOUR_AS: memcpy(&as4, data + 2, sizeof(as4)); memcpy(&u16, data + 6, sizeof(u16)); snprintf(buf, sizeof(buf), "%s %s:%hu", @@ -1081,20 +1084,27 @@ fmt_ext_community(uint8_t *data) case EXT_COMMUNITY_NON_TRANS_OPAQUE: memcpy(&ext, data, sizeof(ext)); ext = be64toh(ext) & 0xffffffffffffLL; - switch (ext) { - case EXT_COMMUNITY_OVS_VALID: - snprintf(buf, sizeof(buf), "%s valid", - log_ext_subtype(type, subtype)); - return buf; - case EXT_COMMUNITY_OVS_NOTFOUND: - snprintf(buf, sizeof(buf), "%s not-found", - log_ext_subtype(type, subtype)); - return buf; - case EXT_COMMUNITY_OVS_INVALID: - snprintf(buf, sizeof(buf), "%s invalid", - log_ext_subtype(type, subtype)); - return buf; - default: + if (subtype == EXT_COMMUNITY_SUBTYPE_OVS) { + switch (ext) { + case EXT_COMMUNITY_OVS_VALID: + snprintf(buf, sizeof(buf), "%s valid", + log_ext_subtype(type, subtype)); + return buf; + case EXT_COMMUNITY_OVS_NOTFOUND: + snprintf(buf, sizeof(buf), "%s not-found", + log_ext_subtype(type, subtype)); + return buf; + case EXT_COMMUNITY_OVS_INVALID: + snprintf(buf, sizeof(buf), "%s invalid", + log_ext_subtype(type, subtype)); + return buf; + default: + snprintf(buf, sizeof(buf), "%s 0x%llx", + log_ext_subtype(type, subtype), + (unsigned long long)ext); + return buf; + } + } else { snprintf(buf, sizeof(buf), "%s 0x%llx", log_ext_subtype(type, subtype), (unsigned long long)ext); diff --git a/usr.sbin/bgpctl/output.c b/usr.sbin/bgpctl/output.c index a1bcb31e32f..b12b363187a 100644 --- a/usr.sbin/bgpctl/output.c +++ b/usr.sbin/bgpctl/output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output.c,v 1.39 2023/04/20 14:01:50 claudio Exp $ */ +/* $OpenBSD: output.c,v 1.40 2023/04/21 10:49:01 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -674,11 +674,10 @@ show_communities(u_char *data, size_t len, struct parse_result *res) break; case COMMUNITY_TYPE_EXT: ext = (uint64_t)c.data3 << 48; - switch (c.data3 >> 8) { + switch ((c.data3 >> 8) & EXT_COMMUNITY_VALUE) { case EXT_COMMUNITY_TRANS_TWO_AS: case EXT_COMMUNITY_TRANS_OPAQUE: case EXT_COMMUNITY_TRANS_EVPN: - case EXT_COMMUNITY_NON_TRANS_OPAQUE: ext |= ((uint64_t)c.data1 & 0xffff) << 32; ext |= (uint64_t)c.data2; break; diff --git a/usr.sbin/bgpctl/output_json.c b/usr.sbin/bgpctl/output_json.c index 3a702917da6..6e623015a35 100644 --- a/usr.sbin/bgpctl/output_json.c +++ b/usr.sbin/bgpctl/output_json.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output_json.c,v 1.31 2023/03/28 12:07:09 claudio Exp $ */ +/* $OpenBSD: output_json.c,v 1.32 2023/04/21 10:49:01 claudio Exp $ */ /* * Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org> @@ -495,11 +495,10 @@ json_communities(u_char *data, size_t len, struct parse_result *res) break; case COMMUNITY_TYPE_EXT: ext = (uint64_t)c.data3 << 48; - switch (c.data3 >> 8) { + switch ((c.data3 >> 8) & EXT_COMMUNITY_VALUE) { case EXT_COMMUNITY_TRANS_TWO_AS: case EXT_COMMUNITY_TRANS_OPAQUE: case EXT_COMMUNITY_TRANS_EVPN: - case EXT_COMMUNITY_NON_TRANS_OPAQUE: ext |= ((uint64_t)c.data1 & 0xffff) << 32; ext |= (uint64_t)c.data2; break; diff --git a/usr.sbin/bgpctl/parser.c b/usr.sbin/bgpctl/parser.c index defe91007eb..ff16473082c 100644 --- a/usr.sbin/bgpctl/parser.c +++ b/usr.sbin/bgpctl/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.131 2023/04/21 09:12:41 claudio Exp $ */ +/* $OpenBSD: parser.c,v 1.132 2023/04/21 10:49:01 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -741,7 +741,7 @@ match_token(int argc, char *argv[], const struct token table[], int *argsused) rd |= ((uint64_t)ext.data1 & 0xffff) << 32; rd |= (uint64_t)ext.data2; - break; + break; case EXT_COMMUNITY_TRANS_IPV4: rd = (1ULL << 48); rd |= (uint64_t)ext.data1 << 16; @@ -1298,7 +1298,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) @@ -1355,6 +1355,9 @@ parseextcommunity(struct community *c, const 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; @@ -1367,10 +1370,13 @@ parseextcommunity(struct community *c, const char *t, char *s) switch (type) { case EXT_COMMUNITY_TRANS_TWO_AS: + case EXT_COMMUNITY_GEN_TWO_AS: getcommunity(p, 1, &uval2, &dflag2); break; case EXT_COMMUNITY_TRANS_IPV4: case EXT_COMMUNITY_TRANS_FOUR_AS: + case EXT_COMMUNITY_GEN_IPV4: + case EXT_COMMUNITY_GEN_FOUR_AS: getcommunity(p, 0, &uval2, &dflag2); break; default: 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) == |