summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2018-06-28 09:54:49 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2018-06-28 09:54:49 +0000
commit3d055042fc55e2a17c7f0bb248715855f60ad6d4 (patch)
treef0b66bc1e1c7b6c3a7d314f0c4cc00156ff9930e
parentb3cb197b949759ba51666900651f4a2b8b1a73ca (diff)
Remove rde_aspath pointer from rde_filter since that argument can be fetched
from the prefix instead. While there also switch to prefix_peer from asp->peer in rde_dump_rib_as(). Makes the code easier overall.
-rw-r--r--usr.sbin/bgpd/rde.c37
-rw-r--r--usr.sbin/bgpd/rde.h5
-rw-r--r--usr.sbin/bgpd/rde_filter.c5
-rw-r--r--usr.sbin/bgpd/rde_update.c11
4 files changed, 27 insertions, 31 deletions
diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c
index 1a33948d18f..07568bf6864 100644
--- a/usr.sbin/bgpd/rde.c
+++ b/usr.sbin/bgpd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.382 2018/06/28 08:07:21 claudio Exp $ */
+/* $OpenBSD: rde.c,v 1.383 2018/06/28 09:54:48 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -1381,7 +1381,7 @@ rde_update_update(struct rde_peer *peer, struct rde_aspath *asp,
if (*ribs[i].name == '\0')
break;
/* input filter */
- action = rde_filter(ribs[i].in_rules, peer, &fasp, p, asp);
+ action = rde_filter(ribs[i].in_rules, peer, &fasp, p);
if (fasp == NULL)
fasp = asp;
@@ -2229,10 +2229,10 @@ rde_dump_rib_as(struct prefix *p, struct rde_aspath *asp, pid_t pid, int flags)
rib.local_pref = asp->lpref;
rib.med = asp->med;
rib.weight = asp->weight;
- strlcpy(rib.descr, asp->peer->conf.descr, sizeof(rib.descr));
- memcpy(&rib.remote_addr, &asp->peer->remote_addr,
+ strlcpy(rib.descr, prefix_peer(p)->conf.descr, sizeof(rib.descr));
+ memcpy(&rib.remote_addr, &prefix_peer(p)->remote_addr,
sizeof(rib.remote_addr));
- rib.remote_id = asp->peer->remote_bgpid;
+ rib.remote_id = prefix_peer(p)->remote_bgpid;
if (asp->nexthop != NULL) {
memcpy(&rib.true_nexthop, &asp->nexthop->true_nexthop,
sizeof(rib.true_nexthop));
@@ -2251,7 +2251,7 @@ rde_dump_rib_as(struct prefix *p, struct rde_aspath *asp, pid_t pid, int flags)
rib.flags = 0;
if (p->re->active == p)
rib.flags |= F_PREF_ACTIVE;
- if (!asp->peer->conf.ebgp)
+ if (!prefix_peer(p)->conf.ebgp)
rib.flags |= F_PREF_INTERNAL;
if (asp->flags & F_PREFIX_ANNOUNCED)
rib.flags |= F_PREF_ANNOUNCE;
@@ -2259,7 +2259,7 @@ rde_dump_rib_as(struct prefix *p, struct rde_aspath *asp, pid_t pid, int flags)
rib.flags |= F_PREF_ELIGIBLE;
if (asp->flags & F_ATTR_LOOP)
rib.flags &= ~F_PREF_ELIGIBLE;
- staletime = asp->peer->staletime[p->re->prefix->aid];
+ staletime = prefix_peer(p)->staletime[p->re->prefix->aid];
if (staletime && p->lastchange <= staletime)
rib.flags |= F_PREF_STALE;
rib.aspath_len = aspath_length(asp->aspath);
@@ -2299,24 +2299,21 @@ rde_dump_filterout(struct rde_peer *peer, struct prefix *p,
struct ctl_show_rib_request *req)
{
struct bgpd_addr addr;
- struct rde_aspath *asp, *fasp;
+ struct rde_aspath *fasp;
enum filter_actions a;
if (up_test_update(peer, p) != 1)
return;
pt_getaddr(p->re->prefix, &addr);
- asp = prefix_aspath(p);
- a = rde_filter(out_rules, peer, &fasp, p, asp);
- if (fasp)
- fasp->peer = asp->peer;
- else
- fasp = asp;
+ a = rde_filter(out_rules, peer, &fasp, p);
+ if (fasp == NULL)
+ fasp = prefix_aspath(p);
if (a == ACTION_ALLOW)
rde_dump_rib_as(p, fasp, req->pid, req->flags);
- if (fasp != asp)
+ if (fasp != prefix_aspath(p))
path_put(fasp);
}
@@ -3067,14 +3064,14 @@ rde_softreconfig_in(struct rib_entry *re, void *ptr)
/* check if prefix changed */
if (rib->state == RECONF_RELOAD) {
- oa = rde_filter(rib->in_rules_tmp, peer, &oasp, p, asp);
+ oa = rde_filter(rib->in_rules_tmp, peer, &oasp, p);
oasp = oasp != NULL ? oasp : asp;
} else {
/* make sure we update everything for RECONF_REINIT */
oa = ACTION_DENY;
oasp = asp;
}
- na = rde_filter(rib->in_rules, peer, &nasp, p, asp);
+ na = rde_filter(rib->in_rules, peer, &nasp, p);
nasp = nasp != NULL ? nasp : asp;
/* go through all 4 possible combinations */
@@ -3123,8 +3120,8 @@ rde_softreconfig_out(struct rib_entry *re, void *ptr)
if (up_test_update(peer, p) != 1)
return;
- oa = rde_filter(out_rules_tmp, peer, &oasp, p, prefix_aspath(p));
- na = rde_filter(out_rules, peer, &nasp, p, prefix_aspath(p));
+ oa = rde_filter(out_rules_tmp, peer, &oasp, p);
+ na = rde_filter(out_rules, peer, &nasp, p);
oasp = oasp != NULL ? oasp : prefix_aspath(p);
nasp = nasp != NULL ? nasp : prefix_aspath(p);
@@ -3166,7 +3163,7 @@ rde_softreconfig_unload_peer(struct rib_entry *re, void *ptr)
if (up_test_update(peer, p) != 1)
return;
- oa = rde_filter(out_rules_tmp, peer, &oasp, p, prefix_aspath(p));
+ oa = rde_filter(out_rules_tmp, peer, &oasp, p);
oasp = oasp != NULL ? oasp : prefix_aspath(p);
if (oa == ACTION_DENY)
diff --git a/usr.sbin/bgpd/rde.h b/usr.sbin/bgpd/rde.h
index c85551b1764..ac8ad3553f7 100644
--- a/usr.sbin/bgpd/rde.h
+++ b/usr.sbin/bgpd/rde.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.h,v 1.173 2018/06/28 08:55:56 claudio Exp $ */
+/* $OpenBSD: rde.h,v 1.174 2018/06/28 09:54:48 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and
@@ -403,8 +403,7 @@ void prefix_evaluate(struct prefix *, struct rib_entry *);
/* rde_filter.c */
enum filter_actions rde_filter(struct filter_head *, struct rde_peer *,
- struct rde_aspath **, struct prefix *,
- struct rde_aspath *);
+ struct rde_aspath **, struct prefix *);
void rde_apply_set(struct filter_set_head *, struct rde_aspath *,
u_int8_t, struct rde_peer *, struct rde_peer *);
int rde_filter_equal(struct filter_head *, struct filter_head *,
diff --git a/usr.sbin/bgpd/rde_filter.c b/usr.sbin/bgpd/rde_filter.c
index ed236ec691a..c7675bda4ed 100644
--- a/usr.sbin/bgpd/rde_filter.c
+++ b/usr.sbin/bgpd/rde_filter.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde_filter.c,v 1.92 2018/06/28 08:55:56 claudio Exp $ */
+/* $OpenBSD: rde_filter.c,v 1.93 2018/06/28 09:54:48 claudio Exp $ */
/*
* Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
@@ -985,9 +985,10 @@ rde_filter_calc_skip_steps(struct filter_head *rules)
enum filter_actions
rde_filter(struct filter_head *rules, struct rde_peer *peer,
- struct rde_aspath **new, struct prefix *p, struct rde_aspath *asp)
+ struct rde_aspath **new, struct prefix *p)
{
struct filter_rule *f;
+ struct rde_aspath *asp = prefix_aspath(p);
enum filter_actions action = ACTION_DENY; /* default deny */
if (new != NULL)
diff --git a/usr.sbin/bgpd/rde_update.c b/usr.sbin/bgpd/rde_update.c
index e5764fc4c8e..c3c88bf0615 100644
--- a/usr.sbin/bgpd/rde_update.c
+++ b/usr.sbin/bgpd/rde_update.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde_update.c,v 1.92 2018/06/28 08:07:21 claudio Exp $ */
+/* $OpenBSD: rde_update.c,v 1.93 2018/06/28 09:54:48 claudio Exp $ */
/*
* Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
@@ -409,9 +409,8 @@ withdraw:
if (up_test_update(peer, old) != 1)
return;
- asp = prefix_aspath(old);
pt_getaddr(old->re->prefix, &addr);
- if (rde_filter(rules, peer, NULL, old, asp) == ACTION_DENY)
+ if (rde_filter(rules, peer, NULL, old) == ACTION_DENY)
return;
/* withdraw prefix */
@@ -427,14 +426,14 @@ withdraw:
}
asp = prefix_aspath(new);
- pt_getaddr(new->re->prefix, &addr);
- if (rde_filter(rules, peer, &fasp, new, asp) == ACTION_DENY) {
+ if (rde_filter(rules, peer, &fasp, new) == ACTION_DENY) {
path_put(fasp);
goto withdraw;
}
if (fasp == NULL)
fasp = asp;
+ pt_getaddr(new->re->prefix, &addr);
up_generate(peer, fasp, &addr, new->re->prefix->prefixlen);
/* free modified aspath */
@@ -487,7 +486,7 @@ up_generate_default(struct filter_head *rules, struct rde_peer *peer,
p.flags = 0;
/* filter as usual */
- if (rde_filter(rules, peer, &fasp, &p, asp) == ACTION_DENY) {
+ if (rde_filter(rules, peer, &fasp, &p) == ACTION_DENY) {
path_put(fasp);
path_put(asp);
return;