-/* $OpenBSD: rde.c,v 1.411 2018/08/06 15:59:01 claudio Exp $ */
+/* $OpenBSD: rde.c,v 1.412 2018/08/08 06:54:50 benno Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
fatal(NULL);
memcpy(nconf, imsg.data, sizeof(struct bgpd_config));
for (rid = 0; rid < rib_size; rid++) {
- if (*ribs[rid].name == '\0')
+ if (!rib_valid(rid))
break;
ribs[rid].state = RECONF_DELETE;
}
fatalx("rde_update_update: no prefix in Adj-RIB-In");
for (i = RIB_LOC_START; i < rib_size; i++) {
- if (*ribs[i].name == '\0')
+ if (!rib_valid(i))
break;
rde_filterstate_prep(&state, &in->aspath, in->nexthop,
in->nhflags);
u_int16_t i;
for (i = RIB_LOC_START; i < rib_size; i++) {
- if (*ribs[i].name == '\0')
+ if (!rib_valid(i))
break;
if (prefix_remove(&ribs[i].rib, peer, prefix, prefixlen, 0))
rde_update_log("withdraw", i, peer, NULL, prefix,
}
/* bring ribs in sync */
for (rid = 0; rid < rib_size; rid++) {
- if (*ribs[rid].name == '\0')
+ if (!rib_valid(rid))
continue;
rde_filter_calc_skip_steps(ribs[rid].in_rules_tmp);
filterlist_free(out_rules_tmp);
out_rules_tmp = NULL;
for (rid = 0; rid < rib_size; rid++) {
- if (*ribs[rid].name == '\0')
+ if (!rib_valid(rid))
continue;
ribs[rid].state = RECONF_NONE;
}
rib = &ribs[i];
if (rib->state != RECONF_RELOAD)
continue;
- if (*rib->name == '\0')
+ if (!rib_valid(i))
break;
rde_filterstate_prep(&state, asp, prefix_nexthop(p),
nc->prefixlen, 0))
peerself->prefix_cnt++;
for (i = RIB_LOC_START; i < rib_size; i++) {
- if (*ribs[i].name == '\0')
+ if (!rib_valid(i))
break;
rde_update_log("announce", i, peerself,
state.nexthop ? &state.nexthop->exit_nexthop : NULL,
}
for (i = RIB_LOC_START; i < rib_size; i++) {
- if (*ribs[i].name == '\0')
+ if (!rib_valid(i))
break;
if (prefix_remove(&ribs[i].rib, peerself, &nc->prefix,
nc->prefixlen, flags))
/* free filters */
filterlist_free(out_rules);
for (i = 0; i < rib_size; i++) {
- if (*ribs[i].name == '\0')
+ if (!rib_valid(i))
break;
filterlist_free(ribs[i].in_rules);
}
-/* $OpenBSD: rde.h,v 1.184 2018/08/06 08:13:31 claudio Exp $ */
+/* $OpenBSD: rde.h,v 1.185 2018/08/08 06:54:50 benno Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and
return (struct rib *)((intptr_t)re->__rib & ~1);
}
+static inline int
+rib_valid(u_int16_t rid)
+{
+ if (rid >= rib_size || *ribs[rid].name == '\0')
+ return 0;
+ return 1;
+}
+
void path_init(u_int32_t);
void path_init(u_int32_t);
void path_shutdown(void);