Instead of walking the Adj-RIB-In per RIB walk it once and check per
prefix if the RIB needs an update or not. This will make it easier to make
this run without blocking the system for a long time.
OK?
--
:wq Claudio
Index: rde.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/rde.c,v
retrieving revision 1.403
diff -u -p -r1.403 rde.c
--- rde.c 31 Jul 2018 08:04:49 -0000 1.403
+++ rde.c 31 Jul 2018 15:35:06 -0000
@@ -2799,10 +2799,9 @@ rde_reload_done(void)
log_debug("in filter change: reloading RIB %s",
ribs[rid].name);
ribs[rid].state = RECONF_RELOAD;
- /* FALLTHROUGH */
+ break;
case RECONF_REINIT:
- rib_dump(&ribs[RIB_ADJ_IN].rib, rde_softreconfig_in,
- &ribs[rid], AID_UNSPEC);
+ ribs[rid].state = RECONF_RELOAD;
break;
case RECONF_RELOAD:
log_warnx("Bad rib reload state");
@@ -2811,6 +2810,8 @@ rde_reload_done(void)
break;
}
}
+ rib_dump(&ribs[RIB_ADJ_IN].rib, rde_softreconfig_in, NULL, AID_UNSPEC);
+
LIST_FOREACH(peer, &peerlist, peer_l) {
if (peer->reconf_out)
rib_dump(peer->rib, rde_softreconfig_out,
@@ -2842,13 +2843,14 @@ void
rde_softreconfig_in(struct rib_entry *re, void *ptr)
{
struct filterstate state;
- struct rib_desc *rib = ptr;
+ struct rib_desc *rib;
struct prefix *p;
struct pt_entry *pt;
struct rde_peer *peer;
struct rde_aspath *asp;
enum filter_actions action;
struct bgpd_addr addr;
+ u_int16_t i;
pt = re->prefix;
pt_getaddr(pt, &addr);
@@ -2856,19 +2858,28 @@ rde_softreconfig_in(struct rib_entry *re
asp = prefix_aspath(p);
peer = asp->peer;
- rde_filterstate_prep(&state, asp, prefix_nexthop(p));
- action = rde_filter(rib->in_rules, peer, p, &state);
+ for (i = RIB_LOC_START; i < rib_size; i++) {
+ rib = &ribs[i];
+ if (rib->state != RECONF_RELOAD)
+ continue;
+ if (*rib->name == '\0')
+ break;
+
+ rde_filterstate_prep(&state, asp, prefix_nexthop(p));
+ action = rde_filter(rib->in_rules, peer, p, &state);
+
+ if (action == ACTION_ALLOW) {
+ /* update Local-RIB */
+ path_update(&rib->rib, peer, &state, &addr,
+ pt->prefixlen, 0);
+ } else if (action == ACTION_DENY) {
+ /* remove from Local-RIB */
+ prefix_remove(&rib->rib, peer, &addr,
+ pt->prefixlen, 0);
+ }
- if (action == ACTION_ALLOW) {
- /* update Local-RIB */
- path_update(&rib->rib, peer, &state, &addr,
- pt->prefixlen, 0);
- } else if (action == ACTION_DENY) {
- /* remove from Local-RIB */
- prefix_remove(&rib->rib, peer, &addr, pt->prefixlen, 0);
+ rde_filterstate_clean(&state);
}
-
- rde_filterstate_clean(&state);
}
}