This is cleanup. rde_filter() and rde_apply_set() are no longer called
with a NULL filterstate (since introduction of the Adj-RIB-Out).
So remove all those extra checks to make sure state is not NULL.
--
:wq Claudio
Index: rde_filter.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/rde_filter.c,v
retrieving revision 1.117
diff -u -p -r1.117 rde_filter.c
--- rde_filter.c 4 Feb 2019 18:53:10 -0000 1.117
+++ rde_filter.c 9 May 2019 16:00:22 -0000
@@ -44,9 +44,6 @@ rde_apply_set(struct filter_set_head *sh
u_int16_t nl;
u_int8_t prepend;
- if (state == NULL)
- return;
-
TAILQ_FOREACH(set, sh, entry) {
switch (set->type) {
case ACTION_SET_LOCALPREF:
@@ -208,12 +205,9 @@ int
rde_filter_match(struct filter_rule *f, struct rde_peer *peer,
struct filterstate *state, struct prefix *p)
{
- struct rde_aspath *asp = NULL;
+ struct rde_aspath *asp = &state->aspath;
int i;
- if (state != NULL)
- asp = &state->aspath;
-
if (f->peer.ebgp && !peer->conf.ebgp)
return (0);
if (f->peer.ibgp && peer->conf.ebgp)
@@ -257,7 +251,7 @@ rde_filter_match(struct filter_rule *f,
}
}
- if (state != NULL && f->match.nexthop.flags != 0) {
+ if (f->match.nexthop.flags != 0) {
struct bgpd_addr *nexthop, *cmpaddr;
if (state->nexthop == NULL)
/* no nexthop, skip */
@@ -798,10 +792,7 @@ rde_filter(struct filter_head *rules, st
struct filter_rule *f;
enum filter_actions action = ACTION_DENY; /* default deny */
- if (state == NULL) /* withdraw should be accepted by default */
- action = ACTION_ALLOW;
-
- if (state && state->aspath.flags & F_ATTR_PARSE_ERR)
+ if (state->aspath.flags & F_ATTR_PARSE_ERR)
/*
* don't try to filter bad updates just deny them
* so they act as implicit withdraws
@@ -827,10 +818,8 @@ rde_filter(struct filter_head *rules, st
f->skip[RDE_FILTER_SKIP_PEERID]);
if (rde_filter_match(f, peer, state, p)) {
- if (state != NULL) {
- rde_apply_set(&f->set, state,
- p->re->prefix->aid, prefix_peer(p), peer);
- }
+ rde_apply_set(&f->set, state,
+ p->re->prefix->aid, prefix_peer(p), peer);
if (f->action != ACTION_NONE)
action = f->action;
if (f->quick)
Index: rde_update.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/rde_update.c,v
retrieving revision 1.108
diff -u -p -r1.108 rde_update.c
--- rde_update.c 21 Jan 2019 02:07:56 -0000 1.108
+++ rde_update.c 9 May 2019 16:01:18 -0000
@@ -202,7 +202,7 @@ up_generate_default(struct filter_head *
* XXX apply default overrides. Not yet possible, mainly a parse.y
* problem.
*/
- /* rde_apply_set(asp, set, af, NULL ???, DIR_IN); */
+ /* rde_apply_set(asp, set, af, &state, DIR_IN); */
/*
* XXX this is ugly because we need to have a prefix for rde_filter()