diff options
-rw-r--r-- | vnet/vnet/vxlan/vxlan.c | 5 | ||||
-rw-r--r-- | vnet/vnet/vxlan/vxlan.h | 3 | ||||
-rw-r--r-- | vpp-api-test/Makefile.am | 1 | ||||
-rw-r--r-- | vpp-api-test/scripts/vppctl | 2 | ||||
-rw-r--r-- | vpp-api-test/vat/api_format.c | 82 | ||||
-rw-r--r-- | vpp/api/api.c | 50 | ||||
-rw-r--r-- | vpp/api/custom_dump.c | 13 | ||||
-rw-r--r-- | vpp/api/vpe.api | 18 |
8 files changed, 170 insertions, 4 deletions
diff --git a/vnet/vnet/vxlan/vxlan.c b/vnet/vnet/vxlan/vxlan.c index 75cbc6c6499..316f8cb1907 100644 --- a/vnet/vnet/vxlan/vxlan.c +++ b/vnet/vnet/vxlan/vxlan.c @@ -218,6 +218,9 @@ int vnet_vxlan_add_del_tunnel t->hw_if_index = hw_if_index; t->sw_if_index = sw_if_index = hi->sw_if_index; + vec_validate_init_empty (vxm->tunnel_index_by_sw_if_index, sw_if_index, ~0); + vxm->tunnel_index_by_sw_if_index[sw_if_index] = t - vxm->tunnels; + if (a->decap_next_index == VXLAN_INPUT_NEXT_L2_INPUT) { l2input_main_t * l2im = &l2input_main; @@ -242,6 +245,8 @@ int vnet_vxlan_add_del_tunnel set_int_l2_mode(vxm->vlib_main, vnm, MODE_L3, t->sw_if_index, 0, 0, 0, 0); vec_add1 (vxm->free_vxlan_tunnel_hw_if_indices, t->hw_if_index); + vxm->tunnel_index_by_sw_if_index[t->sw_if_index] = ~0; + hash_unset (vxm->vxlan_tunnel_by_key, key.as_u64); vec_free (t->rewrite); diff --git a/vnet/vnet/vxlan/vxlan.h b/vnet/vnet/vxlan/vxlan.h index 5c82a3dfd9d..b38e65de4c1 100644 --- a/vnet/vnet/vxlan/vxlan.h +++ b/vnet/vnet/vxlan/vxlan.h @@ -102,6 +102,9 @@ typedef struct { u64 dummy_str [sizeof(ip4_vxlan_header_t)/sizeof(u64) + 2]; #define vxlan_dummy_rewrite ((u8 *) &vxlan_main.dummy_str[1]) + /* Mapping from sw_if_index to tunnel index */ + u32 * tunnel_index_by_sw_if_index; + /* convenience */ vlib_main_t * vlib_main; vnet_main_t * vnet_main; diff --git a/vpp-api-test/Makefile.am b/vpp-api-test/Makefile.am index ae071bcebe0..a818d831b28 100644 --- a/vpp-api-test/Makefile.am +++ b/vpp-api-test/Makefile.am @@ -32,4 +32,3 @@ vpe_json_test_LDADD = -lvppinfra -lm nobase_include_HEADERS = vat/vat.h vat/json_format.h -dist_bin_SCRIPTS = scripts/vppctl diff --git a/vpp-api-test/scripts/vppctl b/vpp-api-test/scripts/vppctl deleted file mode 100644 index b789493f2be..00000000000 --- a/vpp-api-test/scripts/vppctl +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -echo exec ${@} | vpe_api_test | sed 's/vat# //g' diff --git a/vpp-api-test/vat/api_format.c b/vpp-api-test/vat/api_format.c index 352a78a6a4a..a32756bdaaa 100644 --- a/vpp-api-test/vat/api_format.c +++ b/vpp-api-test/vat/api_format.c @@ -1880,6 +1880,7 @@ _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \ _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \ _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \ _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \ +_(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \ _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \ _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \ _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \ @@ -6555,6 +6556,86 @@ static int api_vxlan_add_del_tunnel (vat_main_t * vam) return 0; } +static void vl_api_vxlan_tunnel_details_t_handler +(vl_api_vxlan_tunnel_details_t * mp) +{ + vat_main_t * vam = &vat_main; + + fformat(vam->ofp, "%11d%13U%13U%14d%18d%13d\n", + ntohl(mp->sw_if_index), + format_ip4_address, &mp->src_address, + format_ip4_address, &mp->dst_address, + ntohl(mp->encap_vrf_id), + ntohl(mp->decap_next_index), + ntohl(mp->vni)); +} + +static void vl_api_vxlan_tunnel_details_t_handler_json +(vl_api_vxlan_tunnel_details_t * mp) +{ + vat_main_t * vam = &vat_main; + vat_json_node_t *node = NULL; + struct in_addr ip4; + + if (VAT_JSON_ARRAY != vam->json_tree.type) { + ASSERT(VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array(&vam->json_tree); + } + node = vat_json_array_add(&vam->json_tree); + + vat_json_init_object(node); + vat_json_object_add_uint(node, "sw_if_index", ntohl(mp->sw_if_index)); + memcpy(&ip4, &mp->src_address, sizeof(ip4)); + vat_json_object_add_ip4(node, "src_address", ip4); + memcpy(&ip4, &mp->dst_address, sizeof(ip4)); + vat_json_object_add_ip4(node, "dst_address", ip4); + vat_json_object_add_uint(node, "encap_vrf_id", ntohl(mp->encap_vrf_id)); + vat_json_object_add_uint(node, "decap_next_index", ntohl(mp->decap_next_index)); + vat_json_object_add_uint(node, "vni", ntohl(mp->vni)); +} + +static int api_vxlan_tunnel_dump (vat_main_t * vam) +{ + unformat_input_t * i = vam->input; + vl_api_vxlan_tunnel_dump_t *mp; + f64 timeout; + u32 sw_if_index; + u8 sw_if_index_set = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { + if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else + break; + } + + if (sw_if_index_set == 0) { + sw_if_index = ~0; + } + + if (!vam->json_output) { + fformat(vam->ofp, "%11s%13s%13s%14s%18s%13s\n", + "sw_if_index", "src_address", "dst_address", + "encap_vrf_id", "decap_next_index", "vni"); + } + + /* Get list of l2tpv3-tunnel interfaces */ + M(VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump); + + mp->sw_if_index = htonl(sw_if_index); + + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t * mp; + M(CONTROL_PING, control_ping); + S; + } + W; +} + static int api_l2_fib_clear_table (vat_main_t * vam) { // unformat_input_t * i = vam->input; @@ -8582,6 +8663,7 @@ _(sw_if_l2tpv3_tunnel_dump, "") \ _(vxlan_add_del_tunnel, \ "src <ip4-addr> dst <ip4-addr> vni [encap-vrf-id <nn>]\n" \ " [decap-next l2|ip4|ip6] [del]") \ +_(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \ _(l2_fib_clear_table, "") \ _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \ _(l2_interface_vlan_tag_rewrite, \ diff --git a/vpp/api/api.c b/vpp/api/api.c index 7bbb5c030cd..fe9267914ac 100644 --- a/vpp/api/api.c +++ b/vpp/api/api.c @@ -271,6 +271,7 @@ _(L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable) \ _(L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key) \ _(SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump) \ _(VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel) \ +_(VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump) \ _(L2_FIB_CLEAR_TABLE, l2_fib_clear_table) \ _(L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter) \ _(L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite) \ @@ -4118,6 +4119,55 @@ out: })); } +static void send_vxlan_tunnel_details +(vxlan_tunnel_t * t, unix_shared_memory_queue_t * q) +{ + vl_api_vxlan_tunnel_details_t * rmp; + ip4_main_t * im = &ip4_main; + + rmp = vl_msg_api_alloc (sizeof (*rmp)); + memset (rmp, 0, sizeof (*rmp)); + rmp->_vl_msg_id = ntohs(VL_API_VXLAN_TUNNEL_DETAILS); + rmp->src_address = t->src.data_u32; + rmp->dst_address = t->dst.data_u32; + rmp->encap_vrf_id = htonl(im->fibs[t->encap_fib_index].table_id); + rmp->vni = htonl(t->vni); + rmp->decap_next_index = htonl(t->decap_next_index); + rmp->sw_if_index = htonl(t->sw_if_index); + + vl_msg_api_send_shmem (q, (u8 *)&rmp); +} + +static void vl_api_vxlan_tunnel_dump_t_handler +(vl_api_vxlan_tunnel_dump_t * mp) +{ + unix_shared_memory_queue_t * q; + vxlan_main_t * vxm = &vxlan_main; + vxlan_tunnel_t * t; + u32 sw_if_index; + + q = vl_api_client_index_to_input_queue (mp->client_index); + if (q == 0) { + return; + } + + sw_if_index = ntohl(mp->sw_if_index); + + if (~0 == sw_if_index) { + pool_foreach (t, vxm->tunnels, + ({ + send_vxlan_tunnel_details(t, q); + })); + } else { + if ((sw_if_index >= vec_len(vxm->tunnel_index_by_sw_if_index)) || + (~0 == vxm->tunnel_index_by_sw_if_index[sw_if_index])) { + return; + } + t = &vxm->tunnels[vxm->tunnel_index_by_sw_if_index[sw_if_index]]; + send_vxlan_tunnel_details(t, q); + } +} + static void vl_api_l2_patch_add_del_t_handler (vl_api_l2_patch_add_del_t *mp) { diff --git a/vpp/api/custom_dump.c b/vpp/api/custom_dump.c index 784c9d24d91..85740eeeaab 100644 --- a/vpp/api/custom_dump.c +++ b/vpp/api/custom_dump.c @@ -1285,6 +1285,18 @@ static void * vl_api_vxlan_add_del_tunnel_t_print FINISH; } +static void * vl_api_vxlan_tunnel_dump_t_print +(vl_api_vxlan_tunnel_dump_t * mp, void *handle) +{ + u8 * s; + + s = format (0, "SCRIPT: vxlan_tunnel_dump "); + + s = format (s, "sw_if_index %d ", ntohl(mp->sw_if_index)); + + FINISH; +} + static void *vl_api_l2_fib_clear_table_t_print (vl_api_l2_fib_clear_table_t * mp, void *handle) { @@ -1737,6 +1749,7 @@ _(L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable) \ _(L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key) \ _(SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump) \ _(VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel) \ +_(VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump) \ _(L2_FIB_CLEAR_TABLE, l2_fib_clear_table) \ _(L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter) \ _(L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite) \ diff --git a/vpp/api/vpe.api b/vpp/api/vpe.api index 480558aa4c2..6b54ab82957 100644 --- a/vpp/api/vpe.api +++ b/vpp/api/vpe.api @@ -1854,6 +1854,22 @@ define vxlan_add_del_tunnel_reply { i32 retval; u32 sw_if_index; }; + +manual_java define vxlan_tunnel_dump { + u32 client_index; + u32 context; + u32 sw_if_index; +}; + +manual_java define vxlan_tunnel_details { + u32 context; + u32 sw_if_index; + u32 src_address; + u32 dst_address; + u32 encap_vrf_id; + u32 decap_next_index; + u32 vni; +}; /** \brief L2 interface vlan tag rewrite configure request @param client_index - opaque cookie to identify the sender @@ -2062,7 +2078,7 @@ manual_java define ip_address_details { u8 prefix_length; }; -define ip_address_dump { +manual_java define ip_address_dump { u32 client_index; u32 context; u32 sw_if_index; |