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 <ot@cisco.com>
diff --git a/vnet/vnet/classify/vnet_classify.c b/vnet/vnet/classify/vnet_classify.c
index a9d6049..e179045 100644
--- a/vnet/vnet/classify/vnet_classify.c
+++ b/vnet/vnet/classify/vnet_classify.c
@@ -2090,9 +2090,9 @@
VLIB_CLI_COMMAND (classify_session_command, static) = {
.path = "classify session",
- .short_help =
- "classify session [hit-next|l2-hit-next|acl-hit-next <next_index>|"
- "policer-hit-next <policer_name>]"
+ .short_help =
+ "classify session [hit-next|l2-hit-next|"
+ "acl-hit-next <next_index>|policer-hit-next <policer_name>]"
"\n table-index <nn> match [hex] [l2] [l3 ip4] [opaque-index <index>]",
.function = classify_session_command_fn,
};
@@ -2112,27 +2112,31 @@
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 @@
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