diff options
author | Stanislav Zaikin <stanislav.zaikin@46labs.com> | 2023-03-14 12:32:32 +0100 |
---|---|---|
committer | Neale Ranns <neale@graphiant.com> | 2023-06-23 17:32:31 +0000 |
commit | 601972bb20c3f2846c0d3d3225a0a629126fe1ac (patch) | |
tree | 2fc3031f4d6e5232651026424eac6f313eb7d432 | |
parent | 6052f4b9d8b7f7668649e9a0d3a8a09506465ed8 (diff) |
fib: walk over adj glean per table
Type: fix
Signed-off-by: Stanislav Zaikin <stanislav.zaikin@46labs.com>
Change-Id: I07f54bb643c24b1839a2d0e93acc593d13a43fed
-rw-r--r-- | src/vnet/adj/adj_glean.c | 57 |
1 files changed, 33 insertions, 24 deletions
diff --git a/src/vnet/adj/adj_glean.c b/src/vnet/adj/adj_glean.c index 45477649c1a..0313407b6f1 100644 --- a/src/vnet/adj/adj_glean.c +++ b/src/vnet/adj/adj_glean.c @@ -186,6 +186,37 @@ adj_glean_update_rewrite_walk (adj_index_t ai, return (ADJ_WALK_RC_CONTINUE); } +static void +adj_glean_walk_proto (fib_protocol_t proto, + u32 sw_if_index, + adj_walk_cb_t cb, + void *data) +{ + adj_index_t ai, *aip, *ais = NULL; + ip46_address_t *conn; + + if (vec_len(adj_gleans[proto]) <= sw_if_index || + NULL == adj_gleans[proto][sw_if_index]) + return; + + /* + * Walk first to collect the indices + * then walk the collection. This is safe + * to modifications of the hash table + */ + hash_foreach_mem(conn, ai, adj_gleans[proto][sw_if_index], + ({ + vec_add1(ais, ai); + })); + + vec_foreach(aip, ais) + { + if (ADJ_WALK_RC_STOP == cb(*aip, data)) + return; + } + vec_free(ais); +} + void adj_glean_walk (u32 sw_if_index, adj_walk_cb_t cb, @@ -195,29 +226,7 @@ adj_glean_walk (u32 sw_if_index, FOR_EACH_FIB_IP_PROTOCOL(proto) { - adj_index_t ai, *aip, *ais = NULL; - ip46_address_t *conn; - - if (vec_len(adj_gleans[proto]) <= sw_if_index || - NULL == adj_gleans[proto][sw_if_index]) - continue; - - /* - * Walk first to collect the indices - * then walk the collection. This is safe - * to modifications of the hash table - */ - hash_foreach_mem(conn, ai, adj_gleans[proto][sw_if_index], - ({ - vec_add1(ais, ai); - })); - - vec_foreach(aip, ais) - { - if (ADJ_WALK_RC_STOP == cb(*aip, data)) - break; - } - vec_free(ais); + adj_glean_walk_proto (proto, sw_if_index, cb, data); } } @@ -445,7 +454,7 @@ adj_glean_table_bind (fib_protocol_t fproto, }, }; - adj_glean_walk (sw_if_index, adj_glean_start_backwalk, &bw_ctx); + adj_glean_walk_proto (fproto, sw_if_index, adj_glean_start_backwalk, &bw_ctx); } |