This is the next step in vstate cleanup. Since the vstate is now part of struct filterstate use that information instead of passing an explicit vstate to the various update functions.
-- :wq Claudio Index: rde.c =================================================================== RCS file: /cvs/src/usr.sbin/bgpd/rde.c,v retrieving revision 1.587 diff -u -p -r1.587 rde.c --- rde.c 17 Jan 2023 16:09:01 -0000 1.587 +++ rde.c 18 Jan 2023 13:31:23 -0000 @@ -1744,7 +1744,7 @@ rde_update_update(struct rde_peer *peer, /* 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 */ @@ -1772,7 +1772,7 @@ rde_update_update(struct rde_peer *peer, &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, @@ -3847,8 +3847,7 @@ rde_softreconfig_in(struct rib_entry *re /* 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, @@ -3986,8 +3985,7 @@ rde_roa_softreload(struct rib_entry *re, /* 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, @@ -4187,7 +4185,6 @@ network_add(struct network_config *nc, s 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; @@ -4249,14 +4246,16 @@ network_add(struct network_config *nc, s 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); @@ -4266,7 +4265,7 @@ network_add(struct network_config *nc, s 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); } Index: rde.h =================================================================== RCS file: /cvs/src/usr.sbin/bgpd/rde.h,v retrieving revision 1.279 diff -u -p -r1.279 rde.h --- rde.h 17 Jan 2023 16:09:01 -0000 1.279 +++ rde.h 17 Jan 2023 16:09:50 -0000 @@ -624,14 +624,12 @@ struct prefix *prefix_adjout_lookup(stru 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 *, Index: rde_rib.c =================================================================== RCS file: /cvs/src/usr.sbin/bgpd/rde_rib.c,v retrieving revision 1.251 diff -u -p -r1.251 rde_rib.c --- rde_rib.c 28 Dec 2022 21:30:16 -0000 1.251 +++ rde_rib.c 12 Jan 2023 17:37:15 -0000 @@ -955,7 +955,7 @@ prefix_adjout_match(struct rde_peer *pee 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; @@ -973,7 +973,7 @@ prefix_update(struct rib *rib, struct rd 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); } } @@ -997,11 +997,11 @@ prefix_update(struct rib *rib, struct rd /* 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)); } /* @@ -1123,7 +1123,7 @@ prefix_add_eor(struct rde_peer *peer, ui 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; @@ -1160,7 +1160,7 @@ prefix_adjout_update(struct prefix *p, s 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; @@ -1205,7 +1205,7 @@ prefix_adjout_update(struct prefix *p, s } 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) Index: rde_update.c =================================================================== RCS file: /cvs/src/usr.sbin/bgpd/rde_update.c,v retrieving revision 1.151 diff -u -p -r1.151 rde_update.c --- rde_update.c 12 Jan 2023 17:35:51 -0000 1.151 +++ rde_update.c 12 Jan 2023 17:41:34 -0000 @@ -206,8 +206,7 @@ up_generate_updates(struct filter_head * 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 */ @@ -337,8 +336,7 @@ up_generate_addpath(struct filter_head * 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 */ @@ -441,7 +439,7 @@ up_generate_addpath_all(struct filter_he 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 */ @@ -509,7 +507,7 @@ up_generate_default(struct filter_head * } 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 */