summaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/nat_test.c
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2020-07-06 09:20:01 +0000
committerMatthew Smith <mgsmith@netgate.com>2020-08-31 21:52:42 +0000
commitedc816355a999df476074881ae8ed927cad88532 (patch)
tree76845b254e8801593a7ca2e53b6bc489b66aa810 /src/plugins/nat/nat_test.c
parentb59095f830fbacbe2631dbbaa92f8e9606184015 (diff)
nat: fix type in api message
Translation memory size is internally a uword, but in api it was u32, resulting in the returned value being 0 all the time. Fix the "incorrect" API reply to return a u32 capped to 0xffffffff if the u64 is larger than that, introduce the message with the correct type, deprecate the message with the incorrect type. Also, while we are updating the message definition, add the max translations / max users per worker thread into the new message. Type: fix Signed-off-by: Klement Sekera <ksekera@cisco.com> Change-Id: I92e38a6a2bcb70fc8d1b129bbe416bf7f9e54280 Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
Diffstat (limited to 'src/plugins/nat/nat_test.c')
-rw-r--r--src/plugins/nat/nat_test.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/plugins/nat/nat_test.c b/src/plugins/nat/nat_test.c
index 0cc34f0b3f1..228d5b58157 100644
--- a/src/plugins/nat/nat_test.c
+++ b/src/plugins/nat/nat_test.c
@@ -102,6 +102,7 @@ _(NAT44_ADD_DEL_STATIC_MAPPING_REPLY, \
_(NAT_CONTROL_PING_REPLY, nat_control_ping_reply) \
_(NAT44_STATIC_MAPPING_DETAILS, nat44_static_mapping_details) \
_(NAT_SHOW_CONFIG_REPLY, nat_show_config_reply) \
+_(NAT_SHOW_CONFIG_2_REPLY, nat_show_config_2_reply) \
_(NAT44_ADDRESS_DETAILS, nat44_address_details) \
_(NAT44_INTERFACE_DETAILS, nat44_interface_details) \
_(NAT_SET_WORKERS_REPLY, nat_set_workers_reply) \
@@ -467,6 +468,37 @@ static void vl_api_nat_show_config_reply_t_handler
vam->result_ready = 1;
}
+static void vl_api_nat_show_config_2_reply_t_handler
+ (vl_api_nat_show_config_2_reply_t *mp)
+{
+ snat_test_main_t * sm = &snat_test_main;
+ vat_main_t *vam = sm->vat_main;
+ i32 retval = ntohl (mp->retval);
+
+ if (retval >= 0)
+ {
+ fformat (vam->ofp, "translation hash buckets %d\n",
+ ntohl (mp->translation_buckets));
+ fformat (vam->ofp, "translation hash memory %d\n",
+ ntohl (mp->translation_memory_size));
+ fformat (vam->ofp, "user hash buckets %d\n", ntohl (mp->user_buckets));
+ fformat (vam->ofp, "user hash memory %d\n", ntohl (mp->user_memory_size));
+ fformat (vam->ofp, "max translations per user %d\n",
+ ntohl (mp->max_translations_per_user));
+ fformat (vam->ofp, "outside VRF id %d\n", ntohl (mp->outside_vrf_id));
+ fformat (vam->ofp, "inside VRF id %d\n", ntohl (mp->inside_vrf_id));
+ if (mp->static_mapping_only)
+ {
+ fformat (vam->ofp, "static mapping only");
+ if (mp->static_mapping_connection_tracking)
+ fformat (vam->ofp, " connection tracking");
+ fformat (vam->ofp, "\n");
+ }
+ }
+ vam->retval = retval;
+ vam->result_ready = 1;
+}
+
static int api_nat_show_config(vat_main_t * vam)
{
vl_api_nat_show_config_t * mp;
@@ -484,6 +516,23 @@ static int api_nat_show_config(vat_main_t * vam)
return ret;
}
+static int api_nat_show_config_2(vat_main_t * vam)
+{
+ vl_api_nat_show_config_2_t * mp;
+ int ret;
+
+ if (vam->json_output)
+ {
+ clib_warning ("JSON output not supported for nat_show_config_2");
+ return -99;
+ }
+
+ M(NAT_SHOW_CONFIG_2, mp);
+ S(mp);
+ W (ret);
+ return ret;
+}
+
static void vl_api_nat44_address_details_t_handler
(vl_api_nat44_address_details_t *mp)
{
@@ -904,6 +953,7 @@ _(nat44_add_del_static_mapping, "local_addr <ip>" \
_(nat_set_workers, "<wokrers_bitmap>") \
_(nat44_static_mapping_dump, "") \
_(nat_show_config, "") \
+_(nat_show_config_2, "") \
_(nat44_address_dump, "") \
_(nat44_interface_dump, "") \
_(nat_worker_dump, "") \