|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
22 #include <vpp/app/version.h>
32 .arc_name =
"ip6-unicast",
33 .node_name =
"nat64-in2out",
38 .arc_name =
"ip4-unicast",
39 .node_name =
"nat64-out2in",
44 .arc_name =
"ip6-unicast",
45 .node_name =
"nat64-in2out-handoff",
50 .arc_name =
"ip4-unicast",
51 .node_name =
"nat64-out2in-handoff",
56 .version = VPP_BUILD_VER,
57 .description =
"NAT64",
60 0x00, 0x64, 0xff, 0x9b,
61 0x00, 0x00, 0x00, 0x00,
62 0x00, 0x00, 0x00, 0x00,
63 0x00, 0x00, 0x00, 0x00
67 #define nat_elog_str(_str) \
70 ELOG_TYPE_DECLARE (e) = \
72 .format = "nat-msg " _str, \
75 ELOG_DATA (&vlib_global_main.elog_main, e); \
83 u32 if_address_index,
u32 is_delete)
98 for (j = 0; j <
vec_len (
nm->addr_pool); j++)
99 if (
nm->addr_pool[j].addr.as_u32 ==
address->as_u32)
123 #ifdef clib_crc32c_uses_intrinsics
124 hash = clib_crc32c ((
u8 *)
addr->as_u32, 16);
135 return next_worker_index;
154 ip46_address_t daddr;
155 nat64_db_bib_entry_t *bibe;
158 daddr.ip4.as_u32 =
ip->dst_address.as_u32;
165 return (
u32) (db -
nm->db);
174 icmp46_header_t *
icmp = (icmp46_header_t *) udp;
187 case NAT_PROTOCOL_ICMP:
188 icmp = (icmp46_header_t *) l4_header;
192 case NAT_PROTOCOL_UDP:
193 case NAT_PROTOCOL_TCP:
229 nm->error_node_index =
node->index;
233 nm->in2out_slowpath_node_index =
node->index;
238 nm->expire_worker_walk_node_index =
node->index;
256 nm->total_bibs.name =
"total-bibs";
257 nm->total_bibs.stat_segment_name =
"/nat64/total-bibs";
301 nm->counters.in2out.x.name = #x; \
302 nm->counters.in2out.x.stat_segment_name = "/nat64/in2out/" #x; \
303 nm->counters.out2in.x.name = #x; \
304 nm->counters.out2in.x.stat_segment_name = "/nat64/out2in/" #x;
377 if (
nm->addr_pool[
i].addr.as_u32 ==
addr->as_u32)
379 a =
nm->addr_pool +
i;
387 return VNET_API_ERROR_VALUE_EXIST;
396 #define _(N, id, n, s) \
397 clib_memset (a->busy_##n##_port_refcounts, 0, sizeof(a->busy_##n##_port_refcounts)); \
398 a->busy_##n##_ports = 0; \
399 vec_validate_init_empty (a->busy_##n##_ports_per_thread, tm->n_vlib_mains - 1, 0);
406 return VNET_API_ERROR_NO_SUCH_ENTRY;
408 if (
a->fib_index != ~0)
469 return VNET_API_ERROR_VALUE_EXIST;
475 first_int_addr, ~0, 0);
483 return VNET_API_ERROR_NO_SUCH_ENTRY;
491 first_int_addr, ~0, 1);
500 vlib_validate_simple_counter (&nm->counters.in2out.x, sw_if_index); \
501 vlib_zero_simple_counter (&nm->counters.in2out.x, sw_if_index); \
502 vlib_validate_simple_counter (&nm->counters.out2in.x, sw_if_index); \
503 vlib_zero_simple_counter (&nm->counters.out2in.x, sw_if_index);
517 .ip4.as_u32 =
addr->as_u32,
544 const char *feature_name, *arc_name;
567 interface->flags = 0;
575 nm->total_enabled_count++;
577 nm->expire_walk_node_index,
584 return VNET_API_ERROR_NO_SUCH_ENTRY;
594 nm->total_enabled_count--;
608 is_inside ?
"nat64-in2out-handoff" :
"nat64-out2in-handoff";
617 feature_name = is_inside ?
"nat64-in2out" :
"nat64-out2in";
619 arc_name = is_inside ?
"ip6-unicast" :
"ip4-unicast";
663 if (
r >= min &&
r <= max)
666 return min + (rwide % (max - min + 1));
676 u16 port_per_thread,
u32 nat_thread_index)
687 #define _(N, j, n, s) \
688 case NAT_PROTOCOL_##N: \
689 if (a->busy_##n##_ports_per_thread[thread_index] < port_per_thread) \
691 if (a->fib_index == fib_index) \
695 portnum = (port_per_thread * \
696 nat_thread_index) + \
697 nat64_random_port(0, port_per_thread - 1) + 1024; \
698 if (a->busy_##n##_port_refcounts[portnum]) \
700 --a->busy_##n##_port_refcounts[portnum]; \
701 a->busy_##n##_ports_per_thread[thread_index]++; \
702 a->busy_##n##_ports++; \
704 *port = clib_host_to_net_u16(portnum); \
708 else if (a->fib_index == ~0) \
727 #define _(N, j, n, s) \
728 case NAT_PROTOCOL_##N: \
731 portnum = (port_per_thread * \
732 nat_thread_index) + \
733 nat64_random_port(0, port_per_thread - 1) + 1024; \
734 if (a->busy_##n##_port_refcounts[portnum]) \
736 ++a->busy_##n##_port_refcounts[portnum]; \
737 a->busy_##n##_ports_per_thread[thread_index]++; \
738 a->busy_##n##_ports++; \
740 *port = clib_host_to_net_u16(portnum); \
762 u32 worker_index = 0;
783 u16 port_host_byte_order = clib_net_to_host_u16 (
port);
789 a =
nm->addr_pool +
i;
790 if (
addr->as_u32 !=
a->addr.as_u32)
794 #define _(N, j, n, s) \
795 case NAT_PROTOCOL_##N: \
796 ASSERT (a->busy_##n##_port_refcounts[port_host_byte_order] >= 1); \
797 --a->busy_##n##_port_refcounts[port_host_byte_order]; \
798 a->busy_##n##_ports--; \
799 a->busy_##n##_ports_per_thread[thread_index]--; \
822 nat64_db_bib_entry_t *bibe;
839 static_bib->
proto, 1);
860 static_bib->
done = 1;
873 .state = VLIB_NODE_STATE_INTERRUPT,
874 .name =
"nat64-static-bib-worker",
884 nat64_db_bib_entry_t *bibe;
905 addr.as_u64[0] = in_addr->as_u64[0];
906 addr.as_u64[1] = in_addr->as_u64[1];
909 proto, fib_index, 1);
914 return VNET_API_ERROR_VALUE_EXIST;
920 return VNET_API_ERROR_INVALID_VALUE_2;
925 a =
nm->addr_pool +
i;
926 if (out_addr->
as_u32 !=
a->addr.as_u32)
930 #define _(N, j, n, s) \
931 case NAT_PROTOCOL_##N: \
932 if (a->busy_##n##_port_refcounts[out_port]) \
933 return VNET_API_ERROR_INVALID_VALUE; \
934 ++a->busy_##n##_port_refcounts[out_port]; \
935 if (out_port > 1024) \
937 a->busy_##n##_ports++; \
938 a->busy_##n##_ports_per_thread[thread_index]++; \
947 return VNET_API_ERROR_INVALID_VALUE;
955 clib_host_to_net_u16 (in_port),
956 clib_host_to_net_u16 (out_port),
957 fib_index,
proto, 1);
959 return VNET_API_ERROR_UNSPECIFIED;
968 return VNET_API_ERROR_NO_SUCH_ENTRY;
983 if (static_bib->
done)
984 vec_add1 (to_be_free, static_bib -
nm->static_bibs);
991 static_bib->
in_addr.as_u64[0] = in_addr->as_u64[0];
992 static_bib->
in_addr.as_u64[1] = in_addr->as_u64[1];
993 static_bib->
in_port = clib_host_to_net_u16 (in_port);
995 static_bib->
out_port = clib_host_to_net_u16 (out_port);
998 static_bib->
is_add = is_add;
1000 static_bib->
done = 0;
1006 return VNET_API_ERROR_UNSPECIFIED;
1020 nm->udp_timeout = timeout;
1030 return nm->udp_timeout;
1041 nm->icmp_timeout = timeout;
1062 return nm->icmp_timeout;
1073 nm->tcp_trans_timeout = trans;
1078 nm->tcp_est_timeout = est;
1088 return nm->tcp_trans_timeout;
1096 return nm->tcp_est_timeout;
1107 case NAT_PROTOCOL_ICMP:
1108 ste->expire =
now +
nm->icmp_timeout;
1110 case NAT_PROTOCOL_TCP:
1112 switch (ste->tcp_state)
1114 case NAT64_TCP_STATE_V4_INIT:
1115 case NAT64_TCP_STATE_V6_INIT:
1116 case NAT64_TCP_STATE_V4_FIN_RCV:
1117 case NAT64_TCP_STATE_V6_FIN_RCV:
1118 case NAT64_TCP_STATE_V6_FIN_V4_FIN_RCV:
1119 case NAT64_TCP_STATE_TRANS:
1120 ste->expire =
now +
nm->tcp_trans_timeout;
1122 case NAT64_TCP_STATE_ESTABLISHED:
1123 ste->expire =
now +
nm->tcp_est_timeout;
1129 case NAT_PROTOCOL_UDP:
1130 ste->expire =
now +
nm->udp_timeout;
1133 ste->expire =
now +
nm->udp_timeout;
1142 switch (ste->tcp_state)
1144 case NAT64_TCP_STATE_CLOSED:
1149 ste->tcp_state = NAT64_TCP_STATE_V6_INIT;
1151 ste->tcp_state = NAT64_TCP_STATE_V4_INIT;
1155 case NAT64_TCP_STATE_V4_INIT:
1158 ste->tcp_state = NAT64_TCP_STATE_ESTABLISHED;
1161 case NAT64_TCP_STATE_V6_INIT:
1164 ste->tcp_state = NAT64_TCP_STATE_ESTABLISHED;
1167 case NAT64_TCP_STATE_ESTABLISHED:
1172 ste->tcp_state = NAT64_TCP_STATE_V6_FIN_RCV;
1174 ste->tcp_state = NAT64_TCP_STATE_V4_FIN_RCV;
1178 ste->tcp_state = NAT64_TCP_STATE_TRANS;
1182 case NAT64_TCP_STATE_V4_FIN_RCV:
1185 ste->tcp_state = NAT64_TCP_STATE_V6_FIN_V4_FIN_RCV;
1188 case NAT64_TCP_STATE_V6_FIN_RCV:
1191 ste->tcp_state = NAT64_TCP_STATE_V6_FIN_V4_FIN_RCV;
1194 case NAT64_TCP_STATE_TRANS:
1197 ste->tcp_state = NAT64_TCP_STATE_ESTABLISHED;
1213 if (plen != 32 && plen != 40 && plen != 48 && plen != 56 && plen != 64
1215 return VNET_API_ERROR_INVALID_VALUE;
1245 return VNET_API_ERROR_NO_SUCH_ENTRY;
1299 ip6->as_u32[1] =
ip4->as_u32;
1302 ip6->as_u8[5] =
ip4->as_u8[0];
1303 ip6->as_u8[6] =
ip4->as_u8[1];
1304 ip6->as_u8[7] =
ip4->as_u8[2];
1305 ip6->as_u8[9] =
ip4->as_u8[3];
1308 ip6->as_u8[6] =
ip4->as_u8[0];
1309 ip6->as_u8[7] =
ip4->as_u8[1];
1310 ip6->as_u8[9] =
ip4->as_u8[2];
1311 ip6->as_u8[10] =
ip4->as_u8[3];
1314 ip6->as_u8[7] =
ip4->as_u8[0];
1315 ip6->as_u8[9] =
ip4->as_u8[1];
1316 ip6->as_u8[10] =
ip4->as_u8[2];
1317 ip6->as_u8[11] =
ip4->as_u8[3];
1320 ip6->as_u8[9] =
ip4->as_u8[0];
1321 ip6->as_u8[10] =
ip4->as_u8[1];
1322 ip6->as_u8[11] =
ip4->as_u8[2];
1323 ip6->as_u8[12] =
ip4->as_u8[3];
1326 ip6->as_u32[3] =
ip4->as_u32;
1336 ip6->as_u32[3] =
ip4->as_u32;
1372 ip4->as_u32 =
ip6->as_u32[1];
1375 ip4->as_u8[0] =
ip6->as_u8[5];
1376 ip4->as_u8[1] =
ip6->as_u8[6];
1377 ip4->as_u8[2] =
ip6->as_u8[7];
1378 ip4->as_u8[3] =
ip6->as_u8[9];
1381 ip4->as_u8[0] =
ip6->as_u8[6];
1382 ip4->as_u8[1] =
ip6->as_u8[7];
1383 ip4->as_u8[2] =
ip6->as_u8[9];
1384 ip4->as_u8[3] =
ip6->as_u8[10];
1387 ip4->as_u8[0] =
ip6->as_u8[7];
1388 ip4->as_u8[1] =
ip6->as_u8[9];
1389 ip4->as_u8[2] =
ip6->as_u8[10];
1390 ip4->as_u8[3] =
ip6->as_u8[11];
1393 ip4->as_u8[0] =
ip6->as_u8[9];
1394 ip4->as_u8[1] =
ip6->as_u8[10];
1395 ip4->as_u8[2] =
ip6->as_u8[11];
1396 ip4->as_u8[3] =
ip6->as_u8[12];
1399 ip4->as_u32 =
ip6->as_u32[3];
1438 .state = VLIB_NODE_STATE_INTERRUPT,
1439 .name =
"nat64-expire-worker-walk",
1453 uword event_type, *event_data = 0;
1469 if (
nm->total_enabled_count)
1493 worker_vm = worker_vms[
i];
1495 nm->expire_worker_walk_node_index);
1507 if (
nm->expire_walk_node_index)
1510 "nat64-expire-walk",
1527 c.bib_buckets = 1024;
1529 if (!
c.bib_memory_size)
1530 c.bib_memory_size = 128 << 20;
1533 c.st_buckets = 2048;
1535 if (!
c.st_memory_size)
1536 c.st_memory_size = 256 << 20;
1583 "inside" :
"outside");
1604 if (
a->fib_index != ~0)
1615 u32 *
r = va_arg (*args,
u32 *);
1618 #define _(N, i, n, s) else if (unformat (input, s)) *r = NAT_PROTOCOL_##N;
1634 #define _(N, j, n, str) case NAT_PROTOCOL_##N: t = (u8 *) str; break;
1638 s =
format (s,
"unknown");
int nat64_add_del_prefix(ip6_address_t *prefix, u8 plen, u32 vrf_id, u8 is_add)
Add/delete NAT64 prefix.
int nat64_db_free(nat64_db_t *db)
Free NAT64 DB.
int nat64_add_del_static_bib_entry(ip6_address_t *in_addr, ip4_address_t *out_addr, u16 in_port, u16 out_port, u8 proto, u32 vrf_id, u8 is_add)
Add/delete static NAT64 BIB entry.
vnet_interface_main_t * im
static u8 well_known_prefix[]
void nat64_create_expire_walk_process()
#define NAT_TCP_TRANSITORY_TIMEOUT
u32 nat64_get_udp_timeout(void)
Get UDP session timeout.
clib_error_t * nat64_init(vlib_main_t *vm)
Initialize NAT64.
void nat64_reset_timeouts()
int(* nat64_prefix_walk_fn_t)(nat64_prefix_t *pref64, void *ctx)
Call back function when walking addresses in NAT64 prefixes, non-zero return value stop walk.
void fib_table_entry_delete(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source)
Delete a FIB entry.
ip4_main_t ip4_main
Global ip4 main structure.
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.
static uword * vlib_process_wait_for_event(vlib_main_t *vm)
void nat64_prefix_walk(nat64_prefix_walk_fn_t fn, void *ctx)
Walk NAT64 prefixes.
struct _tcp_header tcp_header_t
nat44_ei_interface_t * interfaces
static nat_protocol_t ip_proto_to_nat_proto(u8 ip_proto)
Common NAT inline functions.
vlib_log_class_t vlib_log_register_class(char *class, char *subclass)
vlib_main_t vlib_node_runtime_t * node
nat64_db_bib_entry_t * nat64_db_bib_entry_create(u32 thread_index, nat64_db_t *db, ip6_address_t *in_addr, ip4_address_t *out_addr, u16 in_port, u16 out_port, u32 fib_index, u8 proto, u8 is_static)
Create new NAT64 BIB entry.
u32 nat64_get_worker_in2out(ip6_address_t *addr)
Get worker thread index for NAT64 in2out.
u8 * format_nat_protocol(u8 *s, va_list *args)
uword unformat_nat_protocol(unformat_input_t *input, va_list *args)
u32 ip4_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
#define pool_put(P, E)
Free an object E in pool P.
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
static vlib_node_registration_t nat64_static_bib_worker_node
(constructor) VLIB_REGISTER_NODE (nat64_static_bib_worker_node)
#define nat_elog_str(_str)
int ip6_sv_reass_enable_disable_with_refcnt(u32 sw_if_index, int is_enable)
int nat64_set_icmp_timeout(u32 timeout)
Set ICMP session timeout.
@ FIB_ENTRY_FLAG_EXCLUSIVE
vnet_hw_if_output_node_runtime_t * r
static_always_inline u8 icmp_type_is_error_message(u8 icmp_type)
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
int ip4_sv_reass_enable_disable_with_refcnt(u32 sw_if_index, int is_enable)
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
clib_error_t * nat64_api_hookup(vlib_main_t *vm)
#define pool_put_index(p, i)
Free pool element with given index.
vlib_node_registration_t nat64_out2in_node
(constructor) VLIB_REGISTER_NODE (nat64_out2in_node)
void nat_ipfix_logging_addresses_exhausted(u32 thread_index, u32 pool_id)
Generate NAT addresses exhausted event.
vlib_node_registration_t nat64_in2out_node
(constructor) VLIB_REGISTER_NODE (nat64_in2out_node)
void nat_ipfix_logging_init(vlib_main_t *vm)
Initialize NAT plugin IPFIX logging.
static u32 random_u32(u32 *seed)
32-bit random number generator
u32 vlib_frame_queue_main_init(u32 node_index, u32 frame_queue_nelts)
int(* nat64_pool_addr_walk_fn_t)(nat64_address_t *addr, void *ctx)
Call back function when walking addresses in NAT64 pool, non-zero return value stop walk.
#define NAT64_INTERFACE_FLAG_IS_INSIDE
static void nat64_free_out_addr_and_port(struct nat64_db_s *db, ip4_address_t *addr, u16 port, u8 protocol)
static uword nat64_expire_walk_fn(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Centralized process to drive per worker expire walk.
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type,...
#define pool_foreach(VAR, POOL)
Iterate through pool.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
int nat64_alloc_out_addr_and_port(u32 fib_index, nat_protocol_t proto, ip4_address_t *addr, u16 *port, u32 thread_index)
Alloce IPv4 address and port pair from NAT64 pool.
IPv6 shallow virtual reassembly.
IPv4 shallow virtual reassembly.
int nat64_plugin_enable(nat64_config_t c)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
vnet_main_t * vnet_get_main(void)
u32 vlib_process_create(vlib_main_t *vm, char *name, vlib_node_function_t *f, u32 log2_n_stack_bytes)
Create a vlib process.
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 NAT64_INTERFACE_FLAG_IS_OUTSIDE
static_always_inline uword vlib_get_thread_index(void)
u32 nat64_get_icmp_timeout(void)
Get ICMP session timeout.
#define static_always_inline
void nat64_pool_addr_walk(nat64_pool_addr_walk_fn_t fn, void *ctx)
Walk NAT64 pool.
int nat64_set_tcp_timeouts(u32 trans, u32 est)
Set TCP session timeouts.
vlib_log_class_t log_class
#define clib_bitmap_free(v)
Free a bitmap.
static vlib_node_registration_t nat64_expire_worker_walk_node
(constructor) VLIB_REGISTER_NODE (nat64_expire_worker_walk_node)
void nat64_interfaces_walk(nat64_interface_walk_fn_t fn, void *ctx)
Walk NAT64 interfaces.
uword * thread_registrations_by_name
char * name
The counter collection's name.
sll srl srl sll sra u16x4 i
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
manual_print typedef address
static u64 clib_xxhash(u64 key)
static uword nat64_static_bib_worker_fn(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Add/delete static BIB entry in worker thread.
#define nat64_interface_is_inside(i)
Check if NAT64 interface is inside.
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.
static void nat64_validate_counters(nat64_main_t *nm, u32 sw_if_index)
struct _vlib_node_registration vlib_node_registration_t
fib_source_t fib_source_allocate(const char *name, fib_source_priority_t prio, fib_source_behaviour_t bh)
void nat64_db_bib_entry_free(u32 thread_index, nat64_db_t *db, nat64_db_bib_entry_t *bibe)
Free NAT64 BIB entry.
#define nat64_interface_is_outside(i)
Check if NAT64 interface is outside.
VNET_FEATURE_INIT(nat64_in2out, static)
static void nat64_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 FIB_SOURCE_PRIORITY_HI
Some priority values that plugins might use when they are not to concerned where in the list they'll ...
ip4_add_del_interface_address_callback_t * add_del_interface_address_callbacks
Functions to call when interface address changes.
ip4_add_del_interface_address_function_t * function
#define vec_free(V)
Free vector's memory (no header).
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
@ NAT64_CLEANER_RESCHEDULE
int nat64_add_del_pool_addr(u32 thread_index, ip4_address_t *addr, u32 vrf_id, u8 is_add)
Add/delete address to NAT64 pool.
static void vlib_set_simple_counter(vlib_simple_counter_main_t *cm, u32 thread_index, u32 index, u64 value)
Set a simple counter.
#define hash_get_mem(h, key)
@ FIB_ENTRY_FLAG_CONNECTED
format_function_t format_vnet_sw_if_index_name
static f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Suspend a cooperative multi-tasking thread Waits for an event, or for the indicated number of seconds...
description fragment has unexpected format
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.
@ FIB_ROUTE_PATH_FLAG_NONE
int(* nat64_interface_walk_fn_t)(nat64_interface_t *i, void *ctx)
Call back function when walking interfaces with NAT64 feature, non-zero return value stop walk.
char * stat_segment_name
Name in stat segment directory.
#define VLIB_INIT_FUNCTION(x)
u32 nat64_get_tcp_est_timeout(void)
Get TCP established timeout.
vl_api_ip_proto_t protocol
static void vlib_node_set_interrupt_pending(vlib_main_t *vm, u32 node_index)
void vlib_validate_simple_counter(vlib_simple_counter_main_t *cm, u32 index)
validate a simple counter
#define nat64_log_err(...)
#define vec_foreach(var, vec)
Vector iterator.
int nat64_init_hash(nat64_config_t c)
int nat64_set_udp_timeout(u32 timeout)
Set UDP session timeout.
int nat64_db_init(nat64_db_t *db, nat64_config_t c, nat64_db_free_addr_port_function_t free_addr_port_cb)
Initialize NAT64 DB.
static vlib_main_t * vlib_get_main_by_index(u32 thread_index)
#define foreach_nat_counter
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)
u32 nat64_get_worker_out2in(vlib_buffer_t *b, ip4_header_t *ip)
Get worker thread index for NAT64 out2in.
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static u32 vlib_get_n_threads()
static uword nat64_expire_worker_walk_fn(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Per worker process checking expire time for NAT64 sessions.
nat64_db_bib_entry_t * nat64_db_bib_entry_find(nat64_db_t *db, ip46_address_t *addr, u16 port, u8 proto, u32 fib_index, u8 is_ip6)
Find NAT64 BIB entry.
static vlib_main_t * vlib_get_main(void)
void nat64_tcp_session_set_state(nat64_db_st_entry_t *ste, tcp_header_t *tcp, u8 is_ip6)
Set NAT64 TCP session state.
#define VNET_FEATURES(...)
u32 nat64_get_tcp_trans_timeout(void)
Get TCP transitory timeout.
vnet_interface_output_runtime_t * rt
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
void fib_table_unlock(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Take a reference counting lock on the table.
@ FIB_SOURCE_BH_SIMPLE
add paths without path extensions
#define pool_free(p)
Free a pool.
#define FIB_SOURCE_PRIORITY_LOW
static_always_inline u8 plugin_enabled()
void nat64_compose_ip6(ip6_address_t *ip6, ip4_address_t *ip4, u32 fib_index)
Compose IPv4-embedded IPv6 addresses.
u32 * auto_add_sw_if_indices
void nat64_add_del_addr_to_fib(ip4_address_t *addr, u8 p_len, u32 sw_if_index, int is_add)
void nat64_session_reset_timeout(nat64_db_st_entry_t *ste, vlib_main_t *vm)
Reset NAT64 session timeout.
static f64 vlib_time_now(vlib_main_t *vm)
ip4_address_t * ip4_interface_first_address(ip4_main_t *im, u32 sw_if_index, ip_interface_address_t **result_ia)
#define clib_bitmap_foreach(i, ai)
Macro to iterate across set bits in a bitmap.
int nat64_add_interface_address(u32 sw_if_index, int is_add)
NAT64 pool address from specific (DHCP addressed) interface.
void nat64_extract_ip4(ip6_address_t *ip6, ip4_address_t *ip4, u32 fib_index)
Extract IPv4 address from the IPv4-embedded IPv6 addresses.
vlib_simple_counter_main_t total_sessions
int nat64_plugin_disable()
static vlib_thread_main_t * vlib_get_thread_main()
static uword is_pow2(uword x)
vl_api_interface_index_t sw_if_index
int nat64_interface_add_del(u32 sw_if_index, u8 is_inside, u8 is_add)
Enable/disable NAT64 feature on the interface.
static_always_inline int nat64_alloc_addr_and_port_default(nat64_address_t *addresses, u32 fib_index, u32 thread_index, nat_protocol_t proto, ip4_address_t *addr, u16 *port, u16 port_per_thread, u32 nat_thread_index)
void nat64_db_free_out_addr(u32 thread_index, nat64_db_t *db, ip4_address_t *out_addr)
Free sessions using specific outside address.
Aggregate type for a prefix.
static_always_inline u16 nat64_random_port(u16 min, u16 max)
void nad64_db_st_free_expired(u32 thread_index, nat64_db_t *db, u32 now)
Free expired session entries in session tables.
#define vec_del1(v, i)
Delete the element at index I.
static void * ip4_next_header(ip4_header_t *i)
#define NAT_TCP_ESTABLISHED_TIMEOUT
VLIB buffer representation.
#define VLIB_REGISTER_NODE(x,...)