aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOle Troan <otroan@employees.org>2023-10-13 08:52:47 +0200
committerAndrew Yourtchenko <ayourtch@gmail.com>2023-10-16 10:52:51 +0000
commit1fe132ec1a33edf89503140aff0a26ed73542296 (patch)
tree58caafa9a50d4ad329d568ea3dedc98bf6870c3e /src
parentd0ffa26a0e2910f9b7108b0b133e2da7de278178 (diff)
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 <otroan@employees.org>
Diffstat (limited to 'src')
-rw-r--r--src/vnet/ip-neighbor/ip_neighbor.c13
1 files changed, 11 insertions, 2 deletions
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] <intfc> <ip-address> <mac-address> "
+ .short_help = "ip neighbor [del] [flush] <intfc> <ip-address> <mac-address> "
"[static] [no-fib-entry] [count <count>]",
.function = ip_neighbor_cmd,
};