aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/nat_api.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_api.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_api.c')
-rw-r--r--src/plugins/nat/nat_api.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/src/plugins/nat/nat_api.c b/src/plugins/nat/nat_api.c
index 503143288f8..ad67375fb7a 100644
--- a/src/plugins/nat/nat_api.c
+++ b/src/plugins/nat/nat_api.c
@@ -104,7 +104,10 @@ vl_api_nat_show_config_t_handler (vl_api_nat_show_config_t * mp)
REPLY_MACRO2 (VL_API_NAT_SHOW_CONFIG_REPLY,
({
rmp->translation_buckets = htonl (sm->translation_buckets);
- rmp->translation_memory_size = clib_host_to_net_u64 (sm->translation_memory_size);
+ rmp->translation_memory_size = clib_host_to_net_u32 (
+ sm->translation_memory_size > 0xffffffffULL
+ ? 0xffffffffUL
+ : (u32)sm->translation_memory_size);
rmp->user_buckets = htonl (sm->user_buckets);
rmp->user_memory_size = clib_host_to_net_u64 (sm->user_memory_size);
rmp->max_translations_per_user = htonl (sm->max_translations_per_user);
@@ -136,6 +139,52 @@ vl_api_nat_show_config_t_print (vl_api_nat_show_config_t * mp, void *handle)
}
static void
+vl_api_nat_show_config_2_t_handler (vl_api_nat_show_config_2_t * mp)
+{
+ vl_api_nat_show_config_2_reply_t *rmp;
+ snat_main_t *sm = &snat_main;
+ //dslite_main_t *dm = &dslite_main;
+ nat64_main_t *n64m = &nat64_main;
+ int rv = 0;
+
+ /* *INDENT-OFF* */
+ REPLY_MACRO2 (VL_API_NAT_SHOW_CONFIG_2_REPLY,
+ ({
+ rmp->translation_buckets = htonl (sm->translation_buckets);
+ rmp->translation_memory_size = clib_host_to_net_u64 (sm->translation_memory_size);
+ rmp->user_buckets = htonl (sm->user_buckets);
+ rmp->user_memory_size = clib_host_to_net_u64 (sm->user_memory_size);
+ rmp->max_translations_per_user = htonl (sm->max_translations_per_user);
+ rmp->outside_vrf_id = htonl (sm->outside_vrf_id);
+ rmp->inside_vrf_id = htonl (sm->inside_vrf_id);
+ rmp->static_mapping_only = sm->static_mapping_only;
+ rmp->static_mapping_connection_tracking =
+ sm->static_mapping_connection_tracking;
+ rmp->deterministic = 0;
+ rmp->endpoint_dependent = sm->endpoint_dependent;
+ rmp->out2in_dpo = sm->out2in_dpo;
+ //rmp->dslite_ce = dm->is_ce;
+ rmp->nat64_bib_buckets = clib_net_to_host_u32(n64m->bib_buckets);
+ rmp->nat64_bib_memory_size = clib_net_to_host_u64(n64m->bib_memory_size);
+ rmp->nat64_st_buckets = clib_net_to_host_u32(n64m->st_buckets);
+ rmp->nat64_st_memory_size = clib_net_to_host_u64(n64m->st_memory_size);
+ rmp->max_translations_per_thread = clib_net_to_host_u32(sm->max_translations_per_thread);
+ rmp->max_users_per_thread = clib_net_to_host_u32(sm->max_users_per_thread);
+ }));
+ /* *INDENT-ON* */
+}
+
+static void *
+vl_api_nat_show_config_2_t_print (vl_api_nat_show_config_t * mp, void *handle)
+{
+ u8 *s;
+
+ s = format (0, "SCRIPT: nat_show_config_2 ");
+
+ FINISH;
+}
+
+static void
vl_api_nat_set_workers_t_handler (vl_api_nat_set_workers_t * mp)
{
snat_main_t *sm = &snat_main;
@@ -2592,6 +2641,7 @@ static void *vl_api_nat64_add_del_interface_addr_t_print
#define foreach_snat_plugin_api_msg \
_(NAT_CONTROL_PING, nat_control_ping) \
_(NAT_SHOW_CONFIG, nat_show_config) \
+_(NAT_SHOW_CONFIG_2, nat_show_config_2) \
_(NAT_SET_WORKERS, nat_set_workers) \
_(NAT_WORKER_DUMP, nat_worker_dump) \
_(NAT44_DEL_USER, nat44_del_user) \