to the various prefix update functions.
While there fix a filterstate leak in up_generate_updates().
With and OK tb@
-/* $OpenBSD: rde.c,v 1.588 2023/01/18 13:20:00 claudio Exp $ */
+/* $OpenBSD: rde.c,v 1.589 2023/01/18 17:40:17 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
/* add original path to the Adj-RIB-In */
if (prefix_update(rib_byid(RIB_ADJ_IN), peer, path_id, path_id_tx,
- in, prefix, prefixlen, in->vstate) == 1)
+ in, prefix, prefixlen) == 1)
peer->prefix_cnt++;
/* max prefix checker */
&state.nexthop->exit_nexthop, prefix,
prefixlen);
prefix_update(rib, peer, path_id, path_id_tx, &state,
- prefix, prefixlen, in->vstate);
+ prefix, prefixlen);
} else if (prefix_withdraw(rib, peer, path_id, prefix,
prefixlen)) {
rde_update_log(wmsg, i, peer,
/* update Local-RIB */
prefix_update(rib, peer, p->path_id,
p->path_id_tx, &state,
- &prefix, pt->prefixlen,
- prefix_roa_vstate(p));
+ &prefix, pt->prefixlen);
} else if (action == ACTION_DENY) {
/* remove from Local-RIB */
prefix_withdraw(rib, peer, p->path_id, &prefix,
/* update Local-RIB */
prefix_update(rib, peer, p->path_id,
p->path_id_tx, &state,
- &prefix, pt->prefixlen,
- prefix_roa_vstate(p));
+ &prefix, pt->prefixlen);
} else if (action == ACTION_DENY) {
/* remove from Local-RIB */
prefix_withdraw(rib, peer, p->path_id, &prefix,
struct filter_set_head *vpnset = NULL;
struct in_addr prefix4;
struct in6_addr prefix6;
- uint8_t vstate;
uint16_t i;
uint32_t path_id_tx;
rde_apply_set(vpnset, peerself, peerself, state,
nc->prefix.aid);
+ path_id_tx = pathid_assign(peerself, 0, &nc->prefix, nc->prefixlen);
+
#if NOTYET
- state.aspath.aspa_state = ASPA_NEVER_KNOWN;
+ state->aspath.aspa_state = ASPA_NEVER_KNOWN;
#endif
- vstate = rde_roa_validity(&rde_roa, &nc->prefix,
+ state->vstate = rde_roa_validity(&rde_roa, &nc->prefix,
nc->prefixlen, aspath_origin(state->aspath.aspath));
- path_id_tx = pathid_assign(peerself, 0, &nc->prefix, nc->prefixlen);
+
if (prefix_update(rib_byid(RIB_ADJ_IN), peerself, 0, path_id_tx,
- state, &nc->prefix, nc->prefixlen, vstate) == 1)
+ state, &nc->prefix, nc->prefixlen) == 1)
peerself->prefix_cnt++;
for (i = RIB_LOC_START; i < rib_size; i++) {
struct rib *rib = rib_byid(i);
state->nexthop ? &state->nexthop->exit_nexthop : NULL,
&nc->prefix, nc->prefixlen);
prefix_update(rib, peerself, 0, path_id_tx, state, &nc->prefix,
- nc->prefixlen, vstate);
+ nc->prefixlen);
}
filterset_free(&nc->attrset);
}
-/* $OpenBSD: rde.h,v 1.279 2023/01/17 16:09:01 claudio Exp $ */
+/* $OpenBSD: rde.h,v 1.280 2023/01/18 17:40:17 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and
int);
struct prefix *prefix_adjout_next(struct rde_peer *, struct prefix *);
int prefix_update(struct rib *, struct rde_peer *, uint32_t,
- uint32_t, struct filterstate *, struct bgpd_addr *,
- int, uint8_t);
+ uint32_t, struct filterstate *, struct bgpd_addr *, int);
int prefix_withdraw(struct rib *, struct rde_peer *, uint32_t,
struct bgpd_addr *, int);
void prefix_add_eor(struct rde_peer *, uint8_t);
void prefix_adjout_update(struct prefix *, struct rde_peer *,
- struct filterstate *, struct bgpd_addr *, int,
- uint32_t, uint8_t);
+ struct filterstate *, struct bgpd_addr *, int, uint32_t);
void prefix_adjout_withdraw(struct prefix *);
void prefix_adjout_destroy(struct prefix *);
void prefix_adjout_dump(struct rde_peer *, void *,
-/* $OpenBSD: rde_rib.c,v 1.251 2022/12/28 21:30:16 jmc Exp $ */
+/* $OpenBSD: rde_rib.c,v 1.252 2023/01/18 17:40:17 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org>
int
prefix_update(struct rib *rib, struct rde_peer *peer, uint32_t path_id,
uint32_t path_id_tx, struct filterstate *state, struct bgpd_addr *prefix,
- int prefixlen, uint8_t vstate)
+ int prefixlen)
{
struct rde_aspath *asp, *nasp = &state->aspath;
struct rde_community *comm, *ncomm = &state->communities;
path_compare(nasp, prefix_aspath(p)) == 0) {
/* no change, update last change */
p->lastchange = getmonotime();
- p->validation_state = vstate;
+ p->validation_state = state->vstate;
return (0);
}
}
/* If the prefix was found move it else add it to the RIB. */
if (p != NULL)
return (prefix_move(p, peer, asp, comm, state->nexthop,
- state->nhflags, vstate));
+ state->nhflags, state->vstate));
else
return (prefix_add(prefix, prefixlen, rib, peer, path_id,
path_id_tx, asp, comm, state->nexthop, state->nhflags,
- vstate));
+ state->vstate));
}
/*
void
prefix_adjout_update(struct prefix *p, struct rde_peer *peer,
struct filterstate *state, struct bgpd_addr *prefix, int prefixlen,
- uint32_t path_id_tx, uint8_t vstate)
+ uint32_t path_id_tx)
{
struct rde_aspath *asp;
struct rde_community *comm;
prefix_communities(p)) &&
path_compare(&state->aspath, prefix_aspath(p)) == 0) {
/* nothing changed */
- p->validation_state = vstate;
+ p->validation_state = state->vstate;
p->lastchange = getmonotime();
p->flags &= ~PREFIX_FLAG_STALE;
return;
}
prefix_link(p, NULL, p->pt, peer, 0, p->path_id_tx, asp, comm,
- state->nexthop, state->nhflags, vstate);
+ state->nexthop, state->nhflags, state->vstate);
peer->prefix_out_cnt++;
if (p->flags & PREFIX_FLAG_MASK)
-/* $OpenBSD: rde_update.c,v 1.151 2023/01/12 17:35:51 claudio Exp $ */
+/* $OpenBSD: rde_update.c,v 1.152 2023/01/18 17:40:17 claudio Exp $ */
/*
* Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
}
/* check if this was actually a withdraw */
- if (need_withdraw)
+ if (need_withdraw) {
+ rde_filterstate_clean(&state);
break;
+ }
/* from here on we know this is an update */
up_prep_adjout(peer, &state, addr.aid);
prefix_adjout_update(p, peer, &state, &addr,
- new->pt->prefixlen, new->path_id_tx,
- prefix_roa_vstate(new));
+ new->pt->prefixlen, new->path_id_tx);
rde_filterstate_clean(&state);
/* max prefix checker outbound */
up_prep_adjout(peer, &state, addr.aid);
prefix_adjout_update(p, peer, &state, &addr,
- new->pt->prefixlen, new->path_id_tx,
- prefix_roa_vstate(new));
+ new->pt->prefixlen, new->path_id_tx);
rde_filterstate_clean(&state);
/* max prefix checker outbound */
up_prep_adjout(peer, &state, addr.aid);
prefix_adjout_update(p, peer, &state, &addr,
- prefixlen, new->path_id_tx, prefix_roa_vstate(new));
+ prefixlen, new->path_id_tx);
rde_filterstate_clean(&state);
/* max prefix checker outbound */
}
up_prep_adjout(peer, &state, addr.aid);
- prefix_adjout_update(p, peer, &state, &addr, 0, 0, ROA_NOTFOUND);
+ prefix_adjout_update(p, peer, &state, &addr, 0, 0);
rde_filterstate_clean(&state);
/* max prefix checker outbound */
goto done;
rde_filterstate_prep(&state, p);
-
r = up_generate_attr(buf + 2, len - 2, peer, &state, AID_INET);
rde_filterstate_clean(&state);
if (r == -1) {