aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/nat64.h
diff options
context:
space:
mode:
authorMatus Fabian <matfabia@cisco.com>2017-12-07 23:22:51 -0800
committerOle Trøan <otroan@employees.org>2017-12-13 14:15:35 +0000
commit51e759fd0655b6089360e1ccf2f5341704549fd4 (patch)
tree125a66214683c3aae9b1ddec253ef7910b3e38d8 /src/plugins/nat/nat64.h
parent331acc632477ed2da1c9c0b90915a227b5e343d5 (diff)
NAT64: multi-thread support (VPP-891)
Change-Id: Iebf859b6d86482e4465423bad598eecf87e53ec4 Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'src/plugins/nat/nat64.h')
-rw-r--r--src/plugins/nat/nat64.h86
1 files changed, 72 insertions, 14 deletions
diff --git a/src/plugins/nat/nat64.h b/src/plugins/nat/nat64.h
index 118076705cc..0c8fd82a730 100644
--- a/src/plugins/nat/nat64.h
+++ b/src/plugins/nat/nat64.h
@@ -49,6 +49,19 @@ typedef struct
typedef struct
{
+ ip6_address_t in_addr;
+ u16 in_port;
+ ip4_address_t out_addr;
+ u16 out_port;
+ u32 fib_index;
+ u32 thread_index;
+ u8 proto;
+ u8 is_add;
+ u8 done;
+} nat64_static_bib_to_update_t;
+
+typedef struct
+{
/** Interface pool */
snat_interface_t *interfaces;
@@ -61,18 +74,31 @@ typedef struct
/** Pref64 vector */
nat64_prefix_t *pref64;
- /** BIB and session DB */
- nat64_db_t db;
+ /** BIB and session DB per thread */
+ nat64_db_t *db;
+
+ /** Worker handoff */
+ u32 fq_in2out_index;
+ u32 fq_out2in_index;
+
+ /** Pool of static BIB entries to be added/deleted in worker threads */
+ nat64_static_bib_to_update_t *static_bibs;
- /* values of various timeouts */
+ u32 error_node_index;
+
+ /** config parameters */
+ u32 bib_buckets;
+ u32 bib_memory_size;
+ u32 st_buckets;
+ u32 st_memory_size;
+
+ /** values of various timeouts */
u32 udp_timeout;
u32 icmp_timeout;
u32 tcp_trans_timeout;
u32 tcp_est_timeout;
u32 tcp_incoming_syn_timeout;
- u8 is_disabled;
-
ip4_main_t *ip4_main;
snat_main_t *sm;
} nat64_main_t;
@@ -171,27 +197,30 @@ int nat64_add_del_static_bib_entry (ip6_address_t * in_addr,
/**
* @brief Alloce IPv4 address and port pair from NAT64 pool.
*
- * @param fib_index FIB index of tenant.
- * @param proto L4 protocol.
- * @param addr Allocated IPv4 address.
- * @param port Allocated port number.
+ * @param fib_index FIB index of tenant.
+ * @param proto L4 protocol.
+ * @param addr Allocated IPv4 address.
+ * @param port Allocated port number.
+ * @param thread_index Thread index.
*
* @returns 0 on success, non-zero value otherwise.
*/
int nat64_alloc_out_addr_and_port (u32 fib_index, snat_protocol_t proto,
- ip4_address_t * addr, u16 * port);
+ ip4_address_t * addr, u16 * port,
+ u32 thread_index);
/**
* @brief Free IPv4 address and port pair from NAT64 pool.
*
- * @param addr IPv4 address to free.
- * @param port Port number to free.
- * @param proto L4 protocol.
+ * @param addr IPv4 address to free.
+ * @param port Port number to free.
+ * @param proto L4 protocol.
+ * @param thread_index Thread index.
*
* @returns 0 on success, non-zero value otherwise.
*/
void nat64_free_out_addr_and_port (ip4_address_t * addr, u16 port,
- snat_protocol_t proto);
+ snat_protocol_t proto, u32 thread_index);
/**
* @brief Set UDP session timeout.
@@ -322,6 +351,35 @@ void nat64_compose_ip6 (ip6_address_t * ip6, ip4_address_t * ip4,
void nat64_extract_ip4 (ip6_address_t * ip6, ip4_address_t * ip4,
u32 fib_index);
+/**
+ * @brief Set NAT64 hash tables configuration.
+ *
+ * @param bib_buckets Number of BIB hash buckets.
+ * @param bib_memory_size Memory size of BIB hash.
+ * @param st_buckets Number of session table hash buckets.
+ * @param st_memory_size Memory size of session table hash.
+ */
+void nat64_set_hash (u32 bib_buckets, u32 bib_memory_size, u32 st_buckets,
+ u32 st_memory_size);
+
+/**
+ * @brief Get worker thread index for NAT64 in2out.
+ *
+ * @param addr IPv6 src address.
+ *
+ * @returns worker thread index.
+ */
+u32 nat64_get_worker_in2out (ip6_address_t * addr);
+
+/**
+ * @brief Get worker thread index for NAT64 out2in.
+ *
+ * @param ip IPv4 header.
+ *
+ * @returns worker thread index.
+ */
+u32 nat64_get_worker_out2in (ip4_header_t * ip);
+
#define u8_ptr_add(ptr, index) (((u8 *)ptr) + index)
#define u16_net_add(u, val) clib_host_to_net_u16(clib_net_to_host_u16(u) + (val))