FD.io VPP  v21.06-3-gbb25fbf28
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 
36 #include <nat/lib/lib.h>
37 #include <nat/lib/inlines.h>
38 
39 /* default number of worker handoff frame queue elements */
40 #define NAT_FQ_NELTS_DEFAULT 64
41 
42 /* External address and port allocation modes */
43 #define foreach_nat44_ei_addr_and_port_alloc_alg \
44  _ (0, DEFAULT, "default") \
45  _ (1, MAPE, "map-e") \
46  _ (2, RANGE, "port-range")
47 
48 typedef enum
49 {
50 #define _(v, N, s) NAT44_EI_ADDR_AND_PORT_ALLOC_ALG_##N = v,
52 #undef _
54 
55 /* Interface flags */
56 #define NAT44_EI_INTERFACE_FLAG_IS_INSIDE (1 << 0)
57 #define NAT44_EI_INTERFACE_FLAG_IS_OUTSIDE (1 << 1)
58 
59 /* Session flags */
60 #define NAT44_EI_SESSION_FLAG_STATIC_MAPPING (1 << 0)
61 #define NAT44_EI_SESSION_FLAG_UNKNOWN_PROTO (1 << 1)
62 
63 /* Static mapping flags */
64 #define NAT44_EI_STATIC_MAPPING_FLAG_ADDR_ONLY (1 << 0)
65 #define NAT44_EI_STATIC_MAPPING_FLAG_IDENTITY_NAT (1 << 1)
66 
67 typedef struct
68 {
71 #define _(N, i, n, s) \
72  u32 busy_##n##_ports; \
73  u32 *busy_##n##_ports_per_thread; \
74  u32 busy_##n##_port_refcounts[0xffff + 1];
76 #undef _
78 
80 
81 /* NAT address and port allocation function */
83  nat44_ei_address_t *addresses, u32 fib_index, u32 thread_index,
85  u16 port_per_thread, u32 snat_thread_index);
86 
87 typedef struct
88 {
92 
93 typedef struct
94 {
97 
98 typedef struct
99 {
100  union
101  {
102  struct
103  {
106  };
108  };
110 
111 typedef struct
112 {
113  /* maximum number of users */
115  /* maximum number of sessions */
117  /* maximum number of ssessions per user */
119 
120  /* plugin features */
124 
127 
129 
130 typedef struct
131 {
143  u8 *tag;
145 
146 // TODO: cleanup/redo (there is no lb in EI nat)
147 typedef struct
148 {
149  /* backend IP address */
151  /* backend port number */
153  /* probability of the backend to be randomly matched */
156  /* backend FIB table */
160 
161 typedef struct
162 {
163  /* prefered pool address */
165  /* local IP address */
167  /* external IP address */
169  /* local port */
171  /* external port */
173  /* local FIB table */
176  /* protocol */
178  /* worker threads used by backends/local host */
180  /* opaque string tag */
181  u8 *tag;
182  /* backends for load-balancing mode */
184  /* flags */
187 
188 typedef struct
189 {
193 
194 typedef struct
195 {
199 
200 typedef struct
201 {
205 
206 typedef CLIB_PACKED (struct {
207  /* Outside network tuple */
208  struct
209  {
211  u32 fib_index;
212  u16 port;
213  } out2in;
214 
215  /* Inside network tuple */
216  struct
217  {
219  u32 fib_index;
220  u16 port;
221  } in2out;
222 
223  nat_protocol_t nat_proto;
224 
225  /* Flags */
226  u32 flags;
227 
228  /* Per-user translations */
229  u32 per_user_index;
230  u32 per_user_list_head_index;
231 
232  /* head of LRU list in which this session is tracked */
233  u32 lru_head_index;
234  /* index in global LRU list */
235  u32 lru_index;
236  f64 last_lru_update;
237 
238  /* Last heard timer */
239  f64 last_heard;
240 
241  /* Last HA refresh */
242  f64 ha_last_refreshed;
243 
244  /* Counters */
245  u64 total_bytes;
246  u32 total_pkts;
247 
248  /* External host address and port */
249  ip4_address_t ext_host_addr;
250  u16 ext_host_port;
251 
252  /* External host address and port after translation */
253  ip4_address_t ext_host_nat_addr;
254  u16 ext_host_nat_port;
255 
256  /* TCP session state */
257  u8 state;
258  u32 i2o_fin_seq;
259  u32 o2i_fin_seq;
260  u64 tcp_closed_timestamp;
261 
262  /* user index */
263  u32 user_index;
264 }) nat44_ei_session_t;
265 
266 typedef CLIB_PACKED (struct {
268  u32 fib_index;
269  u32 sessions_per_user_list_head_index;
270  u32 nsessions;
271  u32 nstaticsessions;
272 }) nat44_ei_user_t;
273 
274 typedef struct
275 {
276  /* Find-a-user => src address lookup */
277  clib_bihash_8_8_t user_hash;
278 
279  /* User pool */
280  nat44_ei_user_t *users;
281 
282  /* Session pool */
283  nat44_ei_session_t *sessions;
284 
285  /* Pool of doubly-linked list elements */
287 
288  /* LRU session list - head is stale, tail is fresh */
295 
296  /* NAT thread index */
298 
299  /* real thread index */
301 
303 
304 typedef struct
305 {
309 
310 typedef struct
311 {
315 
316 typedef struct nat44_ei_main_s
317 {
321 
326 
328 
329  /* Find a static mapping by local */
330  clib_bihash_8_8_t static_mapping_by_local;
331 
332  /* Find a static mapping by external */
333  clib_bihash_8_8_t static_mapping_by_external;
334 
335  /* Static mapping pool */
337 
338  /* Interface pool */
341 
342  /* Is translation memory size calculated or user defined */
344 
348 
351 
354 
355  /* Thread settings */
360 
361  /* Main lookup tables */
362  clib_bihash_8_8_t out2in;
363  clib_bihash_8_8_t in2out;
364 
365  /* Per thread data */
367 
368  /* Vector of outside addresses */
370 
372  /* Address and port allocation type */
374  /* Port set parameters (MAP-E) */
378  /* Port range parameters */
381 
382  /* vector of fibs */
384 
385  /* vector of outside fibs */
387 
388  /* sw_if_indices whose intfc addresses should be auto-added */
390 
391  /* vector of interface address static mappings to resolve. */
393 
397 
401 
402  /* Randomize port allocation order */
404 
406 
407  /* counters */
411 
412 #define _(x) vlib_simple_counter_main_t x;
413  struct
414  {
415  struct
416  {
417  struct
418  {
420  } in2out;
421 
422  struct
423  {
425  } out2in;
426 
427  } fastpath;
428 
429  struct
430  {
431  struct
432  {
434  } in2out;
435 
436  struct
437  {
439  } out2in;
440  } slowpath;
441 
443  } counters;
444 #undef _
445 
446  /* API message ID base */
448 
449  /* log class */
451  /* logging level */
453 
454  /* convenience */
458 
461 
462  /* pat (port address translation)
463  * dynamic mapping enabled or conneciton tracking */
465 
466  /* number of worker handoff frame queue elements */
468 
469  /* nat44 plugin enabled */
471 
473 
478 
481 
483 
485 
487 
488 /**
489  * @brief Delete specific NAT44 EI user and his sessions
490  *
491  * @param addr IPv4 address
492  * @param fib_index FIB table index
493  */
494 int nat44_ei_user_del (ip4_address_t *addr, u32 fib_index);
495 
496 /**
497  * @brief Delete session for static mapping
498  *
499  * @param addr IPv4 address
500  * @param fib_index FIB table index
501  */
504  nat44_ei_user_key_t u_key, int addr_only, ip4_address_t e_addr, u16 e_port);
505 
507  u8 is_output);
508 
510  u32 rx_fib_index0, u8 is_output);
511 
512 /**
513  * @brief Set address and port assignment algorithm to default/standard
514  */
515 void nat44_ei_set_alloc_default (void);
516 
517 /**
518  * @brief Set address and port assignment algorithm for MAP-E CE
519  *
520  * @param psid Port Set Identifier value
521  * @param psid_offset number of offset bits
522  * @param psid_length length of PSID
523  */
524 void nat44_ei_set_alloc_mape (u16 psid, u16 psid_offset, u16 psid_length);
525 
526 /**
527  * @brief Set address and port assignment algorithm for port range
528  *
529  * @param start_port beginning of the port range
530  * @param end_port end of the port range
531  */
533 
534 /**
535  * @brief Add/delete NAT44-EI static mapping
536  *
537  * @param l_addr local IPv4 address
538  * @param e_addr external IPv4 address
539  * @param l_port local port number
540  * @param e_port external port number
541  * @param proto L4 protocol
542  * @param sw_if_index use interface address as external IPv4 address
543  * @param vrf_id local VRF ID
544  * @param addr_only 1 = 1:1NAT, 0 = 1:1NAPT
545  * @param identity_nat identity NAT
546  * @param tag opaque string tag
547  * @param is_add 1 = add, 0 = delete
548  *
549  * @return 0 on success, non-zero value otherwise
550 
551  */
553  ip4_address_t e_addr, u16 l_port,
554  u16 e_port, nat_protocol_t proto,
555  u32 sw_if_index, u32 vrf_id, u8 addr_only,
556  u8 identity_nat, u8 *tag, u8 is_add);
557 
558 /**
559  * @brief Delete NAT44-EI session
560  *
561  * @param addr IPv4 address
562  * @param port L4 port number
563  * @param proto L4 protocol
564  * @param vrf_id VRF ID
565  * @param is_in 1 = inside network address and port pair, 0 = outside
566  *
567  * @return 0 on success, non-zero value otherwise
568  */
570  nat_protocol_t proto, u32 vrf_id, int is_in);
571 
572 /**
573  * @brief Match NAT44-EI static mapping.
574  *
575  * @param key address and port to match
576  * @param addr external/local address of the matched mapping
577  * @param port port of the matched mapping
578  * @param fib_index fib index of the matched mapping
579  * @param by_external if 0 match by local address otherwise match by
580  * external address
581  * @param is_addr_only 1 if matched mapping is address only
582  * @param is_identity_nat 1 if indentity mapping
583  *
584  * @returns 0 if match found otherwise 1.
585  */
586 int nat44_ei_static_mapping_match (ip4_address_t match_addr, u16 match_port,
587  u32 match_fib_index,
588  nat_protocol_t match_protocol,
589  ip4_address_t *mapping_addr,
590  u16 *mapping_port, u32 *mapping_fib_index,
591  u8 by_external, u8 *is_addr_only,
592  u8 *is_identity_nat);
593 
594 /**
595  * @brief Clear all active NAT44-EI sessions.
596  */
598 
601  u32 fib_index, u32 thread_index);
602 
604  nat44_ei_user_t *u,
606  f64 now);
607 
608 void nat44_ei_free_session_data_v2 (nat44_ei_main_t *nm, nat44_ei_session_t *s,
609  u32 thread_index, u8 is_ha);
610 
615 
620 
622  u8 delete_sm);
623 
624 void nat44_ei_free_session_data (nat44_ei_main_t *nm, nat44_ei_session_t *s,
625  u32 thread_index, u8 is_ha);
626 
627 int nat44_ei_set_workers (uword *bitmap);
628 
630 
632  u32 vrf_id);
633 
634 void nat44_ei_delete_session (nat44_ei_main_t *nm, nat44_ei_session_t *ses,
635  u32 thread_index);
636 
637 int nat44_ei_interface_add_del (u32 sw_if_index, u8 is_inside, int is_del);
638 
640  int is_del);
641 
643  int is_del);
644 
645 /* Call back functions for clib_bihash_add_or_overwrite_stale */
648 
651  vlib_buffer_t *b0, ip4_header_t *ip0,
652  udp_header_t *udp0, tcp_header_t *tcp0, u32 proto0,
653  int do_trace, u32 *required_thread_index);
654 
656  vlib_buffer_t *b,
657  ip4_header_t *ip);
658 
661  icmp46_header_t *icmp0,
662  u32 *required_thread_index);
663 
664 int nat44_ei_set_frame_queue_nelts (u32 frame_queue_nelts);
665 
666 #define nat44_ei_is_session_static(sp) \
667  (sp->flags & NAT44_EI_SESSION_FLAG_STATIC_MAPPING)
668 #define nat44_ei_is_unk_proto_session(sp) \
669  (sp->flags & NAT44_EI_SESSION_FLAG_UNKNOWN_PROTO)
670 
671 #define nat44_ei_interface_is_inside(ip) \
672  (ip->flags & NAT44_EI_INTERFACE_FLAG_IS_INSIDE)
673 #define nat44_ei_interface_is_outside(ip) \
674  (ip->flags & NAT44_EI_INTERFACE_FLAG_IS_OUTSIDE)
675 
676 #define nat44_ei_is_addr_only_static_mapping(mp) \
677  (mp->flags & NAT44_EI_STATIC_MAPPING_FLAG_ADDR_ONLY)
678 #define nat44_ei_is_identity_static_mapping(mp) \
679  (mp->flags & NAT44_EI_STATIC_MAPPING_FLAG_IDENTITY_NAT)
680 
681 /* logging */
682 #define nat44_ei_log_err(...) \
683  vlib_log (VLIB_LOG_LEVEL_ERR, nat44_ei_main.log_class, __VA_ARGS__)
684 #define nat44_ei_log_warn(...) \
685  vlib_log (VLIB_LOG_LEVEL_WARNING, nat44_ei_main.log_class, __VA_ARGS__)
686 #define nat44_ei_log_notice(...) \
687  vlib_log (VLIB_LOG_LEVEL_NOTICE, nat44_ei_main.log_class, __VA_ARGS__)
688 #define nat44_ei_log_info(...) \
689  vlib_log (VLIB_LOG_LEVEL_INFO, nat44_ei_main.log_class, __VA_ARGS__)
690 #define nat44_ei_log_debug(...) \
691  vlib_log (VLIB_LOG_LEVEL_DEBUG, nat44_ei_main.log_class, __VA_ARGS__)
692 
693 #endif /* __included_nat44_ei_h__ */
694 /*
695  * fd.io coding-style-patch-verification: ON
696  *
697  * Local Variables:
698  * eval: (c-set-style "gnu")
699  * End:
700  */
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:405
lib.h
NAT port/address allocation lib.
nat44_ei_fib_t::fib_index
u32 fib_index
Definition: nat44_ei.h:196
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:375
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:185
nat44_ei_main_s::rconfig
nat44_ei_config_t rconfig
Definition: nat44_ei.h:472
nat44_ei_main_s::fq_in2out_output_index
u32 fq_in2out_output_index
Definition: nat44_ei.h:399
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:292
thread_index
u32 thread_index
Definition: nat44_ei_hairpinning.c:492
nat44_ei_address_t
Definition: nat44_ei.h:67
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:203
bihash_8_8.h
nat44_ei_user_key_t::fib_index
u32 fib_index
Definition: nat44_ei.h:105
nat44_ei_static_mapping_t::external_port
u16 external_port
Definition: nat44_ei.h:172
nat44_ei_lb_addr_port_t::probability
u8 probability
Definition: nat44_ei.h:154
nat44_ei_user_key_t::addr
ip4_address_t addr
Definition: nat44_ei.h:104
nat44_ei_main_s::user_buckets
u32 user_buckets
Definition: nat44_ei.h:320
nat44_ei_main_s::static_mappings
nat44_ei_static_mapping_t * static_mappings
Definition: nat44_ei.h:336
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:380
nat44_ei_main_per_thread_data_t::thread_index
u32 thread_index
Definition: nat44_ei.h:300
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:464
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:339
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:395
nat44_ei_lb_addr_port_t::addr
ip4_address_t addr
Definition: nat44_ei.h:150
dlist.h
nat44_ei_static_mapping_t::fib_index
u32 fib_index
Definition: nat44_ei.h:175
nat44_ei_main_per_thread_data_t::snat_thread_index
u32 snat_thread_index
Definition: nat44_ei.h:297
nat44_ei_addr_and_port_alloc_alg_t
nat44_ei_addr_and_port_alloc_alg_t
Definition: nat44_ei.h:48
nat44_ei_main_s::fq_out2in_index
u32 fq_out2in_index
Definition: nat44_ei.h:400
nat44_ei_static_mapping_t::workers
u32 * workers
Definition: nat44_ei.h:179
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:376
nat44_ei_interface_t
Definition: nat44_ei.h:188
nat44_ei_static_mapping_t::tag
u8 * tag
Definition: nat44_ei.h:181
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:477
api.h
nat44_ei_main_per_thread_data_t::list_pool
dlist_elt_t * list_pool
Definition: nat44_ei.h:286
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:197
port
u16 port
Definition: lb_types.api:73
nat44_ei_lb_addr_port_t
Definition: nat44_ei.h:147
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:373
nat44_ei_main_s::addresses
nat44_ei_address_t * addresses
Definition: nat44_ei.h:369
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:346
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:82
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:116
nat44_ei_main_per_thread_data_t::sessions
nat44_ei_session_t * sessions
Definition: nat44_ei.h:283
nat44_ei_main_s
Definition: nat44_ei.h:316
icmp_echo_header_t::sequence
u16 sequence
Definition: nat44_ei.h:90
nat44_ei_main_s::inside_vrf_id
u32 inside_vrf_id
Definition: nat44_ei.h:349
nat44_ei_main_per_thread_data_t::tcp_trans_lru_head_index
u32 tcp_trans_lru_head_index
Definition: nat44_ei.h:290
foreach_nat_protocol
@ foreach_nat_protocol
Definition: lib.h:66
nat44_ei_interface_t::flags
u8 flags
Definition: nat44_ei.h:191
nat44_ei_main_s::random_seed
u32 random_seed
Definition: nat44_ei.h:403
nat44_ei_main_s::inside_fib_index
u32 inside_fib_index
Definition: nat44_ei.h:350
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:398
nat44_ei_config_t::out2in_dpo
u8 out2in_dpo
Definition: nat44_ei.h:123
nat44_ei_main_s::fibs
nat44_ei_fib_t * fibs
Definition: nat44_ei.h:383
nat44_ei_config_t::user_sessions
u32 user_sessions
Definition: nat44_ei.h:118
nat44_ei_main_s::to_resolve
nat44_ei_static_map_resolve_t * to_resolve
Definition: nat44_ei.h:392
error.h
nat44_ei_main_s::enabled
u8 enabled
Definition: nat44_ei.h:470
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:442
nat44_ei_lb_addr_port_t::fib_index
u32 fib_index
Definition: nat44_ei.h:158
tcp_udp_header_t::src_port
u16 src_port
Definition: nat44_ei.h:95
nat44_ei_user_key_t
Definition: nat44_ei.h:98
nat44_ei_main_s::static_mapping_only
u8 static_mapping_only
Definition: nat44_ei.h:324
nat44_ei_static_map_resolve_t::proto
nat_protocol_t proto
Definition: nat44_ei.h:139
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:294
nat44_ei_config_t::users
u32 users
Definition: nat44_ei.h:114
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:347
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:450
nat44_ei_main_s::translation_buckets
u32 translation_buckets
Definition: nat44_ei.h:319
nat44_ei_static_map_resolve_t::tag
u8 * tag
Definition: nat44_ei.h:143
uword
u64 uword
Definition: types.h:112
tcp_udp_header_t
Definition: nat44_ei.h:93
nat44_ei_main_s::outside_fib_index
u32 outside_fib_index
Definition: nat44_ei.h:353
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:475
nat44_ei_main_s::vnet_main
vnet_main_t * vnet_main
Definition: nat44_ei.h:479
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:133
nat44_ei_config_t::static_mapping_only
u8 static_mapping_only
Definition: nat44_ei.h:121
nat44_ei_main_s::workers
u32 * workers
Definition: nat44_ei.h:358
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:366
icmp_echo_header_t::identifier
u16 identifier
Definition: nat44_ei.h:89
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:161
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:345
ip4_address_t
Definition: ip4_packet.h:50
nat44_ei_static_mapping_t::external_addr
ip4_address_t external_addr
Definition: nat44_ei.h:168
nat44_ei_main_s::static_mapping_by_external
clib_bihash_8_8_t static_mapping_by_external
Definition: nat44_ei.h:333
inlines.h
nat44_ei_runtime_t
Definition: nat44_ei.h:304
nat44_ei_main_s::msg_id_base
u16 msg_id_base
Definition: nat44_ei.h:447
nat44_ei_static_map_resolve_t::flags
u32 flags
Definition: nat44_ei.h:138
nat44_ei_address_t::addr
ip4_address_t addr
Definition: nat44_ei.h:69
nat44_ei_static_mapping_t::pool_addr
ip4_address_t pool_addr
Definition: nat44_ei.h:164
nat44_ei_main_s::fib_src_hi
fib_source_t fib_src_hi
Definition: nat44_ei.h:459
nat44_ei_main_per_thread_data_t::icmp_lru_head_index
u32 icmp_lru_head_index
Definition: nat44_ei.h:293
nat44_ei_config_t
Definition: nat44_ei.h:111
nat44_ei_main_s::output_feature_interfaces
nat44_ei_interface_t * output_feature_interfaces
Definition: nat44_ei.h:340
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:371
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:352
nat44_ei_main_s::foreach_nat_counter
foreach_nat_counter
Definition: nat44_ei.h:419
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:166
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:43
nat44_ei_is_idle_session_ctx_t::thread_index
u32 thread_index
Definition: nat44_ei.h:312
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:70
nat44_ei_static_map_resolve_t::e_port
u16 e_port
Definition: nat44_ei.h:135
nat44_ei_main_s::hairpinning_fq_index
u32 hairpinning_fq_index
Definition: nat44_ei.h:476
vnet_main_t
Definition: vnet.h:76
nat44_ei_main_s::first_worker_index
u32 first_worker_index
Definition: nat44_ei.h:357
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:122
nat44_ei_main_per_thread_data_t::user_hash
clib_bihash_8_8_t user_hash
Definition: nat44_ei.h:277
nat44_ei_outside_fib_t::fib_index
u32 fib_index
Definition: nat44_ei.h:202
nat44_ei_user_key_t::as_u64
u64 as_u64
Definition: nat44_ei.h:107
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:330
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:280
nat44_ei_main_s::in2out_node_index
u32 in2out_node_index
Definition: nat44_ei.h:394
nat44_ei_outside_fib_t
Definition: nat44_ei.h:200
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:467
nat44_ei_main_s::translations
u32 translations
Definition: nat44_ei.h:318
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:325
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:379
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:190
nat44_ei_main_s::user_limit_reached
vlib_simple_counter_main_t user_limit_reached
Definition: nat44_ei.h:410
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:126
nat44_ei_main_s::in2out
clib_bihash_8_8_t in2out
Definition: nat44_ei.h:363
nat44_ei_static_mapping_t::proto
nat_protocol_t proto
Definition: nat44_ei.h:177
nat44_ei_static_mapping_t::vrf_id
u32 vrf_id
Definition: nat44_ei.h:174
nm
nat44_ei_main_t * nm
Definition: nat44_ei_hairpinning.c:413
nat44_ei_main_s::fib_src_low
fib_source_t fib_src_low
Definition: nat44_ei.h:460
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:87
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:194
nat44_ei_lb_addr_port_t::prefix
u8 prefix
Definition: nat44_ei.h:155
vlib_main_t
Definition: main.h:102
nat44_ei_main_s::out2in_dpo
u8 out2in_dpo
Definition: nat44_ei.h:322
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:313
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:474
nat44_ei_runtime_t::cached_sw_if_index
u32 cached_sw_if_index
Definition: nat44_ei.h:306
nat44_ei_main_s::ip4_main
ip4_main_t * ip4_main
Definition: nat44_ei.h:456
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:396
icmp46_packet.h
nat44_ei_main_s::log_level
u8 log_level
Definition: nat44_ei.h:452
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:362
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:152
nat44_ei_static_map_resolve_t
Definition: nat44_ei.h:130
nat44_ei_main_s::total_users
vlib_simple_counter_main_t total_users
Definition: nat44_ei.h:408
nat44_ei_main_s::psid
u16 psid
Definition: nat44_ei.h:377
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:134
nat44_ei_static_map_resolve_t::identity_nat
u8 identity_nat
Definition: nat44_ei.h:141
nat44_ei_main_s::auto_add_sw_if_indices
u32 * auto_add_sw_if_indices
Definition: nat44_ei.h:389
nat44_ei_main_per_thread_data_t::lru_pool
dlist_elt_t * lru_pool
Definition: nat44_ei.h:289
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:343
nat44_ei_config_t::inside_vrf
u32 inside_vrf
Definition: nat44_ei.h:125
vnet.h
api_errno.h
nat44_ei_main_s::mss_clamping
u16 mss_clamping
Definition: nat44_ei.h:327
nat44_ei_static_map_resolve_t::addr_only
u8 addr_only
Definition: nat44_ei.h:140
nat44_ei_main_s::ip4_lookup_main
ip_lookup_main_t * ip4_lookup_main
Definition: nat44_ei.h:457
nat44_ei_main_s::forwarding_enabled
u8 forwarding_enabled
Definition: nat44_ei.h:323
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:291
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:157
nat44_ei_main_s::total_sessions
vlib_simple_counter_main_t total_sessions
Definition: nat44_ei.h:409
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:359
nat44_ei_static_map_resolve_t::vrf_id
u32 vrf_id
Definition: nat44_ei.h:137
nat44_ei_static_mapping_t::local_port
u16 local_port
Definition: nat44_ei.h:170
nat44_ei_static_map_resolve_t::sw_if_index
u32 sw_if_index
Definition: nat44_ei.h:136
nat44_ei_main_s::num_workers
u32 num_workers
Definition: nat44_ei.h:356
nat44_ei_main_s::outside_fibs
nat44_ei_outside_fib_t * outside_fibs
Definition: nat44_ei.h:386
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:142
nat44_ei_main_s::api_main
api_main_t * api_main
Definition: nat44_ei.h:455
nat44_ei_static_map_resolve_t::l_addr
ip4_address_t l_addr
Definition: nat44_ei.h:132
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:183
nat44_ei_is_idle_session_ctx_t
Definition: nat44_ei.h:310
nat44_ei_runtime_t::cached_ip4_address
u32 cached_ip4_address
Definition: nat44_ei.h:307
nat44_ei_main_per_thread_data_t
Definition: nat44_ei.h:274
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