diff options
author | Keith Burns (alagalah) <alagalah@gmail.com> | 2016-07-19 14:47:43 -0700 |
---|---|---|
committer | Keith Burns (alagalah) <alagalah@gmail.com> | 2016-07-19 14:47:43 -0700 |
commit | c61080e76c9771de6f2beaba23fabe3aa4764a9b (patch) | |
tree | 254a447737a2c2797252629fc56e7f1a9a5c9b0e /vpp | |
parent | 3b2944d5f1bc7b42b31293d0d19f36b237490cd6 (diff) |
VPP-203 Find the relative next node index by node names
vat# get_next_index node-name vxlan4-input next-node-name l2-input
next node index 1
Change-Id: Ib71be8a408d08d59b0ed7dfb6ada9711cf29bd69
Signed-off-by: Keith Burns (alagalah) <alagalah@gmail.com>
Diffstat (limited to 'vpp')
-rw-r--r-- | vpp/vpp-api/api.c | 45 | ||||
-rw-r--r-- | vpp/vpp-api/custom_dump.c | 17 | ||||
-rw-r--r-- | vpp/vpp-api/vpe.api | 24 |
3 files changed, 83 insertions, 3 deletions
diff --git a/vpp/vpp-api/api.c b/vpp/vpp-api/api.c index f3909287..f6b1b739 100644 --- a/vpp/vpp-api/api.c +++ b/vpp/vpp-api/api.c @@ -368,7 +368,8 @@ _(CLASSIFY_TABLE_INFO,classify_table_info) \ _(CLASSIFY_SESSION_DUMP,classify_session_dump) \ _(CLASSIFY_SESSION_DETAILS,classify_session_details) \ _(IPFIX_ENABLE,ipfix_enable) \ -_(IPFIX_DUMP,ipfix_dump) +_(IPFIX_DUMP,ipfix_dump) \ +_(GET_NEXT_INDEX, get_next_index) #define QUOTE_(x) #x #define QUOTE(x) QUOTE_(x) @@ -4243,6 +4244,48 @@ static void vl_api_get_node_index_t_handler })) } +static void vl_api_get_next_index_t_handler +(vl_api_get_next_index_t * mp) +{ + vlib_main_t * vm = vlib_get_main(); + vl_api_get_next_index_reply_t * rmp; + vlib_node_t * node, * next_node; + int rv = 0; + u32 next_node_index = ~0, next_index = ~0; + uword * p; + + node = vlib_get_node_by_name (vm, mp->node_name); + + if (node == 0) { + rv = VNET_API_ERROR_NO_SUCH_NODE; + goto out; + } + + next_node = vlib_get_node_by_name (vm, mp->next_name); + + if (next_node == 0) { + rv = VNET_API_ERROR_NO_SUCH_NODE2; + goto out; + } + else + next_node_index = next_node->index; + + p = hash_get (node->next_slot_by_node, next_node_index); + + if (p == 0) { + rv = VNET_API_ERROR_NO_SUCH_ENTRY; + goto out; + } + else + next_index = p[0]; + + out: + REPLY_MACRO2(VL_API_GET_NEXT_INDEX_REPLY, + ({ + rmp->next_index = ntohl(next_index); + })); +} + static void vl_api_add_node_next_t_handler (vl_api_add_node_next_t * mp) { diff --git a/vpp/vpp-api/custom_dump.c b/vpp/vpp-api/custom_dump.c index 9967d5b9..4e8b0642 100644 --- a/vpp/vpp-api/custom_dump.c +++ b/vpp/vpp-api/custom_dump.c @@ -1875,6 +1875,18 @@ static void *vl_api_ipfix_dump_t_print FINISH; } +static void *vl_api_get_next_index_t_print +(vl_api_get_next_index_t * mp, void *handle) +{ + u8 * s; + + s = format (0, "SCRIPT: get_next_index "); + s = format (s, "node-name %s ", mp->node_name); + s = format (s, "next-node-name %s ", mp->next_name); + + FINISH; +} + #define foreach_custom_print_function \ _(CREATE_LOOPBACK, create_loopback) \ _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \ @@ -1972,9 +1984,10 @@ _(CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface) \ _(CLASSIFY_TABLE_INFO,classify_table_info) \ _(CLASSIFY_SESSION_DUMP,classify_session_dump) \ _(IPFIX_ENABLE,ipfix_enable) \ -_(IPFIX_DUMP,ipfix_dump) +_(IPFIX_DUMP,ipfix_dump) \ +_(GET_NEXT_INDEX, get_next_index) -void vl_msg_api_custom_dump_configure (api_main_t *am) +void vl_msg_api_custom_dump_configure (api_main_t *am) { #define _(n,f) am->msg_print_handlers[VL_API_##n] \ = (void *) vl_api_##f##_t_print; diff --git a/vpp/vpp-api/vpe.api b/vpp/vpp-api/vpe.api index dd50d840..25e6ebaa 100644 --- a/vpp/vpp-api/vpe.api +++ b/vpp/vpp-api/vpe.api @@ -4087,3 +4087,27 @@ manual_java define ipfix_details { u32 path_mtu; u32 template_interval; }; + +/** \brief Query relative index via node names + @param client_index - opaque cookie to identify the sender + @param context - sender context, to match reply w/ request + @param node_name - name of node to find relative index from + @param next_name - next node from node_name to find relative index of +*/ +define get_next_index { + u32 client_index; + u32 context; + u8 node_name[64]; + u8 next_name[64]; +}; + +/** \brief Reply for get next node index + @param context - sender context which was passed in the request + @param retval - return value + @param next_index - index of the next_node +*/ +define get_next_index_reply { + u32 context; + i32 retval; + u32 next_index; +}; |