From 1e66d5c54b81b8d6290153f1b3c2b021c4b62fad Mon Sep 17 00:00:00 2001 From: Ole Troan Date: Fri, 30 Sep 2016 09:22:36 +0200 Subject: [PATCH] VPP-213: vnet classifier does not work for l3 ip4 rules The classifier was written with the assumption that next-indicies of IP4 and IP6 IP_LOOKUP_NEXT nodes are equal. That's not true, and this patch splits the classifier session for IP4 and IP6. Change-Id: Id0368f17bb1d3f145b771d2dc283b56871264e99 Signed-off-by: Ole Troan --- vnet/vnet/classify/vnet_classify.c | 60 +++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/vnet/vnet/classify/vnet_classify.c b/vnet/vnet/classify/vnet_classify.c index a9d60494ca3..e179045814c 100644 --- a/vnet/vnet/classify/vnet_classify.c +++ b/vnet/vnet/classify/vnet_classify.c @@ -2090,9 +2090,9 @@ classify_session_command_fn (vlib_main_t * vm, VLIB_CLI_COMMAND (classify_session_command, static) = { .path = "classify session", - .short_help = - "classify session [hit-next|l2-hit-next|acl-hit-next |" - "policer-hit-next ]" + .short_help = + "classify session [hit-next|l2-hit-next|" + "acl-hit-next |policer-hit-next ]" "\n table-index match [hex] [l2] [l3 ip4] [opaque-index ]", .function = classify_session_command_fn, }; @@ -2112,27 +2112,31 @@ unformat_opaque_sw_if_index (unformat_input_t * input, va_list * args) return 0; } -static uword +static uword unformat_ip_next_node (unformat_input_t * input, va_list * args) { vnet_classify_main_t * cm = &vnet_classify_main; u32 * next_indexp = va_arg (*args, u32 *); u32 node_index; - u32 next_index, rv; + u32 next_index = ~0; - if (unformat (input, "node %U", unformat_vlib_node, + if (unformat (input, "ip6-node %U", unformat_vlib_node, cm->vlib_main, &node_index)) { - rv = next_index = vlib_node_add_next - (cm->vlib_main, ip4_classify_node.index, node_index); - next_index = vlib_node_add_next - (cm->vlib_main, ip6_classify_node.index, node_index); - ASSERT(rv == next_index); - - *next_indexp = next_index; - return 1; + next_index = vlib_node_add_next (cm->vlib_main, + ip6_classify_node.index, node_index); } - return 0; + else if (unformat (input, "ip4-node %U", unformat_vlib_node, + cm->vlib_main, &node_index)) + { + next_index = vlib_node_add_next (cm->vlib_main, + ip4_classify_node.index, node_index); + } + else + return 0; + + *next_indexp = next_index; + return 1; } static uword @@ -2141,21 +2145,25 @@ unformat_acl_next_node (unformat_input_t * input, va_list * args) vnet_classify_main_t * cm = &vnet_classify_main; u32 * next_indexp = va_arg (*args, u32 *); u32 node_index; - u32 next_index, rv; + u32 next_index; - if (unformat (input, "node %U", unformat_vlib_node, + if (unformat (input, "ip6-node %U", unformat_vlib_node, cm->vlib_main, &node_index)) { - rv = next_index = vlib_node_add_next - (cm->vlib_main, ip4_inacl_node.index, node_index); - next_index = vlib_node_add_next - (cm->vlib_main, ip6_inacl_node.index, node_index); - ASSERT(rv == next_index); - - *next_indexp = next_index; - return 1; + next_index = vlib_node_add_next (cm->vlib_main, + ip6_inacl_node.index, node_index); } - return 0; + else if (unformat (input, "ip4-node %U", unformat_vlib_node, + cm->vlib_main, &node_index)) + { + next_index = vlib_node_add_next (cm->vlib_main, + ip4_inacl_node.index, node_index); + } + else + return 0; + + *next_indexp = next_index; + return 1; } static uword -- 2.16.6