37 #include <vpp/app/version.h> 47 .arc_name =
"ip4-unicast",
48 .node_name =
"nat-pre-in2out",
50 "ip4-sv-reassembly-feature"),
53 .arc_name =
"ip4-unicast",
54 .node_name =
"nat-pre-out2in",
56 "ip4-dhcp-client-detect",
57 "ip4-sv-reassembly-feature"),
60 .arc_name =
"ip4-unicast",
61 .node_name =
"nat44-in2out-worker-handoff",
65 .arc_name =
"ip4-unicast",
66 .node_name =
"nat44-out2in-worker-handoff",
68 "ip4-dhcp-client-detect"),
71 .arc_name =
"ip4-unicast",
72 .node_name =
"nat44-in2out",
73 .runs_after =
VNET_FEATURES (
"acl-plugin-in-ip4-fa",
"ip4-sv-reassembly-feature"),
76 .arc_name =
"ip4-unicast",
77 .node_name =
"nat44-out2in",
78 .runs_after =
VNET_FEATURES (
"acl-plugin-in-ip4-fa",
"ip4-sv-reassembly-feature",
79 "ip4-dhcp-client-detect"),
82 .arc_name =
"ip4-unicast",
83 .node_name =
"nat44-classify",
84 .runs_after =
VNET_FEATURES (
"acl-plugin-in-ip4-fa",
"ip4-sv-reassembly-feature"),
87 .arc_name =
"ip4-unicast",
88 .node_name =
"nat44-det-in2out",
89 .runs_after =
VNET_FEATURES (
"acl-plugin-in-ip4-fa",
"ip4-sv-reassembly-feature"),
92 .arc_name =
"ip4-unicast",
93 .node_name =
"nat44-det-out2in",
94 .runs_after =
VNET_FEATURES (
"acl-plugin-in-ip4-fa",
"ip4-sv-reassembly-feature",
95 "ip4-dhcp-client-detect"),
98 .arc_name =
"ip4-unicast",
99 .node_name =
"nat44-det-classify",
100 .runs_after =
VNET_FEATURES (
"acl-plugin-in-ip4-fa",
"ip4-sv-reassembly-feature"),
103 .arc_name =
"ip4-unicast",
104 .node_name =
"nat44-ed-in2out",
105 .runs_after =
VNET_FEATURES (
"acl-plugin-in-ip4-fa",
"ip4-sv-reassembly-feature"),
108 .arc_name =
"ip4-unicast",
109 .node_name =
"nat44-ed-out2in",
110 .runs_after =
VNET_FEATURES (
"acl-plugin-in-ip4-fa",
"ip4-sv-reassembly-feature",
111 "ip4-dhcp-client-detect"),
114 .arc_name =
"ip4-unicast",
115 .node_name =
"nat44-ed-classify",
116 .runs_after =
VNET_FEATURES (
"acl-plugin-in-ip4-fa",
"ip4-sv-reassembly-feature"),
119 .arc_name =
"ip4-unicast",
120 .node_name =
"nat44-handoff-classify",
121 .runs_after =
VNET_FEATURES (
"acl-plugin-in-ip4-fa",
"ip4-sv-reassembly-feature"),
124 .arc_name =
"ip4-unicast",
125 .node_name =
"nat44-in2out-fast",
126 .runs_after =
VNET_FEATURES (
"acl-plugin-in-ip4-fa",
"ip4-sv-reassembly-feature"),
129 .arc_name =
"ip4-unicast",
130 .node_name =
"nat44-out2in-fast",
131 .runs_after =
VNET_FEATURES (
"acl-plugin-in-ip4-fa",
"ip4-sv-reassembly-feature",
132 "ip4-dhcp-client-detect"),
135 .arc_name =
"ip4-unicast",
136 .node_name =
"nat44-hairpin-dst",
137 .runs_after =
VNET_FEATURES (
"acl-plugin-in-ip4-fa",
"ip4-sv-reassembly-feature"),
140 .arc_name =
"ip4-unicast",
141 .node_name =
"nat44-ed-hairpin-dst",
142 .runs_after =
VNET_FEATURES (
"acl-plugin-in-ip4-fa",
"ip4-sv-reassembly-feature"),
147 .arc_name =
"ip4-output",
148 .node_name =
"nat44-in2out-output",
149 .runs_after =
VNET_FEATURES (
"acl-plugin-out-ip4-fa",
"ip4-sv-reassembly-output-feature"),
152 .arc_name =
"ip4-output",
153 .node_name =
"nat44-in2out-output-worker-handoff",
154 .runs_after =
VNET_FEATURES (
"acl-plugin-out-ip4-fa",
"ip4-sv-reassembly-output-feature"),
157 .arc_name =
"ip4-output",
158 .node_name =
"nat44-hairpin-src",
159 .runs_after =
VNET_FEATURES (
"acl-plugin-out-ip4-fa",
"ip4-sv-reassembly-output-feature"),
162 .arc_name =
"ip4-output",
163 .node_name =
"nat44-ed-in2out-output",
164 .runs_after =
VNET_FEATURES (
"acl-plugin-out-ip4-fa",
"ip4-sv-reassembly-output-feature"),
167 .arc_name =
"ip4-output",
168 .node_name =
"nat44-ed-hairpin-src",
169 .runs_after =
VNET_FEATURES (
"acl-plugin-out-ip4-fa",
"ip4-sv-reassembly-output-feature"),
175 .arc_name =
"ip4-local",
176 .node_name =
"nat44-hairpinning",
181 .arc_name =
"ip4-local",
182 .node_name =
"nat44-ed-hairpinning",
188 .version = VPP_BUILD_VER,
189 .description =
"Network Address Translation (NAT)",
208 ed_key.
proto = s->in2out.port;
215 ed_key.
l_port = s->in2out.port;
216 ed_key.
r_port = s->ext_host_port;
218 ed_key.
l_addr = s->in2out.addr;
219 ed_key.
r_addr = s->ext_host_addr;
223 if (clib_bihash_add_del_16_8 (&tsm->
in2out_ed, &ed_kv, 0))
233 s->in2out.protocol, s->out2in.port);
234 ed_key.
l_addr = s->out2in.addr;
235 ed_key.
r_addr = s->ext_host_addr;
239 ed_key.
proto = s->in2out.port;
246 ed_key.
l_port = s->out2in.port;
247 ed_key.
r_port = s->ext_host_port;
251 if (clib_bihash_add_del_16_8 (&tsm->
out2in_ed, &ed_kv, 0))
253 ed_key.
l_addr = s->in2out.addr;
256 ed_key.
l_port = s->in2out.port;
259 ed_key.
r_addr = s->ext_host_nat_addr;
260 ed_key.
r_port = s->ext_host_nat_port;
264 if (clib_bihash_add_del_16_8 (&tsm->
in2out_ed, &ed_kv, 0))
269 &s->in2out.addr, s->in2out.port,
270 &s->ext_host_nat_addr, s->ext_host_nat_port,
271 &s->out2in.addr, s->out2in.port,
272 &s->ext_host_addr, s->ext_host_port,
277 kv.
key = s->in2out.as_u64;
278 if (clib_bihash_add_del_8_8 (&tsm->
in2out, &kv, 0))
280 kv.
key = s->out2in.as_u64;
281 if (clib_bihash_add_del_8_8 (&tsm->
out2in, &kv, 0))
286 &s->in2out.addr, s->in2out.port,
287 &s->out2in.addr, s->out2in.port,
298 s->in2out.addr.as_u32,
299 s->out2in.addr.as_u32,
303 s->in2out.fib_index);
305 nat_ha_sdel (&s->out2in.addr, s->out2in.port, &s->ext_host_addr,
306 s->ext_host_port, s->out2in.protocol, s->out2in.fib_index,
314 key.
port = s->ext_host_nat_port;
315 key.
addr.
as_u32 = s->ext_host_nat_addr.as_u32;
342 if (clib_bihash_search_8_8 (&tsm->
user_hash, &kv, &value))
360 if (clib_bihash_add_del_8_8 (&tsm->
user_hash, &kv, 1))
376 u32 thread_index,
f64 now)
380 u32 oldest_per_user_translation_list_index, session_index;
387 oldest_per_user_translation_list_index =
391 ASSERT (oldest_per_user_translation_list_index != ~0);
396 oldest_per_user_translation_list_index);
398 oldest_per_user_translation_list_elt =
400 oldest_per_user_translation_list_index);
403 session_index = oldest_per_user_translation_list_elt->
value;
416 s->ext_host_addr.as_u32 = 0;
417 s->ext_host_port = 0;
418 s->ext_host_nat_addr.as_u32 = 0;
419 s->ext_host_nat_port = 0;
429 per_user_translation_list_elt - tsm->
list_pool);
432 s->per_user_index = per_user_translation_list_elt - tsm->
list_pool;
436 s->per_user_list_head_index,
437 per_user_translation_list_elt - tsm->
list_pool);
439 s->user_index = u - tsm->
users;
444 s->ha_last_refreshed = now;
455 dlist_elt_t *per_user_translation_list_elt, *oldest_elt;
457 u64 sess_timeout_time;
469 if (now >= sess_timeout_time)
482 s->ext_host_addr.as_u32 = 0;
483 s->ext_host_port = 0;
484 s->ext_host_nat_addr.as_u32 = 0;
485 s->ext_host_nat_port = 0;
494 nat_elog_addr (SNAT_LOG_WARNING,
"[warn] max translations per user",
509 per_user_translation_list_elt - tsm->
list_pool);
512 s->per_user_index = per_user_translation_list_elt - tsm->
list_pool;
516 s->per_user_list_head_index,
517 per_user_translation_list_elt - tsm->
list_pool);
524 s->ha_last_refreshed = now;
537 .ip4.as_u32 = addr->
as_u32,
566 return VNET_API_ERROR_FEATURE_DISABLED;
573 return VNET_API_ERROR_VALUE_EXIST;
589 #define _(N, i, n, s) \ 590 clib_bitmap_alloc (ap->busy_##n##_port_bitmap, 65535); \ 591 ap->busy_##n##_ports = 0; \ 592 ap->busy_##n##_ports_per_thread = 0;\ 593 vec_validate_init_empty (ap->busy_##n##_ports_per_thread, tm->n_vlib_mains - 1, 0); 603 if (nat_interface_is_inside(i) || sm->out2in_dpo)
606 snat_add_del_addr_to_fib(addr, 32, i->sw_if_index, 1);
611 if (nat_interface_is_inside(i) || sm->out2in_dpo)
614 snat_add_del_addr_to_fib(addr, 32, i->sw_if_index, 1);
629 if (is_addr_only_static_mapping (m) ||
630 is_out2in_only_static_mapping (m) ||
631 is_identity_static_mapping (m))
633 if (m->external_addr.as_u32 == addr.as_u32)
646 v = clib_net_to_host_u32 (a->
as_u32) + 1;
647 a->
as_u32 = clib_host_to_net_u32 (v);
658 int addr_only,
int is_add,
u8 * tag,
659 int twice_nat,
int out2in_only,
712 u32 elt_index, head_index;
722 if (twice_nat || out2in_only)
723 return VNET_API_ERROR_FEATURE_DISABLED;
727 if (sw_if_index != ~0)
757 return VNET_API_ERROR_VALUE_EXIST;
760 (sm, l_addr, l_port, sw_if_index, e_port, vrf_id, proto,
761 addr_only, is_add, tag, twice_nat, out2in_only, identity_nat);
764 if (first_int_addr == 0)
779 return VNET_API_ERROR_NO_SUCH_ENTRY;
796 m_key.
port = addr_only ? 0 : e_port;
814 if (local->vrf_id == vrf_id)
815 return VNET_API_ERROR_VALUE_EXIST;
833 return VNET_API_ERROR_VALUE_EXIST;
836 if (twice_nat && addr_only)
837 return VNET_API_ERROR_UNSUPPORTED;
852 if (!(out2in_only || identity_nat))
855 m_key.
port = addr_only ? 0 : l_port;
859 if (!clib_bihash_search_8_8
861 return VNET_API_ERROR_VALUE_EXIST;
876 #define _(N, j, n, s) \ 877 case SNAT_PROTOCOL_##N: \ 878 if (clib_bitmap_get_no_check (a->busy_##n##_port_bitmap, e_port)) \ 879 return VNET_API_ERROR_INVALID_VALUE; \ 880 clib_bitmap_set_no_check (a->busy_##n##_port_bitmap, e_port, 1); \ 883 a->busy_##n##_ports++; \ 884 a->busy_##n##_ports_per_thread[get_thread_idx_by_port(e_port)]++; \ 891 return VNET_API_ERROR_INVALID_VALUE_2;
899 if (sw_if_index != ~0)
916 return VNET_API_ERROR_NO_SUCH_ENTRY;
982 if (!clib_bihash_search_8_8 (&tsm->
user_hash, &kv, &value))
984 user_index = value.
value;
990 elt_index = head->
next;
992 ses_index = elt->
value;
993 while (ses_index != ~0)
997 ses_index = elt->
value;
1003 && (clib_net_to_host_u16 (s->in2out.port) !=
1022 if (sw_if_index != ~0)
1025 return VNET_API_ERROR_NO_SUCH_ENTRY;
1036 if (local->vrf_id == vrf_id)
1037 find = local - m->locals;
1041 return VNET_API_ERROR_NO_SUCH_ENTRY;
1060 #define _(N, j, n, s) \ 1061 case SNAT_PROTOCOL_##N: \ 1062 clib_bitmap_set_no_check (a->busy_##n##_port_bitmap, e_port, 0); \ 1063 if (e_port > 1024) \ 1065 a->busy_##n##_ports--; \ 1066 a->busy_##n##_ports_per_thread[get_thread_idx_by_port(e_port)]--; \ 1073 return VNET_API_ERROR_INVALID_VALUE_2;
1100 if (!clib_bihash_search_8_8 (&tsm->
user_hash, &kv, &value))
1102 user_index = value.
value;
1108 elt_index = head->
next;
1110 ses_index = elt->
value;
1111 while (ses_index != ~0)
1115 ses_index = elt->
value;
1119 if ((s->out2in.addr.as_u32 != e_addr.
as_u32) ||
1120 (clib_net_to_host_u16 (s->out2in.port) !=
1165 if (nat_interface_is_inside(interface) || sm->out2in_dpo)
1168 snat_add_del_addr_to_fib(&e_addr, 32, interface->sw_if_index, is_add);
1173 if (nat_interface_is_inside(interface) || sm->out2in_dpo)
1176 snat_add_del_addr_to_fib(&e_addr, 32, interface->sw_if_index, is_add);
1189 u8 * tag,
u32 affinity)
1198 u32 elt_index, head_index, ses_index;
1207 return VNET_API_ERROR_FEATURE_DISABLED;
1209 m_key.
addr = e_addr;
1210 m_key.
port = e_port;
1222 return VNET_API_ERROR_VALUE_EXIST;
1225 return VNET_API_ERROR_INVALID_VALUE;
1239 #define _(N, j, n, s) \ 1240 case SNAT_PROTOCOL_##N: \ 1241 if (clib_bitmap_get_no_check (a->busy_##n##_port_bitmap, e_port)) \ 1242 return VNET_API_ERROR_INVALID_VALUE; \ 1243 clib_bitmap_set_no_check (a->busy_##n##_port_bitmap, e_port, 1); \ 1244 if (e_port > 1024) \ 1246 a->busy_##n##_ports++; \ 1247 a->busy_##n##_ports_per_thread[get_thread_idx_by_port(e_port)]++; \ 1254 return VNET_API_ERROR_INVALID_VALUE_2;
1261 return VNET_API_ERROR_NO_SUCH_ENTRY;
1290 nat_elog_err (
"static_mapping_by_external key add failed");
1291 return VNET_API_ERROR_UNSPECIFIED;
1295 for (i = 0; i <
vec_len (locals); i++)
1340 return VNET_API_ERROR_NO_SUCH_ENTRY;
1343 return VNET_API_ERROR_INVALID_VALUE;
1355 #define _(N, j, n, s) \ 1356 case SNAT_PROTOCOL_##N: \ 1357 clib_bitmap_set_no_check (a->busy_##n##_port_bitmap, e_port, 0); \ 1358 if (e_port > 1024) \ 1360 a->busy_##n##_ports--; \ 1361 a->busy_##n##_ports_per_thread[get_thread_idx_by_port(e_port)]--; \ 1368 return VNET_API_ERROR_INVALID_VALUE_2;
1382 nat_elog_err (
"static_mapping_by_external key del failed");
1383 return VNET_API_ERROR_UNSPECIFIED;
1389 fib_table_unlock (local->fib_index, FIB_PROTOCOL_IP4,
1391 m_key.addr = local->addr;
1394 m_key.port = local->port;
1395 m_key.fib_index = local->fib_index;
1396 kv.key = m_key.as_u64;
1397 if (clib_bihash_add_del_8_8(&sm->static_mapping_by_local, &kv, 0))
1399 nat_elog_err (
"static_mapping_by_local key del failed");
1400 return VNET_API_ERROR_UNSPECIFIED;
1407 .src_address = local->addr,
1419 if (!clib_bihash_search_8_8 (&tsm->
user_hash, &kv, &value))
1426 elt_index = head->
next;
1428 ses_index = elt->
value;
1429 while (ses_index != ~0)
1433 ses_index = elt->
value;
1438 if ((s->in2out.addr.as_u32 != local->
addr.
as_u32) ||
1439 (clib_net_to_host_u16 (s->in2out.port) != local->
port))
1477 u32 elt_index, head_index, ses_index, *locals = 0;
1482 return VNET_API_ERROR_FEATURE_DISABLED;
1484 m_key.
addr = e_addr;
1485 m_key.
port = e_port;
1493 return VNET_API_ERROR_NO_SUCH_ENTRY;
1496 return VNET_API_ERROR_INVALID_VALUE;
1501 if ((local->addr.as_u32 == l_addr.as_u32) && (local->port == l_port) &&
1502 (local->vrf_id == vrf_id))
1504 match_local = local;
1513 return VNET_API_ERROR_VALUE_EXIST;
1517 local->addr.as_u32 = l_addr.as_u32;
1518 local->port = l_port;
1527 m_key.addr = l_addr;
1528 m_key.port = l_port;
1529 m_key.fib_index = local->fib_index;
1530 kv.key = m_key.as_u64;
1531 kv.value = m - sm->static_mappings;
1532 if (clib_bihash_add_del_8_8 (&sm->static_mapping_by_local, &kv, 1))
1533 nat_elog_err (
"static_mapping_by_local key add failed");
1539 return VNET_API_ERROR_NO_SUCH_ENTRY;
1542 return VNET_API_ERROR_UNSPECIFIED;
1549 m_key.addr = l_addr;
1550 m_key.port = l_port;
1551 m_key.fib_index = match_local->fib_index;
1552 kv.key = m_key.as_u64;
1553 if (clib_bihash_add_del_8_8 (&sm->static_mapping_by_local, &kv, 0))
1554 nat_elog_err (
"static_mapping_by_local key del failed");
1557 if (sm->num_workers > 1)
1563 sm->worker_in2out_cb (&ip, m->fib_index,
1570 u_key.addr = match_local->addr;
1571 u_key.fib_index = match_local->fib_index;
1572 kv.key = u_key.as_u64;
1573 if (!clib_bihash_search_8_8 (&tsm->user_hash, &kv, &
value))
1576 if (u->nstaticsessions)
1578 head_index = u->sessions_per_user_list_head_index;
1580 elt_index = head->next;
1582 ses_index = elt->value;
1583 while (ses_index != ~0)
1587 ses_index = elt->value;
1592 if ((s->in2out.addr.as_u32 != match_local->addr.as_u32) ||
1593 (clib_net_to_host_u16 (s->in2out.port) !=
1611 vec_add1 (locals, local - m->locals);
1612 if (sm->num_workers > 1)
1615 ip.src_address.as_u32 = local->addr.as_u32,
1616 bitmap = clib_bitmap_set (bitmap,
1617 sm->worker_in2out_cb (&ip, local->fib_index, 0),
1626 local->prefix = local->probability;
1631 local->prefix = local->probability + prev_local->prefix;
1635 if (sm->num_workers > 1)
1650 snat_session_t *ses;
1651 u32 *ses_to_be_removed = 0, *ses_index;
1660 for (i = 0; i <
vec_len (addresses); i++)
1669 return VNET_API_ERROR_NO_SUCH_ENTRY;
1676 if (m->external_addr.as_u32 == addr.as_u32)
1677 (void) snat_add_static_mapping (m->local_addr, m->external_addr,
1678 m->local_port, m->external_port,
1679 m->vrf_id, is_addr_only_static_mapping(m), ~0,
1680 m->proto, 0, m->twice_nat,
1681 is_out2in_only_static_mapping(m), m->tag, is_identity_static_mapping(m));
1691 return VNET_API_ERROR_UNSPECIFIED;
1699 if (a->busy_tcp_ports || a->busy_udp_ports || a->busy_icmp_ports)
1705 if (ses->out2in.addr.as_u32 == addr.as_u32)
1707 nat_free_session_data (sm, ses, tsm - sm->per_thread_data, 0);
1708 vec_add1 (ses_to_be_removed, ses - tsm->sessions);
1723 #define _(N, i, n, s) \ 1724 clib_bitmap_free (a->busy_##n##_port_bitmap); \ 1725 vec_free (a->busy_##n##_ports_per_thread); 1740 if (nat_interface_is_inside(interface) || sm->out2in_dpo)
1743 snat_add_del_addr_to_fib(&addr, 32, interface->sw_if_index, 0);
1746 pool_foreach (interface, sm->output_feature_interfaces,
1748 if (nat_interface_is_inside(interface) || sm->out2in_dpo)
1751 snat_add_del_addr_to_fib(&addr, 32, interface->sw_if_index, 0);
1764 const char *feature_name, *del_feature_name;
1773 return VNET_API_ERROR_UNSUPPORTED;
1778 if (i->sw_if_index == sw_if_index)
1779 return VNET_API_ERROR_VALUE_EXIST;
1784 feature_name = is_inside ?
"nat44-in2out-fast" :
"nat44-out2in-fast";
1789 is_inside ?
"nat44-in2out-worker-handoff" :
1790 "nat44-out2in-worker-handoff";
1792 feature_name = is_inside ?
"nat44-det-in2out" :
"nat44-det-out2in";
1795 feature_name = is_inside ?
"nat-pre-in2out" :
"nat-pre-out2in";
1798 feature_name = is_inside ?
"nat44-in2out" :
"nat44-out2in";
1814 if (outside_fib->
fib_index == fib_index)
1839 if (i->sw_if_index == sw_if_index)
1843 if (nat_interface_is_inside(i) && nat_interface_is_outside(i))
1846 i->flags &= ~NAT_INTERFACE_FLAG_IS_INSIDE;
1848 i->flags &= ~NAT_INTERFACE_FLAG_IS_OUTSIDE;
1850 if (sm->num_workers > 1 && !sm->deterministic)
1852 del_feature_name =
"nat44-handoff-classify";
1853 feature_name = !is_inside ?
"nat44-in2out-worker-handoff" :
1854 "nat44-out2in-worker-handoff";
1856 else if (sm->deterministic)
1858 del_feature_name =
"nat44-det-classify";
1859 feature_name = !is_inside ?
"nat44-det-in2out" :
1862 else if (sm->endpoint_dependent)
1864 del_feature_name =
"nat44-ed-classify";
1865 feature_name = !is_inside ?
"nat-pre-in2out" :
1870 del_feature_name =
"nat44-classify";
1871 feature_name = !is_inside ?
"nat44-in2out" :
"nat44-out2in";
1874 int rv = ip4_sv_reass_enable_disable_with_refcnt (sw_if_index, 0);
1877 vnet_feature_enable_disable (
"ip4-unicast", del_feature_name,
1878 sw_if_index, 0, 0, 0);
1879 vnet_feature_enable_disable (
"ip4-unicast", feature_name,
1880 sw_if_index, 1, 0, 0);
1883 if (sm->endpoint_dependent)
1884 vnet_feature_enable_disable (
"ip4-local",
1885 "nat44-ed-hairpinning",
1886 sw_if_index, 1, 0, 0);
1887 else if (!sm->deterministic)
1888 vnet_feature_enable_disable (
"ip4-local",
1889 "nat44-hairpinning",
1890 sw_if_index, 1, 0, 0);
1895 int rv = ip4_sv_reass_enable_disable_with_refcnt (sw_if_index, 0);
1898 vnet_feature_enable_disable (
"ip4-unicast", feature_name,
1899 sw_if_index, 0, 0, 0);
1900 pool_put (sm->interfaces, i);
1903 if (sm->endpoint_dependent)
1904 vnet_feature_enable_disable (
"ip4-local",
1905 "nat44-ed-hairpinning",
1906 sw_if_index, 0, 0, 0);
1907 else if (!sm->deterministic)
1908 vnet_feature_enable_disable (
"ip4-local",
1909 "nat44-hairpinning",
1910 sw_if_index, 0, 0, 0);
1916 if ((nat_interface_is_inside(i) && is_inside) ||
1917 (nat_interface_is_outside(i) && !is_inside))
1920 if (sm->num_workers > 1 && !sm->deterministic)
1922 del_feature_name = !is_inside ?
"nat44-in2out-worker-handoff" :
1923 "nat44-out2in-worker-handoff";
1924 feature_name =
"nat44-handoff-classify";
1926 else if (sm->deterministic)
1928 del_feature_name = !is_inside ?
"nat44-det-in2out" :
1930 feature_name =
"nat44-det-classify";
1932 else if (sm->endpoint_dependent)
1934 del_feature_name = !is_inside ?
"nat-pre-in2out" :
1937 feature_name =
"nat44-ed-classify";
1941 del_feature_name = !is_inside ?
"nat44-in2out" :
"nat44-out2in";
1942 feature_name =
"nat44-classify";
1945 int rv = ip4_sv_reass_enable_disable_with_refcnt (sw_if_index, 1);
1948 vnet_feature_enable_disable (
"ip4-unicast", del_feature_name,
1949 sw_if_index, 0, 0, 0);
1950 vnet_feature_enable_disable (
"ip4-unicast", feature_name,
1951 sw_if_index, 1, 0, 0);
1954 if (sm->endpoint_dependent)
1955 vnet_feature_enable_disable (
"ip4-local",
"nat44-ed-hairpinning",
1956 sw_if_index, 0, 0, 0);
1957 else if (!sm->deterministic)
1958 vnet_feature_enable_disable (
"ip4-local",
"nat44-hairpinning",
1959 sw_if_index, 0, 0, 0);
1970 return VNET_API_ERROR_NO_SUCH_ENTRY;
1982 if (is_inside && !sm->out2in_dpo)
1984 if (sm->endpoint_dependent)
1987 else if (!sm->deterministic)
2009 if (!(is_addr_only_static_mapping(m)) || (m->local_addr.as_u32 == m->external_addr.as_u32))
2012 snat_add_del_addr_to_fib(&m->external_addr, 32, sw_if_index, !is_del);
2017 snat_add_del_addr_to_fib(&dm->out_addr, dm->out_plen, sw_if_index, !is_del);
2026 u8 is_inside,
int is_del)
2039 return VNET_API_ERROR_UNSUPPORTED;
2044 if (i->sw_if_index == sw_if_index)
2045 return VNET_API_ERROR_VALUE_EXIST;
2054 if (outside_fib->
fib_index == fib_index)
2091 sw_if_index, !is_del, 0, 0);
2093 sw_if_index, !is_del, 0, 0);
2107 sw_if_index, !is_del, 0, 0);
2109 sw_if_index, !is_del, 0, 0);
2124 "nat44-out2in-worker-handoff",
2125 sw_if_index, !is_del, 0, 0);
2127 "nat44-in2out-output-worker-handoff",
2128 sw_if_index, !is_del, 0, 0);
2144 sw_if_index, !is_del, 0, 0);
2146 sw_if_index, !is_del, 0, 0);
2160 sw_if_index, !is_del, 0, 0);
2162 sw_if_index, !is_del, 0, 0);
2178 if (i->sw_if_index == sw_if_index)
2181 pool_put (sm->output_feature_interfaces, i);
2183 return VNET_API_ERROR_VALUE_EXIST;
2191 return VNET_API_ERROR_NO_SUCH_ENTRY;
2193 pool_get (sm->output_feature_interfaces,
i);
2212 if (!((is_addr_only_static_mapping(m))) || (m->local_addr.as_u32 == m->external_addr.as_u32))
2215 snat_add_del_addr_to_fib(&m->external_addr, 32, sw_if_index, !is_del);
2229 return VNET_API_ERROR_FEATURE_DISABLED;
2232 return VNET_API_ERROR_INVALID_WORKER;
2261 if (new_fib_index == old_fib_index)
2270 if (i->sw_if_index == sw_if_index)
2272 if (!(nat_interface_is_outside (i)))
2280 if (i->sw_if_index == sw_if_index)
2282 if (!(nat_interface_is_outside (i)))
2294 if (outside_fib->fib_index == old_fib_index)
2296 outside_fib->refcount--;
2297 if (!outside_fib->refcount)
2298 vec_del1 (sm->outside_fibs, outside_fib - sm->outside_fibs);
2305 if (outside_fib->fib_index == new_fib_index)
2307 outside_fib->refcount++;
2315 vec_add2 (sm->outside_fibs, outside_fib, 1);
2316 outside_fib->refcount = 1;
2317 outside_fib->fib_index = new_fib_index;
2335 u32 if_address_index,
u32 is_delete);
2343 u32 if_address_index,
u32 is_delete);
2350 u16 port_per_thread,
u32 snat_thread_index);
2535 u16 port_host_byte_order = clib_net_to_host_u16 (k->
port);
2537 for (address_index = 0; address_index <
vec_len (addresses);
2544 ASSERT (address_index < vec_len (addresses));
2546 a = addresses + address_index;
2550 #define _(N, i, n, s) \ 2551 case SNAT_PROTOCOL_##N: \ 2552 ASSERT (clib_bitmap_get_no_check (a->busy_##n##_port_bitmap, \ 2553 port_host_byte_order) == 1); \ 2554 clib_bitmap_set_no_check (a->busy_##n##_port_bitmap, \ 2555 port_host_byte_order, 0); \ 2556 a->busy_##n##_ports--; \ 2557 a->busy_##n##_ports_per_thread[thread_index]--; \ 2573 u16 port_host_byte_order = clib_net_to_host_u16 (k->
port);
2575 for (address_index = 0; address_index <
vec_len (addresses);
2581 a = addresses + address_index;
2584 #define _(N, j, n, s) \ 2585 case SNAT_PROTOCOL_##N: \ 2586 if (clib_bitmap_get_no_check (a->busy_##n##_port_bitmap, port_host_byte_order)) \ 2587 return VNET_API_ERROR_INSTANCE_IN_USE; \ 2588 clib_bitmap_set_no_check (a->busy_##n##_port_bitmap, port_host_byte_order, 1); \ 2589 a->busy_##n##_ports_per_thread[thread_index]++; \ 2590 a->busy_##n##_ports++; \ 2600 return VNET_API_ERROR_NO_SUCH_ENTRY;
2611 u8 * is_identity_nat)
2617 u32 rand,
lo = 0,
hi, mid, *tmp = 0,
i;
2629 m_key.
port = clib_net_to_host_u16 (match.
port);
2634 if (clib_bihash_search_8_8 (mapping_hash, &kv, &value))
2640 if (clib_bihash_search_8_8 (mapping_hash, &kv, &value))
2660 mapping->
port = clib_host_to_net_u16 (local->
port);
2671 local = pool_elt_at_index (m->locals, i);
2674 .src_address = local->addr,
2700 mid = ((hi -
lo) >> 1) +
lo;
2702 (rand > local->
prefix) ? (lo = mid + 1) : (hi = mid);
2705 if (!(local->
prefix >= rand))
2708 mapping->
port = clib_host_to_net_u16 (local->
port);
2734 mapping->addr = m->external_addr;
2737 : clib_host_to_net_u16 (m->external_port);
2738 mapping->fib_index = sm->outside_fib_index;
2746 *twice_nat = m->twice_nat;
2767 u16 port_per_thread,
2768 u32 snat_thread_index)
2773 port_per_thread, snat_thread_index);
2781 u16 port_per_thread,
u32 snat_thread_index)
2787 for (i = 0; i <
vec_len (addresses); i++)
2792 #define _(N, j, n, s) \ 2793 case SNAT_PROTOCOL_##N: \ 2794 if (a->busy_##n##_ports_per_thread[thread_index] < port_per_thread) \ 2796 if (a->fib_index == fib_index) \ 2800 portnum = (port_per_thread * \ 2801 snat_thread_index) + \ 2802 snat_random_port(1, port_per_thread) + 1024; \ 2803 if (clib_bitmap_get_no_check (a->busy_##n##_port_bitmap, portnum)) \ 2805 clib_bitmap_set_no_check (a->busy_##n##_port_bitmap, portnum, 1); \ 2806 a->busy_##n##_ports_per_thread[thread_index]++; \ 2807 a->busy_##n##_ports++; \ 2808 k->addr = a->addr; \ 2809 k->port = clib_host_to_net_u16(portnum); \ 2813 else if (a->fib_index == ~0) \ 2833 #define _(N, j, n, s) \ 2834 case SNAT_PROTOCOL_##N: \ 2837 portnum = (port_per_thread * \ 2838 snat_thread_index) + \ 2839 snat_random_port(1, port_per_thread) + 1024; \ 2840 if (clib_bitmap_get_no_check (a->busy_##n##_port_bitmap, portnum)) \ 2842 clib_bitmap_set_no_check (a->busy_##n##_port_bitmap, portnum, 1); \ 2843 a->busy_##n##_ports_per_thread[thread_index]++; \ 2844 a->busy_##n##_ports++; \ 2845 k->addr = a->addr; \ 2846 k->port = clib_host_to_net_u16(portnum); \ 2868 u16 port_per_thread,
u32 snat_thread_index)
2872 u16 m, ports, portnum,
A, j;
2881 #define _(N, i, n, s) \ 2882 case SNAT_PROTOCOL_##N: \ 2883 if (a->busy_##n##_ports < ports) \ 2887 A = snat_random_port(1, pow2_mask(sm->psid_offset)); \ 2888 j = snat_random_port(0, pow2_mask(m)); \ 2889 portnum = A | (sm->psid << sm->psid_offset) | (j << (16 - m)); \ 2890 if (clib_bitmap_get_no_check (a->busy_##n##_port_bitmap, portnum)) \ 2892 clib_bitmap_set_no_check (a->busy_##n##_port_bitmap, portnum, 1); \ 2893 a->busy_##n##_ports++; \ 2894 k->addr = a->addr; \ 2895 k->port = clib_host_to_net_u16 (portnum); \ 2918 u16 port_per_thread,
u32 snat_thread_index)
2931 #define _(N, i, n, s) \ 2932 case SNAT_PROTOCOL_##N: \ 2933 if (a->busy_##n##_ports < ports) \ 2937 portnum = snat_random_port(sm->start_port, sm->end_port); \ 2938 if (clib_bitmap_get_no_check (a->busy_##n##_port_bitmap, portnum)) \ 2940 clib_bitmap_set_no_check (a->busy_##n##_port_bitmap, portnum, 1); \ 2941 a->busy_##n##_ports++; \ 2942 k->addr = a->addr; \ 2943 k->port = clib_host_to_net_u16 (portnum); \ 2968 .fp_addr.ip4.as_u32 = addr.
as_u32,
3005 s =
format (s,
"%U static-mapping-index %llu",
3035 format (s,
"local %U:%d remote %U:%d proto %U fib %d session-index %llu",
3048 u32 next_worker_index = 0;
3056 next_worker_index += sm->
workers[hash & (_vec_len (sm->
workers) - 1)];
3060 return next_worker_index;
3065 u32 rx_fib_index0,
u8 is_output)
3074 u32 next_worker_index = 0;
3084 if (!clib_bihash_search_8_8
3105 icmp46_header_t *icmp = (icmp46_header_t *) udp;
3108 (
vnet_buffer (b)->ip.reass.icmp_type_or_tcp_flags))
3118 case SNAT_PROTOCOL_ICMP:
3119 icmp = (icmp46_header_t *) l4_header;
3123 case SNAT_PROTOCOL_UDP:
3124 case SNAT_PROTOCOL_TCP:
3137 m_key.
port = clib_net_to_host_u16 (port);
3141 if (!clib_bihash_search_8_8
3151 next_worker_index +=
3153 return next_worker_index;
3222 "HANDOFF IN2OUT-OUTPUT-FEATURE (session)",
3223 next_worker_index, fib_index,
3227 return next_worker_index;
3237 next_worker_index += sm->
workers[hash & (_vec_len (sm->
workers) - 1)];
3244 next_worker_index, rx_fib_index,
3251 next_worker_index, rx_fib_index,
3256 return next_worker_index;
3261 u32 rx_fib_index,
u8 is_output)
3276 if (
PREDICT_TRUE (proto == SNAT_PROTOCOL_UDP || proto == SNAT_PROTOCOL_TCP))
3291 next_worker_index, rx_fib_index,
3294 return next_worker_index;
3299 else if (proto == SNAT_PROTOCOL_ICMP)
3319 next_worker_index, rx_fib_index,
3322 return next_worker_index;
3333 if (!clib_bihash_search_8_8
3337 next_worker_index = m->
workers[0];
3355 icmp46_header_t *icmp = (icmp46_header_t *) udp;
3358 (
vnet_buffer (b)->ip.reass.icmp_type_or_tcp_flags))
3368 case SNAT_PROTOCOL_ICMP:
3369 icmp = (icmp46_header_t *) l4_header;
3373 case SNAT_PROTOCOL_UDP:
3374 case SNAT_PROTOCOL_TCP:
3388 clib_net_to_host_u16 (port));
3389 if (!clib_bihash_search_8_8
3395 next_worker_index = m->
workers[0];
3413 next_worker_index +=
3420 return next_worker_index;
3443 .ip4.as_u32 = eh_addr->
as_u32,
3450 key.
port = out_port;
3468 s->last_heard = now;
3470 s->ext_host_addr.as_u32 = eh_addr->
as_u32;
3471 s->ext_host_port = eh_port;
3501 if (clib_bihash_add_del_8_8 (&tsm->
out2in, &kv, 1))
3509 if (clib_bihash_add_del_8_8 (&tsm->
in2out, &kv, 1))
3528 (sm->
workers[(clib_net_to_host_u16 (out_port) -
3535 key.
port = out_port;
3539 if (clib_bihash_search_8_8 (&tsm->
out2in, &kv, &value))
3550 u32 total_pkts,
u64 total_bytes,
u32 thread_index)
3561 key.
port = out_port;
3565 if (clib_bihash_search_8_8 (&tsm->
out2in, &kv, &value))
3569 s->total_pkts = total_pkts;
3570 s->total_bytes = total_bytes;
3593 .ip4.as_u32 = eh_addr->
as_u32,
3600 key.
port = out_port;
3611 key.
port = ehn_port;
3627 s->last_heard = now;
3629 s->ext_host_nat_addr.as_u32 = s->ext_host_addr.as_u32 = eh_addr->
as_u32;
3630 s->ext_host_nat_port = s->ext_host_port = eh_port;
3633 s->ext_host_nat_addr.as_u32 = ehn_addr->
as_u32;
3634 s->ext_host_nat_port = ehn_port;
3663 key.
port = out_port;
3672 make_ed_kv (&kv, in_addr, &s->ext_host_nat_addr,
3674 s->ext_host_nat_port);
3675 if (clib_bihash_add_del_16_8 (&tsm->
in2out_ed, &kv, 1))
3679 s->out2in.fib_index, out_port, eh_port);
3680 if (clib_bihash_add_del_16_8 (&tsm->
out2in_ed, &kv, 1))
3699 (sm->
workers[(clib_net_to_host_u16 (out_port) -
3713 if (clib_bihash_search_16_8 (&tsm->
out2in_ed, &kv, &value))
3724 u32 fib_index,
u32 total_pkts,
u64 total_bytes,
3743 if (clib_bihash_search_16_8 (&tsm->
out2in_ed, &kv, &value))
3747 s->total_pkts = total_pkts;
3748 s->total_bytes = total_bytes;
3759 u32 static_mapping_buckets = 1024;
3760 u32 static_mapping_memory_size = 64 << 20;
3762 u32 nat64_bib_buckets = 1024;
3763 u32 nat64_bib_memory_size = 128 << 20;
3765 u32 nat64_st_buckets = 2048;
3766 u32 nat64_st_memory_size = 256 << 20;
3768 u32 user_buckets = 128;
3769 u32 user_memory_size = 64 << 20;
3770 u32 translation_buckets = 1024;
3771 u32 translation_memory_size = 128 << 20;
3773 u32 max_translations_per_user = ~0;
3775 u32 outside_vrf_id = 0;
3776 u32 outside_ip6_vrf_id = 0;
3777 u32 inside_vrf_id = 0;
3778 u8 static_mapping_only = 0;
3779 u8 static_mapping_connection_tracking = 0;
3794 (input,
"translation hash buckets %d", &translation_buckets))
3796 else if (
unformat (input,
"udp timeout %d", &udp_timeout))
3798 else if (
unformat (input,
"icmp timeout %d", &icmp_timeout))
3800 else if (
unformat (input,
"tcp transitory timeout %d",
3801 &tcp_transitory_timeout));
3802 else if (
unformat (input,
"tcp established timeout %d",
3803 &tcp_established_timeout));
3804 else if (
unformat (input,
"translation hash memory %d",
3805 &translation_memory_size));
3806 else if (
unformat (input,
"user hash buckets %d", &user_buckets))
3808 else if (
unformat (input,
"user hash memory %d", &user_memory_size))
3810 else if (
unformat (input,
"max translations per user %d",
3811 &max_translations_per_user))
3813 else if (
unformat (input,
"outside VRF id %d", &outside_vrf_id))
3815 else if (
unformat (input,
"outside ip6 VRF id %d", &outside_ip6_vrf_id))
3817 else if (
unformat (input,
"inside VRF id %d", &inside_vrf_id))
3819 else if (
unformat (input,
"static mapping only"))
3821 static_mapping_only = 1;
3822 if (
unformat (input,
"connection tracking"))
3823 static_mapping_connection_tracking = 1;
3825 else if (
unformat (input,
"deterministic"))
3827 else if (
unformat (input,
"nat64 bib hash buckets %d",
3828 &nat64_bib_buckets))
3830 else if (
unformat (input,
"nat64 bib hash memory %d",
3831 &nat64_bib_memory_size))
3834 if (
unformat (input,
"nat64 st hash buckets %d", &nat64_st_buckets))
3836 else if (
unformat (input,
"nat64 st hash memory %d",
3837 &nat64_st_memory_size))
3839 else if (
unformat (input,
"out2in dpo"))
3841 else if (
unformat (input,
"dslite ce"))
3843 else if (
unformat (input,
"endpoint-dependent"))
3852 "deterministic and endpoint-dependent modes are mutually exclusive");
3856 "static mapping only mode available only for simple nat");
3860 "out2in dpo mode available only for simple nat");
3894 nat64_set_hash (nat64_bib_buckets, nat64_bib_memory_size, nat64_st_buckets,
3895 nat64_st_memory_size);
3942 if (!static_mapping_only ||
3943 (static_mapping_only && static_mapping_connection_tracking))
3950 clib_bihash_init_16_8 (&tsm->
in2out_ed,
"in2out-ed",
3951 translation_buckets,
3952 translation_memory_size);
3953 clib_bihash_set_kvp_format_fn_16_8 (&tsm->
in2out_ed,
3956 clib_bihash_init_16_8 (&tsm->
out2in_ed,
"out2in-ed",
3957 translation_buckets,
3958 translation_memory_size);
3959 clib_bihash_set_kvp_format_fn_16_8 (&tsm->
out2in_ed,
3964 clib_bihash_init_8_8 (&tsm->
in2out,
"in2out",
3965 translation_buckets,
3966 translation_memory_size);
3967 clib_bihash_set_kvp_format_fn_8_8 (&tsm->
in2out,
3970 clib_bihash_init_8_8 (&tsm->
out2in,
"out2in",
3971 translation_buckets,
3972 translation_memory_size);
3973 clib_bihash_set_kvp_format_fn_8_8 (&tsm->
out2in,
3977 clib_bihash_init_8_8 (&tsm->
user_hash,
"users", user_buckets,
3979 clib_bihash_set_kvp_format_fn_8_8 (&tsm->
user_hash,
3991 "static_mapping_by_local", static_mapping_buckets,
3992 static_mapping_memory_size);
3997 "static_mapping_by_external",
3998 static_mapping_buckets,
3999 static_mapping_memory_size);
4015 u32 if_address_index,
u32 is_delete)
4083 u32 if_address_index,
u32 is_delete)
4113 for (j = 0; j <
vec_len (addresses); j++)
4114 if (addresses[j].
addr.as_u32 == address->
as_u32)
4166 u32 *indices_to_delete = 0;
4168 u32 *auto_add_sw_if_indices =
4175 for (i = 0; i <
vec_len (auto_add_sw_if_indices); i++)
4177 if (auto_add_sw_if_indices[i] == sw_if_index)
4192 if (vec_len (indices_to_delete))
4194 for (j = vec_len (indices_to_delete) - 1; j >= 0; j--)
4205 return VNET_API_ERROR_VALUE_EXIST;
4212 return VNET_API_ERROR_NO_SUCH_ENTRY;
4237 clib_bihash_8_8_t *t;
4240 return VNET_API_ERROR_UNSUPPORTED;
4251 key.
port = clib_host_to_net_u16 (port);
4255 t = is_in ? &tsm->in2out : &tsm->out2in;
4256 if (!clib_bihash_search_8_8 (t, &kv, &value))
4259 return VNET_API_ERROR_UNSPECIFIED;
4267 return VNET_API_ERROR_NO_SUCH_ENTRY;
4276 clib_bihash_16_8_t *t;
4284 return VNET_API_ERROR_FEATURE_DISABLED;
4294 t = is_in ? &tsm->in2out_ed : &tsm->out2in_ed;
4297 key.
l_port = clib_host_to_net_u16 (port);
4298 key.
r_port = clib_host_to_net_u16 (eh_port);
4303 if (clib_bihash_search_16_8 (t, &kv, &value))
4304 return VNET_API_ERROR_NO_SUCH_ENTRY;
4307 return VNET_API_ERROR_UNSPECIFIED;
4355 .name =
"nat-default",
4356 .vector_size =
sizeof (
u32),
ip4_address_t external_addr
vlib_log_class_t vlib_log_register_class(char *class, char *subclass)
#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
static void snat_update_outside_fib(u32 sw_if_index, u32 new_fib_index, u32 old_fib_index)
nat_outside_fib_t * outside_fibs
void snat_ipfix_logging_max_entries_per_user(u32 thread_index, u32 limit, u32 src_ip)
Generate maximum entries per user exceeded event.
enum fib_source_t_ fib_source_t
The different sources that can create a route.
#define snat_is_session_static(s)
Check if SNAT session is created from static mapping.
u32 sessions_per_user_list_head_index
vlib_node_registration_t nat_default_node
(constructor) VLIB_REGISTER_NODE (nat_default_node)
vlib_node_registration_t nat44_ed_in2out_output_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_output_node)
#define nat_elog_debug_handoff(_str, _tid, _fib, _src, _dst)
ip4_table_bind_function_t * function
int nat_affinity_create_and_lock(ip4_address_t client_addr, ip4_address_t service_addr, u8 proto, u16 service_port, u8 backend_index, u32 sticky_time, u32 affinity_per_service_list_head_index)
Create affinity record and take reference counting lock.
int snat_del_address(snat_main_t *sm, ip4_address_t addr, u8 delete_sm, u8 twice_nat)
Delete external address from NAT44 pool.
u32 hairpin_dst_node_index
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.
u32 ed_hairpinning_node_index
static void clib_dlist_init(dlist_elt_t *pool, u32 index)
int ip4_sv_reass_enable_disable_with_refcnt(u32 sw_if_index, int is_enable)
vnet_main_t * vnet_get_main(void)
#define nat_elog_info(nat_elog_str)
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 twice_nat, int out2in_only, int identity_nat)
static u32 nat44_session_get_timeout(snat_main_t *sm, snat_session_t *s)
u32 fq_in2out_output_index
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...
#define nat_elog_notice(nat_elog_str)
static int nat_alloc_addr_and_port_range(snat_address_t *addresses, u32 fib_index, u32 thread_index, snat_session_key_t *k, u16 port_per_thread, u32 snat_thread_index)
#define SNAT_TCP_ESTABLISHED_TIMEOUT
#define is_ed_session(s)
Check if NAT session is endpoint dependent.
static u32 nat44_ed_get_worker_out2in_cb(vlib_buffer_t *b, ip4_header_t *ip, u32 rx_fib_index, u8 is_output)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
ip4_address_t * ip4_interface_first_address(ip4_main_t *im, u32 sw_if_index, ip_interface_address_t **result_ia)
static f64 vlib_time_now(vlib_main_t *vm)
u32 fib_table_get_index_for_sw_if_index(fib_protocol_t proto, u32 sw_if_index)
Get the index of the FIB bound to the interface.
static void make_sm_kv(clib_bihash_kv_8_8_t *kv, ip4_address_t *addr, u8 proto, u32 fib_index, u16 port)
u32 vlib_frame_queue_main_init(u32 node_index, u32 frame_queue_nelts)
void nat_free_session_data(snat_main_t *sm, snat_session_t *s, u32 thread_index, u8 is_ha)
Free NAT44 session data (lookup keys, external addrres port)
add paths without path extensions
int ip4_sv_reass_output_enable_disable_with_refcnt(u32 sw_if_index, int is_enable)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
void nat_ha_sref_ed_cb(ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, u8 proto, u32 fib_index, u32 total_pkts, u64 total_bytes, u32 thread_index)
u32 ed_out2in_slowpath_node_index
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. ...
u8 * format_user_kvp(u8 *s, va_list *args)
void nat_syslog_nat44_sdel(u32 ssubix, u32 sfibix, ip4_address_t *isaddr, u16 isport, ip4_address_t *idaddr, u16 idport, ip4_address_t *xsaddr, u16 xsport, ip4_address_t *xdaddr, u16 xdport, snat_protocol_t proto, u8 is_twicenat)
ip_lookup_main_t lookup_main
#define nat_elog_warn(nat_elog_str)
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.
int nat44_del_ed_session(snat_main_t *sm, ip4_address_t *addr, u16 port, ip4_address_t *eh_addr, u16 eh_port, u8 proto, u32 vrf_id, int is_in)
Delete NAT44 endpoint-dependent session.
format_function_t format_snat_key
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.
#define VLIB_NODE_FN(node)
#define nat_elog_addr(_level, _str, _addr)
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.
static int nat_alloc_addr_and_port_mape(snat_address_t *addresses, u32 fib_index, u32 thread_index, snat_session_key_t *k, u16 port_per_thread, u32 snat_thread_index)
static int nat_alloc_addr_and_port_default(snat_address_t *addresses, u32 fib_index, u32 thread_index, snat_session_key_t *k, u16 port_per_thread, u32 snat_thread_index)
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.
int snat_interface_add_del(u32 sw_if_index, u8 is_inside, int is_del)
Enable/disable NAT44 feature on the interface.
u32 icmp_match_out2in_ed(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)
VNET_FEATURE_INIT(nat_pre_in2out, static)
nat44_lb_addr_port_t * locals
clib_bihash_8_8_t user_hash
int nat44_add_del_lb_static_mapping(ip4_address_t e_addr, u16 e_port, snat_protocol_t proto, nat44_lb_addr_port_t *locals, u8 is_add, twice_nat_type_t twice_nat, u8 out2in_only, u8 *tag, u32 affinity)
Add/delete static mapping with load-balancing (multiple backends)
snat_session_t * nat_session_alloc_or_recycle(snat_main_t *sm, snat_user_t *u, u32 thread_index, f64 now)
Allocate new NAT session or recycle last used.
#define NAT_STATIC_MAPPING_FLAG_OUT2IN_ONLY
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
void nat_ha_sadd_cb(ip4_address_t *in_addr, u16 in_port, ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, ip4_address_t *ehn_addr, u16 ehn_port, u8 proto, u32 fib_index, u16 flags, u32 thread_index)
u32 in2out_output_node_index
u32 ip4_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
snat_get_worker_out2in_function_t * worker_out2in_cb
#define static_always_inline
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
vl_api_interface_index_t sw_if_index
#define VLIB_INIT_FUNCTION(x)
vlib_node_registration_t snat_out2in_node
(constructor) VLIB_REGISTER_NODE (snat_out2in_node)
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.
u8 * format_static_mapping_kvp(u8 *s, va_list *args)
void nat_ha_sadd_ed_cb(ip4_address_t *in_addr, u16 in_port, ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, ip4_address_t *ehn_addr, u16 ehn_port, u8 proto, u32 fib_index, u16 flags, u32 thread_index)
u32 det_in2out_node_index
int snat_add_address(snat_main_t *sm, ip4_address_t *addr, u32 vrf_id, u8 twice_nat)
Add external address to NAT44 pool.
u8 * format_ed_session_kvp(u8 *s, va_list *args)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Aggregate type for a prefix.
#define clib_error_return(e, args...)
#define is_fwd_bypass_session(s)
Check if NAT session is forwarding bypass.
static u32 snat_get_worker_in2out_cb(ip4_header_t *ip0, u32 rx_fib_index0, u8 is_output)
void snat_ipfix_logging_init(vlib_main_t *vm)
Initialize NAT plugin IPFIX logging.
static void * ip4_next_header(ip4_header_t *i)
void snat_ipfix_logging_addresses_exhausted(u32 thread_index, u32 pool_id)
Generate NAT addresses exhausted event.
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
void nat_ha_sdel_ed_cb(ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, u8 proto, u32 fib_index, u32 ti)
fib_node_index_t fib_table_lookup(u32 fib_index, const fib_prefix_t *prefix)
Perfom a longest prefix match in the non-forwarding table.
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)
void nat_affinity_unlock(ip4_address_t client_addr, ip4_address_t service_addr, u8 proto, u16 service_port)
Release a reference counting lock for affinity.
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, twice_nat_type_t *twice_nat, lb_nat_type_t *lb, ip4_address_t *ext_host_addr, u8 *is_identity_nat)
Match NAT44 static mapping.
fib_source_t fib_source_allocate(const char *name, fib_source_priority_t prio, fib_source_behaviour_t bh)
void snat_free_outside_address_and_port(snat_address_t *addresses, u32 thread_index, snat_session_key_t *k)
Free outside address and port pair.
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 void nat44_delete_session(snat_main_t *sm, snat_session_t *ses, u32 thread_index)
char * name
The counter collection's name.
vl_api_fib_path_type_t type
twice_nat_type_t twice_nat
static u32 snat_get_worker_out2in_cb(vlib_buffer_t *b, ip4_header_t *ip0, u32 rx_fib_index0, u8 is_output)
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
void nat66_init(vlib_main_t *vm)
vlib_node_registration_t nat44_ed_out2in_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_out2in_node)
int snat_alloc_outside_address_and_port(snat_address_t *addresses, u32 fib_index, u32 thread_index, snat_session_key_t *k, u16 port_per_thread, u32 snat_thread_index)
Alloc outside address and port.
snat_user_t * nat_user_get_or_create(snat_main_t *sm, ip4_address_t *addr, u32 fib_index, u32 thread_index)
Find or create NAT user.
#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_dpo_module_init(void)
u32 handoff_in2out_output_index
nat_addr_and_port_alloc_alg_t addr_and_port_alloc_alg
#define FIB_SOURCE_PRIORITY_HI
Some priority values that plugins might use when they are not to concerned where in the list they'll ...
clib_bihash_16_8_t out2in_ed
static_always_inline u8 icmp_type_is_error_message(u8 icmp_type)
static uword clib_bitmap_last_set(uword *ai)
Return the higest numbered set bit in a bitmap.
void nat_ha_sdel_cb(ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, u8 proto, u32 fib_index, u32 ti)
IPv4 shallow virtual reassembly.
void nat_ha_sref_cb(ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, u8 proto, u32 fib_index, u32 total_pkts, u64 total_bytes, u32 thread_index)
static void clib_dlist_addtail(dlist_elt_t *pool, u32 head_index, u32 new_index)
u32 pre_in2out_node_index
snat_session_t * nat_ed_session_alloc(snat_main_t *sm, snat_user_t *u, u32 thread_index, f64 now)
Allocate NAT endpoint-dependent session.
snat_static_mapping_t * static_mappings
#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.
u32 hairpin_src_node_index
clib_bihash_8_8_t static_mapping_by_external
u32 in2out_slowpath_output_node_index
static void vlib_set_simple_counter(vlib_simple_counter_main_t *cm, u32 thread_index, u32 index, u64 value)
Set a simple counter.
void nat_set_alloc_addr_and_port_default(void)
Set address and port assignment algorithm to default/standard.
void fib_table_unlock(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Take a reference counting lock on the table.
#define is_lb_session(s)
Check if NAT session is load-balancing.
u32 fib_entry_get_resolving_interface(fib_node_index_t entry_index)
snat_interface_t * output_feature_interfaces
u32 pre_out2in_node_index
u32 ed_hairpin_src_node_index
#define pool_free(p)
Free a pool.
void snat_ipfix_logging_nat44_ses_delete(u32 thread_index, 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 snat_det_in2out_node
(constructor) VLIB_REGISTER_NODE (snat_det_in2out_node)
vlib_node_registration_t nat_pre_in2out_node
(constructor) VLIB_REGISTER_NODE (nat_pre_in2out_node)
#define is_affinity_sessions(s)
Check if NAT session has affinity record.
#define VLIB_REGISTER_NODE(x,...)
static u8 snat_proto_to_ip_proto(snat_protocol_t snat_proto)
#define NAT_STATIC_MAPPING_FLAG_IDENTITY_NAT
u32 nat_affinity_get_per_service_list_head_index(void)
Get new affinity per service list head index.
static void clib_dlist_addhead(dlist_elt_t *pool, u32 head_index, u32 new_index)
static u32 random_u32_max(void)
Maximum value returned by random_u32()
static_always_inline uword vlib_get_thread_index(void)
fib_source_t nat_fib_src_low
void nat44_add_del_address_dpo(ip4_address_t addr, u8 is_add)
Add/delete external address to FIB DPO (out2in DPO mode)
vlib_node_registration_t snat_in2out_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_node)
u8 static_mapping_connection_tracking
#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
int nat_affinity_find_and_lock(ip4_address_t client_addr, ip4_address_t service_addr, u8 proto, u16 service_port, u8 *backend_index)
Find service backend index for client-IP and take a reference counting lock.
u32 ed_in2out_slowpath_node_index
int snat_interface_add_del_output_feature(u32 sw_if_index, u8 is_inside, int is_del)
Enable/disable NAT44 output feature on the interface (postrouting NAT)
#define nat_elog_notice_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1)
dslite_main_t dslite_main
static void snat_ip4_table_bind(ip4_main_t *im, uword opaque, u32 sw_if_index, u32 new_fib_index, u32 old_fib_index)
u8 * format_session_kvp(u8 *s, va_list *args)
u32 fib_node_index_t
A typedef of a node index.
#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
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
u32 ed_hairpin_dst_node_index
fib_source_t nat_fib_src_hi
static void make_ed_kv(clib_bihash_kv_16_8_t *kv, ip4_address_t *l_addr, ip4_address_t *r_addr, u8 proto, u32 fib_index, u16 l_port, u16 r_port)
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...
vlib_main_t vlib_node_runtime_t * node
u32 tcp_transitory_timeout
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, twice_nat_type_t twice_nat, u8 out2in_only, u8 *tag, u8 identity_nat)
Add/delete NAT44 static mapping.
void fib_table_lock(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Release a reference counting lock on the table.
u32 * auto_add_sw_if_indices
u32 in2out_fast_node_index
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...
void vlib_validate_simple_counter(vlib_simple_counter_main_t *cm, u32 index)
validate a simple counter
static_always_inline u16 snat_random_port(u16 min, u16 max)
#define NAT_INTERFACE_FLAG_IS_INSIDE
#define is_addr_only_static_mapping(sm)
Check if NAT static mapping is address only (1:1NAT).
manual_print typedef address
#define is_identity_static_mapping(sm)
Check if NAT static mapping is identity NAT.
u32 det_out2in_node_index
clib_error_t * nat_affinity_init(vlib_main_t *vm)
Initialize NAT client-IP based affinity.
u32 in2out_slowpath_node_index
snat_icmp_match_function_t * icmp_match_out2in_cb
vlib_log_class_t log_class
#define SNAT_SESSION_FLAG_TWICE_NAT
void nat_set_alloc_addr_and_port_range(u16 start_port, u16 end_port)
Set address and port assignment algorithm for port range.
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.
static void vlib_zero_simple_counter(vlib_simple_counter_main_t *cm, u32 index)
Clear a simple counter Clears the set of per-thread u16 counters, and the u64 counter.
uword * thread_registrations_by_name
vlib_node_registration_t nat44_ed_in2out_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_node)
#define FIB_SOURCE_PRIORITY_LOW
int nat44_del_session(snat_main_t *sm, ip4_address_t *addr, u16 port, snat_protocol_t proto, u32 vrf_id, int is_in)
Delete NAT44 session.
static_always_inline int get_icmp_o2i_ed_key(vlib_buffer_t *b, ip4_header_t *ip0, nat_ed_ses_key_t *p_key0)
snat_address_t * twice_nat_addresses
#define VNET_FEATURES(...)
void nat_syslog_nat44_apmdel(u32 ssubix, u32 sfibix, ip4_address_t *isaddr, u16 isport, ip4_address_t *xsaddr, u16 xsport, snat_protocol_t proto)
static clib_error_t * snat_init(vlib_main_t *vm)
void nat_ha_sdel(ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, u8 proto, u32 fib_index, u32 thread_index)
Create session delete HA event.
static uword is_pow2(uword x)
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.
ip4_table_bind_callback_t * table_bind_callbacks
Functions to call when interface to table biding changes.
clib_error_t * nat64_init(vlib_main_t *vm)
Initialize NAT64.
NAT64 global declarations.
#define is_lb_static_mapping(sm)
Check if NAT static mapping is load-balancing.
void increment_v4_address(ip4_address_t *a)
Increment IPv4 address.
char * stat_segment_name
Name in stat segment directory.
vlib_simple_counter_main_t total_users
#define nat_elog_err(nat_elog_str)
static u32 ip_proto_to_snat_proto(u8 ip_proto)
#define FIB_NODE_INDEX_INVALID
format_function_t format_static_mapping_key
static void user_session_increment(snat_main_t *sm, snat_user_t *u, u8 is_static)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u32 hairpinning_node_index
#define is_out2in_only_static_mapping(sm)
Check if NAT static mapping match only out2in direction.
VLIB buffer representation.
snat_main_per_thread_data_t * per_thread_data
void nat_affinity_flush_service(u32 affinity_per_service_list_head_index)
Flush all service affinity data.
#define DPO_INVALID
An initialiser for DPOs declared on the stack.
u32 affinity_per_service_list_head_index
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)
Add/delete NAT44 pool address from specific interfce.
u32 out2in_fast_node_index
#define hash_get_mem(h, key)
#define SNAT_ICMP_TIMEOUT
snat_get_worker_in2out_function_t * worker_in2out_cb
snat_static_map_resolve_t * to_resolve
static api_main_t * vlibapi_get_main(void)
static u32 random_u32(u32 *seed)
32-bit random number generator
#define SNAT_SESSION_FLAG_STATIC_MAPPING
ip4_main_t ip4_main
Global ip4 main structure.
static vlib_thread_main_t * vlib_get_thread_main()
static u32 get_thread_idx_by_port(u16 e_port)
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)
f64 end
end of the time range
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
int snat_set_workers(uword *bitmap)
Set NAT plugin workers.
u32 icmp_match_in2out_ed(snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b, ip4_header_t *ip, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
#define is_twice_nat_session(s)
Check if NAT session is twice NAT.
clib_bihash_16_8_t in2out_ed
static clib_error_t * snat_config(vlib_main_t *vm, unformat_input_t *input)
static u32 nat44_ed_get_worker_in2out_cb(ip4_header_t *ip, u32 rx_fib_index, u8 is_output)
#define pool_foreach_index(i, v, body)
Iterate pool by index.
void nat_set_alloc_addr_and_port_mape(u16 psid, u16 psid_offset, u16 psid_length)
Set address and port assignment algorithm for MAP-E CE.
NAT66 global declarations.
NAT plugin client-IP based session affinity for load-balancing.
vlib_simple_counter_main_t total_sessions
#define SNAT_TCP_TRANSITORY_TIMEOUT
ip_lookup_main_t * ip4_lookup_main
#define NAT_STATIC_MAPPING_FLAG_LB
static int is_snat_address_used_in_static_mapping(snat_main_t *sm, ip4_address_t addr)
#define NAT_STATIC_MAPPING_FLAG_ADDR_ONLY
snat_session_t * sessions
snat_icmp_match_function_t * icmp_match_in2out_cb
clib_bihash_8_8_t static_mapping_by_local
int nat44_lb_static_mapping_add_del_local(ip4_address_t e_addr, u16 e_port, ip4_address_t l_addr, u16 l_port, snat_protocol_t proto, u32 vrf_id, u8 probability, u8 is_add)
snat_interface_t * interfaces
void nat_ha_init(vlib_main_t *vm, nat_ha_sadd_cb_t sadd_cb, nat_ha_sdel_cb_t sdel_cb, nat_ha_sref_cb_t sref_cb)
Initialize NAT HA.
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)
vlib_node_registration_t nat_pre_out2in_node
(constructor) VLIB_REGISTER_NODE (nat_pre_out2in_node)
static u32 clib_dlist_remove_head(dlist_elt_t *pool, u32 head_index)
static int nat_set_outside_address_and_port(snat_address_t *addresses, u32 thread_index, snat_session_key_t *k)
u32 tcp_established_timeout
static uword pool_elts(void *v)
Number of active elements in a pool.