To not recreate the issue of missing another check in one of the
up_generate_updates() call points factor out the common code into
rde_skip_peer().
I hope this way a similar f-up can be avoided
--
:wq Claudio
? obj
Index: rde.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/rde.c,v
retrieving revision 1.525
diff -u -p -r1.525 rde.c
--- rde.c 17 Jun 2021 08:43:06 -0000 1.525
+++ rde.c 17 Jun 2021 08:50:37 -0000
@@ -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, st
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 *r
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)