diff options
Diffstat (limited to 'nsh-plugin')
-rw-r--r-- | nsh-plugin/nsh/nsh.c | 62 | ||||
-rw-r--r-- | nsh-plugin/nsh/nsh.h | 11 |
2 files changed, 69 insertions, 4 deletions
diff --git a/nsh-plugin/nsh/nsh.c b/nsh-plugin/nsh/nsh.c index c26c228..9d16335 100644 --- a/nsh-plugin/nsh/nsh.c +++ b/nsh-plugin/nsh/nsh.c @@ -998,6 +998,10 @@ nsh_input_map (vlib_main_t * vm, nsp_nsi0 = clib_net_to_host_u32(hdr0->nsp_nsi); header_len0 = hdr0->length * 4; } + else if(node_type == NSH_CLASSIFIER_TYPE) + { + nsp_nsi0 = vnet_buffer(b0)->l2_classify.opaque_index; + } else { memset (&key0, 0, sizeof(key0)); @@ -1029,6 +1033,10 @@ nsh_input_map (vlib_main_t * vm, nsp_nsi1 = clib_net_to_host_u32(hdr1->nsp_nsi); header_len1 = hdr1->length * 4; } + else if(node_type == NSH_CLASSIFIER_TYPE) + { + nsp_nsi1 = vnet_buffer(b1)->l2_classify.opaque_index; + } else { memset (&key1, 0, sizeof(key1)); @@ -1223,6 +1231,10 @@ nsh_input_map (vlib_main_t * vm, nsp_nsi0 = clib_net_to_host_u32(hdr0->nsp_nsi); header_len0 = hdr0->length * 4; } + else if(node_type == NSH_CLASSIFIER_TYPE) + { + nsp_nsi0 = vnet_buffer(b0)->l2_classify.opaque_index; + } else { memset (&key0, 0, sizeof(key0)); @@ -1359,6 +1371,24 @@ nsh_proxy (vlib_main_t * vm, vlib_node_runtime_t * node, return nsh_input_map (vm, node, from_frame, NSH_PROXY_TYPE); } +/** + * @brief Graph processing dispatch function for NSH Classifier + * + * @node nsh_classifier + * @param *vm + * @param *node + * @param *from_frame + * + * @return from_frame->n_vectors + * + */ +static uword +nsh_classifier (vlib_main_t * vm, vlib_node_runtime_t * node, + vlib_frame_t * from_frame) +{ + return nsh_input_map (vm, node, from_frame, NSH_CLASSIFIER_TYPE); +} + static char * nsh_node_error_strings[] = { #define _(sym,string) string, foreach_nsh_node_error @@ -1411,6 +1441,29 @@ VLIB_REGISTER_NODE (nsh_proxy_node) = { VLIB_NODE_FUNCTION_MULTIARCH (nsh_proxy_node, nsh_proxy); +/* register nsh-classifier node */ +VLIB_REGISTER_NODE (nsh_classifier_node) = { + .function = nsh_classifier, + .name = "nsh-classifier", + .vector_size = sizeof (u32), + .format_trace = format_nsh_node_map_trace, + .format_buffer = format_nsh_header_with_length, + .type = VLIB_NODE_TYPE_INTERNAL, + + .n_errors = ARRAY_LEN(nsh_node_error_strings), + .error_strings = nsh_node_error_strings, + + .n_next_nodes = NSH_NODE_N_NEXT, + + .next_nodes = { +#define _(s,n) [NSH_NODE_NEXT_##s] = n, + foreach_nsh_node_next +#undef _ + }, +}; + +VLIB_NODE_FUNCTION_MULTIARCH (nsh_classifier_node, nsh_classifier); + clib_error_t *nsh_init (vlib_main_t *vm) { nsh_main_t *nm = &nsh_main; @@ -1471,6 +1524,15 @@ clib_error_t *nsh_init (vlib_main_t *vm) ASSERT(vxlan6_input_node); vlib_node_add_next (vm, vxlan6_input_node->index, nsh_proxy_node.index); + /* Add NSH-Classifier support */ + ip4_classify_node = vlib_get_node_by_name (vm, (u8 *)"ip4-classify"); + ASSERT(ip4_classify_node); + vlib_node_add_next (vm, ip4_classify_node->index, nsh_classifier_node.index); + + ip6_classify_node = vlib_get_node_by_name (vm, (u8 *)"ip6-classify"); + ASSERT(ip6_classify_node); + vlib_node_add_next (vm, ip6_classify_node->index, nsh_classifier_node.index); + vec_free(name); return error; diff --git a/nsh-plugin/nsh/nsh.h b/nsh-plugin/nsh/nsh.h index 781245b..7a8e54e 100644 --- a/nsh-plugin/nsh/nsh.h +++ b/nsh-plugin/nsh/nsh.h @@ -100,6 +100,8 @@ nsh_main_t nsh_main; vlib_node_t * vxlan4_input_node = 0; vlib_node_t * vxlan6_input_node = 0; +vlib_node_t * ip4_classify_node = 0; +vlib_node_t * ip6_classify_node = 0; u8 * format_nsh_input_map_trace (u8 * s, va_list * args); u8 * format_nsh_header_with_length (u8 * s, va_list * args); @@ -161,12 +163,13 @@ typedef enum { typedef enum { NSH_ACTION_SWAP, NSH_ACTION_PUSH, - NSH_ACTION_POP -}; + NSH_ACTION_POP, +} nsh_action_type; typedef enum { NSH_INPUT_TYPE, - NSH_PROXY_TYPE -}; + NSH_PROXY_TYPE, + NSH_CLASSIFIER_TYPE, +} nsh_entity_type; #endif /* included_nsh_h */ |