diff options
Diffstat (limited to 'src/plugins/snat')
-rw-r--r-- | src/plugins/snat/snat.api | 2 | ||||
-rw-r--r-- | src/plugins/snat/snat.c | 2 | ||||
-rw-r--r-- | src/plugins/snat/snat_test.c | 16 |
3 files changed, 20 insertions, 0 deletions
diff --git a/src/plugins/snat/snat.api b/src/plugins/snat/snat.api index 8ff69b25742..612830f9a6e 100644 --- a/src/plugins/snat/snat.api +++ b/src/plugins/snat/snat.api @@ -387,12 +387,14 @@ define snat_user_details { /** \brief S-NAT user's sessions @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request + @param is_ip4 - 1 if address type is IPv4 @param user_ip - IP address of the user to dump @param vrf_id - VRF_ID */ define snat_user_session_dump { u32 client_index; u32 context; + u8 is_ip4; u8 ip_address[16]; u32 vrf_id; }; diff --git a/src/plugins/snat/snat.c b/src/plugins/snat/snat.c index 1cf2b0c5cee..fc9f58687e4 100644 --- a/src/plugins/snat/snat.c +++ b/src/plugins/snat/snat.c @@ -1539,6 +1539,8 @@ vl_api_snat_user_session_dump_t_handler q = vl_api_client_index_to_input_queue (mp->client_index); if (q == 0) return; + if (!mp->is_ip4) + return; clib_memcpy (&ukey.addr, mp->ip_address, 4); ukey.fib_index = ip4_fib_index_from_table_id (ntohl(mp->vrf_id)); diff --git a/src/plugins/snat/snat_test.c b/src/plugins/snat/snat_test.c index c60554b21d5..39db45cd8be 100644 --- a/src/plugins/snat/snat_test.c +++ b/src/plugins/snat/snat_test.c @@ -667,8 +667,11 @@ static void vl_api_snat_user_session_details_t_handler static int api_snat_user_session_dump(vat_main_t * vam) { + unformat_input_t* i = vam->input; vl_api_snat_user_session_dump_t * mp; vl_api_snat_control_ping_t *mp_ping; + ip4_address_t addr; + u32 vrf_id = ~0; int ret; if (vam->json_output) @@ -677,11 +680,24 @@ static int api_snat_user_session_dump(vat_main_t * vam) return -99; } + if (unformat (i, "ip_address %U vrf_id %d", + unformat_ip4_address, &addr, &vrf_id)) + ; + else + { + clib_warning("unknown input '%U'", format_unformat_error, i); + return -99; + } + M(SNAT_USER_SESSION_DUMP, mp); S(mp); /* Use a control ping for synchronization */ M(SNAT_CONTROL_PING, mp_ping); + memset(mp->ip_address, 0, 16); + clib_memcpy(mp->ip_address, &addr, 4); + mp->vrf_id = htonl(vrf_id); + mp->is_ip4 = 1; S(mp_ping); W (ret); |