summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2022-06-27 13:27:39 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2022-06-27 13:27:39 +0000
commite1893109e968c646c1763a45dccf8d917812d9b4 (patch)
treec840791e41dec72a851d26a7ca76c1748a1c53b3
parent29bd286b432203d5fc38c366582ece24d86d24ba (diff)
bgpctl bits for RFC 9234 support.
OK tb@
-rw-r--r--usr.sbin/bgpctl/bgpctl.c12
-rw-r--r--usr.sbin/bgpctl/output.c23
-rw-r--r--usr.sbin/bgpctl/output_json.c16
3 files changed, 46 insertions, 5 deletions
diff --git a/usr.sbin/bgpctl/bgpctl.c b/usr.sbin/bgpctl/bgpctl.c
index 9c50ab647f5..f4857d17a98 100644
--- a/usr.sbin/bgpctl/bgpctl.c
+++ b/usr.sbin/bgpctl/bgpctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpctl.c,v 1.278 2022/06/23 12:40:32 claudio Exp $ */
+/* $OpenBSD: bgpctl.c,v 1.279 2022/06/27 13:27:38 claudio Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@@ -684,6 +684,8 @@ fmt_flags(uint8_t flags, int sum)
if (sum) {
if (flags & F_PREF_INVALID)
*p++ = 'E';
+ if (flags & F_PREF_OTC_LOOP)
+ *p++ = 'L';
if (flags & F_PREF_ANNOUNCE)
*p++ = 'A';
if (flags & F_PREF_INTERNAL)
@@ -702,6 +704,10 @@ fmt_flags(uint8_t flags, int sum)
else
strlcpy(buf, "external", sizeof(buf));
+ if (flags & F_PREF_INVALID)
+ strlcat(buf, ", invalid", sizeof(buf));
+ if (flags & F_PREF_OTC_LOOP)
+ strlcat(buf, ", otc loop", sizeof(buf));
if (flags & F_PREF_STALE)
strlcat(buf, ", stale", sizeof(buf));
if (flags & F_PREF_ELIGIBLE)
@@ -882,6 +888,10 @@ fmt_attr(uint8_t type, int flags)
CHECK_FLAGS(flags, ATTR_OPTIONAL|ATTR_TRANSITIVE, ATTR_PARTIAL);
strlcpy(cstr, "Large Communities", sizeof(cstr));
break;
+ case ATTR_OTC:
+ CHECK_FLAGS(flags, ATTR_OPTIONAL|ATTR_TRANSITIVE, ATTR_PARTIAL);
+ strlcpy(cstr, "OTC", sizeof(cstr));
+ break;
default:
/* ignore unknown attributes */
snprintf(cstr, sizeof(cstr), "Unknown Attribute #%u", type);
diff --git a/usr.sbin/bgpctl/output.c b/usr.sbin/bgpctl/output.c
index d22e6d0b111..3a8e38bb74e 100644
--- a/usr.sbin/bgpctl/output.c
+++ b/usr.sbin/bgpctl/output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: output.c,v 1.22 2022/06/22 14:49:51 claudio Exp $ */
+/* $OpenBSD: output.c,v 1.23 2022/06/27 13:27:38 claudio Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@@ -325,7 +325,7 @@ show_neighbor_full(struct peer *p, struct parse_result *res)
}
if (hascapamp || hascapaap || p->capa.peer.grestart.restart ||
p->capa.peer.refresh || p->capa.peer.enhanced_rr ||
- p->capa.peer.as4byte) {
+ p->capa.peer.as4byte || p->capa.peer.role_ena) {
printf(" Neighbor capabilities:\n");
if (hascapamp)
show_neighbor_capa_mp(&p->capa.peer);
@@ -339,6 +339,10 @@ show_neighbor_full(struct peer *p, struct parse_result *res)
show_neighbor_capa_restart(&p->capa.peer);
if (hascapaap)
show_neighbor_capa_add_path(&p->capa.peer);
+ if (p->capa.peer.role_ena)
+ printf(" Open Policy role %s (local %s)\n",
+ log_policy(p->capa.peer.role),
+ log_policy(p->capa.ann.role));
}
hascapamp = 0;
@@ -351,7 +355,7 @@ show_neighbor_full(struct peer *p, struct parse_result *res)
}
if (hascapamp || hascapaap || p->capa.neg.grestart.restart ||
p->capa.neg.refresh || p->capa.neg.enhanced_rr ||
- p->capa.neg.as4byte) {
+ p->capa.neg.as4byte || p->capa.neg.role_ena) {
printf(" Negotiated capabilities:\n");
if (hascapamp)
show_neighbor_capa_mp(&p->capa.neg);
@@ -365,6 +369,10 @@ show_neighbor_full(struct peer *p, struct parse_result *res)
show_neighbor_capa_restart(&p->capa.neg);
if (hascapaap)
show_neighbor_capa_add_path(&p->capa.neg);
+ if (p->capa.neg.role_ena)
+ printf(" Open Policy role %s (local %s)\n",
+ log_policy(p->capa.neg.role),
+ log_policy(p->capa.ann.role));
}
printf("\n");
@@ -875,6 +883,15 @@ show_attr(u_char *data, size_t len, int reqflags, int addpath)
case ATTR_LARGE_COMMUNITIES:
show_large_community(data, alen);
break;
+ case ATTR_OTC:
+ if (alen == 4) {
+ memcpy(&as, data, sizeof(as));
+ as = ntohl(as);
+ printf("%s", log_as(as));
+ } else {
+ printf("bad length");
+ }
+ break;
case ATTR_ATOMIC_AGGREGATE:
default:
printf(" len %u", alen);
diff --git a/usr.sbin/bgpctl/output_json.c b/usr.sbin/bgpctl/output_json.c
index 8e02a1e2a20..78ff0eb0c1c 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.16 2022/06/22 14:49:51 claudio Exp $ */
+/* $OpenBSD: output_json.c,v 1.17 2022/06/27 13:27:38 claudio Exp $ */
/*
* Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
@@ -125,6 +125,12 @@ json_neighbor_capabilities(struct capabilities *capa)
json_do_end();
}
+ if (capa->role_ena) {
+ json_do_printf("open_policy_role", "%s%s",
+ log_policy(capa->role),
+ capa->role_ena == 2 ? " enforce" : "");
+ }
+
json_do_end();
}
@@ -812,6 +818,14 @@ bad_len:
case ATTR_LARGE_COMMUNITIES:
json_do_large_community(data, alen);
break;
+ case ATTR_OTC:
+ if (alen == 4) {
+ memcpy(&as, data, sizeof(as));
+ as = ntohl(as);
+ json_do_uint("as", as);
+ } else
+ json_do_printf("error", "bad length");
+ break;
case ATTR_ATOMIC_AGGREGATE:
default:
if (alen)