aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuraj Sloboda <jsloboda@cisco.com>2016-12-06 21:25:19 +0100
committerDamjan Marion <dmarion.lists@gmail.com>2016-12-07 09:42:18 +0000
commit288e8930ee7f1cf4980c06c167ef4e0cdf559528 (patch)
tree1078c0a14d6545729bdcadbf5bba1a2b07294b6a
parent32575801c97073285771a26d076876ea88bfbdf8 (diff)
Make table chain deletion optional in classifier API (VPP-206)
Change-Id: If30c0f6d5de34943bc399b3412c2d10847538c3c Signed-off-by: Juraj Sloboda <jsloboda@cisco.com>
-rw-r--r--plugins/acl-plugin/acl/acl.c6
-rw-r--r--vnet/vnet/classify/vnet_classify.c25
-rw-r--r--vnet/vnet/classify/vnet_classify.h3
-rw-r--r--vpp-api-test/vat/api_format.c9
-rw-r--r--vpp/vpp-api/api.c2
-rw-r--r--vpp/vpp-api/custom_dump.c2
-rw-r--r--vpp/vpp-api/vpe.api2
7 files changed, 35 insertions, 14 deletions
diff --git a/plugins/acl-plugin/acl/acl.c b/plugins/acl-plugin/acl/acl.c
index 149f006d46c..6b7f637b1d3 100644
--- a/plugins/acl-plugin/acl/acl.c
+++ b/plugins/acl-plugin/acl/acl.c
@@ -416,7 +416,8 @@ acl_classify_add_del_table_big (vnet_classify_main_t * cm, u8 * mask,
memory_size, skip, match,
next_table_index, miss_next_index,
table_index, current_data_flag,
- current_data_offset, is_add);
+ current_data_offset, is_add,
+ 1 /* delete_chain */);
}
static int
@@ -440,7 +441,8 @@ acl_classify_add_del_table_small (vnet_classify_main_t * cm, u8 * mask,
memory_size, skip, match,
next_table_index, miss_next_index,
table_index, current_data_flag,
- current_data_offset, is_add);
+ current_data_offset, is_add,
+ 1 /* delete_chain */);
}
diff --git a/vnet/vnet/classify/vnet_classify.c b/vnet/vnet/classify/vnet_classify.c
index d7a0d815e5c..ce38f9f173e 100644
--- a/vnet/vnet/classify/vnet_classify.c
+++ b/vnet/vnet/classify/vnet_classify.c
@@ -142,7 +142,7 @@ vnet_classify_new_table (vnet_classify_main_t *cm,
}
void vnet_classify_delete_table_index (vnet_classify_main_t *cm,
- u32 table_index)
+ u32 table_index, int del_chain)
{
vnet_classify_table_t * t;
@@ -151,8 +151,9 @@ void vnet_classify_delete_table_index (vnet_classify_main_t *cm,
return;
t = pool_elt_at_index (cm->tables, table_index);
- if (t->next_table_index != ~0)
- vnet_classify_delete_table_index (cm, t->next_table_index);
+ if (del_chain && t->next_table_index != ~0)
+ /* Recursively delete the entire chain */
+ vnet_classify_delete_table_index (cm, t->next_table_index, del_chain);
vec_free (t->mask);
vec_free (t->buckets);
@@ -656,7 +657,8 @@ int vnet_classify_add_del_table (vnet_classify_main_t * cm,
u32 * table_index,
u8 current_data_flag,
i16 current_data_offset,
- int is_add)
+ int is_add,
+ int del_chain)
{
vnet_classify_table_t * t;
@@ -688,7 +690,7 @@ int vnet_classify_add_del_table (vnet_classify_main_t * cm,
return 0;
}
- vnet_classify_delete_table_index (cm, *table_index);
+ vnet_classify_delete_table_index (cm, *table_index, del_chain);
return 0;
}
@@ -1385,6 +1387,7 @@ classify_table_command_fn (vlib_main_t * vm,
u32 skip = ~0;
u32 match = ~0;
int is_add = 1;
+ int del_chain = 0;
u32 table_index = ~0;
u32 next_table_index = ~0;
u32 miss_next_index = ~0;
@@ -1400,6 +1403,11 @@ classify_table_command_fn (vlib_main_t * vm,
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
if (unformat (input, "del"))
is_add = 0;
+ else if (unformat (input, "del-chain"))
+ {
+ is_add = 0;
+ del_chain = 1;
+ }
else if (unformat (input, "buckets %d", &nbuckets))
;
else if (unformat (input, "skip %d", &skip))
@@ -1451,8 +1459,8 @@ classify_table_command_fn (vlib_main_t * vm,
return clib_error_return (0, "table index required for delete");
rv = vnet_classify_add_del_table (cm, mask, nbuckets, memory_size,
- skip, match, next_table_index, miss_next_index,
- &table_index, current_data_flag, current_data_offset, is_add);
+ skip, match, next_table_index, miss_next_index, &table_index,
+ current_data_flag, current_data_offset, is_add, del_chain);
switch (rv)
{
case 0:
@@ -1470,7 +1478,8 @@ VLIB_CLI_COMMAND (classify_table, static) = {
.short_help =
"classify table [miss-next|l2-miss_next|acl-miss-next <next_index>]"
"\n mask <mask-value> buckets <nn> [skip <n>] [match <n>]"
- "\n [current-data-flag <n>] [current-data-offset <n>] [table <n>] [del]",
+ "\n [current-data-flag <n>] [current-data-offset <n>] [table <n>]"
+ "\n [del] [del-chain]",
.function = classify_table_command_fn,
};
diff --git a/vnet/vnet/classify/vnet_classify.h b/vnet/vnet/classify/vnet_classify.h
index ed8442b3dce..d0b896ed7d2 100644
--- a/vnet/vnet/classify/vnet_classify.h
+++ b/vnet/vnet/classify/vnet_classify.h
@@ -489,7 +489,8 @@ int vnet_classify_add_del_table (vnet_classify_main_t * cm,
u32 * table_index,
u8 current_data_flag,
i16 current_data_offset,
- int is_add);
+ int is_add,
+ int del_chain);
unformat_function_t unformat_ip4_mask;
unformat_function_t unformat_ip6_mask;
diff --git a/vpp-api-test/vat/api_format.c b/vpp-api-test/vat/api_format.c
index 344259b88cd..c6e5ac8d1da 100644
--- a/vpp-api-test/vat/api_format.c
+++ b/vpp-api-test/vat/api_format.c
@@ -8891,6 +8891,7 @@ api_classify_add_del_table (vat_main_t * vam)
u32 skip = ~0;
u32 match = ~0;
int is_add = 1;
+ int del_chain = 0;
u32 table_index = ~0;
u32 next_table_index = ~0;
u32 miss_next_index = ~0;
@@ -8904,6 +8905,11 @@ api_classify_add_del_table (vat_main_t * vam)
{
if (unformat (i, "del"))
is_add = 0;
+ else if (unformat (i, "del-chain"))
+ {
+ is_add = 0;
+ del_chain = 1;
+ }
else if (unformat (i, "buckets %d", &nbuckets))
;
else if (unformat (i, "memory_size %d", &memory_size))
@@ -8963,6 +8969,7 @@ api_classify_add_del_table (vat_main_t * vam)
M2 (CLASSIFY_ADD_DEL_TABLE, classify_add_del_table, vec_len (mask));
mp->is_add = is_add;
+ mp->del_chain = del_chain;
mp->table_index = ntohl (table_index);
mp->nbuckets = ntohl (nbuckets);
mp->memory_size = ntohl (memory_size);
@@ -17485,7 +17492,7 @@ _(sr_multicast_map_add_del, \
"address [ip6 multicast address] sr-policy [policy name] [del]") \
_(classify_add_del_table, \
"buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
- " [del] mask <mask-value>\n" \
+ " [del] [del-chain] mask <mask-value>\n" \
" [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
" [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
_(classify_add_del_session, \
diff --git a/vpp/vpp-api/api.c b/vpp/vpp-api/api.c
index 7e90f74dab1..967e6327ae4 100644
--- a/vpp/vpp-api/api.c
+++ b/vpp/vpp-api/api.c
@@ -2499,7 +2499,7 @@ static void vl_api_classify_add_del_table_t_handler
(cm, mp->mask, nbuckets, memory_size,
skip_n_vectors, match_n_vectors,
next_table_index, miss_next_index, &table_index,
- current_data_flag, current_data_offset, mp->is_add);
+ current_data_flag, current_data_offset, mp->is_add, mp->del_chain);
out:
/* *INDENT-OFF* */
diff --git a/vpp/vpp-api/custom_dump.c b/vpp/vpp-api/custom_dump.c
index 82195f60ca8..bfebf49fdd8 100644
--- a/vpp/vpp-api/custom_dump.c
+++ b/vpp/vpp-api/custom_dump.c
@@ -1179,7 +1179,7 @@ static void *vl_api_classify_add_del_table_t_print
if (mp->is_add == 0)
{
s = format (s, "table %d ", ntohl (mp->table_index));
- s = format (s, "del ");
+ s = format (s, "%s ", mp->del_chain ? "del-chain" : "del");
}
else
{
diff --git a/vpp/vpp-api/vpe.api b/vpp/vpp-api/vpe.api
index b1760fd14f0..537f5688301 100644
--- a/vpp/vpp-api/vpe.api
+++ b/vpp/vpp-api/vpe.api
@@ -1211,6 +1211,7 @@ define bd_ip_mac_add_del_reply
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@param is_add- if non-zero add the table, else delete it
+ @param del_chain - if non-zero delete the whole chain of tables
@param table_index - if add, reuturns index of the created table, else specifies the table to delete
@param nbuckets - number of buckets when adding a table
@param memory_size - memory size when adding a table
@@ -1235,6 +1236,7 @@ define classify_add_del_table
u32 client_index;
u32 context;
u8 is_add;
+ u8 del_chain;
u32 table_index;
u32 nbuckets;
u32 memory_size;