diff options
author | Neale Ranns <nranns@cisco.com> | 2020-04-23 09:04:59 +0000 |
---|---|---|
committer | Ole Trøan <otroan@employees.org> | 2020-04-30 20:24:45 +0000 |
commit | 240dcb24a00004017ec2d1b23b93d9ae8d3c9f65 (patch) | |
tree | 5c0397ecbf4c0936ce703871888ff666239f775f /src/vnet/ip-neighbor/ip_neighbor.c | |
parent | f3783e15014c4c93a1b43697bfcc6422b0a7e369 (diff) |
ip-neighbor: Add flush API
Type: feature
Signed-off-by: Neale Ranns <nranns@cisco.com>
Change-Id: I96509c274895b917c3e220204d7959d9270de30d
Diffstat (limited to 'src/vnet/ip-neighbor/ip_neighbor.c')
-rw-r--r-- | src/vnet/ip-neighbor/ip_neighbor.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/vnet/ip-neighbor/ip_neighbor.c b/src/vnet/ip-neighbor/ip_neighbor.c index 5b18473e462..afb97acb39c 100644 --- a/src/vnet/ip-neighbor/ip_neighbor.c +++ b/src/vnet/ip-neighbor/ip_neighbor.c @@ -576,6 +576,40 @@ ip_neighbor_del (const ip46_address_t * ip, ip46_type_t type, u32 sw_if_index) return (0); } +typedef struct ip_neighbor_del_all_ctx_t_ +{ + index_t *ipn_del; +} ip_neighbor_del_all_ctx_t; + +static walk_rc_t +ip_neighbor_del_all_walk_cb (index_t ipni, void *arg) +{ + ip_neighbor_del_all_ctx_t *ctx = arg; + + vec_add1 (ctx->ipn_del, ipni); + + return (WALK_CONTINUE); +} + +void +ip_neighbor_del_all (ip46_type_t type, u32 sw_if_index) +{ + IP_NEIGHBOR_INFO ("delete-all: %U, %U", + format_ip46_type, type, + format_vnet_sw_if_index_name, vnet_get_main (), + sw_if_index); + + ip_neighbor_del_all_ctx_t ctx = { + .ipn_del = NULL, + }; + index_t *ipni; + + ip_neighbor_walk (type, sw_if_index, ip_neighbor_del_all_walk_cb, &ctx); + + vec_foreach (ipni, ctx.ipn_del) ip_neighbor_free (ip_neighbor_get (*ipni)); + vec_free (ctx.ipn_del); +} + void ip_neighbor_update (vnet_main_t * vnm, adj_index_t ai) { |