diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bgpd/rde.c | 24 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde.h | 13 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde_decide.c | 6 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde_rib.c | 28 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde_update.c | 11 |
5 files changed, 42 insertions, 40 deletions
diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index be8bd3beb4a..f468720e9df 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.483 2019/08/07 10:26:41 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.484 2019/08/09 13:44:27 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -1413,7 +1413,7 @@ rde_update_update(struct rde_peer *peer, struct filterstate *in, aspath_origin(in->aspath.aspath)); /* add original path to the Adj-RIB-In */ - if (path_update(&ribs[RIB_ADJ_IN].rib, peer, in, prefix, prefixlen, + if (prefix_update(&ribs[RIB_ADJ_IN].rib, peer, in, prefix, prefixlen, vstate) == 1) peer->prefix_cnt++; @@ -1444,9 +1444,9 @@ rde_update_update(struct rde_peer *peer, struct filterstate *in, rde_update_log("update", i, peer, &state.nexthop->exit_nexthop, prefix, prefixlen); - path_update(&ribs[i].rib, peer, &state, prefix, + prefix_update(&ribs[i].rib, peer, &state, prefix, prefixlen, vstate); - } else if (prefix_remove(&ribs[i].rib, peer, prefix, + } else if (prefix_withdraw(&ribs[i].rib, peer, prefix, prefixlen)) { rde_update_log(wmsg, i, peer, NULL, prefix, prefixlen); @@ -1467,13 +1467,13 @@ rde_update_withdraw(struct rde_peer *peer, struct bgpd_addr *prefix, for (i = RIB_LOC_START; i < rib_size; i++) { if (!rib_valid(i)) continue; - if (prefix_remove(&ribs[i].rib, peer, prefix, prefixlen)) + if (prefix_withdraw(&ribs[i].rib, peer, prefix, prefixlen)) rde_update_log("withdraw", i, peer, NULL, prefix, prefixlen); } /* remove original path form the Adj-RIB-In */ - if (prefix_remove(&ribs[RIB_ADJ_IN].rib, peer, prefix, prefixlen)) + if (prefix_withdraw(&ribs[RIB_ADJ_IN].rib, peer, prefix, prefixlen)) peer->prefix_cnt--; peer->prefix_rcvd_withdraw++; @@ -3331,11 +3331,11 @@ rde_softreconfig_in(struct rib_entry *re, void *bula) if (action == ACTION_ALLOW) { /* update Local-RIB */ - path_update(&rib->rib, peer, &state, &prefix, + prefix_update(&rib->rib, peer, &state, &prefix, pt->prefixlen, p->validation_state); } else if (action == ACTION_DENY) { /* remove from Local-RIB */ - prefix_remove(&rib->rib, peer, &prefix, + prefix_withdraw(&rib->rib, peer, &prefix, pt->prefixlen); } @@ -3966,7 +3966,7 @@ network_add(struct network_config *nc, struct filterstate *state) vstate = rde_roa_validity(&conf->rde_roa, &nc->prefix, nc->prefixlen, aspath_origin(state->aspath.aspath)); - if (path_update(&ribs[RIB_ADJ_IN].rib, peerself, state, &nc->prefix, + if (prefix_update(&ribs[RIB_ADJ_IN].rib, peerself, state, &nc->prefix, nc->prefixlen, vstate) == 1) peerself->prefix_cnt++; for (i = RIB_LOC_START; i < rib_size; i++) { @@ -3975,7 +3975,7 @@ network_add(struct network_config *nc, struct filterstate *state) rde_update_log("announce", i, peerself, state->nexthop ? &state->nexthop->exit_nexthop : NULL, &nc->prefix, nc->prefixlen); - path_update(&ribs[i].rib, peerself, state, &nc->prefix, + prefix_update(&ribs[i].rib, peerself, state, &nc->prefix, nc->prefixlen, vstate); } filterset_free(&nc->attrset); @@ -4036,12 +4036,12 @@ network_delete(struct network_config *nc) for (i = RIB_LOC_START; i < rib_size; i++) { if (!rib_valid(i)) continue; - if (prefix_remove(&ribs[i].rib, peerself, &nc->prefix, + if (prefix_withdraw(&ribs[i].rib, peerself, &nc->prefix, nc->prefixlen)) rde_update_log("withdraw announce", i, peerself, NULL, &nc->prefix, nc->prefixlen); } - if (prefix_remove(&ribs[RIB_ADJ_IN].rib, peerself, &nc->prefix, + if (prefix_withdraw(&ribs[RIB_ADJ_IN].rib, peerself, &nc->prefix, nc->prefixlen)) peerself->prefix_cnt--; } diff --git a/usr.sbin/bgpd/rde.h b/usr.sbin/bgpd/rde.h index 471dc5187e6..a6e573f2ae2 100644 --- a/usr.sbin/bgpd/rde.h +++ b/usr.sbin/bgpd/rde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.h,v 1.222 2019/08/07 10:26:41 claudio Exp $ */ +/* $OpenBSD: rde.h,v 1.223 2019/08/09 13:44:27 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and @@ -543,8 +543,6 @@ void path_init(u_int32_t); void path_init(u_int32_t); void path_shutdown(void); void path_hash_stats(struct rde_hashstats *); -int path_update(struct rib *, struct rde_peer *, - struct filterstate *, struct bgpd_addr *, int, u_int8_t); int path_compare(struct rde_aspath *, struct rde_aspath *); u_int32_t path_remove_stale(struct rde_aspath *, u_int8_t, time_t); struct rde_aspath *path_copy(struct rde_aspath *, const struct rde_aspath *); @@ -558,12 +556,15 @@ struct prefix *prefix_get(struct rib *, struct rde_peer *, struct bgpd_addr *, int); struct prefix *prefix_lookup(struct rde_peer *, struct bgpd_addr *, int); struct prefix *prefix_match(struct rde_peer *, struct bgpd_addr *); -int prefix_remove(struct rib *, struct rde_peer *, +int prefix_update(struct rib *, struct rde_peer *, + struct filterstate *, struct bgpd_addr *, int, u_int8_t); +int prefix_withdraw(struct rib *, struct rde_peer *, struct bgpd_addr *, int); void prefix_add_eor(struct rde_peer *, u_int8_t); -int prefix_update(struct rde_peer *, struct filterstate *, +int prefix_adjout_update(struct rde_peer *, struct filterstate *, struct bgpd_addr *, int, u_int8_t); -int prefix_withdraw(struct rde_peer *, struct bgpd_addr *, int); +int prefix_adjout_withdraw(struct rde_peer *, struct bgpd_addr *, + int); void prefix_adjout_destroy(struct prefix *p); void prefix_adjout_dump(struct rde_peer *, void *, void (*)(struct prefix *, void *)); diff --git a/usr.sbin/bgpd/rde_decide.c b/usr.sbin/bgpd/rde_decide.c index 25692fb4eb0..83cfefac77d 100644 --- a/usr.sbin/bgpd/rde_decide.c +++ b/usr.sbin/bgpd/rde_decide.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_decide.c,v 1.77 2019/08/07 10:26:41 claudio Exp $ */ +/* $OpenBSD: rde_decide.c,v 1.78 2019/08/09 13:44:27 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> @@ -94,8 +94,8 @@ int prefix_cmp(struct prefix *, struct prefix *); * Ineligible routes are flagged as ineligible via nexthop_add(). * Phase 3 is done together with Phase 2. * In following cases a prefix needs to be reevaluated: - * - update of a prefix (path_update) - * - withdraw of a prefix (prefix_remove) + * - update of a prefix (prefix_update) + * - withdraw of a prefix (prefix_withdraw) * - state change of the nexthop (nexthop-{in}validate) * - state change of session (session down) */ diff --git a/usr.sbin/bgpd/rde_rib.c b/usr.sbin/bgpd/rde_rib.c index 2a6767dc27c..19b93f75bf6 100644 --- a/usr.sbin/bgpd/rde_rib.c +++ b/usr.sbin/bgpd/rde_rib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_rib.c,v 1.202 2019/08/07 10:26:41 claudio Exp $ */ +/* $OpenBSD: rde_rib.c,v 1.203 2019/08/09 13:44:27 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> @@ -655,12 +655,11 @@ path_hash_stats(struct rde_hashstats *hs) } /* - * Update a prefix belonging to a possible new aspath. - * Return 1 if prefix was newly added, 0 if it was just changed or 2 if no - * change happened at all. + * Update a prefix. + * Return 1 if prefix was newly added, 0 if it was just changed. */ int -path_update(struct rib *rib, struct rde_peer *peer, struct filterstate *state, +prefix_update(struct rib *rib, struct rde_peer *peer, struct filterstate *state, struct bgpd_addr *prefix, int prefixlen, u_int8_t vstate) { struct rde_aspath *asp, *nasp = &state->aspath; @@ -683,7 +682,7 @@ path_update(struct rib *rib, struct rde_peer *peer, struct filterstate *state, /* no change, update last change */ p->lastchange = time(NULL); p->validation_state = vstate; - return (2); + return (0); } } @@ -1099,12 +1098,12 @@ prefix_move(struct prefix *p, struct rde_peer *peer, } /* - * Removes a prefix from all lists. If the parent objects -- path or - * pt_entry -- become empty remove them too. + * Removes a prefix from the specified RIB. If the parent objects -- rib_entry + * or pt_entry -- become empty remove them too. */ int -prefix_remove(struct rib *rib, struct rde_peer *peer, struct bgpd_addr *prefix, - int prefixlen) +prefix_withdraw(struct rib *rib, struct rde_peer *peer, + struct bgpd_addr *prefix, int prefixlen) { struct prefix *p; struct rde_aspath *asp; @@ -1146,7 +1145,7 @@ prefix_add_eor(struct rde_peer *peer, u_int8_t aid) * Put a prefix from the Adj-RIB-Out onto the update queue. */ int -prefix_update(struct rde_peer *peer, struct filterstate *state, +prefix_adjout_update(struct rde_peer *peer, struct filterstate *state, struct bgpd_addr *prefix, int prefixlen, u_int8_t vstate) { struct prefix_tree *prefix_head = NULL; @@ -1237,7 +1236,8 @@ prefix_update(struct rde_peer *peer, struct filterstate *state, * the prefix in the RIB linked to the peer withdraw list. */ int -prefix_withdraw(struct rde_peer *peer, struct bgpd_addr *prefix, int prefixlen) +prefix_adjout_withdraw(struct rde_peer *peer, struct bgpd_addr *prefix, + int prefixlen) { struct prefix *p; @@ -1531,7 +1531,7 @@ prefix_bypeer(struct rib_entry *re, struct rde_peer *peer) } static void -prefix_updateall(struct prefix *p, enum nexthop_state state, +prefix_evaluate_all(struct prefix *p, enum nexthop_state state, enum nexthop_state oldstate) { /* Skip non local-RIBs or RIBs that are flagged as noeval. */ @@ -1745,7 +1745,7 @@ nexthop_runner(void) p = nh->next_prefix; for (j = 0; p != NULL && j < RDE_RUNNER_ROUNDS; j++) { - prefix_updateall(p, nh->state, nh->oldstate); + prefix_evaluate_all(p, nh->state, nh->oldstate); p = LIST_NEXT(p, entry.list.nexthop); } diff --git a/usr.sbin/bgpd/rde_update.c b/usr.sbin/bgpd/rde_update.c index 9ca9ca58c92..44dcc7cfe1b 100644 --- a/usr.sbin/bgpd/rde_update.c +++ b/usr.sbin/bgpd/rde_update.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_update.c,v 1.120 2019/07/17 10:13:26 claudio Exp $ */ +/* $OpenBSD: rde_update.c,v 1.121 2019/08/09 13:44:27 claudio Exp $ */ /* * Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org> @@ -143,7 +143,8 @@ withdraw: /* withdraw prefix */ pt_getaddr(old->pt, &addr); - if (prefix_withdraw(peer, &addr, old->pt->prefixlen) == 1) + if (prefix_adjout_withdraw(peer, &addr, + old->pt->prefixlen) == 1) peer->up_wcnt++; } else { switch (up_test_update(peer, new)) { @@ -166,8 +167,8 @@ withdraw: pt_getaddr(new->pt, &addr); /* only send update if path changed */ - if (prefix_update(peer, &state, &addr, new->pt->prefixlen, - prefix_vstate(new)) == 1) + if (prefix_adjout_update(peer, &state, &addr, + new->pt->prefixlen, prefix_vstate(new)) == 1) peer->up_nlricnt++; rde_filterstate_clean(&state); @@ -226,7 +227,7 @@ up_generate_default(struct filter_head *rules, struct rde_peer *peer, return; } - if (prefix_update(peer, &state, &addr, 0, ROA_NOTFOUND) == 1) + if (prefix_adjout_update(peer, &state, &addr, 0, ROA_NOTFOUND) == 1) peer->up_nlricnt++; /* no longer needed */ |