diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2023-01-24 14:13:13 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2023-01-24 14:13:13 +0000 |
commit | cb26202c646e356790215e8996ba5c51179d1a26 (patch) | |
tree | 11ff585381405a1d385195abe390cd6c529113ea /usr.sbin/bgpd/rde.c | |
parent | 9eb32957966466066043810c0ba9d19398c63e24 (diff) |
Implement filter and control message matching for ASAP.
This adds avs (ASPA validation state) which can be 'unknown', 'valid'
or 'invalid'. It behaves similar to ovs but the ASPA validation state
of paths from iBGP sessions is 'unknown' and the role of the ebgp session
is important to get the right validation state.
OK tb@
Diffstat (limited to 'usr.sbin/bgpd/rde.c')
-rw-r--r-- | usr.sbin/bgpd/rde.c | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index bca75af2158..62593bc35cb 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.590 2023/01/24 11:28:41 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.591 2023/01/24 14:13:12 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -103,7 +103,8 @@ static void network_dump_upcall(struct rib_entry *, void *); static void network_flush_upcall(struct rib_entry *, void *); void rde_shutdown(void); -int ovs_match(struct prefix *, uint32_t); +static int ovs_match(struct prefix *, uint32_t); +static int avs_match(struct prefix *, uint32_t); static struct imsgbuf *ibuf_se; static struct imsgbuf *ibuf_se_ctl; @@ -2776,6 +2777,8 @@ rde_dump_filter(struct prefix *p, struct ctl_show_rib_request *req, int adjout) } if (!ovs_match(p, req->flags)) return; + if (!avs_match(p, req->flags)) + return; rde_dump_rib_as(p, asp, req->pid, req->flags, adjout); } @@ -4528,7 +4531,7 @@ rde_roa_validity(struct rde_prefixset *ps, struct bgpd_addr *prefix, return (r & ROA_MASK); } -int +static int ovs_match(struct prefix *p, uint32_t flag) { if (flag & (F_CTL_OVS_VALID|F_CTL_OVS_INVALID|F_CTL_OVS_NOTFOUND)) { @@ -4552,3 +4555,28 @@ ovs_match(struct prefix *p, uint32_t flag) return 1; } + +static int +avs_match(struct prefix *p, uint32_t flag) +{ + if (flag & (F_CTL_AVS_VALID|F_CTL_AVS_INVALID|F_CTL_AVS_UNKNOWN)) { + switch (prefix_aspa_vstate(p) & ASPA_MASK) { + case ASPA_VALID: + if (!(flag & F_CTL_AVS_VALID)) + return 0; + break; + case ASPA_INVALID: + if (!(flag & F_CTL_AVS_INVALID)) + return 0; + break; + case ASPA_UNKNOWN: + if (!(flag & F_CTL_AVS_UNKNOWN)) + return 0; + break; + default: + break; + } + } + + return 1; +} |