diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2021-06-17 10:28:37 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2021-06-17 10:28:37 +0000 |
commit | d02dc6b751a606bb0a2b36f76ce1f60ad0a49eac (patch) | |
tree | e2b8440c42398132f1b4bee84d98f87900d5190b /usr.sbin | |
parent | 4636d4a73f302a3614fde2558bfc6ac03874cca2 (diff) |
Refactor common code for peer filtering out into rde_skip_peer()
and use it in the two places that need to keep in sync.
OK sthen@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bgpd/rde.c | 54 |
1 files changed, 25 insertions, 29 deletions
diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index cd0add1765b..85d8172df26 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.525 2021/06/17 08:43:06 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.526 2021/06/17 10:28:36 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -2879,6 +2879,28 @@ rde_evaluate_all(void) return rde_eval_all; } +static int +rde_skip_peer(struct rde_peer *peer, u_int16_t rib_id, u_int8_t aid) +{ + /* skip ourself */ + if (peer == peerself) + return 1; + if (peer->state != PEER_UP) + return 1; + /* skip peers using a different rib */ + if (peer->loc_rib_id != rib_id) + return 1; + /* check if peer actually supports the address family */ + if (peer->capa.mp[aid] == 0) + return 1; + /* skip peers with special export types */ + if (peer->export_type == EXPORT_NONE || + peer->export_type == EXPORT_DEFAULT_ROUTE) + return 1; + + return 0; +} + void rde_generate_updates(struct rib *rib, struct prefix *new, struct prefix *old, int eval_all) @@ -2903,20 +2925,7 @@ rde_generate_updates(struct rib *rib, struct prefix *new, struct prefix *old, aid = old->pt->aid; LIST_FOREACH(peer, &peerlist, peer_l) { - /* skip ourself */ - if (peer == peerself) - continue; - if (peer->state != PEER_UP) - continue; - /* skip peers using a different rib */ - if (peer->loc_rib_id != rib->id) - continue; - /* check if peer actually supports the address family */ - if (peer->capa.mp[aid] == 0) - continue; - /* skip peers with special export types */ - if (peer->export_type == EXPORT_NONE || - peer->export_type == EXPORT_DEFAULT_ROUTE) + if (rde_skip_peer(peer, rib->id, aid)) continue; /* skip regular peers if the best path didn't change */ if ((peer->flags & PEERFLAG_EVALUATE_ALL) == 0 && eval_all) @@ -3571,20 +3580,7 @@ rde_softreconfig_out(struct rib_entry *re, void *bula) return; LIST_FOREACH(peer, &peerlist, peer_l) { - /* skip ourself */ - if (peer == peerself) - continue; - if (peer->state != PEER_UP) - continue; - /* skip peers using a different rib */ - if (peer->loc_rib_id != p->re->rib_id) - continue; - /* check if peer actually supports the address family */ - if (peer->capa.mp[aid] == 0) - continue; - /* skip peers with special export types */ - if (peer->export_type == EXPORT_NONE || - peer->export_type == EXPORT_DEFAULT_ROUTE) + if (rde_skip_peer(peer, re->rib_id, aid)) continue; /* skip peers which don't need to reconfigure */ if (peer->reconf_out == 0) |