aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/ip/lookup.c
diff options
context:
space:
mode:
authorAloys Augustin <aloaugus@cisco.com>2021-09-16 20:53:14 +0200
committerNeale Ranns <neale@graphiant.com>2021-09-22 09:02:18 +0000
commit6e4cfb506806a0e214a5498952c2587e128b4870 (patch)
treeaed045509ce249c8a8d0a05468dad25bd316360e /src/vnet/ip/lookup.c
parentc3b62d1d132453390644171673ffbcd775d19850 (diff)
ip: add ip_table_allocate to api
Set tableID = ~0 for auto selection unused ID https://jira.fd.io/browse/VPP-1993 Type: improvement Change-Id: I4eec2cc1d18fc025196cb6ac4c9a4b374388eb56 Signed-off-by: Artem Glazychev <artem.glazychev@xored.com> Signed-off-by: Aloys Augustin <aloaugus@cisco.com>
Diffstat (limited to 'src/vnet/ip/lookup.c')
-rw-r--r--src/vnet/ip/lookup.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/vnet/ip/lookup.c b/src/vnet/ip/lookup.c
index 1753ffd9232..5db14bac092 100644
--- a/src/vnet/ip/lookup.c
+++ b/src/vnet/ip/lookup.c
@@ -399,27 +399,32 @@ vnet_ip_table_cmd (vlib_main_t * vm,
}
}
- if (~0 == table_id)
- {
- error = clib_error_return (0, "No table id");
- goto done;
- }
- else if (0 == table_id)
+ if (0 == table_id)
{
error = clib_error_return (0, "Can't change the default table");
goto done;
}
else
- {
- if (is_add)
{
- ip_table_create (fproto, table_id, 0, name);
- }
- else
- {
- ip_table_delete (fproto, table_id, 0);
+ if (is_add)
+ {
+ if (~0 == table_id)
+ {
+ table_id = ip_table_get_unused_id (fproto);
+ vlib_cli_output (vm, "%u\n", table_id);
+ }
+ ip_table_create (fproto, table_id, 0, name);
+ }
+ else
+ {
+ if (~0 == table_id)
+ {
+ error = clib_error_return (0, "No table id");
+ goto done;
+ }
+ ip_table_delete (fproto, table_id, 0);
+ }
}
- }
done:
unformat_free (line_input);