diff options
author | Matus Fabian <matfabia@cisco.com> | 2017-12-07 23:22:51 -0800 |
---|---|---|
committer | Ole Trøan <otroan@employees.org> | 2017-12-13 14:15:35 +0000 |
commit | 51e759fd0655b6089360e1ccf2f5341704549fd4 (patch) | |
tree | 125a66214683c3aae9b1ddec253ef7910b3e38d8 /src/plugins/nat/nat_api.c | |
parent | 331acc632477ed2da1c9c0b90915a227b5e343d5 (diff) |
NAT64: multi-thread support (VPP-891)
Change-Id: Iebf859b6d86482e4465423bad598eecf87e53ec4
Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'src/plugins/nat/nat_api.c')
-rw-r--r-- | src/plugins/nat/nat_api.c | 88 |
1 files changed, 16 insertions, 72 deletions
diff --git a/src/plugins/nat/nat_api.c b/src/plugins/nat/nat_api.c index 3c58097e332..f1d9ec83af3 100644 --- a/src/plugins/nat/nat_api.c +++ b/src/plugins/nat/nat_api.c @@ -1776,7 +1776,6 @@ static void { vl_api_nat64_add_del_pool_addr_range_reply_t *rmp; snat_main_t *sm = &snat_main; - nat64_main_t *nm = &nat64_main; int rv = 0; ip4_address_t this_addr; u32 start_host_order, end_host_order; @@ -1784,12 +1783,6 @@ static void int i, count; u32 *tmp; - if (nm->is_disabled) - { - rv = VNET_API_ERROR_FEATURE_DISABLED; - goto send_reply; - } - tmp = (u32 *) mp->start_addr; start_host_order = clib_host_to_net_u32 (tmp[0]); tmp = (u32 *) mp->end_addr; @@ -1831,6 +1824,7 @@ typedef struct nat64_api_walk_ctx_t_ { unix_shared_memory_queue_t *q; u32 context; + nat64_db_t *db; } nat64_api_walk_ctx_t; static int @@ -1864,10 +1858,6 @@ static void vl_api_nat64_pool_addr_dump_t_handler (vl_api_nat64_pool_addr_dump_t * mp) { unix_shared_memory_queue_t *q; - nat64_main_t *nm = &nat64_main; - - if (nm->is_disabled) - return; q = vl_api_client_index_to_input_queue (mp->client_index); if (q == 0) @@ -1897,16 +1887,9 @@ vl_api_nat64_add_del_interface_t_handler (vl_api_nat64_add_del_interface_t * mp) { snat_main_t *sm = &snat_main; - nat64_main_t *nm = &nat64_main; vl_api_nat64_add_del_interface_reply_t *rmp; int rv = 0; - if (nm->is_disabled) - { - rv = VNET_API_ERROR_FEATURE_DISABLED; - goto send_reply; - } - VALIDATE_SW_IF_INDEX (mp); rv = @@ -1915,7 +1898,6 @@ vl_api_nat64_add_del_interface_t_handler (vl_api_nat64_add_del_interface_t * BAD_SW_IF_INDEX_LABEL; -send_reply: REPLY_MACRO (VL_API_NAT64_ADD_DEL_INTERFACE_REPLY); } @@ -1958,10 +1940,6 @@ static void vl_api_nat64_interface_dump_t_handler (vl_api_nat64_interface_dump_t * mp) { unix_shared_memory_queue_t *q; - nat64_main_t *nm = &nat64_main; - - if (nm->is_disabled) - return; q = vl_api_client_index_to_input_queue (mp->client_index); if (q == 0) @@ -1991,18 +1969,11 @@ static void (vl_api_nat64_add_del_static_bib_t * mp) { snat_main_t *sm = &snat_main; - nat64_main_t *nm = &nat64_main; vl_api_nat64_add_del_static_bib_reply_t *rmp; ip6_address_t in_addr; ip4_address_t out_addr; int rv = 0; - if (nm->is_disabled) - { - rv = VNET_API_ERROR_FEATURE_DISABLED; - goto send_reply; - } - memcpy (&in_addr.as_u8, mp->i_addr, 16); memcpy (&out_addr.as_u8, mp->o_addr, 4); @@ -2014,7 +1985,6 @@ static void clib_net_to_host_u32 (mp->vrf_id), mp->is_add); -send_reply: REPLY_MACRO (VL_API_NAT64_ADD_DEL_STATIC_BIB_REPLY); } @@ -2069,9 +2039,7 @@ vl_api_nat64_bib_dump_t_handler (vl_api_nat64_bib_dump_t * mp) { unix_shared_memory_queue_t *q; nat64_main_t *nm = &nat64_main; - - if (nm->is_disabled) - return; + nat64_db_t *db; q = vl_api_client_index_to_input_queue (mp->client_index); if (q == 0) @@ -2082,7 +2050,10 @@ vl_api_nat64_bib_dump_t_handler (vl_api_nat64_bib_dump_t * mp) .context = mp->context, }; - nat64_db_bib_walk (&nm->db, mp->proto, nat64_api_bib_walk, &ctx); + /* *INDENT-OFF* */ + vec_foreach (db, nm->db) + nat64_db_bib_walk (db, mp->proto, nat64_api_bib_walk, &ctx); + /* *INDENT-ON* */ } static void * @@ -2099,16 +2070,9 @@ static void vl_api_nat64_set_timeouts_t_handler (vl_api_nat64_set_timeouts_t * mp) { snat_main_t *sm = &snat_main; - nat64_main_t *nm = &nat64_main; vl_api_nat64_set_timeouts_reply_t *rmp; int rv = 0; - if (nm->is_disabled) - { - rv = VNET_API_ERROR_FEATURE_DISABLED; - goto send_reply; - } - rv = nat64_set_icmp_timeout (ntohl (mp->icmp)); if (rv) goto send_reply; @@ -2142,13 +2106,9 @@ static void vl_api_nat64_get_timeouts_t_handler (vl_api_nat64_get_timeouts_t * mp) { snat_main_t *sm = &snat_main; - nat64_main_t *nm = &nat64_main; vl_api_nat64_get_timeouts_reply_t *rmp; int rv = 0; - if (nm->is_disabled) - return; - /* *INDENT-OFF* */ REPLY_MACRO2 (VL_API_NAT64_GET_TIMEOUTS_REPLY, ({ @@ -2177,11 +2137,10 @@ nat64_api_st_walk (nat64_db_st_entry_t * ste, void *arg) vl_api_nat64_st_details_t *rmp; snat_main_t *sm = &snat_main; nat64_api_walk_ctx_t *ctx = arg; - nat64_main_t *nm = &nat64_main; nat64_db_bib_entry_t *bibe; fib_table_t *fib; - bibe = nat64_db_bib_entry_by_index (&nm->db, ste->proto, ste->bibe_index); + bibe = nat64_db_bib_entry_by_index (ctx->db, ste->proto, ste->bibe_index); if (!bibe) return -1; @@ -2213,9 +2172,7 @@ vl_api_nat64_st_dump_t_handler (vl_api_nat64_st_dump_t * mp) { unix_shared_memory_queue_t *q; nat64_main_t *nm = &nat64_main; - - if (nm->is_disabled) - return; + nat64_db_t *db; q = vl_api_client_index_to_input_queue (mp->client_index); if (q == 0) @@ -2226,7 +2183,13 @@ vl_api_nat64_st_dump_t_handler (vl_api_nat64_st_dump_t * mp) .context = mp->context, }; - nat64_db_st_walk (&nm->db, mp->proto, nat64_api_st_walk, &ctx); + /* *INDENT-OFF* */ + vec_foreach (db, nm->db) + { + ctx.db = db; + nat64_db_st_walk (db, mp->proto, nat64_api_st_walk, &ctx); + } + /* *INDENT-ON* */ } static void * @@ -2244,22 +2207,14 @@ vl_api_nat64_add_del_prefix_t_handler (vl_api_nat64_add_del_prefix_t * mp) { vl_api_nat64_add_del_prefix_reply_t *rmp; snat_main_t *sm = &snat_main; - nat64_main_t *nm = &nat64_main; ip6_address_t prefix; int rv = 0; - if (nm->is_disabled) - { - rv = VNET_API_ERROR_FEATURE_DISABLED; - goto send_reply; - } - memcpy (&prefix.as_u8, mp->prefix, 16); rv = nat64_add_del_prefix (&prefix, mp->prefix_len, clib_net_to_host_u32 (mp->vrf_id), mp->is_add); -send_reply: REPLY_MACRO (VL_API_NAT64_ADD_DEL_PREFIX_REPLY); } @@ -2300,10 +2255,6 @@ static void vl_api_nat64_prefix_dump_t_handler (vl_api_nat64_prefix_dump_t * mp) { unix_shared_memory_queue_t *q; - nat64_main_t *nm = &nat64_main; - - if (nm->is_disabled) - return; q = vl_api_client_index_to_input_queue (mp->client_index); if (q == 0) @@ -2332,24 +2283,17 @@ static void vl_api_nat64_add_del_interface_addr_t_handler (vl_api_nat64_add_del_interface_addr_t * mp) { - nat64_main_t *nm = &nat64_main; snat_main_t *sm = &snat_main; vl_api_nat64_add_del_interface_addr_reply_t *rmp; u32 sw_if_index = ntohl (mp->sw_if_index); int rv = 0; - if (nm->is_disabled) - { - rv = VNET_API_ERROR_FEATURE_DISABLED; - goto send_reply; - } - VALIDATE_SW_IF_INDEX (mp); rv = nat64_add_interface_address (sw_if_index, mp->is_add); BAD_SW_IF_INDEX_LABEL; -send_reply: + REPLY_MACRO (VL_API_NAT64_ADD_DEL_INTERFACE_ADDR_REPLY); } |