summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd/bgpd.c
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2020-12-29 15:30:35 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2020-12-29 15:30:35 +0000
commit68b30a4a74fac863ff7b169f5fe5e4fbd00b63d3 (patch)
tree5c51382c1807e6a3efdfbb3969b081d07a100127 /usr.sbin/bgpd/bgpd.c
parent52b095eff069b55cbb0cf52c477e8219e6a3feef (diff)
In preparation for RTR support change the representation of the roa-set
in the parent to a simple RB tree based on struct roa. With this overlapping ROAs (same prefix & source-as but different maxlen) are now merged in the RDE when the lookup trie is constructed. OK benno@
Diffstat (limited to 'usr.sbin/bgpd/bgpd.c')
-rw-r--r--usr.sbin/bgpd/bgpd.c46
1 files changed, 12 insertions, 34 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c
index b181811a62c..264202b65f8 100644
--- a/usr.sbin/bgpd/bgpd.c
+++ b/usr.sbin/bgpd/bgpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.c,v 1.230 2020/11/05 11:52:59 claudio Exp $ */
+/* $OpenBSD: bgpd.c,v 1.231 2020/12/29 15:30:34 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -502,6 +502,7 @@ send_config(struct bgpd_config *conf)
struct as_set *aset;
struct prefixset *ps;
struct prefixset_item *psi, *npsi;
+ struct roa *roa, *nroa;
reconfpending = 2; /* one per child */
@@ -567,7 +568,6 @@ send_config(struct bgpd_config *conf)
if (imsg_compose(ibuf_rde, IMSG_RECONF_PREFIX_SET_ITEM,
0, 0, -1, psi, sizeof(*psi)) == -1)
return (-1);
- set_free(psi->set);
free(psi);
}
free(ps);
@@ -579,23 +579,12 @@ send_config(struct bgpd_config *conf)
if (imsg_compose(ibuf_rde, IMSG_RECONF_ORIGIN_SET, 0, 0, -1,
ps->name, sizeof(ps->name)) == -1)
return (-1);
- RB_FOREACH_SAFE(psi, prefixset_tree, &ps->psitems, npsi) {
- struct roa_set *rs;
- size_t i, l, n;
- RB_REMOVE(prefixset_tree, &ps->psitems, psi);
- rs = set_get(psi->set, &n);
- for (i = 0; i < n; i += l) {
- l = (n - i > 1024 ? 1024 : n - i);
- if (imsg_compose(ibuf_rde,
- IMSG_RECONF_ROA_SET_ITEMS,
- 0, 0, -1, rs + i, l * sizeof(*rs)) == -1)
- return -1;
- }
- if (imsg_compose(ibuf_rde, IMSG_RECONF_PREFIX_SET_ITEM,
- 0, 0, -1, psi, sizeof(*psi)) == -1)
+ RB_FOREACH_SAFE(roa, roa_tree, &ps->roaitems, nroa) {
+ RB_REMOVE(roa_tree, &conf->roa, roa);
+ if (imsg_compose(ibuf_rde, IMSG_RECONF_ROA_ITEM, 0, 0,
+ -1, roa, sizeof(*roa)) == -1)
return (-1);
- set_free(psi->set);
- free(psi);
+ free(roa);
}
free(ps);
}
@@ -604,23 +593,12 @@ send_config(struct bgpd_config *conf)
if (imsg_compose(ibuf_rde, IMSG_RECONF_ROA_SET, 0, 0, -1,
NULL, 0) == -1)
return (-1);
- RB_FOREACH_SAFE(psi, prefixset_tree, &conf->roa, npsi) {
- struct roa_set *rs;
- size_t i, l, n;
- RB_REMOVE(prefixset_tree, &conf->roa, psi);
- rs = set_get(psi->set, &n);
- for (i = 0; i < n; i += l) {
- l = (n - i > 1024 ? 1024 : n - i);
- if (imsg_compose(ibuf_rde,
- IMSG_RECONF_ROA_SET_ITEMS,
- 0, 0, -1, rs + i, l * sizeof(*rs)) == -1)
- return -1;
- }
- if (imsg_compose(ibuf_rde, IMSG_RECONF_PREFIX_SET_ITEM,
- 0, 0, -1, psi, sizeof(*psi)) == -1)
+ RB_FOREACH_SAFE(roa, roa_tree, &conf->roa, nroa) {
+ RB_REMOVE(roa_tree, &conf->roa, roa);
+ if (imsg_compose(ibuf_rde, IMSG_RECONF_ROA_ITEM, 0, 0,
+ -1, roa, sizeof(*roa)) == -1)
return (-1);
- set_free(psi->set);
- free(psi);
+ free(roa);
}
}