33 #include <vpp/app/version.h> 40 .arc_name =
"ip4-unicast",
41 .node_name =
"nat44-in2out",
45 .arc_name =
"ip4-unicast",
46 .node_name =
"nat44-out2in",
50 .arc_name =
"ip4-unicast",
51 .node_name =
"nat44-classify",
55 .arc_name =
"ip4-unicast",
56 .node_name =
"nat44-det-in2out",
60 .arc_name =
"ip4-unicast",
61 .node_name =
"nat44-det-out2in",
65 .arc_name =
"ip4-unicast",
66 .node_name =
"nat44-det-classify",
70 .arc_name =
"ip4-unicast",
71 .node_name =
"nat44-in2out-worker-handoff",
75 .arc_name =
"ip4-unicast",
76 .node_name =
"nat44-out2in-worker-handoff",
80 .arc_name =
"ip4-unicast",
81 .node_name =
"nat44-handoff-classify",
85 .arc_name =
"ip4-unicast",
86 .node_name =
"nat44-in2out-fast",
90 .arc_name =
"ip4-unicast",
91 .node_name =
"nat44-out2in-fast",
95 .arc_name =
"ip4-unicast",
96 .node_name =
"nat44-hairpin-dst",
102 .arc_name =
"ip4-output",
103 .node_name =
"nat44-in2out-output",
107 .arc_name =
"ip4-output",
108 .node_name =
"nat44-in2out-output-worker-handoff",
112 .arc_name =
"ip4-output",
113 .node_name =
"nat44-hairpin-src",
120 .arc_name =
"ip4-local",
121 .node_name =
"nat44-hairpinning",
128 .version = VPP_BUILD_VER,
129 .description =
"Network Address Translation",
158 ed_key.
l_addr = s->out2in.addr;
159 ed_key.
r_addr = s->ext_host_addr;
163 ed_key.
proto = s->in2out.port;
170 ed_key.
l_port = s->out2in.port;
171 ed_key.
r_port = s->ext_host_port;
175 if (clib_bihash_add_del_16_8 (&sm->
out2in_ed, &ed_kv, 0))
178 ed_key.
l_addr = s->in2out.addr;
181 ed_key.
l_port = s->in2out.port;
184 ed_key.
r_addr = s->ext_host_nat_addr;
185 ed_key.
r_port = s->ext_host_nat_port;
189 if (clib_bihash_add_del_16_8 (&sm->
in2out_ed, &ed_kv, 0))
198 s->out2in.addr.as_u32,
202 s->in2out.fib_index);
210 key.
port = s->ext_host_nat_port;
212 if (a->
addr.
as_u32 == s->ext_host_nat_addr.as_u32)
215 thread_index, &key, i);
225 kv.
key = s->in2out.as_u64;
226 if (clib_bihash_add_del_8_8 (&tsm->
in2out, &kv, 0))
228 kv.
key = s->out2in.as_u64;
229 if (clib_bihash_add_del_8_8 (&tsm->
out2in, &kv, 0))
235 if (s->outside_address_index != ~0)
237 &s->out2in, s->outside_address_index);
255 if (clib_bihash_search_8_8 (&tsm->
user_hash, &kv, &value))
259 memset (u, 0,
sizeof (*u));
273 if (clib_bihash_add_del_8_8 (&tsm->
user_hash, &kv, 1))
289 u32 oldest_per_user_translation_list_index, session_index;
290 dlist_elt_t * oldest_per_user_translation_list_elt;
296 oldest_per_user_translation_list_index =
300 ASSERT (oldest_per_user_translation_list_index != ~0);
305 oldest_per_user_translation_list_index);
307 oldest_per_user_translation_list_elt =
309 oldest_per_user_translation_list_index);
312 session_index = oldest_per_user_translation_list_elt->
value;
317 s->outside_address_index = ~0;
325 memset (s, 0,
sizeof (*s));
326 s->outside_address_index = ~0;
331 per_user_translation_list_elt - tsm->
list_pool);
334 s->per_user_index = per_user_translation_list_elt - tsm->
list_pool;
338 s->per_user_list_head_index,
339 per_user_translation_list_elt - tsm->
list_pool);
350 u32 n_left_from, * from, * to_next;
358 while (n_left_from > 0)
363 to_next, n_left_to_next);
365 while (n_left_from > 0 && n_left_to_next > 0)
418 to_next, n_left_to_next,
438 .name =
"nat44-classify",
439 .vector_size =
sizeof (
u32),
461 .name =
"nat44-det-classify",
462 .vector_size =
sizeof (
u32),
484 .name =
"nat44-handoff-classify",
485 .vector_size =
sizeof (
u32),
517 .ip4.as_u32 = addr->
as_u32,
568 #define _(N, i, n, s) \ 569 clib_bitmap_alloc (ap->busy_##n##_port_bitmap, 65535); \ 570 ap->busy_##n##_ports = 0; \ 571 vec_validate_init_empty (ap->busy_##n##_ports_per_thread, tm->n_vlib_mains - 1, 0); 581 if (nat_interface_is_inside(i) || sm->out2in_dpo)
584 snat_add_del_addr_to_fib(addr, 32, i->sw_if_index, 1);
589 if (nat_interface_is_inside(i) || sm->out2in_dpo)
592 snat_add_del_addr_to_fib(addr, 32, i->sw_if_index, 1);
603 if (m->external_addr.as_u32 == addr.as_u32)
614 v = clib_net_to_host_u32(a->
as_u32) + 1;
615 a->
as_u32 = clib_host_to_net_u32(v);
664 u16 l_port,
u16 e_port,
u32 vrf_id,
int addr_only,
666 u8 twice_nat,
u8 out2in_only,
u8 * tag)
681 u32 elt_index, head_index;
688 if (sw_if_index != ~0)
717 return VNET_API_ERROR_VALUE_EXIST;
720 (sm, l_addr, l_port, sw_if_index, e_port, vrf_id, proto,
721 addr_only, is_add, tag);
724 if (first_int_addr == 0)
739 return VNET_API_ERROR_NO_SUCH_ENTRY;
756 m_key.
port = addr_only ? 0 : e_port;
757 m_key.
protocol = addr_only ? 0 : proto;
768 return VNET_API_ERROR_VALUE_EXIST;
770 if (twice_nat && addr_only)
771 return VNET_API_ERROR_UNSUPPORTED;
778 return VNET_API_ERROR_NO_SUCH_FIB;
791 m_key.
port = addr_only ? 0 : l_port;
792 m_key.
protocol = addr_only ? 0 : proto;
796 return VNET_API_ERROR_VALUE_EXIST;
811 #define _(N, j, n, s) \ 812 case SNAT_PROTOCOL_##N: \ 813 if (clib_bitmap_get_no_check (a->busy_##n##_port_bitmap, e_port)) \ 814 return VNET_API_ERROR_INVALID_VALUE; \ 815 clib_bitmap_set_no_check (a->busy_##n##_port_bitmap, e_port, 1); \ 818 a->busy_##n##_ports++; \ 819 a->busy_##n##_ports_per_thread[(e_port - 1024) / sm->port_per_thread]++; \ 826 return VNET_API_ERROR_INVALID_VALUE_2;
834 if (sw_if_index != ~0)
851 return VNET_API_ERROR_NO_SUCH_ENTRY;
856 memset (m, 0,
sizeof (*m));
891 if (twice_nat || out2in_only)
893 m_key.
port = clib_host_to_net_u16 (l_port);
896 if (clib_bihash_add_del_8_8(&tsm->
in2out, &kv, 1))
906 if (twice_nat || out2in_only)
908 m_key.
port = clib_host_to_net_u16 (e_port);
911 if (clib_bihash_add_del_8_8(&tsm->
out2in, &kv, 1))
921 if (!clib_bihash_search_8_8 (&tsm->
user_hash, &kv, &value))
923 user_index = value.
value;
929 elt_index = head->
next;
931 ses_index = elt->
value;
932 while (ses_index != ~0)
936 ses_index = elt->
value;
943 if ((s->out2in.addr.as_u32 != e_addr.
as_u32) &&
944 (clib_net_to_host_u16 (s->out2in.port) != e_port))
965 if (sw_if_index != ~0)
968 return VNET_API_ERROR_NO_SUCH_ENTRY;
981 #define _(N, j, n, s) \ 982 case SNAT_PROTOCOL_##N: \ 983 clib_bitmap_set_no_check (a->busy_##n##_port_bitmap, e_port, 0); \ 986 a->busy_##n##_ports--; \ 987 a->busy_##n##_ports_per_thread[(e_port - 1024) / sm->port_per_thread]--; \ 994 return VNET_API_ERROR_INVALID_VALUE_2;
1013 if (twice_nat || out2in_only)
1018 if (clib_bihash_add_del_8_8(&tsm->
in2out, &kv, 0))
1027 if (twice_nat || out2in_only)
1032 if (clib_bihash_add_del_8_8(&tsm->
out2in, &kv, 0))
1043 if (!clib_bihash_search_8_8 (&tsm->
user_hash, &kv, &value))
1045 user_index = value.
value;
1051 elt_index = head->
next;
1053 ses_index = elt->
value;
1054 while (ses_index != ~0)
1058 ses_index = elt->
value;
1062 if ((s->out2in.addr.as_u32 != e_addr.
as_u32) &&
1063 (clib_net_to_host_u16 (s->out2in.port) != e_port))
1079 clib_bihash_add_del_8_8 (&tsm->
user_hash, &kv, 0);
1096 if (nat_interface_is_inside(interface) || sm->out2in_dpo)
1099 snat_add_del_addr_to_fib(&e_addr, 32, interface->sw_if_index, is_add);
1104 if (nat_interface_is_inside(interface) || sm->out2in_dpo)
1107 snat_add_del_addr_to_fib(&e_addr, 32, interface->sw_if_index, is_add);
1124 if (vec_len(m->locals))
1126 if (m->external_port == e_port && m->external_addr.as_u32 == e_addr->as_u32)
1129 vec_foreach (ap, m->locals)
1131 if (ap->port == local->port && ap->addr.as_u32 == local->addr.as_u32)
1144 u8 twice_nat,
u8 out2in_only,
u8 *tag)
1154 u32 worker_index = 0, elt_index, head_index, ses_index;
1161 m_key.
addr = e_addr;
1162 m_key.
port = e_port;
1174 return VNET_API_ERROR_VALUE_EXIST;
1177 return VNET_API_ERROR_INVALID_VALUE;
1195 #define _(N, j, n, s) \ 1196 case SNAT_PROTOCOL_##N: \ 1197 if (clib_bitmap_get_no_check (a->busy_##n##_port_bitmap, e_port)) \ 1198 return VNET_API_ERROR_INVALID_VALUE; \ 1199 clib_bitmap_set_no_check (a->busy_##n##_port_bitmap, e_port, 1); \ 1200 if (e_port > 1024) \ 1202 a->busy_##n##_ports++; \ 1203 a->busy_##n##_ports_per_thread[(e_port - 1024) / sm->port_per_thread]++; \ 1210 return VNET_API_ERROR_INVALID_VALUE_2;
1217 return VNET_API_ERROR_NO_SUCH_ENTRY;
1221 memset (m, 0,
sizeof (*m));
1240 clib_warning (
"static_mapping_by_external key add failed");
1241 return VNET_API_ERROR_UNSPECIFIED;
1258 if (clib_bihash_add_del_8_8(&tsm->
out2in, &kv, 1))
1261 return VNET_API_ERROR_UNSPECIFIED;
1265 for (i = 0; i <
vec_len (locals); i++)
1275 locals[
i].
prefix = (i == 0) ? locals[i].probability :\
1276 (locals[i - 1].prefix + locals[i].probability);
1279 m_key.
port = clib_host_to_net_u16 (locals[i].port);
1282 if (clib_bihash_add_del_8_8(&tsm->
in2out, &kv, 1))
1285 return VNET_API_ERROR_UNSPECIFIED;
1292 return VNET_API_ERROR_NO_SUCH_ENTRY;
1306 #define _(N, j, n, s) \ 1307 case SNAT_PROTOCOL_##N: \ 1308 clib_bitmap_set_no_check (a->busy_##n##_port_bitmap, e_port, 0); \ 1309 if (e_port > 1024) \ 1311 a->busy_##n##_ports--; \ 1312 a->busy_##n##_ports_per_thread[(e_port - 1024) / sm->port_per_thread]--; \ 1319 return VNET_API_ERROR_INVALID_VALUE_2;
1334 clib_warning (
"static_mapping_by_external key del failed");
1335 return VNET_API_ERROR_UNSPECIFIED;
1340 if (clib_bihash_add_del_8_8(&tsm->
out2in, &kv, 0))
1343 return VNET_API_ERROR_UNSPECIFIED;
1356 clib_warning (
"static_mapping_by_local key del failed");
1357 return VNET_API_ERROR_UNSPECIFIED;
1363 m_key.
port = clib_host_to_net_u16 (local->
port);
1365 if (clib_bihash_add_del_8_8(&tsm->
in2out, &kv, 0))
1368 return VNET_API_ERROR_UNSPECIFIED;
1375 if (!clib_bihash_search_8_8 (&tsm->
user_hash, &kv, &value))
1382 elt_index = head->
next;
1384 ses_index = elt->
value;
1385 while (ses_index != ~0)
1389 ses_index = elt->
value;
1391 if ((s->in2out.addr.as_u32 != local->
addr.
as_u32) &&
1392 (clib_net_to_host_u16 (s->in2out.port) != local->
port))
1418 snat_session_t *ses;
1419 u32 *ses_to_be_removed = 0, *ses_index;
1430 for (i=0; i <
vec_len (addresses); i++)
1439 return VNET_API_ERROR_NO_SUCH_ENTRY;
1445 if (m->external_addr.as_u32 == addr.as_u32)
1446 (void) snat_add_static_mapping (m->local_addr, m->external_addr,
1447 m->local_port, m->external_port,
1448 m->vrf_id, m->addr_only, ~0,
1449 m->proto, 0, m->twice_nat,
1450 m->out2in_only, m->tag);
1459 return VNET_API_ERROR_UNSPECIFIED;
1468 if (a->busy_tcp_ports || a->busy_udp_ports || a->busy_icmp_ports)
1473 if (ses->out2in.addr.as_u32 == addr.as_u32)
1475 ses->outside_address_index = ~0;
1476 nat_free_session_data (sm, ses, tsm - sm->per_thread_data);
1477 clib_dlist_remove (tsm->list_pool, ses->per_user_index);
1478 pool_put_index (tsm->list_pool, ses->per_user_index);
1479 vec_add1 (ses_to_be_removed, ses - tsm->sessions);
1480 user_key.addr = ses->in2out.addr;
1481 user_key.fib_index = ses->in2out.fib_index;
1482 kv.key = user_key.as_u64;
1483 if (!clib_bihash_search_8_8 (&tsm->user_hash, &kv, &value))
1485 u = pool_elt_at_index (tsm->users, value.value);
1509 if (nat_interface_is_inside(interface) || sm->out2in_dpo)
1512 snat_add_del_addr_to_fib(&addr, 32, interface->sw_if_index, 0);
1515 pool_foreach (interface, sm->output_feature_interfaces,
1517 if (nat_interface_is_inside(interface) || sm->out2in_dpo)
1520 snat_add_del_addr_to_fib(&addr, 32, interface->sw_if_index, 0);
1531 const char * feature_name, *del_feature_name;
1537 return VNET_API_ERROR_UNSUPPORTED;
1541 if (i->sw_if_index == sw_if_index)
1542 return VNET_API_ERROR_VALUE_EXIST;
1546 feature_name = is_inside ?
"nat44-in2out-fast" :
"nat44-out2in-fast";
1550 feature_name = is_inside ?
"nat44-in2out-worker-handoff" :
"nat44-out2in-worker-handoff";
1552 feature_name = is_inside ?
"nat44-det-in2out" :
"nat44-det-out2in";
1554 feature_name = is_inside ?
"nat44-in2out" :
"nat44-out2in";
1565 if (i->sw_if_index == sw_if_index)
1569 if (nat_interface_is_inside(i) && nat_interface_is_outside(i))
1572 i->flags &= ~NAT_INTERFACE_FLAG_IS_INSIDE;
1574 i->flags &= ~NAT_INTERFACE_FLAG_IS_OUTSIDE;
1576 if (sm->num_workers > 1 && !sm->deterministic)
1578 del_feature_name =
"nat44-handoff-classify";
1579 feature_name = !is_inside ?
"nat44-in2out-worker-handoff" :
1580 "nat44-out2in-worker-handoff";
1582 else if (sm->deterministic)
1584 del_feature_name =
"nat44-det-classify";
1585 feature_name = !is_inside ?
"nat44-det-in2out" :
1590 del_feature_name =
"nat44-classify";
1591 feature_name = !is_inside ?
"nat44-in2out" :
"nat44-out2in";
1594 vnet_feature_enable_disable (
"ip4-unicast", del_feature_name,
1595 sw_if_index, 0, 0, 0);
1596 vnet_feature_enable_disable (
"ip4-unicast", feature_name,
1597 sw_if_index, 1, 0, 0);
1601 vnet_feature_enable_disable (
"ip4-unicast", feature_name,
1602 sw_if_index, 0, 0, 0);
1603 pool_put (sm->interfaces, i);
1608 if ((nat_interface_is_inside(i) && is_inside) ||
1609 (nat_interface_is_outside(i) && !is_inside))
1612 if (sm->num_workers > 1 && !sm->deterministic)
1614 del_feature_name = !is_inside ?
"nat44-in2out-worker-handoff" :
1615 "nat44-out2in-worker-handoff";
1616 feature_name =
"nat44-handoff-classify";
1618 else if (sm->deterministic)
1620 del_feature_name = !is_inside ?
"nat44-det-in2out" :
1622 feature_name =
"nat44-det-classify";
1626 del_feature_name = !is_inside ?
"nat44-in2out" :
"nat44-out2in";
1627 feature_name =
"nat44-classify";
1630 vnet_feature_enable_disable (
"ip4-unicast", del_feature_name,
1631 sw_if_index, 0, 0, 0);
1632 vnet_feature_enable_disable (
"ip4-unicast", feature_name,
1633 sw_if_index, 1, 0, 0);
1642 return VNET_API_ERROR_NO_SUCH_ENTRY;
1645 i->sw_if_index = sw_if_index;
1657 if (is_inside && !sm->out2in_dpo)
1660 sw_if_index, !is_del, 0, 0);
1669 if (!(m->addr_only) || (m->local_addr.as_u32 == m->external_addr.as_u32))
1672 snat_add_del_addr_to_fib(&m->external_addr, 32, sw_if_index, !is_del);
1677 snat_add_del_addr_to_fib(&dm->out_addr, dm->out_plen, sw_if_index, !is_del);
1694 return VNET_API_ERROR_UNSUPPORTED;
1698 if (i->sw_if_index == sw_if_index)
1699 return VNET_API_ERROR_VALUE_EXIST;
1705 sw_if_index, !is_del, 0, 0);
1707 sw_if_index, !is_del, 0, 0);
1714 sw_if_index, !is_del, 0, 0);
1716 "nat44-in2out-output-worker-handoff",
1717 sw_if_index, !is_del, 0, 0);
1724 sw_if_index, !is_del, 0, 0);
1737 if (i->sw_if_index == sw_if_index)
1740 pool_put (sm->output_feature_interfaces, i);
1742 return VNET_API_ERROR_VALUE_EXIST;
1749 return VNET_API_ERROR_NO_SUCH_ENTRY;
1751 pool_get (sm->output_feature_interfaces,
i);
1752 i->sw_if_index = sw_if_index;
1769 if (!(m->addr_only))
1772 snat_add_del_addr_to_fib(&m->external_addr, 32, sw_if_index, !is_del);
1784 return VNET_API_ERROR_FEATURE_DISABLED;
1787 return VNET_API_ERROR_INVALID_WORKER;
1810 u32 if_address_index,
1819 u32 if_address_index,
1827 u32 * address_indexp,
1828 u16 port_per_thread,
1829 u32 snat_thread_index);
1931 u16 port_host_byte_order = clib_net_to_host_u16 (k->
port);
1935 a = addresses + address_index;
1939 #define _(N, i, n, s) \ 1940 case SNAT_PROTOCOL_##N: \ 1941 ASSERT (clib_bitmap_get_no_check (a->busy_##n##_port_bitmap, \ 1942 port_host_byte_order) == 1); \ 1943 clib_bitmap_set_no_check (a->busy_##n##_port_bitmap, \ 1944 port_host_byte_order, 0); \ 1945 a->busy_##n##_ports--; \ 1946 a->busy_##n##_ports_per_thread[thread_index]--; \ 1986 m_key.
port = clib_net_to_host_u16 (match.
port);
1992 if (clib_bihash_search_8_8 (mapping_hash, &kv, &value))
1998 if (clib_bihash_search_8_8 (mapping_hash, &kv, &value))
2012 mid = ((
hi -
lo) >> 1) +
lo;
2061 u32 * address_indexp,
2062 u16 port_per_thread,
2063 u32 snat_thread_index)
2068 address_indexp, port_per_thread,
2077 u32 * address_indexp,
2078 u16 port_per_thread,
2079 u32 snat_thread_index)
2085 for (i = 0; i <
vec_len (addresses); i++)
2090 #define _(N, j, n, s) \ 2091 case SNAT_PROTOCOL_##N: \ 2092 if (a->busy_##n##_ports_per_thread[thread_index] < port_per_thread) \ 2094 if (a->fib_index == fib_index) \ 2098 portnum = (port_per_thread * \ 2099 snat_thread_index) + \ 2100 snat_random_port(1, port_per_thread) + 1024; \ 2101 if (clib_bitmap_get_no_check (a->busy_##n##_port_bitmap, portnum)) \ 2103 clib_bitmap_set_no_check (a->busy_##n##_port_bitmap, portnum, 1); \ 2104 a->busy_##n##_ports_per_thread[thread_index]++; \ 2105 a->busy_##n##_ports++; \ 2106 k->addr = a->addr; \ 2107 k->port = clib_host_to_net_u16(portnum); \ 2108 *address_indexp = i; \ 2112 else if (a->fib_index == ~0) \ 2133 #define _(N, j, n, s) \ 2134 case SNAT_PROTOCOL_##N: \ 2137 portnum = (port_per_thread * \ 2138 snat_thread_index) + \ 2139 snat_random_port(1, port_per_thread) + 1024; \ 2140 if (clib_bitmap_get_no_check (a->busy_##n##_port_bitmap, portnum)) \ 2142 clib_bitmap_set_no_check (a->busy_##n##_port_bitmap, portnum, 1); \ 2143 a->busy_##n##_ports_per_thread[thread_index]++; \ 2144 a->busy_##n##_ports++; \ 2145 k->addr = a->addr; \ 2146 k->port = clib_host_to_net_u16(portnum); \ 2147 *address_indexp = gi; \ 2169 u32 * address_indexp,
2170 u16 port_per_thread,
2171 u32 snat_thread_index)
2175 u16 m, ports, portnum, A, j;
2184 #define _(N, i, n, s) \ 2185 case SNAT_PROTOCOL_##N: \ 2186 if (a->busy_##n##_ports < ports) \ 2190 A = snat_random_port(1, pow2_mask(sm->psid_offset)); \ 2191 j = snat_random_port(0, pow2_mask(m)); \ 2192 portnum = A | (sm->psid << sm->psid_offset) | (j << (16 - m)); \ 2193 if (clib_bitmap_get_no_check (a->busy_##n##_port_bitmap, portnum)) \ 2195 clib_bitmap_set_no_check (a->busy_##n##_port_bitmap, portnum, 1); \ 2196 a->busy_##n##_ports++; \ 2197 k->addr = a->addr; \ 2198 k->port = clib_host_to_net_u16 (portnum); \ 2199 *address_indexp = i; \ 2224 .fp_addr.ip4.as_u32 = addr.
as_u32,
2243 u32 *r = va_arg (*args,
u32 *);
2246 #define _(N, i, n, s) else if (unformat (input, s)) *r = SNAT_PROTOCOL_##N; 2262 #define _(N, j, n, str) case SNAT_PROTOCOL_##N: t = (u8 *) str; break; 2266 s =
format (s,
"unknown");
2277 u32 next_worker_index = 0;
2285 next_worker_index += sm->
workers[hash & (_vec_len (sm->
workers) - 1)];
2289 return next_worker_index;
2307 u32 next_worker_index = 0;
2335 nat_reass_ip4_t *reass;
2340 if (reass && (reass->thread_index != (
u32) ~ 0))
2341 return reass->thread_index;
2359 if (!clib_bihash_search_16_8 (&sm->
out2in_ed, &s_kv, &s_value))
2381 icmp46_header_t * icmp = (icmp46_header_t *) udp;
2392 case SNAT_PROTOCOL_ICMP:
2393 icmp = (icmp46_header_t*)l4_header;
2397 case SNAT_PROTOCOL_UDP:
2398 case SNAT_PROTOCOL_TCP:
2410 m_key.addr = ip0->dst_address;
2411 m_key.port = clib_net_to_host_u16 (port);
2412 m_key.protocol = proto;
2413 m_key.fib_index = rx_fib_index0;
2414 kv.key = m_key.as_u64;
2415 if (!clib_bihash_search_8_8 (&sm->static_mapping_by_external, &kv, &value))
2418 return m->worker_index;
2423 next_worker_index = sm->first_worker_index;
2424 next_worker_index +=
2425 sm->workers[(clib_net_to_host_u16 (port) - 1024) / sm->port_per_thread];
2426 return next_worker_index;
2434 u32 translation_buckets = 1024;
2435 u32 translation_memory_size = 128<<20;
2436 u32 user_buckets = 128;
2437 u32 user_memory_size = 64<<20;
2438 u32 max_translations_per_user = 100;
2439 u32 outside_vrf_id = 0;
2440 u32 outside_ip6_vrf_id = 0;
2441 u32 inside_vrf_id = 0;
2442 u32 static_mapping_buckets = 1024;
2443 u32 static_mapping_memory_size = 64<<20;
2444 u32 nat64_bib_buckets = 1024;
2445 u32 nat64_bib_memory_size = 128 << 20;
2446 u32 nat64_st_buckets = 2048;
2447 u32 nat64_st_memory_size = 256 << 20;
2448 u8 static_mapping_only = 0;
2449 u8 static_mapping_connection_tracking = 0;
2458 if (
unformat (input,
"translation hash buckets %d", &translation_buckets))
2460 else if (
unformat (input,
"translation hash memory %d",
2461 &translation_memory_size));
2462 else if (
unformat (input,
"user hash buckets %d", &user_buckets))
2464 else if (
unformat (input,
"user hash memory %d",
2467 else if (
unformat (input,
"max translations per user %d",
2468 &max_translations_per_user))
2470 else if (
unformat (input,
"outside VRF id %d",
2473 else if (
unformat (input,
"outside ip6 VRF id %d",
2474 &outside_ip6_vrf_id))
2476 else if (
unformat (input,
"inside VRF id %d",
2479 else if (
unformat (input,
"static mapping only"))
2481 static_mapping_only = 1;
2482 if (
unformat (input,
"connection tracking"))
2483 static_mapping_connection_tracking = 1;
2485 else if (
unformat (input,
"deterministic"))
2487 else if (
unformat (input,
"nat64 bib hash buckets %d",
2488 &nat64_bib_buckets))
2490 else if (
unformat (input,
"nat64 bib hash memory %d",
2491 &nat64_bib_memory_size))
2493 else if (
unformat (input,
"nat64 st hash buckets %d", &nat64_st_buckets))
2495 else if (
unformat (input,
"nat64 st hash memory %d",
2496 &nat64_st_memory_size))
2498 else if (
unformat (input,
"out2in dpo"))
2500 else if (
unformat (input,
"dslite ce"))
2530 nat64_set_hash(nat64_bib_buckets, nat64_bib_memory_size, nat64_st_buckets,
2531 nat64_st_memory_size);
2548 if (!static_mapping_only ||
2549 (static_mapping_only && static_mapping_connection_tracking))
2556 clib_bihash_init_8_8 (&tsm->
in2out,
"in2out", translation_buckets,
2557 translation_memory_size);
2559 clib_bihash_init_8_8 (&tsm->
out2in,
"out2in", translation_buckets,
2560 translation_memory_size);
2562 clib_bihash_init_8_8 (&tsm->
user_hash,
"users", user_buckets,
2566 clib_bihash_init_16_8 (&sm->
in2out_ed,
"in2out-ed",
2567 translation_buckets, translation_memory_size);
2569 clib_bihash_init_16_8 (&sm->
out2in_ed,
"out2in-ed",
2570 translation_buckets, translation_memory_size);
2578 "static_mapping_by_local", static_mapping_buckets,
2579 static_mapping_memory_size);
2582 "static_mapping_by_external", static_mapping_buckets,
2583 static_mapping_memory_size);
2598 #define _(v, N, str) case SNAT_SESSION_##N: t = (u8 *) str; break; 2602 t =
format (t,
"unknown");
2612 s =
format (s,
"%U proto %U port %d fib %d",
2622 snat_session_t * sess = va_arg (*args, snat_session_t *);
2626 s =
format (s,
" i2o %U proto %u fib %u\n",
2628 clib_net_to_host_u16 (sess->in2out.port),
2629 sess->in2out.fib_index);
2630 s =
format (s,
" o2i %U proto %u fib %u\n",
2632 clib_net_to_host_u16 (sess->out2in.port),
2633 sess->out2in.fib_index);
2642 s =
format (s,
" external host o2i %U:%d i2o %U:%d\n",
2644 clib_net_to_host_u16 (sess->ext_host_port),
2646 clib_net_to_host_u16 (sess->ext_host_nat_port));
2650 if (sess->ext_host_addr.as_u32)
2651 s =
format (s,
" external host %U\n",
2654 s =
format (s,
" last heard %.2f\n", sess->last_heard);
2655 s =
format (s,
" total pkts %d, total bytes %lld\n",
2656 sess->total_pkts, sess->total_bytes);
2658 s =
format (s,
" static translation\n");
2660 s =
format (s,
" dynamic translation\n");
2662 s =
format (s,
" load-balancing\n");
2664 s =
format (s,
" twice-nat\n");
2673 int verbose = va_arg (*args,
int);
2675 u32 elt_index, head_index;
2677 snat_session_t * sess;
2679 s =
format (s,
"%U: %d dynamic translations, %d static translations\n",
2690 elt_index = head->
next;
2692 session_index = elt->
value;
2694 while (session_index != ~0)
2700 elt_index = elt->
next;
2702 session_index = elt->
value;
2715 s =
format (s,
"local %U external %U vrf %d %s",
2723 s =
format (s,
"%U vrf %d external %U:%d %s %s",
2730 s =
format (s,
"\n local %U:%d probability %d\%",
2735 s =
format (s,
"%U local %U:%d external %U:%d vrf %d %s %s",
2751 s =
format (s,
"local %U external %U vrf %d",
2756 s =
format (s,
"%U local %U:%d external %U:%d vrf %d",
2769 u32 in_offset, out_offset;
2771 u32 *
i = va_arg (*args,
u32 *);
2774 in_addr.
as_u32 = clib_host_to_net_u32 (
2775 clib_net_to_host_u32(det_map->
in_addr.
as_u32) + user_index);
2776 in_offset = clib_net_to_host_u32(in_addr.
as_u32) -
2779 out_addr.
as_u32 = clib_host_to_net_u32(
2781 s =
format (s,
"in %U:%d out %U:%d external host %U:%d state: %U expire: %d\n",
2783 clib_net_to_host_u16 (ses->
in_port),
2800 u32 if_address_index,
2862 clib_warning (
"snat_add_static_mapping returned %d", rv);
2871 u32 if_address_index,
2902 for (j = 0; j <
vec_len(addresses); j++)
2903 if (addresses[j].
addr.as_u32 == address->
as_u32)
2953 u32 *indices_to_delete = 0;
2955 u32 *auto_add_sw_if_indices =
2961 for (i = 0; i <
vec_len(auto_add_sw_if_indices); i++)
2963 if (auto_add_sw_if_indices[i] == sw_if_index)
2978 if (
vec_len(indices_to_delete))
2980 for (j =
vec_len(indices_to_delete)-1; j >= 0; j--)
2991 return VNET_API_ERROR_VALUE_EXIST;
2998 return VNET_API_ERROR_NO_SUCH_ENTRY;
3023 clib_bihash_8_8_t *t;
3036 key.
port = clib_host_to_net_u16 (port);
3040 t = is_in ? &tsm->in2out : &tsm->out2in;
3041 if (!clib_bihash_search_8_8 (t, &kv, &value))
3044 kv.
key = s->in2out.as_u64;
3045 clib_bihash_add_del_8_8 (&tsm->in2out, &kv, 0);
3046 kv.
key = s->out2in.as_u64;
3047 clib_bihash_add_del_8_8 (&tsm->out2in, &kv, 0);
3048 u_key.
addr = s->in2out.addr;
3051 if (!clib_bihash_search_8_8 (&tsm->user_hash, &kv, &value))
3061 return VNET_API_ERROR_NO_SUCH_ENTRY;
ip4_address_t external_addr
u8 * format_snat_user(u8 *s, va_list *args)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
clib_error_t * snat_api_init(vlib_main_t *vm, snat_main_t *sm)
void dslite_set_ce(dslite_main_t *dm, u8 set)
fib_protocol_t fp_proto
protocol type
#define snat_is_session_static(s)
Check if SNAT session is created from static mapping.
u32 sessions_per_user_list_head_index
clib_bihash_16_8_t out2in_ed
int snat_del_address(snat_main_t *sm, ip4_address_t addr, u8 delete_sm, u8 twice_nat)
vlib_node_registration_t nat44_handoff_classify_node
(constructor) VLIB_REGISTER_NODE (nat44_handoff_classify_node)
void dslite_init(vlib_main_t *vm)
ip4_add_del_interface_address_callback_t * add_del_interface_address_callbacks
Functions to call when interface address changes.
VLIB_NODE_FUNCTION_MULTIARCH(nat44_classify_node, nat44_classify_node_fn)
u8 * format_snat_protocol(u8 *s, va_list *args)
static void clib_dlist_init(dlist_elt_t *pool, u32 index)
vnet_main_t * vnet_get_main(void)
static int nat_alloc_addr_and_port_mape(snat_address_t *addresses, u32 fib_index, u32 thread_index, snat_session_key_t *k, u32 *address_indexp, u16 port_per_thread, u32 snat_thread_index)
u32 fq_in2out_output_index
clib_error_t * nat_reass_init(vlib_main_t *vm)
Initialize NAT virtual fragmentation reassembly.
#define SNAT_TCP_ESTABLISHED_TIMEOUT
#define is_ed_session(s)
Check if NAT session is endpoint dependent.
ip4_address_t * ip4_interface_first_address(ip4_main_t *im, u32 sw_if_index, ip_interface_address_t **result_ia)
u32 vlib_frame_queue_main_init(u32 node_index, u32 frame_queue_nelts)
nat_reass_ip4_t * nat_ip4_reass_find(ip4_address_t src, ip4_address_t dst, u16 frag_id, u8 proto)
Find reassembly.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
u32 icmp_match_out2in_slow(snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
Get address and port values to be used for ICMP packet translation and create session if needed...
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
#define NAT_INTERFACE_FLAG_IS_OUTSIDE
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
vlib_node_registration_t snat_det_out2in_node
(constructor) VLIB_REGISTER_NODE (snat_det_out2in_node)
void nat64_set_hash(u32 bib_buckets, u32 bib_memory_size, u32 st_buckets, u32 st_memory_size)
Set NAT64 hash tables configuration.
clib_bihash_16_8_t in2out_ed
int snat_static_mapping_match(snat_main_t *sm, snat_session_key_t match, snat_session_key_t *mapping, u8 by_external, u8 *is_addr_only, u8 *twice_nat)
Match NAT44 static mapping.
void snat_add_del_addr_to_fib(ip4_address_t *addr, u8 p_len, u32 sw_if_index, int is_add)
Add/del NAT address to FIB.
nat_alloc_out_addr_and_port_function_t * alloc_addr_and_port
static void snat_ip4_add_del_interface_address_cb(ip4_main_t *im, uword opaque, u32 sw_if_index, ip4_address_t *address, u32 address_length, u32 if_address_index, u32 is_delete)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
#define snat_is_unk_proto_session(s)
Check if SNAT session for unknown protocol.
u8 * format_snat_static_mapping(u8 *s, va_list *args)
u32 icmp_match_in2out_fast(snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
Get address and port values to be used for ICMP packet translation.
format_function_t format_vnet_sw_if_index_name
int snat_interface_add_del(u32 sw_if_index, u8 is_inside, int is_del)
static uword nat44_classify_node_fn_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
nat44_lb_addr_port_t * locals
clib_bihash_8_8_t user_hash
fib_node_index_t fib_table_entry_update_one_path(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, dpo_proto_t next_hop_proto, const ip46_address_t *next_hop, u32 next_hop_sw_if_index, u32 next_hop_fib_index, u32 next_hop_weight, fib_mpls_label_t *next_hop_labels, fib_route_path_flags_t path_flags)
Update the entry to have just one path.
u32 max_translations_per_user
static void snat_add_static_mapping_when_resolved(snat_main_t *sm, ip4_address_t l_addr, u16 l_port, u32 sw_if_index, u16 e_port, u32 vrf_id, snat_protocol_t proto, int addr_only, int is_add, u8 *tag)
int nat44_add_del_lb_static_mapping(ip4_address_t e_addr, u16 e_port, snat_protocol_t proto, u32 vrf_id, nat44_lb_addr_port_t *locals, u8 is_add, u8 twice_nat, u8 out2in_only, u8 *tag)
u32 in2out_output_node_index
u32 ip4_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
#define static_always_inline
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
vlib_node_registration_t snat_out2in_node
(constructor) VLIB_REGISTER_NODE (snat_out2in_node)
ip4_address_t ext_host_addr
void fib_table_entry_special_remove(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source)
Remove a 'special' entry from the FIB.
static u32 snat_get_worker_in2out_cb(ip4_header_t *ip0, u32 rx_fib_index0)
#define SNAT_DET_SES_PER_USER
A high priority source a plugin can use.
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Aggregrate type for a prefix.
#define clib_error_return(e, args...)
void snat_ipfix_logging_init(vlib_main_t *vm)
Initialize NAT plugin IPFIX logging.
u8 * format_snat_key(u8 *s, va_list *args)
static void * ip4_next_header(ip4_header_t *i)
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
u16 fp_len
The mask length.
static void nat_ip4_add_del_addr_only_sm_cb(ip4_main_t *im, uword opaque, u32 sw_if_index, ip4_address_t *address, u32 address_length, u32 if_address_index, u32 is_delete)
static uword nat44_det_classify_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
u32 icmp_match_out2in_det(snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
Get address and port values to be used for ICMP packet translation and create session if needed...
static int ip4_is_fragment(ip4_header_t *i)
VNET_FEATURE_INIT(ip4_snat_in2out, static)
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
u32 * auto_add_sw_if_indices_twice_nat
snat_user_t * nat_user_get_or_create(snat_main_t *sm, ip4_address_t *addr, u32 fib_index, u32 thread_index)
#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.
void nat_free_session_data(snat_main_t *sm, snat_session_t *s, u32 thread_index)
void nat_dpo_module_init(void)
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 clib_dlist_addtail(dlist_elt_t *pool, u32 head_index, u32 new_index)
snat_static_mapping_t * static_mappings
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
void snat_ipfix_logging_nat44_ses_delete(u32 src_ip, u32 nat_src_ip, snat_protocol_t snat_proto, u16 src_port, u16 nat_src_port, u32 vrf_id)
Generate NAT44 session delete event.
vlib_node_registration_t nat44_classify_node
(constructor) VLIB_REGISTER_NODE (nat44_classify_node)
#define pool_put(P, E)
Free an object E in pool P.
#define vec_dup(V)
Return copy of vector (no header, no alignment)
#define VLIB_CONFIG_FUNCTION(x, n,...)
#define vec_del1(v, i)
Delete the element at index I.
clib_bihash_8_8_t static_mapping_by_external
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, u32 sw_if_index, snat_protocol_t proto, int is_add, u8 twice_nat, u8 out2in_only, u8 *tag)
Add static mapping.
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
void nat_set_alloc_addr_and_port_default(void)
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
void fib_table_unlock(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Take a reference counting lock on the table.
snat_interface_t * output_feature_interfaces
static uword nat44_handoff_classify_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define VLIB_REGISTER_NODE(x,...)
void snat_free_outside_address_and_port(snat_address_t *addresses, u32 thread_index, snat_session_key_t *k, u32 address_index)
static u32 random_u32_max(void)
Maximum value returned by random_u32()
static_always_inline uword vlib_get_thread_index(void)
u8 nat_reass_is_drop_frag(u8 is_ip6)
Get status of virtual fragmentation reassembly.
void nat44_add_del_address_dpo(ip4_address_t addr, u8 is_add)
vlib_node_registration_t snat_in2out_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_node)
u8 static_mapping_connection_tracking
snat_get_worker_function_t * worker_in2out_cb
#define vec_free(V)
Free vector's memory (no header).
void fib_table_entry_delete(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source)
Delete a FIB entry.
ip4_add_del_interface_address_function_t * function
deterministic NAT definitions
#define clib_warning(format, args...)
int snat_interface_add_del_output_feature(u32 sw_if_index, u8 is_inside, int is_del)
static int ip4_is_first_fragment(ip4_header_t *i)
static uword nat44_classify_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
dslite_main_t dslite_main
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
8 octet key, 8 octet key value pair
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
u32 icmp_match_in2out_slow(snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
Get address and port values to be used for ICMP packet translation and create session if needed...
u32 tcp_transitory_timeout
u32 * auto_add_sw_if_indices
fib_node_index_t fib_table_entry_special_dpo_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, const dpo_id_t *dpo)
Add a 'special' entry to the FIB that links to the DPO passed A special entry is an entry that the FI...
static_always_inline u16 snat_random_port(u16 min, u16 max)
static int nat_alloc_addr_and_port_default(snat_address_t *addresses, u32 fib_index, u32 thread_index, snat_session_key_t *k, u32 *address_indexp, u16 port_per_thread, u32 snat_thread_index)
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
#define pool_put_index(p, i)
Free pool element with given index.
#define NAT_INTERFACE_FLAG_IS_INSIDE
u8 * format_snat_static_map_to_resolve(u8 *s, va_list *args)
snat_get_worker_function_t * worker_out2in_cb
static u32 ip_proto_to_snat_proto(u8 ip_proto)
snat_icmp_match_function_t * icmp_match_out2in_cb
u32 fib_table_find_or_create_and_lock(fib_protocol_t proto, u32 table_id, fib_source_t src)
Get the index of the FIB for a Table-ID.
#define clib_bitmap_free(v)
Free a bitmap.
uword * thread_registrations_by_name
static void clib_dlist_remove(dlist_elt_t *pool, u32 index)
int nat44_del_session(snat_main_t *sm, ip4_address_t *addr, u16 port, snat_protocol_t proto, u32 vrf_id, int is_in)
snat_address_t * twice_nat_addresses
#define VNET_FEATURES(...)
static clib_error_t * snat_init(vlib_main_t *vm)
static uword is_pow2(uword x)
snat_session_t * nat_session_alloc_or_recycle(snat_main_t *sm, snat_user_t *u, u32 thread_index)
vlib_node_registration_t snat_det_in2out_node
(constructor) VLIB_REGISTER_NODE (snat_det_in2out_node)
u32 icmp_match_out2in_fast(snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
Get address and port values to be used for ICMP packet translation.
clib_error_t * nat64_init(vlib_main_t *vm)
Initialize NAT64.
struct _vlib_node_registration vlib_node_registration_t
NAT64 global declarations.
void increment_v4_address(ip4_address_t *a)
void snat_add_address(snat_main_t *sm, ip4_address_t *addr, u32 vrf_id, u8 twice_nat)
int snat_alloc_outside_address_and_port(snat_address_t *addresses, u32 fib_index, u32 thread_index, snat_session_key_t *k, u32 *address_indexp, u16 port_per_thread, u32 snat_thread_index)
static int lb_local_exists(nat44_lb_addr_port_t *local, ip4_address_t *e_addr, u16 e_port)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void snat_ipfix_logging_addresses_exhausted(u32 pool_id)
Generate NAT addresses exhausted event.
snat_main_per_thread_data_t * per_thread_data
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
#define DPO_INVALID
An initialiser for DPOs declared on the stack.
snat_address_t * addresses
void nat_dpo_create(dpo_proto_t dproto, u32 aftr_index, dpo_id_t *dpo)
int snat_add_interface_address(snat_main_t *sm, u32 sw_if_index, int is_del, u8 twice_nat)
u32 icmp_match_in2out_det(snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
Get address and port values to be used for ICMP packet translation and create session if needed...
u8 * format_snat_session(u8 *s, va_list *args)
#define hash_get_mem(h, key)
u8 * format_det_map_ses(u8 *s, va_list *args)
#define SNAT_ICMP_TIMEOUT
uword unformat_snat_protocol(unformat_input_t *input, va_list *args)
snat_static_map_resolve_t * to_resolve
static u32 random_u32(u32 *seed)
32-bit random number generator
ip4_main_t ip4_main
Global ip4 main structure.
static vlib_thread_main_t * vlib_get_thread_main()
u32 translation_memory_size
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
#define vec_foreach(var, vec)
Vector iterator.
vlib_node_registration_t snat_in2out_output_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_output_node)
vlib_node_registration_t nat44_det_classify_node
(constructor) VLIB_REGISTER_NODE (nat44_det_classify_node)
int snat_set_workers(uword *bitmap)
#define is_twice_nat_session(s)
Check if NAT session is twice NAT.
static clib_error_t * snat_config(vlib_main_t *vm, unformat_input_t *input)
NAT plugin virtual fragmentation reassembly.
void nat_set_alloc_addr_and_port_mape(u16 psid, u16 psid_offset, u16 psid_length)
NAT66 global declarations.
#define SNAT_TCP_TRANSITORY_TIMEOUT
ip_lookup_main_t * ip4_lookup_main
static int is_snat_address_used_in_static_mapping(snat_main_t *sm, ip4_address_t addr)
snat_session_t * sessions
u8 * format_snat_session_state(u8 *s, va_list *args)
A low (below routing) priority source a plugin can use.
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
snat_icmp_match_function_t * icmp_match_in2out_cb
#define SNAT_SESSION_FLAG_LOAD_BALANCING
clib_bihash_8_8_t static_mapping_by_local
static u32 snat_get_worker_out2in_cb(ip4_header_t *ip0, u32 rx_fib_index0)
snat_interface_t * interfaces
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_always_inline u8 icmp_is_error_message(icmp46_header_t *icmp)
static u8 snat_proto_to_ip_proto(snat_protocol_t snat_proto)
static u32 clib_dlist_remove_head(dlist_elt_t *pool, u32 head_index)
u32 tcp_established_timeout
static uword pool_elts(void *v)
Number of active elements in a pool.