42 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 45 #define vl_api_version(n,v) static u32 api_version=(v); 52 vl_print (handle, (char *)s); \ 64 #define REPLY_MACRO(t) \ 66 unix_shared_memory_queue_t * q = \ 67 vl_api_client_index_to_input_queue (mp->client_index); \ 71 rmp = vl_msg_api_alloc (sizeof (*rmp)); \ 72 rmp->_vl_msg_id = ntohs((t)+sm->msg_id_base); \ 73 rmp->context = mp->context; \ 74 rmp->retval = ntohl(rv); \ 76 vl_msg_api_send_shmem (q, (u8 *)&rmp); \ 79 #define REPLY_MACRO2(t, body) \ 81 unix_shared_memory_queue_t * q = \ 82 vl_api_client_index_to_input_queue (mp->client_index); \ 86 rmp = vl_msg_api_alloc (sizeof (*rmp)); \ 87 rmp->_vl_msg_id = ntohs((t)+sm->msg_id_base); \ 88 rmp->context = mp->context; \ 89 rmp->retval = ntohl(rv); \ 90 do {body;} while (0); \ 91 vl_msg_api_send_shmem (q, (u8 *)&rmp); \ 97 .arc_name =
"ip4-unicast",
98 .node_name =
"snat-in2out",
102 .arc_name =
"ip4-unicast",
103 .node_name =
"snat-out2in",
107 .arc_name =
"ip4-unicast",
108 .node_name =
"snat-in2out-worker-handoff",
112 .arc_name =
"ip4-unicast",
113 .node_name =
"snat-out2in-worker-handoff",
117 .arc_name =
"ip4-unicast",
118 .node_name =
"snat-in2out-fast",
122 .arc_name =
"ip4-unicast",
123 .node_name =
"snat-out2in-fast",
150 #if (1 || CLIB_DEBUG > 0) 152 #define VALIDATE_SW_IF_INDEX(mp) \ 153 do { u32 __sw_if_index = ntohl(mp->sw_if_index); \ 154 vnet_main_t *__vnm = vnet_get_main(); \ 155 if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \ 157 rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \ 158 goto bad_sw_if_index; \ 162 #define BAD_SW_IF_INDEX_LABEL \ 168 #define VALIDATE_RX_SW_IF_INDEX(mp) \ 169 do { u32 __rx_sw_if_index = ntohl(mp->rx_sw_if_index); \ 170 vnet_main_t *__vnm = vnet_get_main(); \ 171 if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \ 172 __rx_sw_if_index)) { \ 173 rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \ 174 goto bad_rx_sw_if_index; \ 178 #define BAD_RX_SW_IF_INDEX_LABEL \ 180 bad_rx_sw_if_index: \ 184 #define VALIDATE_TX_SW_IF_INDEX(mp) \ 185 do { u32 __tx_sw_if_index = ntohl(mp->tx_sw_if_index); \ 186 vnet_main_t *__vnm = vnet_get_main(); \ 187 if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \ 188 __tx_sw_if_index)) { \ 189 rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \ 190 goto bad_tx_sw_if_index; \ 194 #define BAD_TX_SW_IF_INDEX_LABEL \ 196 bad_tx_sw_if_index: \ 202 #define VALIDATE_SW_IF_INDEX(mp) 203 #define BAD_SW_IF_INDEX_LABEL 204 #define VALIDATE_RX_SW_IF_INDEX(mp) 205 #define BAD_RX_SW_IF_INDEX_LABEL 206 #define VALIDATE_TX_SW_IF_INDEX(mp) 207 #define BAD_TX_SW_IF_INDEX_LABEL 233 if (m->external_addr.as_u32 == addr.as_u32)
244 u32 *ses_to_be_removed = 0, *ses_index;
262 return VNET_API_ERROR_NO_SUCH_ENTRY;
268 return VNET_API_ERROR_UNSPECIFIED;
277 if (ses->out2in.addr.as_u32 == addr.as_u32)
279 vec_add1 (ses_to_be_removed, ses - tsm->sessions);
280 kv.key = ses->in2out.as_u64;
281 clib_bihash_add_del_8_8 (&sm->in2out, &kv, 0);
282 kv.key = ses->out2in.as_u64;
283 clib_bihash_add_del_8_8 (&sm->out2in, &kv, 0);
284 clib_dlist_remove (tsm->list_pool, ses->per_user_index);
285 user_key.addr = ses->in2out.addr;
286 user_key.fib_index = ses->in2out.fib_index;
287 kv.key = user_key.as_u64;
288 if (!clib_bihash_search_8_8 (&sm->user_hash, &kv, &value))
290 u = pool_elt_at_index (tsm->users, value.value);
312 v = clib_net_to_host_u32(a->
as_u32) + 1;
313 a->
as_u32 = clib_host_to_net_u32(v);
332 u16 l_port,
u16 e_port,
u32 vrf_id,
int addr_only,
349 return VNET_API_ERROR_NO_SUCH_FIB;
354 m_key.
port = addr_only ? 0 : e_port;
365 return VNET_API_ERROR_VALUE_EXIST;
372 return VNET_API_ERROR_NO_SUCH_FIB;
382 return VNET_API_ERROR_NO_SUCH_FIB;
403 return VNET_API_ERROR_INVALID_VALUE;
413 return VNET_API_ERROR_NO_SUCH_ENTRY;
417 memset (m, 0,
sizeof (*m));
453 if (clib_bihash_search_8_8 (&sm->
worker_by_in, &kv, &value))
475 return VNET_API_ERROR_NO_SUCH_ENTRY;
512 u32 elt_index, head_index, del_elt_index;
521 if (!clib_bihash_search_8_8 (&sm->
user_hash, &kv, &value))
523 user_index = value.
value;
524 if (!clib_bihash_search_8_8 (&sm->
worker_by_in, &kv, &value))
533 elt_index = head->
next;
535 ses_index = elt->
value;
536 while (ses_index != ~0)
539 del_elt_index = elt_index;
540 elt_index = elt->
next;
542 ses_index = elt->
value;
546 if ((s->out2in.addr.as_u32 != e_addr.
as_u32) &&
547 (clib_net_to_host_u16 (s->out2in.port) != e_port))
551 value.
key = s->in2out.as_u64;
552 clib_bihash_add_del_8_8 (&sm->
in2out, &value, 0);
553 value.
key = s->out2in.as_u64;
554 clib_bihash_add_del_8_8 (&sm->
out2in, &value, 0);
567 clib_bihash_add_del_8_8 (&sm->
user_hash, &kv, 0);
584 const char * feature_name;
587 feature_name = is_inside ?
"snat-in2out-fast" :
"snat-out2in-fast";
591 feature_name = is_inside ?
"snat-in2out-worker-handoff" :
"snat-out2in-worker-handoff";
593 feature_name = is_inside ?
"snat-in2out" :
"snat-out2in";
607 if (i->sw_if_index == sw_if_index)
610 pool_put (sm->interfaces, i);
612 return VNET_API_ERROR_VALUE_EXIST;
619 return VNET_API_ERROR_NO_SUCH_ENTRY;
634 return VNET_API_ERROR_FEATURE_DISABLED;
637 return VNET_API_ERROR_INVALID_WORKER;
655 u32 start_host_order, end_host_order;
662 rv = VNET_API_ERROR_UNIMPLEMENTED;
668 rv = VNET_API_ERROR_FEATURE_DISABLED;
673 start_host_order = clib_host_to_net_u32 (tmp[0]);
675 end_host_order = clib_host_to_net_u32 (tmp[0]);
677 count = (end_host_order - start_host_order) + 1;
687 for (i = 0; i < count; i++)
709 s =
format (0,
"SCRIPT: snat_add_address_range ");
726 memset (rmp, 0,
sizeof (*rmp));
727 rmp->_vl_msg_id = ntohs (VL_API_SNAT_ADDRESS_DETAILS+sm->
msg_id_base);
756 s =
format (0,
"SCRIPT: snat_address_dump ");
777 REPLY_MACRO(VL_API_SNAT_INTERFACE_ADD_DEL_FEATURE_REPLY);
785 s =
format (0,
"SCRIPT: snat_interface_add_del_feature ");
786 s =
format (s,
"sw_if_index %d %s %s",
802 memset (rmp, 0,
sizeof (*rmp));
803 rmp->_vl_msg_id = ntohs (VL_API_SNAT_INTERFACE_DETAILS+sm->
msg_id_base);
825 send_snat_interface_details(i, q, mp->context);
834 s =
format (0,
"SCRIPT: snat_interface_dump ");
845 u16 local_port = 0, external_port = 0;
851 rv = VNET_API_ERROR_UNIMPLEMENTED;
859 local_port = clib_net_to_host_u16 (mp->
local_port);
862 vrf_id = clib_net_to_host_u32 (mp->
vrf_id);
877 s =
format (0,
"SCRIPT: snat_add_static_mapping ");
878 s =
format (s,
"local_addr %U external_addr %U ",
883 s =
format (s,
"local_port %d external_port %d ",
888 s =
format (s,
"vrf %d", clib_net_to_host_u32 (mp->
vrf_id));
901 memset (rmp, 0,
sizeof (*rmp));
902 rmp->_vl_msg_id = ntohs (VL_API_SNAT_STATIC_MAPPING_DETAILS+sm->
msg_id_base);
929 send_snat_static_mapping_details (m, q, mp->context);
938 s =
format (0,
"SCRIPT: snat_static_mapping_dump ");
953 rmp->
vpe_pid = ntohl (getpid());
962 s =
format (0,
"SCRIPT: snat_control_ping ");
995 s =
format (0,
"SCRIPT: snat_show_config ");
1012 rv = VNET_API_ERROR_FEATURE_DISABLED;
1033 s =
format (0,
"SCRIPT: snat_set_workers ");
1040 s =
format (s,
",%d", i);
1057 memset (rmp, 0,
sizeof (*rmp));
1058 rmp->_vl_msg_id = ntohs (VL_API_SNAT_WORKER_DETAILS+sm->
msg_id_base);
1090 s =
format (0,
"SCRIPT: snat_worker_dump ");
1096 #define foreach_snat_plugin_api_msg \ 1097 _(SNAT_ADD_ADDRESS_RANGE, snat_add_address_range) \ 1098 _(SNAT_INTERFACE_ADD_DEL_FEATURE, snat_interface_add_del_feature) \ 1099 _(SNAT_ADD_STATIC_MAPPING, snat_add_static_mapping) \ 1100 _(SNAT_CONTROL_PING, snat_control_ping) \ 1101 _(SNAT_STATIC_MAPPING_DUMP, snat_static_mapping_dump) \ 1102 _(SNAT_SHOW_CONFIG, snat_show_config) \ 1103 _(SNAT_ADDRESS_DUMP, snat_address_dump) \ 1104 _(SNAT_INTERFACE_DUMP, snat_interface_dump) \ 1105 _(SNAT_SET_WORKERS, snat_set_workers) \ 1106 _(SNAT_WORKER_DUMP, snat_worker_dump) 1114 vl_msg_api_set_handlers((VL_API_##N + sm->msg_id_base), \ 1116 vl_api_##n##_t_handler, \ 1118 vl_api_##n##_t_endian, \ 1119 vl_api_##n##_t_print, \ 1120 sizeof(vl_api_##n##_t), 1); 1127 #define vl_msg_name_crc_list 1129 #undef vl_msg_name_crc_list 1134 #define _(id,n,crc) \ 1135 vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + sm->msg_id_base); 1136 foreach_vl_msg_name_crc_snat;
1142 #define _(n,f) sm->api_main->msg_print_handlers \ 1143 [VL_API_##n + sm->msg_id_base] \ 1144 = (void *) vl_api_##f##_t_print; 1162 name =
format (0,
"snat_%08x%c", api_version, 0);
1218 u16 port_host_byte_order = clib_net_to_host_u16 (k->
port);
1225 port_host_byte_order) == 1);
1256 m_key.
port = clib_net_to_host_u16 (match.
port);
1261 if (clib_bihash_search_8_8 (mapping_hash, &kv, &value))
1266 if (clib_bihash_search_8_8 (mapping_hash, &kv, &value))
1294 u32 * address_indexp)
1318 k->
port = clib_host_to_net_u16(portnum);
1319 *address_indexp =
i;
1337 u32 start_host_order, end_host_order;
1348 if (
unformat (line_input,
"%U - %U",
1353 end_addr = start_addr;
1354 else if (
unformat (line_input,
"del"))
1365 start_host_order = clib_host_to_net_u32 (start_addr.
as_u32);
1366 end_host_order = clib_host_to_net_u32 (end_addr.
as_u32);
1368 if (end_host_order < start_host_order)
1371 count = (end_host_order - start_host_order) + 1;
1379 this_addr = start_addr;
1381 for (i = 0; i < count; i++)
1390 case VNET_API_ERROR_NO_SUCH_ENTRY:
1393 case VNET_API_ERROR_UNSPECIFIED:
1407 .path =
"snat add address",
1408 .short_help =
"snat add addresses <ip4-range-start> [- <ip4-range-end>] [del]",
1421 u32 * inside_sw_if_indices = 0;
1422 u32 * outside_sw_if_indices = 0;
1436 vec_add1 (inside_sw_if_indices, sw_if_index);
1439 vec_add1 (outside_sw_if_indices, sw_if_index);
1440 else if (
unformat (line_input,
"del"))
1448 if (
vec_len (inside_sw_if_indices))
1450 for (i = 0; i <
vec_len(inside_sw_if_indices); i++)
1452 sw_if_index = inside_sw_if_indices[
i];
1457 if (
vec_len (outside_sw_if_indices))
1459 for (i = 0; i <
vec_len(outside_sw_if_indices); i++)
1461 sw_if_index = outside_sw_if_indices[
i];
1473 .path =
"set interface snat",
1475 .short_help =
"set interface snat in <intfc> out <intfc> [del]",
1486 u32 l_port = 0, e_port = 0, vrf_id = ~0;
1508 else if (
unformat (line_input,
"vrf %u", &vrf_id))
1510 else if (
unformat (line_input,
"del"))
1519 vrf_id, addr_only, is_add);
1523 case VNET_API_ERROR_INVALID_VALUE:
1526 case VNET_API_ERROR_NO_SUCH_ENTRY:
1532 case VNET_API_ERROR_NO_SUCH_FIB:
1534 case VNET_API_ERROR_VALUE_EXIST:
1558 .path =
"snat add static mapping",
1561 "snat add static mapping local <addr> [<port>] external <addr> [<port>] [vrf <table-id>] [del]",
1596 case VNET_API_ERROR_INVALID_WORKER:
1599 case VNET_API_ERROR_FEATURE_DISABLED:
1601 "Supported only if 2 or more workes available.");
1618 .path =
"set snat workers",
1621 "set snat workers <workers-list>",
1628 u32 translation_buckets = 1024;
1629 u32 translation_memory_size = 128<<20;
1630 u32 user_buckets = 128;
1631 u32 user_memory_size = 64<<20;
1632 u32 max_translations_per_user = 100;
1633 u32 outside_vrf_id = 0;
1634 u32 inside_vrf_id = 0;
1635 u32 static_mapping_buckets = 1024;
1636 u32 static_mapping_memory_size = 64<<20;
1637 u8 static_mapping_only = 0;
1638 u8 static_mapping_connection_tracking = 0;
1643 if (
unformat (input,
"translation hash buckets %d", &translation_buckets))
1645 else if (
unformat (input,
"translation hash memory %d",
1646 &translation_memory_size));
1647 else if (
unformat (input,
"user hash buckets %d", &user_buckets))
1649 else if (
unformat (input,
"user hash memory %d",
1652 else if (
unformat (input,
"max translations per user %d",
1653 &max_translations_per_user))
1655 else if (
unformat (input,
"outside VRF id %d",
1658 else if (
unformat (input,
"inside VRF id %d",
1661 else if (
unformat (input,
"static mapping only"))
1663 static_mapping_only = 1;
1664 if (
unformat (input,
"connection tracking"))
1665 static_mapping_connection_tracking = 1;
1685 if (!static_mapping_only ||
1686 (static_mapping_only && static_mapping_connection_tracking))
1688 clib_bihash_init_8_8 (&sm->
worker_by_in,
"worker-by-in", user_buckets,
1691 clib_bihash_init_8_8 (&sm->
worker_by_out,
"worker-by-out", user_buckets,
1696 clib_bihash_init_8_8 (&sm->
in2out,
"in2out", translation_buckets,
1697 translation_memory_size);
1699 clib_bihash_init_8_8 (&sm->
out2in,
"out2in", translation_buckets,
1700 translation_memory_size);
1702 clib_bihash_init_8_8 (&sm->
user_hash,
"users", user_buckets,
1706 "static_mapping_by_local", static_mapping_buckets,
1707 static_mapping_memory_size);
1710 "static_mapping_by_external", static_mapping_buckets,
1711 static_mapping_memory_size);
1720 char * protocol_string =
"unknown";
1721 static char *protocol_strings[] = {
1728 protocol_string = protocol_strings[key->
protocol];
1730 s =
format (s,
"%U proto %s port %d fib %d",
1739 snat_session_t * sess = va_arg (*args, snat_session_t *);
1743 s =
format (s,
" last heard %.2f\n", sess->last_heard);
1744 s =
format (s,
" total pkts %d, total bytes %lld\n",
1745 sess->total_pkts, sess->total_bytes);
1747 s =
format (s,
" static translation\n");
1749 s =
format (s,
" dynamic translation\n");
1758 int verbose = va_arg (*args,
int);
1760 u32 elt_index, head_index;
1762 snat_session_t * sess;
1764 s =
format (s,
"%U: %d dynamic translations, %d static translations\n",
1775 elt_index = head->
next;
1777 session_index = elt->
value;
1779 while (session_index != ~0)
1785 elt_index = elt->
next;
1787 session_index = elt->
value;
1799 s =
format (s,
"local %U external %U vrf %d",
1804 s =
format (s,
"local %U:%d external %U:%d vrf %d",
1825 u32 users_num = 0, sessions_num = 0, *worker;
1830 else if (
unformat (input,
"verbose"))
1850 vlib_cli_output (vm,
"%U %s", format_vnet_sw_interface_name, vnm,
1851 vnet_get_sw_interface (vnm, i->sw_if_index),
1852 i->is_inside ?
"in" :
"out");
1861 s = format (s,
" %d", j);
1890 vlib_cli_output (vm,
"%U", format_snat_static_mapping, m);
1902 vlib_cli_output (vm,
"%d users, %d outside addresses, %d active sessions," 1903 " %d static mappings",
1934 vlib_cli_output (vm,
" %U", format_snat_user, tsm, u,
1944 vlib_cli_output (vm,
"%U", format_snat_static_mapping, m);
1954 .path =
"show snat",
1955 .short_help =
"show snat",
ip4_address_t external_addr
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
u32 translation_memory_size
u8 external_ip_address[16]
clib_bihash_8_8_t static_mapping_by_external
static void * vl_api_snat_worker_dump_t_print(vl_api_snat_worker_dump_t *mp, void *handle)
Add/del S-NAT address range.
static vlib_cli_command_t set_interface_snat_command
(constructor) VLIB_CLI_COMMAND (set_interface_snat_command)
#define vec_foreach_index(var, v)
Iterate over vector indices.
u32 sessions_per_user_list_head_index
u32 max_translations_per_user
static void vl_api_snat_interface_add_del_feature_t_handler(vl_api_snat_interface_add_del_feature_t *mp)
sll srl srl sll sra u16x4 i
static void * vl_api_snat_add_static_mapping_t_print(vl_api_snat_add_static_mapping_t *mp, void *handle)
#define REPLY_MACRO2(t, body)
static void * vl_api_snat_interface_add_del_feature_t_print(vl_api_snat_interface_add_del_feature_t *mp, void *handle)
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
static void vl_api_snat_add_address_range_t_handler(vl_api_snat_add_address_range_t *mp)
u8 static_mapping_connection_tracking
u32 vlib_frame_queue_main_init(u32 node_index, u32 frame_queue_nelts)
ip_lookup_main_t * ip4_lookup_main
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
static void send_snat_worker_details(u32 worker_index, unix_shared_memory_queue_t *q, u32 context)
static uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap. ...
ip_lookup_main_t lookup_main
void snat_add_address(snat_main_t *sm, ip4_address_t *addr)
unformat_function_t unformat_vnet_sw_interface
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
static clib_error_t * snat_init(vlib_main_t *vm)
static uword clib_bitmap_get_no_check(uword *ai, uword i)
Gets the ith bit value from a bitmap Does not sanity-check the bit position.
snat_interface_t * interfaces
static clib_error_t * add_address_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static void vl_api_snat_add_static_mapping_t_handler(vl_api_snat_add_static_mapping_t *mp)
static uword clib_bitmap_set_no_check(uword *a, uword i, uword new_value)
Sets the ith bit of a bitmap to new_value.
ethernet_main_t * ethernet_main
static void vl_api_snat_control_ping_t_handler(vl_api_snat_control_ping_t *mp)
static int snat_interface_add_del(u32 sw_if_index, u8 is_inside, int is_del)
u8 * format_snat_key(u8 *s, va_list *args)
vnet_main_t * vnet_get_main(void)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
static void * vl_api_snat_control_ping_t_print(vl_api_snat_control_ping_t *mp, void *handle)
#define VLIB_INIT_FUNCTION(x)
snat_main_per_thread_data_t * per_thread_data
u8 * format_snat_user(u8 *s, va_list *args)
int snat_static_mapping_match(snat_main_t *sm, snat_session_key_t match, snat_session_key_t *mapping, u8 by_external)
Match SNAT static mapping.
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define foreach_snat_plugin_api_msg
snat_static_mapping_t * static_mappings
#define VALIDATE_SW_IF_INDEX(mp)
#define clib_warning(format, args...)
static clib_error_t * snat_plugin_api_hookup(vlib_main_t *vm)
Control ping from the client to the server response.
u32 translation_memory_size
static heap_elt_t * first(heap_header_t *h)
clib_bihash_8_8_t worker_by_in
S-NAT static mapping details response.
vlib_worker_thread_t * vlib_worker_threads
#define clib_bitmap_foreach(i, ai, body)
Macro to iterate across set bits in a bitmap.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
uword * fib_index_by_table_id
Hash table mapping table id to fib index.
static uword clib_bitmap_last_set(uword *ai)
Return the higest numbered set bit in a bitmap.
static void send_snat_static_mapping_details(snat_static_mapping_t *m, unix_shared_memory_queue_t *q, u32 context)
static int is_snat_address_used_in_static_mapping(snat_main_t *sm, ip4_address_t addr)
#define pool_put(P, E)
Free an object E in pool P.
Enable/disable S-NAT feature on the interface reply.
#define VLIB_CONFIG_FUNCTION(x, n,...)
int snat_del_address(snat_main_t *sm, ip4_address_t addr)
#define vec_del1(v, i)
Delete the element at index I.
vlib_node_registration_t snat_out2in_node
(constructor) VLIB_REGISTER_NODE (snat_out2in_node)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static void * vl_api_snat_address_dump_t_print(vl_api_snat_address_dump_t *mp, void *handle)
static void increment_v4_address(ip4_address_t *a)
u8 * format_snat_session(u8 *s, va_list *args)
Dump S-NAT static mappings.
VNET_FEATURE_INIT(ip4_snat_in2out, static)
u8 external_ip_address[16]
#define clib_bitmap_alloc(v, n_bits)
Allocate a bitmap with the supplied number of bits.
static void * vl_api_snat_set_workers_t_print(vl_api_snat_set_workers_t *mp, void *handle)
void * vl_msg_api_alloc(int nbytes)
static clib_error_t * show_snat_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static void * vl_api_snat_static_mapping_dump_t_print(vl_api_snat_static_mapping_dump_t *mp, void *handle)
vlib_node_registration_t snat_in2out_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_node)
clib_bihash_8_8_t user_hash
#define vec_free(V)
Free vector's memory (no header).
snat_address_t * addresses
static clib_error_t * add_static_mapping_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static vlib_thread_main_t * vlib_get_thread_main()
Dump interfaces with S-NAT feature.
int snat_alloc_outside_address_and_port(snat_main_t *sm, snat_session_key_t *k, u32 *address_indexp)
u32 max_translations_per_user
#define clib_memcpy(a, b, c)
clib_error_t * vlib_plugin_register(vlib_main_t *vm, vnet_plugin_handoff_t *h, int from_early_init)
static void send_snat_interface_details(snat_interface_t *i, unix_shared_memory_queue_t *q, u32 context)
static uword * clib_bitmap_set_multiple(uword *bitmap, uword i, uword value, uword n_bits)
sets the ith through ith + n_bits bits in a bitmap
static clib_error_t * snat_config(vlib_main_t *vm, unformat_input_t *input)
8 octet key, 8 octet key value pair
clib_bihash_8_8_t static_mapping_by_local
S-NAT address details response.
Add S-NAT address range reply.
Add/delete S-NAT static mapping.
Enable/disable S-NAT feature on the interface.
#define VLIB_CLI_COMMAND(x,...)
#define pool_put_index(p, i)
Free pool element with given index.
static void vl_api_snat_set_workers_t_handler(vl_api_snat_set_workers_t *mp)
int snat_add_static_mapping(ip4_address_t l_addr, ip4_address_t e_addr, u16 l_port, u16 e_port, u32 vrf_id, int addr_only, int is_add)
Add static mapping.
u8 * format_snat_static_mapping(u8 *s, va_list *args)
static void vl_api_snat_show_config_t_handler(vl_api_snat_show_config_t *mp)
#define clib_bitmap_free(v)
Free a bitmap.
uword * thread_registrations_by_name
static void clib_dlist_remove(dlist_elt_t *pool, u32 index)
#define BAD_SW_IF_INDEX_LABEL
#define VNET_FEATURES(...)
static vlib_cli_command_t show_snat_command
(constructor) VLIB_CLI_COMMAND (show_snat_command)
static void vl_api_snat_static_mapping_dump_t_handler(vl_api_snat_static_mapping_dump_t *mp)
S-NAT workers details response.
static void vl_api_snat_interface_dump_t_handler(vl_api_snat_interface_dump_t *mp)
static void * vl_api_snat_add_address_range_t_print(vl_api_snat_add_address_range_t *mp, void *handle)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static uword unformat_bitmap_list(unformat_input_t *input, va_list *va)
unformat a list of bit ranges into a bitmap (eg "0-3,5-7,11" )
static vlib_cli_command_t add_address_command
(constructor) VLIB_CLI_COMMAND (add_address_command)
static void * vl_api_snat_show_config_t_print(vl_api_snat_show_config_t *mp, void *handle)
void snat_free_outside_address_and_port(snat_main_t *sm, snat_session_key_t *k, u32 address_index)
static vlib_cli_command_t add_static_mapping_command
(constructor) VLIB_CLI_COMMAND (add_static_mapping_command)
S-NAT interface details response.
#define hash_get_mem(h, key)
static void send_snat_address_details(snat_address_t *a, unix_shared_memory_queue_t *q, u32 context)
static u32 random_u32(u32 *seed)
32-bit random number generator
Show S-NAT plugin startup config reply.
ip4_main_t ip4_main
Global ip4 main structure.
Control ping from client to api server request.
static void vl_api_snat_worker_dump_t_handler(vl_api_snat_worker_dump_t *mp)
#define vec_foreach(var, vec)
Vector iterator.
static void vl_api_snat_address_dump_t_handler(vl_api_snat_address_dump_t *mp)
static void plugin_custom_dump_configure(snat_main_t *sm)
u16 vl_msg_api_get_msg_ids(char *name, int n)
u8 static_mapping_connection_tracking
#define clib_error_return(e, args...)
Add/delete S-NAT static mapping reply.
static vlib_cli_command_t set_workers_command
(constructor) VLIB_CLI_COMMAND (set_workers_command)
ethernet_main_t * ethernet_main
static void * vl_api_snat_interface_dump_t_print(vl_api_snat_interface_dump_t *mp, void *handle)
Show S-NAT plugin startup config.
snat_session_t * sessions
static clib_error_t * snat_feature_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define snat_is_session_static(s)
Check if SNAT session is created from static mapping.
static void setup_message_id_table(snat_main_t *sm, api_main_t *am)
static clib_error_t * set_workers_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
clib_bihash_8_8_t worker_by_out
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
static int snat_set_workers(uword *bitmap)
struct _unix_shared_memory_queue unix_shared_memory_queue_t
static uword pool_elts(void *v)
Number of active elements in a pool.