From: Ole Troan Date: Fri, 13 Oct 2023 06:52:47 +0000 (+0200) Subject: ip-neighbor: add ip neighbor flush X-Git-Tag: v24.06-rc0~215 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=1fe132ec1a33edf89503140aff0a26ed73542296;p=vpp.git ip-neighbor: add ip neighbor flush Flushing the neighbor cache was only available through API. Add CLI command. Either flushes whole table (IP4,IP6) or all neighbors on specified interface. Type: improvement Change-Id: Ia8c68fb032a2dfd940a136edc2aee80db5c37685 Signed-off-by: Ole Troan --- diff --git a/src/vnet/ip-neighbor/ip_neighbor.c b/src/vnet/ip-neighbor/ip_neighbor.c index d7450f9cd3e..d341698abfb 100644 --- a/src/vnet/ip-neighbor/ip_neighbor.c +++ b/src/vnet/ip-neighbor/ip_neighbor.c @@ -797,7 +797,7 @@ ip_neighbor_cmd (vlib_main_t * vm, vnet_main_t *vnm = vnet_get_main (); ip_neighbor_flags_t flags; u32 sw_if_index = ~0; - int is_add = 1; + int is_add = 1, is_flush = 0; int count = 1; flags = IP_NEIGHBOR_FLAG_DYNAMIC; @@ -811,6 +811,8 @@ ip_neighbor_cmd (vlib_main_t * vm, ; else if (unformat (input, "delete") || unformat (input, "del")) is_add = 0; + else if (unformat (input, "flush")) + is_flush = 1; else if (unformat (input, "static")) { flags |= IP_NEIGHBOR_FLAG_STATIC; @@ -824,6 +826,13 @@ ip_neighbor_cmd (vlib_main_t * vm, break; } + if (is_flush) + { + ip_neighbor_del_all (AF_IP4, sw_if_index); + ip_neighbor_del_all (AF_IP6, sw_if_index); + return NULL; + } + if (sw_if_index == ~0 || ip_address_is_zero (&ip) || mac_address_is_zero (&mac)) return clib_error_return (0, @@ -888,7 +897,7 @@ VLIB_CLI_COMMAND (ip_neighbor_command, static) = { }; VLIB_CLI_COMMAND (ip_neighbor_command2, static) = { .path = "ip neighbor", - .short_help = "ip neighbor [del] " + .short_help = "ip neighbor [del] [flush] " "[static] [no-fib-entry] [count ]", .function = ip_neighbor_cmd, };