FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
nat44_ei.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 /**
16  * @file nat44_ei.h
17  * NAT44 endpoint independent plugin declarations
18  */
19 #ifndef __included_nat44_ei_h__
20 #define __included_nat44_ei_h__
21 
22 #include <vlib/log.h>
23 #include <vlibapi/api.h>
24 
25 #include <vnet/vnet.h>
26 #include <vnet/ip/ip.h>
27 #include <vnet/ethernet/ethernet.h>
28 #include <vnet/ip/icmp46_packet.h>
29 #include <vnet/api_errno.h>
30 #include <vnet/fib/fib_source.h>
31 
32 #include <vppinfra/dlist.h>
33 #include <vppinfra/error.h>
34 #include <vppinfra/bihash_8_8.h>
35 #include <vppinfra/hash.h>
36 
37 #include <nat/lib/lib.h>
38 #include <nat/lib/inlines.h>
39 
40 /* default number of worker handoff frame queue elements */
41 #define NAT_FQ_NELTS_DEFAULT 64
42 
43 /* External address and port allocation modes */
44 #define foreach_nat44_ei_addr_and_port_alloc_alg \
45  _ (0, DEFAULT, "default") \
46  _ (1, MAPE, "map-e") \
47  _ (2, RANGE, "port-range")
48 
49 typedef enum
50 {
51 #define _(v, N, s) NAT44_EI_ADDR_AND_PORT_ALLOC_ALG_##N = v,
53 #undef _
55 
56 /* Interface flags */
57 #define NAT44_EI_INTERFACE_FLAG_IS_INSIDE (1 << 0)
58 #define NAT44_EI_INTERFACE_FLAG_IS_OUTSIDE (1 << 1)
59 
60 /* Session flags */
61 #define NAT44_EI_SESSION_FLAG_STATIC_MAPPING (1 << 0)
62 #define NAT44_EI_SESSION_FLAG_UNKNOWN_PROTO (1 << 1)
63 
64 /* Static mapping flags */
65 #define NAT44_EI_STATIC_MAPPING_FLAG_ADDR_ONLY (1 << 0)
66 #define NAT44_EI_STATIC_MAPPING_FLAG_IDENTITY_NAT (1 << 1)
67 
68 typedef struct
69 {
72 #define _(N, i, n, s) \
73  u32 busy_##n##_ports; \
74  u32 *busy_##n##_ports_per_thread; \
75  u32 busy_##n##_port_refcounts[0xffff + 1];
77 #undef _
79 
81 
82 /* NAT address and port allocation function */
84  nat44_ei_address_t *addresses, u32 fib_index, u32 thread_index,
86  u16 port_per_thread, u32 snat_thread_index);
87 
88 typedef struct
89 {
93 
94 typedef struct
95 {
98 
99 typedef struct
100 {
101  union
102  {
103  struct
104  {
107  };
109  };
111 
112 typedef struct
113 {
114  /* maximum number of users */
116  /* maximum number of sessions */
118  /* maximum number of ssessions per user */
120 
121  /* plugin features */
125 
128 
130 
131 typedef struct
132 {
144  u8 *tag;
146 
147 // TODO: cleanup/redo (there is no lb in EI nat)
148 typedef struct
149 {
150  /* backend IP address */
152  /* backend port number */
154  /* probability of the backend to be randomly matched */
157  /* backend FIB table */
161 
162 typedef struct
163 {
164  /* prefered pool address */
166  /* local IP address */
168  /* external IP address */
170  /* local port */
172  /* external port */
174  /* local FIB table */
177  /* protocol */
179  /* worker threads used by backends/local host */
181  /* opaque string tag */
182  u8 *tag;
183  /* backends for load-balancing mode */
185  /* flags */
188 
189 typedef struct
190 {
194 
195 typedef struct
196 {
200 
201 typedef struct
202 {
206 
207 typedef CLIB_PACKED (struct {
208  /* Outside network tuple */
209  struct
210  {
212  u32 fib_index;
213  u16 port;
214  } out2in;
215 
216  /* Inside network tuple */
217  struct
218  {
220  u32 fib_index;
221  u16 port;
222  } in2out;
223 
224  nat_protocol_t nat_proto;
225 
226  /* Flags */
227  u32 flags;
228 
229  /* Per-user translations */
230  u32 per_user_index;
231  u32 per_user_list_head_index;
232 
233  /* head of LRU list in which this session is tracked */
234  u32 lru_head_index;
235  /* index in global LRU list */
236  u32 lru_index;
237  f64 last_lru_update;
238 
239  /* Last heard timer */
240  f64 last_heard;
241 
242  /* Last HA refresh */
243  f64 ha_last_refreshed;
244 
245  /* Counters */
246  u64 total_bytes;
247  u32 total_pkts;
248 
249  /* External host address and port */
250  ip4_address_t ext_host_addr;
251  u16 ext_host_port;
252 
253  /* External host address and port after translation */
254  ip4_address_t ext_host_nat_addr;
255  u16 ext_host_nat_port;
256 
257  /* TCP session state */
258  u8 state;
259  u32 i2o_fin_seq;
260  u32 o2i_fin_seq;
261  u64 tcp_closed_timestamp;
262 
263  /* user index */
264  u32 user_index;
265 }) nat44_ei_session_t;
266 
267 typedef CLIB_PACKED (struct {
269  u32 fib_index;
270  u32 sessions_per_user_list_head_index;
271  u32 nsessions;
272  u32 nstaticsessions;
273 }) nat44_ei_user_t;
274 
275 typedef struct
276 {
277  /* Find-a-user => src address lookup */
278  clib_bihash_8_8_t user_hash;
279 
280  /* User pool */
281  nat44_ei_user_t *users;
282 
283  /* Session pool */
284  nat44_ei_session_t *sessions;
285 
286  /* Pool of doubly-linked list elements */
288 
289  /* LRU session list - head is stale, tail is fresh */
296 
297  /* NAT thread index */
299 
300  /* real thread index */
302 
304 
305 typedef struct
306 {
310 
311 typedef struct
312 {
316 
317 typedef struct nat44_ei_main_s
318 {
322 
327 
329 
330  /* Find a static mapping by local */
331  clib_bihash_8_8_t static_mapping_by_local;
332 
333  /* Find a static mapping by external */
334  clib_bihash_8_8_t static_mapping_by_external;
335 
336  /* Static mapping pool */
338 
339  /* Interface pool */
342 
343  /* Is translation memory size calculated or user defined */
345 
349 
352 
355 
356  /* Thread settings */
361 
362  /* Main lookup tables */
363  clib_bihash_8_8_t out2in;
364  clib_bihash_8_8_t in2out;
365 
366  /* Per thread data */
368 
369  /* Vector of outside addresses */
371 
373  /* Address and port allocation type */
375  /* Port set parameters (MAP-E) */
379  /* Port range parameters */
382 
383  /* vector of fibs */
385 
386  /* vector of outside fibs */
388 
389  /* sw_if_indices whose intfc addresses should be auto-added */
391 
392  /* vector of interface address static mappings to resolve. */
394 
398 
402 
403  /* Randomize port allocation order */
405 
407 
408  /* counters */
412 
413 #define _(x) vlib_simple_counter_main_t x;
414  struct
415  {
416  struct
417  {
418  struct
419  {
421  } in2out;
422 
423  struct
424  {
426  } out2in;
427 
428  } fastpath;
429 
430  struct
431  {
432  struct
433  {
435  } in2out;
436 
437  struct
438  {
440  } out2in;
441  } slowpath;
442 
444  } counters;
445 #undef _
446 
447  /* API message ID base */
449 
450  /* log class */
452  /* logging level */
454 
455  /* convenience */
459 
462 
463  /* pat (port address translation)
464  * dynamic mapping enabled or conneciton tracking */
466 
467  /* number of worker handoff frame queue elements */
469 
470  /* nat44 plugin enabled */
472 
474 
479 
482 
484 
486 
488 
489 /**
490  * @brief Delete specific NAT44 EI user and his sessions
491  *
492  * @param addr IPv4 address
493  * @param fib_index FIB table index
494  */
495 int nat44_ei_user_del (ip4_address_t *addr, u32 fib_index);
496 
497 /**
498  * @brief Delete session for static mapping
499  *
500  * @param addr IPv4 address
501  * @param fib_index FIB table index
502  */
505  nat44_ei_user_key_t u_key, int addr_only, ip4_address_t e_addr, u16 e_port);
506 
508  u8 is_output);
509 
511  u32 rx_fib_index0, u8 is_output);
512 
513 /**
514  * @brief Set address and port assignment algorithm to default/standard
515  */
516 void nat44_ei_set_alloc_default (void);
517 
518 /**
519  * @brief Set address and port assignment algorithm for MAP-E CE
520  *
521  * @param psid Port Set Identifier value
522  * @param psid_offset number of offset bits
523  * @param psid_length length of PSID
524  */
525 void nat44_ei_set_alloc_mape (u16 psid, u16 psid_offset, u16 psid_length);
526 
527 /**
528  * @brief Set address and port assignment algorithm for port range
529  *
530  * @param start_port beginning of the port range
531  * @param end_port end of the port range
532  */
534 
535 /**
536  * @brief Add/delete NAT44-EI static mapping
537  *
538  * @param l_addr local IPv4 address
539  * @param e_addr external IPv4 address
540  * @param l_port local port number
541  * @param e_port external port number
542  * @param proto L4 protocol
543  * @param sw_if_index use interface address as external IPv4 address
544  * @param vrf_id local VRF ID
545  * @param addr_only 1 = 1:1NAT, 0 = 1:1NAPT
546  * @param identity_nat identity NAT
547  * @param tag opaque string tag
548  * @param is_add 1 = add, 0 = delete
549  *
550  * @return 0 on success, non-zero value otherwise
551 
552  */
554  ip4_address_t e_addr, u16 l_port,
555  u16 e_port, nat_protocol_t proto,
556  u32 sw_if_index, u32 vrf_id, u8 addr_only,
557  u8 identity_nat, u8 *tag, u8 is_add);
558 
559 /**
560  * @brief Delete NAT44-EI session
561  *
562  * @param addr IPv4 address
563  * @param port L4 port number
564  * @param proto L4 protocol
565  * @param vrf_id VRF ID
566  * @param is_in 1 = inside network address and port pair, 0 = outside
567  *
568  * @return 0 on success, non-zero value otherwise
569  */
571  nat_protocol_t proto, u32 vrf_id, int is_in);
572 
573 /**
574  * @brief Match NAT44-EI static mapping.
575  *
576  * @param key address and port to match
577  * @param addr external/local address of the matched mapping
578  * @param port port of the matched mapping
579  * @param fib_index fib index of the matched mapping
580  * @param by_external if 0 match by local address otherwise match by
581  * external address
582  * @param is_addr_only 1 if matched mapping is address only
583  * @param is_identity_nat 1 if indentity mapping
584  *
585  * @returns 0 if match found otherwise 1.
586  */
587 int nat44_ei_static_mapping_match (ip4_address_t match_addr, u16 match_port,
588  u32 match_fib_index,
589  nat_protocol_t match_protocol,
590  ip4_address_t *mapping_addr,
591  u16 *mapping_port, u32 *mapping_fib_index,
592  u8 by_external, u8 *is_addr_only,
593  u8 *is_identity_nat);
594 
595 /**
596  * @brief Clear all active NAT44-EI sessions.
597  */
599 
602  u32 fib_index, u32 thread_index);
603 
605  nat44_ei_user_t *u,
607  f64 now);
608 
609 void nat44_ei_free_session_data_v2 (nat44_ei_main_t *nm, nat44_ei_session_t *s,
610  u32 thread_index, u8 is_ha);
611 
616 
621 
623  u8 delete_sm);
624 
625 void nat44_ei_free_session_data (nat44_ei_main_t *nm, nat44_ei_session_t *s,
626  u32 thread_index, u8 is_ha);
627 
628 int nat44_ei_set_workers (uword *bitmap);
629 
631 
633  u32 vrf_id);
634 
635 void nat44_ei_delete_session (nat44_ei_main_t *nm, nat44_ei_session_t *ses,
636  u32 thread_index);
637 
638 int nat44_ei_interface_add_del (u32 sw_if_index, u8 is_inside, int is_del);
639 
641  int is_del);
642 
644  int is_del);
645 
646 /* Call back functions for clib_bihash_add_or_overwrite_stale */
649 
652  vlib_buffer_t *b0, ip4_header_t *ip0,
653  udp_header_t *udp0, tcp_header_t *tcp0, u32 proto0,
654  int do_trace, u32 *required_thread_index);
655 
657  vlib_buffer_t *b,
658  ip4_header_t *ip);
659 
662  icmp46_header_t *icmp0,
663  u32 *required_thread_index);
664 
665 int nat44_ei_set_frame_queue_nelts (u32 frame_queue_nelts);
666 
667 #define nat44_ei_is_session_static(sp) \
668  (sp->flags & NAT44_EI_SESSION_FLAG_STATIC_MAPPING)
669 #define nat44_ei_is_unk_proto_session(sp) \
670  (sp->flags & NAT44_EI_SESSION_FLAG_UNKNOWN_PROTO)
671 
672 #define nat44_ei_interface_is_inside(ip) \
673  (ip->flags & NAT44_EI_INTERFACE_FLAG_IS_INSIDE)
674 #define nat44_ei_interface_is_outside(ip) \
675  (ip->flags & NAT44_EI_INTERFACE_FLAG_IS_OUTSIDE)
676 
677 #define nat44_ei_is_addr_only_static_mapping(mp) \
678  (mp->flags & NAT44_EI_STATIC_MAPPING_FLAG_ADDR_ONLY)
679 #define nat44_ei_is_identity_static_mapping(mp) \
680  (mp->flags & NAT44_EI_STATIC_MAPPING_FLAG_IDENTITY_NAT)
681 
682 /* logging */
683 #define nat44_ei_log_err(...) \
684  vlib_log (VLIB_LOG_LEVEL_ERR, nat44_ei_main.log_class, __VA_ARGS__)
685 #define nat44_ei_log_warn(...) \
686  vlib_log (VLIB_LOG_LEVEL_WARNING, nat44_ei_main.log_class, __VA_ARGS__)
687 #define nat44_ei_log_notice(...) \
688  vlib_log (VLIB_LOG_LEVEL_NOTICE, nat44_ei_main.log_class, __VA_ARGS__)
689 #define nat44_ei_log_info(...) \
690  vlib_log (VLIB_LOG_LEVEL_INFO, nat44_ei_main.log_class, __VA_ARGS__)
691 #define nat44_ei_log_debug(...) \
692  vlib_log (VLIB_LOG_LEVEL_DEBUG, nat44_ei_main.log_class, __VA_ARGS__)
693 
694 #endif /* __included_nat44_ei_h__ */
695 /*
696  * fd.io coding-style-patch-verification: ON
697  *
698  * Local Variables:
699  * eval: (c-set-style "gnu")
700  * End:
701  */
nat44_ei_icmp_hairpinning
u32 nat44_ei_icmp_hairpinning(nat44_ei_main_t *nm, vlib_buffer_t *b0, u32 thread_index, ip4_header_t *ip0, icmp46_header_t *icmp0, u32 *required_thread_index)
Definition: nat44_ei_hairpinning.c:251
fib_source.h
nat44_ei_main_s::timeouts
nat_timeouts_t timeouts
Definition: nat44_ei.h:406
lib.h
NAT port/address allocation lib.
nat44_ei_fib_t::fib_index
u32 fib_index
Definition: nat44_ei.h:197
tnm
nat44_ei_main_per_thread_data_t * tnm
Definition: nat44_ei_out2in.c:712
nat44_ei_main_s::psid_offset
u8 psid_offset
Definition: nat44_ei.h:376
nat44_ei_hairpinning
int nat44_ei_hairpinning(vlib_main_t *vm, vlib_node_runtime_t *node, nat44_ei_main_t *nm, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, udp_header_t *udp0, tcp_header_t *tcp0, u32 proto0, int do_trace, u32 *required_thread_index)
Definition: nat44_ei_hairpinning.c:124
nat44_ei_static_mapping_t::flags
u32 flags
Definition: nat44_ei.h:186
nat44_ei_main_s::rconfig
nat44_ei_config_t rconfig
Definition: nat44_ei.h:473
nat44_ei_main_s::fq_in2out_output_index
u32 fq_in2out_output_index
Definition: nat44_ei.h:400
nat44_ei_free_session_data
void nat44_ei_free_session_data(nat44_ei_main_t *nm, nat44_ei_session_t *s, u32 thread_index, u8 is_ha)
Definition: nat44_ei.c:1252
nat44_ei_main_per_thread_data_t::udp_lru_head_index
u32 udp_lru_head_index
Definition: nat44_ei.h:293
thread_index
u32 thread_index
Definition: nat44_ei_hairpinning.c:495
nat44_ei_address_t
Definition: nat44_ei.h:68
dst_port
vl_api_ip_port_and_mask_t dst_port
Definition: flow_types.api:92
nat44_ei_outside_fib_t::refcount
u32 refcount
Definition: nat44_ei.h:204
bihash_8_8.h
nat44_ei_user_key_t::fib_index
u32 fib_index
Definition: nat44_ei.h:106
nat44_ei_static_mapping_t::external_port
u16 external_port
Definition: nat44_ei.h:173
nat44_ei_lb_addr_port_t::probability
u8 probability
Definition: nat44_ei.h:155
nat44_ei_user_key_t::addr
ip4_address_t addr
Definition: nat44_ei.h:105
nat44_ei_main_s::user_buckets
u32 user_buckets
Definition: nat44_ei.h:321
nat44_ei_main_s::static_mappings
nat44_ei_static_mapping_t * static_mappings
Definition: nat44_ei.h:337
nat44_ei_api_hookup
clib_error_t * nat44_ei_api_hookup(vlib_main_t *vm)
Definition: nat44_ei_api.c:1188
nat44_ei_main_s::end_port
u16 end_port
Definition: nat44_ei.h:381
nat44_ei_main_per_thread_data_t::thread_index
u32 thread_index
Definition: nat44_ei.h:301
nat44_o2i_is_idle_session_cb
int nat44_o2i_is_idle_session_cb(clib_bihash_kv_8_8_t *kv, void *arg)
Definition: nat44_ei_out2in.c:103
vlib_log_class_t
u32 vlib_log_class_t
Definition: vlib.h:52
nat44_ei_sessions_clear
void nat44_ei_sessions_clear()
Clear all active NAT44-EI sessions.
Definition: nat44_ei.c:2478
nat44_ei_main_s::pat
u8 pat
Definition: nat44_ei.h:465
nat44_ei_interface_add_del_output_feature
int nat44_ei_interface_add_del_output_feature(u32 sw_if_index, u8 is_inside, int is_del)
Definition: nat44_ei.c:747
tcp_header_t
struct _tcp_header tcp_header_t
nat44_ei_main_s::interfaces
nat44_ei_interface_t * interfaces
Definition: nat44_ei.h:340
nat_timeouts_t
Definition: lib.h:76
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
nat_protocol_t
nat_protocol_t
Definition: lib.h:63
nat44_ei_main_s::out2in_node_index
u32 out2in_node_index
Definition: nat44_ei.h:396
nat44_ei_lb_addr_port_t::addr
ip4_address_t addr
Definition: nat44_ei.h:151
dlist.h
nat44_ei_static_mapping_t::fib_index
u32 fib_index
Definition: nat44_ei.h:176
nat44_ei_main_per_thread_data_t::snat_thread_index
u32 snat_thread_index
Definition: nat44_ei.h:298
nat44_ei_addr_and_port_alloc_alg_t
nat44_ei_addr_and_port_alloc_alg_t
Definition: nat44_ei.h:49
nat44_ei_main_s::fq_out2in_index
u32 fq_out2in_index
Definition: nat44_ei.h:401
nat44_ei_static_mapping_t::workers
u32 * workers
Definition: nat44_ei.h:180
u16
unsigned short u16
Definition: types.h:57
nat44_ei_set_frame_queue_nelts
int nat44_ei_set_frame_queue_nelts(u32 frame_queue_nelts)
Definition: nat44_ei.c:2874
nat44_ei_main_s::psid_length
u8 psid_length
Definition: nat44_ei.h:377
nat44_ei_interface_t
Definition: nat44_ei.h:189
nat44_ei_static_mapping_t::tag
u8 * tag
Definition: nat44_ei.h:182
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
nat44_ei_main_s::hairpin_dst_fq_index
u32 hairpin_dst_fq_index
Definition: nat44_ei.h:478
api.h
nat44_ei_main_per_thread_data_t::list_pool
dlist_elt_t * list_pool
Definition: nat44_ei.h:287
state
vl_api_dhcp_client_state_t state
Definition: dhcp.api:201
nat44_ei_fib_t::ref_count
u32 ref_count
Definition: nat44_ei.h:198
port
u16 port
Definition: lb_types.api:73
nat44_ei_lb_addr_port_t
Definition: nat44_ei.h:148
nat44_ei_main_s::addr_and_port_alloc_alg
nat44_ei_addr_and_port_alloc_alg_t addr_and_port_alloc_alg
Definition: nat44_ei.h:374
nat44_ei_main_s::addresses
nat44_ei_address_t * addresses
Definition: nat44_ei.h:370
nat44_ei_main_s::counters
struct nat44_ei_main_s::@81 counters
addr
vhost_vring_addr_t addr
Definition: vhost_user.h:130
nat44_ei_main_s::max_translations_per_thread
u32 max_translations_per_thread
Definition: nat44_ei.h:347
udp_header_t
Definition: udp_packet.h:45
ip4_header_t
Definition: ip4_packet.h:87
ethernet.h
nat44_ei_alloc_out_addr_and_port_function_t
int() nat44_ei_alloc_out_addr_and_port_function_t(nat44_ei_address_t *addresses, u32 fib_index, u32 thread_index, nat_protocol_t proto, ip4_address_t s_addr, ip4_address_t *addr, u16 *port, u16 port_per_thread, u32 snat_thread_index)
Definition: nat44_ei.h:83
nat44_i2o_is_idle_session_cb
int nat44_i2o_is_idle_session_cb(clib_bihash_kv_8_8_t *kv, void *arg)
Definition: nat44_ei_in2out.c:250
nat44_ei_config_t::sessions
u32 sessions
Definition: nat44_ei.h:117
nat44_ei_main_per_thread_data_t::sessions
nat44_ei_session_t * sessions
Definition: nat44_ei.h:284
nat44_ei_main_s
Definition: nat44_ei.h:317
icmp_echo_header_t::sequence
u16 sequence
Definition: nat44_ei.h:91
nat44_ei_main_s::inside_vrf_id
u32 inside_vrf_id
Definition: nat44_ei.h:350
nat44_ei_main_per_thread_data_t::tcp_trans_lru_head_index
u32 tcp_trans_lru_head_index
Definition: nat44_ei.h:291
foreach_nat_protocol
@ foreach_nat_protocol
Definition: lib.h:66
nat44_ei_interface_t::flags
u8 flags
Definition: nat44_ei.h:192
nat44_ei_main_s::random_seed
u32 random_seed
Definition: nat44_ei.h:404
nat44_ei_main_s::inside_fib_index
u32 inside_fib_index
Definition: nat44_ei.h:351
hash.h
nat44_ei_add_del_static_mapping
int nat44_ei_add_del_static_mapping(ip4_address_t l_addr, ip4_address_t e_addr, u16 l_port, u16 e_port, nat_protocol_t proto, u32 sw_if_index, u32 vrf_id, u8 addr_only, u8 identity_nat, u8 *tag, u8 is_add)
Add/delete NAT44-EI static mapping.
Definition: nat44_ei.c:1853
start_port
u16 start_port
Definition: ikev2_types.api:35
nat44_ei_main_s::fq_in2out_index
u32 fq_in2out_index
Definition: nat44_ei.h:399
nat44_ei_config_t::out2in_dpo
u8 out2in_dpo
Definition: nat44_ei.h:124
nat44_ei_main_s::fibs
nat44_ei_fib_t * fibs
Definition: nat44_ei.h:384
nat44_ei_config_t::user_sessions
u32 user_sessions
Definition: nat44_ei.h:119
nat44_ei_main_s::to_resolve
nat44_ei_static_map_resolve_t * to_resolve
Definition: nat44_ei.h:393
error.h
nat44_ei_main_s::enabled
u8 enabled
Definition: nat44_ei.h:471
nat44_ei_hairpinning_sm_unknown_proto
void nat44_ei_hairpinning_sm_unknown_proto(nat44_ei_main_t *nm, vlib_buffer_t *b, ip4_header_t *ip)
Definition: nat44_ei_hairpinning.c:97
nat44_ei_main_s::hairpinning
vlib_simple_counter_main_t hairpinning
Definition: nat44_ei.h:443
nat44_ei_lb_addr_port_t::fib_index
u32 fib_index
Definition: nat44_ei.h:159
tcp_udp_header_t::src_port
u16 src_port
Definition: nat44_ei.h:96
nat44_ei_user_key_t
Definition: nat44_ei.h:99
nat44_ei_main_s::static_mapping_only
u8 static_mapping_only
Definition: nat44_ei.h:325
nat44_ei_static_map_resolve_t::proto
nat_protocol_t proto
Definition: nat44_ei.h:140
nat44_ei_plugin_enable
int nat44_ei_plugin_enable(nat44_ei_config_t c)
Definition: nat44_ei.c:419
nat44_ei_main_s::fastpath
struct nat44_ei_main_s::@81::@82 fastpath
c
svmdb_client_t * c
Definition: vpp_get_metrics.c:48
log.h
nat44_ei_main
nat44_ei_main_t nat44_ei_main
Definition: nat44_ei.c:40
nat44_ei_main_per_thread_data_t::unk_proto_lru_head_index
u32 unk_proto_lru_head_index
Definition: nat44_ei.h:295
nat44_ei_config_t::users
u32 users
Definition: nat44_ei.h:115
nat44_ei_set_alloc_default
void nat44_ei_set_alloc_default(void)
Set address and port assignment algorithm to default/standard.
Definition: nat44_ei.c:1697
nat44_ei_main_s::max_translations_per_user
u32 max_translations_per_user
Definition: nat44_ei.h:348
nat44_ei_interface_add_del
int nat44_ei_interface_add_del(u32 sw_if_index, u8 is_inside, int is_del)
Definition: nat44_ei.c:496
nat44_ei_user_get_or_create
nat44_ei_user_t * nat44_ei_user_get_or_create(nat44_ei_main_t *nm, ip4_address_t *addr, u32 fib_index, u32 thread_index)
Definition: nat44_ei.c:1121
nat44_ei_main_s::log_class
vlib_log_class_t log_class
Definition: nat44_ei.h:451
nat44_ei_main_s::translation_buckets
u32 translation_buckets
Definition: nat44_ei.h:320
nat44_ei_static_map_resolve_t::tag
u8 * tag
Definition: nat44_ei.h:144
uword
u64 uword
Definition: types.h:112
tcp_udp_header_t
Definition: nat44_ei.h:94
nat44_ei_main_s::outside_fib_index
u32 outside_fib_index
Definition: nat44_ei.h:354
nat44_ei_free_session_data_v2
void nat44_ei_free_session_data_v2(nat44_ei_main_t *nm, nat44_ei_session_t *s, u32 thread_index, u8 is_ha)
Definition: nat44_ei.c:1079
nat44_ei_static_mapping_del_sessions
void nat44_ei_static_mapping_del_sessions(nat44_ei_main_t *nm, nat44_ei_main_per_thread_data_t *tnm, nat44_ei_user_key_t u_key, int addr_only, ip4_address_t e_addr, u16 e_port)
Delete session for static mapping.
Definition: nat44_ei.c:1356
nat44_ei_main_s::in2out_hairpinning_finish_interface_output_node_fq_index
u32 in2out_hairpinning_finish_interface_output_node_fq_index
Definition: nat44_ei.h:476
nat44_ei_main_s::vnet_main
vnet_main_t * vnet_main
Definition: nat44_ei.h:480
CLIB_PACKED
typedef CLIB_PACKED(struct { struct { ip4_address_t addr;u32 fib_index;u16 port;} out2in;struct { ip4_address_t addr;u32 fib_index;u16 port;} in2out;nat_protocol_t nat_proto;u32 flags;u32 per_user_index;u32 per_user_list_head_index;u32 lru_head_index;u32 lru_index;f64 last_lru_update;f64 last_heard;f64 ha_last_refreshed;u64 total_bytes;u32 total_pkts;ip4_address_t ext_host_addr;u16 ext_host_port;ip4_address_t ext_host_nat_addr;u16 ext_host_nat_port;u8 state;u32 i2o_fin_seq;u32 o2i_fin_seq;u64 tcp_closed_timestamp;u32 user_index;}) nat44_ei_session_t
nat44_ei_static_map_resolve_t::pool_addr
ip4_address_t pool_addr
Definition: nat44_ei.h:134
nat44_ei_config_t::static_mapping_only
u8 static_mapping_only
Definition: nat44_ei.h:122
nat44_ei_main_s::workers
u32 * workers
Definition: nat44_ei.h:359
f64
double f64
Definition: types.h:142
nat44_ei_main_s::per_thread_data
nat44_ei_main_per_thread_data_t * per_thread_data
Definition: nat44_ei.h:367
icmp_echo_header_t::identifier
u16 identifier
Definition: nat44_ei.h:90
dlist_elt_t
Definition: dlist.h:28
nat44_ei_free_outside_address_and_port
void nat44_ei_free_outside_address_and_port(nat44_ei_address_t *addresses, u32 thread_index, ip4_address_t *addr, u16 port, nat_protocol_t protocol)
Definition: nat44_ei.c:1043
nat44_ei_static_mapping_t
Definition: nat44_ei.h:162
nat44_ei_static_mapping_match
int nat44_ei_static_mapping_match(ip4_address_t match_addr, u16 match_port, u32 match_fib_index, nat_protocol_t match_protocol, ip4_address_t *mapping_addr, u16 *mapping_port, u32 *mapping_fib_index, u8 by_external, u8 *is_addr_only, u8 *is_identity_nat)
Match NAT44-EI static mapping.
Definition: nat44_ei.c:2253
nat44_ei_main_s::max_users_per_thread
u32 max_users_per_thread
Definition: nat44_ei.h:346
ip4_address_t
Definition: ip4_packet.h:50
nat44_ei_static_mapping_t::external_addr
ip4_address_t external_addr
Definition: nat44_ei.h:169
nat44_ei_main_s::static_mapping_by_external
clib_bihash_8_8_t static_mapping_by_external
Definition: nat44_ei.h:334
inlines.h
nat44_ei_runtime_t
Definition: nat44_ei.h:305
nat44_ei_main_s::msg_id_base
u16 msg_id_base
Definition: nat44_ei.h:448
nat44_ei_static_map_resolve_t::flags
u32 flags
Definition: nat44_ei.h:139
nat44_ei_address_t::addr
ip4_address_t addr
Definition: nat44_ei.h:70
nat44_ei_static_mapping_t::pool_addr
ip4_address_t pool_addr
Definition: nat44_ei.h:165
nat44_ei_main_s::fib_src_hi
fib_source_t fib_src_hi
Definition: nat44_ei.h:460
nat44_ei_main_per_thread_data_t::icmp_lru_head_index
u32 icmp_lru_head_index
Definition: nat44_ei.h:294
nat44_ei_config_t
Definition: nat44_ei.h:112
nat44_ei_main_s::output_feature_interfaces
nat44_ei_interface_t * output_feature_interfaces
Definition: nat44_ei.h:341
nat44_ei_main_s::alloc_addr_and_port
nat44_ei_alloc_out_addr_and_port_function_t * alloc_addr_and_port
Definition: nat44_ei.h:372
nat44_ei_del_session
int nat44_ei_del_session(nat44_ei_main_t *nm, ip4_address_t *addr, u16 port, nat_protocol_t proto, u32 vrf_id, int is_in)
Delete NAT44-EI session.
Definition: nat44_ei.c:1785
nat44_ei_add_del_address_dpo
void nat44_ei_add_del_address_dpo(ip4_address_t addr, u8 is_add)
Definition: nat44_ei.c:1019
nat44_ei_main_s::outside_vrf_id
u32 outside_vrf_id
Definition: nat44_ei.h:353
nat44_ei_main_s::foreach_nat_counter
foreach_nat_counter
Definition: nat44_ei.h:420
api_main_t
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:228
nat44_ei_static_mapping_t::local_addr
ip4_address_t local_addr
Definition: nat44_ei.h:167
nat44_ei_plugin_disable
int nat44_ei_plugin_disable()
Definition: nat44_ei.c:920
foreach_nat44_ei_addr_and_port_alloc_alg
#define foreach_nat44_ei_addr_and_port_alloc_alg
Definition: nat44_ei.h:44
nat44_ei_is_idle_session_ctx_t::thread_index
u32 thread_index
Definition: nat44_ei.h:313
nat44_ei_session_alloc_or_recycle
nat44_ei_session_t * nat44_ei_session_alloc_or_recycle(nat44_ei_main_t *nm, nat44_ei_user_t *u, u32 thread_index, f64 now)
Definition: nat44_ei.c:1180
nat44_ei_address_t::fib_index
u32 fib_index
Definition: nat44_ei.h:71
nat44_ei_static_map_resolve_t::e_port
u16 e_port
Definition: nat44_ei.h:136
nat44_ei_main_s::hairpinning_fq_index
u32 hairpinning_fq_index
Definition: nat44_ei.h:477
vnet_main_t
Definition: vnet.h:76
nat44_ei_main_s::first_worker_index
u32 first_worker_index
Definition: nat44_ei.h:358
nat44_ei_set_outside_address_and_port
int nat44_ei_set_outside_address_and_port(nat44_ei_address_t *addresses, u32 thread_index, ip4_address_t addr, u16 port, nat_protocol_t protocol)
Definition: nat44_ei.c:983
nat44_ei_config_t::connection_tracking
u8 connection_tracking
Definition: nat44_ei.h:123
nat44_ei_main_per_thread_data_t::user_hash
clib_bihash_8_8_t user_hash
Definition: nat44_ei.h:278
nat44_ei_outside_fib_t::fib_index
u32 fib_index
Definition: nat44_ei.h:203
nat44_ei_user_key_t::as_u64
u64 as_u64
Definition: nat44_ei.h:108
nat44_ei_user_del
int nat44_ei_user_del(ip4_address_t *addr, u32 fib_index)
Delete specific NAT44 EI user and his sessions.
Definition: nat44_ei.c:1314
nat44_ei_main_s::static_mapping_by_local
clib_bihash_8_8_t static_mapping_by_local
Definition: nat44_ei.h:331
u64
unsigned long u64
Definition: types.h:89
nat44_ei_main_per_thread_data_t::users
nat44_ei_user_t * users
Definition: nat44_ei.h:281
nat44_ei_main_s::in2out_node_index
u32 in2out_node_index
Definition: nat44_ei.h:395
nat44_ei_outside_fib_t
Definition: nat44_ei.h:201
end_port
u16 end_port
Definition: ikev2_types.api:36
nat44_ei_main_s::frame_queue_nelts
u32 frame_queue_nelts
Definition: nat44_ei.h:468
nat44_ei_main_s::translations
u32 translations
Definition: nat44_ei.h:319
ip.h
nat44_ei_del_address
int nat44_ei_del_address(nat44_ei_main_t *nm, ip4_address_t addr, u8 delete_sm)
Definition: nat44_ei.c:2708
u32
unsigned int u32
Definition: types.h:88
nat44_ei_main_s::static_mapping_connection_tracking
u8 static_mapping_connection_tracking
Definition: nat44_ei.h:326
nat44_ei_delete_session
void nat44_ei_delete_session(nat44_ei_main_t *nm, nat44_ei_session_t *ses, u32 thread_index)
Definition: nat44_ei.c:1753
protocol
vl_api_ip_proto_t protocol
Definition: lb_types.api:72
nat44_ei_main_s::start_port
u16 start_port
Definition: nat44_ei.h:380
nat44_ei_get_out2in_worker_index
u32 nat44_ei_get_out2in_worker_index(vlib_buffer_t *b, ip4_header_t *ip0, u32 rx_fib_index0, u8 is_output)
Definition: nat44_ei.c:1428
nat44_ei_interface_t::sw_if_index
u32 sw_if_index
Definition: nat44_ei.h:191
nat44_ei_main_s::user_limit_reached
vlib_simple_counter_main_t user_limit_reached
Definition: nat44_ei.h:411
clib_bihash_kv_8_8_t
8 octet key, 8 octet key value pair
Definition: bihash_8_8.h:41
nat44_ei_config_t::outside_vrf
u32 outside_vrf
Definition: nat44_ei.h:127
nat44_ei_main_s::in2out
clib_bihash_8_8_t in2out
Definition: nat44_ei.h:364
nat44_ei_static_mapping_t::proto
nat_protocol_t proto
Definition: nat44_ei.h:178
nat44_ei_static_mapping_t::vrf_id
u32 vrf_id
Definition: nat44_ei.h:175
nm
nat44_ei_main_t * nm
Definition: nat44_ei_hairpinning.c:413
nat44_ei_runtime_t::cached_presence_by_ip4_address
uword * cached_presence_by_ip4_address
Definition: nat44_ei.h:308
nat44_ei_main_s::fib_src_low
fib_source_t fib_src_low
Definition: nat44_ei.h:461
nat44_ei_set_alloc_mape
void nat44_ei_set_alloc_mape(u16 psid, u16 psid_offset, u16 psid_length)
Set address and port assignment algorithm for MAP-E CE.
Definition: nat44_ei.c:1717
icmp_echo_header_t
Definition: nat44_ei.h:88
ip_lookup_main_t
Definition: lookup.h:121
now
f64 now
Definition: nat44_ei_out2in.c:710
nat44_ei_fib_t
Definition: nat44_ei.h:195
nat44_ei_lb_addr_port_t::prefix
u8 prefix
Definition: nat44_ei.h:156
vlib_main_t
Definition: main.h:102
nat44_ei_main_s::out2in_dpo
u8 out2in_dpo
Definition: nat44_ei.h:323
vlib_simple_counter_main_t
A collection of simple counters.
Definition: counter.h:57
nat44_ei_is_idle_session_ctx_t::now
f64 now
Definition: nat44_ei.h:314
b
vlib_buffer_t ** b
Definition: nat44_ei_out2in.c:717
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
nat44_ei_main_s::in2out_hairpinning_finish_ip4_lookup_node_fq_index
u32 in2out_hairpinning_finish_ip4_lookup_node_fq_index
Definition: nat44_ei.h:475
nat44_ei_runtime_t::cached_sw_if_index
u32 cached_sw_if_index
Definition: nat44_ei.h:307
nat44_ei_main_s::ip4_main
ip4_main_t * ip4_main
Definition: nat44_ei.h:457
ip
vl_api_address_t ip
Definition: l2.api:558
nat44_ei_main_s::in2out_output_node_index
u32 in2out_output_node_index
Definition: nat44_ei.h:397
icmp46_packet.h
nat44_ei_main_s::log_level
u8 log_level
Definition: nat44_ei.h:453
nat44_ei_main_s::slowpath
struct nat44_ei_main_s::@81::@83 slowpath
nat44_ei_main_s::out2in
clib_bihash_8_8_t out2in
Definition: nat44_ei.h:363
nat44_ei_main_t
struct nat44_ei_main_s nat44_ei_main_t
nat44_ei_lb_addr_port_t::port
u16 port
Definition: nat44_ei.h:153
nat44_ei_static_map_resolve_t
Definition: nat44_ei.h:131
nat44_ei_main_s::total_users
vlib_simple_counter_main_t total_users
Definition: nat44_ei.h:409
nat44_ei_main_s::psid
u16 psid
Definition: nat44_ei.h:378
fib_source_t
enum fib_source_t_ fib_source_t
The different sources that can create a route.
nat44_ei_static_map_resolve_t::l_port
u16 l_port
Definition: nat44_ei.h:135
nat44_ei_static_map_resolve_t::identity_nat
u8 identity_nat
Definition: nat44_ei.h:142
nat44_ei_main_s::auto_add_sw_if_indices
u32 * auto_add_sw_if_indices
Definition: nat44_ei.h:390
nat44_ei_main_per_thread_data_t::lru_pool
dlist_elt_t * lru_pool
Definition: nat44_ei.h:290
vrf_id
u32 vrf_id
Definition: nat44_ed.api:1053
nat44_ei_main_s::translation_memory_size_set
u8 translation_memory_size_set
Definition: nat44_ei.h:344
nat44_ei_config_t::inside_vrf
u32 inside_vrf
Definition: nat44_ei.h:126
vnet.h
api_errno.h
nat44_ei_main_s::mss_clamping
u16 mss_clamping
Definition: nat44_ei.h:328
nat44_ei_static_map_resolve_t::addr_only
u8 addr_only
Definition: nat44_ei.h:141
nat44_ei_main_s::ip4_lookup_main
ip_lookup_main_t * ip4_lookup_main
Definition: nat44_ei.h:458
nat44_ei_main_s::forwarding_enabled
u8 forwarding_enabled
Definition: nat44_ei.h:324
vlib_node_runtime_t
Definition: node.h:454
nat44_ei_main_per_thread_data_t::tcp_estab_lru_head_index
u32 tcp_estab_lru_head_index
Definition: nat44_ei.h:292
proto
vl_api_ip_proto_t proto
Definition: acl_types.api:51
nat44_ei_lb_addr_port_t::vrf_id
u32 vrf_id
Definition: nat44_ei.h:158
nat44_ei_main_s::total_sessions
vlib_simple_counter_main_t total_sessions
Definition: nat44_ei.h:410
nat44_ei_add_interface_address
int nat44_ei_add_interface_address(nat44_ei_main_t *nm, u32 sw_if_index, int is_del)
Definition: nat44_ei.c:2632
ip4_main_t
IPv4 main type.
Definition: ip4.h:107
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
nat44_ei_main_s::port_per_thread
u16 port_per_thread
Definition: nat44_ei.h:360
nat44_ei_static_map_resolve_t::vrf_id
u32 vrf_id
Definition: nat44_ei.h:138
nat44_ei_static_mapping_t::local_port
u16 local_port
Definition: nat44_ei.h:171
nat44_ei_static_map_resolve_t::sw_if_index
u32 sw_if_index
Definition: nat44_ei.h:137
nat44_ei_main_s::num_workers
u32 num_workers
Definition: nat44_ei.h:357
nat44_ei_main_s::outside_fibs
nat44_ei_outside_fib_t * outside_fibs
Definition: nat44_ei.h:387
nat44_ei_set_alloc_range
void nat44_ei_set_alloc_range(u16 start_port, u16 end_port)
Set address and port assignment algorithm for port range.
Definition: nat44_ei.c:1706
nat44_ei_get_in2out_worker_index
u32 nat44_ei_get_in2out_worker_index(ip4_header_t *ip0, u32 rx_fib_index0, u8 is_output)
Definition: nat44_ei.c:1408
nat44_ei_static_map_resolve_t::exact
u8 exact
Definition: nat44_ei.h:143
nat44_ei_main_s::api_main
api_main_t * api_main
Definition: nat44_ei.h:456
nat44_ei_static_map_resolve_t::l_addr
ip4_address_t l_addr
Definition: nat44_ei.h:133
nat44_ei_set_workers
int nat44_ei_set_workers(uword *bitmap)
Definition: nat44_ei.c:252
nat44_ei_static_mapping_t::locals
nat44_ei_lb_addr_port_t * locals
Definition: nat44_ei.h:184
nat44_ei_is_idle_session_ctx_t
Definition: nat44_ei.h:311
nat44_ei_main_per_thread_data_t
Definition: nat44_ei.h:275
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
nat44_ei_add_address
int nat44_ei_add_address(nat44_ei_main_t *nm, ip4_address_t *addr, u32 vrf_id)
Definition: nat44_ei.c:2575
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105