FD.io VPP  v17.10-9-gd594711
Vector Packet Processing
nat.h
Go to the documentation of this file.
1 
2 /*
3  * nat.h - NAT plugin definitions
4  *
5  * Copyright (c) 2016 Cisco and/or its affiliates.
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at:
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 #ifndef __included_nat_h__
19 #define __included_nat_h__
20 
21 #include <vnet/vnet.h>
22 #include <vnet/ip/ip.h>
23 #include <vnet/ethernet/ethernet.h>
24 #include <vnet/ip/icmp46_packet.h>
25 #include <vnet/api_errno.h>
26 #include <vppinfra/bihash_8_8.h>
27 #include <vppinfra/bihash_16_8.h>
28 #include <vppinfra/dlist.h>
29 #include <vppinfra/error.h>
30 #include <vlibapi/api.h>
31 
32 
33 #define SNAT_UDP_TIMEOUT 300
34 #define SNAT_UDP_TIMEOUT_MIN 120
35 #define SNAT_TCP_TRANSITORY_TIMEOUT 240
36 #define SNAT_TCP_ESTABLISHED_TIMEOUT 7440
37 #define SNAT_TCP_INCOMING_SYN 6
38 #define SNAT_ICMP_TIMEOUT 60
39 
40 #define SNAT_FLAG_HAIRPINNING (1 << 0)
41 
42 /* Key */
43 typedef struct {
44  union
45  {
46  struct
47  {
50  u16 protocol:3,
51  fib_index:13;
52  };
54  };
56 
57 typedef struct {
58  union
59  {
60  struct
61  {
68  };
69  u64 as_u64[2];
70  };
72 
73 typedef struct {
74  union
75  {
76  struct
77  {
81  };
83  };
85 
86 typedef struct {
87  union
88  {
89  struct
90  {
93  };
95  };
97 
98 
99 #define foreach_snat_protocol \
100  _(UDP, 0, udp, "udp") \
101  _(TCP, 1, tcp, "tcp") \
102  _(ICMP, 2, icmp, "icmp")
103 
104 typedef enum {
105 #define _(N, i, n, s) SNAT_PROTOCOL_##N = i,
107 #undef _
109 
110 
111 #define foreach_snat_session_state \
112  _(0, UNKNOWN, "unknown") \
113  _(1, UDP_ACTIVE, "udp-active") \
114  _(2, TCP_SYN_SENT, "tcp-syn-sent") \
115  _(3, TCP_ESTABLISHED, "tcp-established") \
116  _(4, TCP_FIN_WAIT, "tcp-fin-wait") \
117  _(5, TCP_CLOSE_WAIT, "tcp-close-wait") \
118  _(6, TCP_LAST_ACK, "tcp-last-ack") \
119  _(7, ICMP_ACTIVE, "icmp-active")
120 
121 typedef enum {
122 #define _(v, N, s) SNAT_SESSION_##N = v,
124 #undef _
126 
127 
128 #define SNAT_SESSION_FLAG_STATIC_MAPPING 1
129 #define SNAT_SESSION_FLAG_UNKNOWN_PROTO 2
130 #define SNAT_SESSION_FLAG_LOAD_BALANCING 4
131 
132 typedef CLIB_PACKED(struct {
133  snat_session_key_t out2in; /* 0-15 */
134 
135  snat_session_key_t in2out; /* 16-31 */
136 
137  u32 flags; /* 32-35 */
138 
139  /* per-user translations */
140  u32 per_user_index; /* 36-39 */
141 
142  u32 per_user_list_head_index; /* 40-43 */
143 
144  /* Last heard timer */
145  f64 last_heard; /* 44-51 */
146 
147  u64 total_bytes; /* 52-59 */
148 
149  u32 total_pkts; /* 60-63 */
150 
151  /* Outside address */
152  u32 outside_address_index; /* 64-67 */
153 
154  /* External host address */
155  ip4_address_t ext_host_addr; /* 68-71 */
156 
157 }) snat_session_t;
158 
159 
160 typedef struct {
166 } snat_user_t;
167 
168 typedef struct {
171 #define _(N, i, n, s) \
172  u16 busy_##n##_ports; \
173  u16 * busy_##n##_ports_per_thread; \
174  uword * busy_##n##_port_bitmap;
176 #undef _
177 } snat_address_t;
178 
179 typedef struct {
185 
186 typedef struct {
194  /* vector of sessions */
197 
198 typedef struct {
204 
205 typedef struct {
213  snat_protocol_t proto;
217 
218 typedef struct {
222 
223 typedef struct {
229  snat_protocol_t proto;
231  int is_add;
233 
234 typedef struct {
235  /* Main lookup tables */
236  clib_bihash_8_8_t out2in;
237  clib_bihash_8_8_t in2out;
238 
239  /* Find-a-user => src address lookup */
240  clib_bihash_8_8_t user_hash;
241 
242  /* User pool */
244 
245  /* Session pool */
246  snat_session_t * sessions;
247 
248  /* Pool of doubly-linked list elements */
250 
253 
254 struct snat_main_s;
255 
257  vlib_node_runtime_t *node,
258  u32 thread_index,
259  vlib_buffer_t *b0,
260  ip4_header_t *ip0,
261  u8 *p_proto,
262  snat_session_key_t *p_value,
263  u8 *p_dont_translate,
264  void *d,
265  void *e);
266 
267 typedef u32 (snat_get_worker_function_t) (ip4_header_t * ip, u32 rx_fib_index);
268 
269 typedef struct snat_main_s {
270  /* Endpoint address dependent sessions lookup tables */
271  clib_bihash_16_8_t out2in_ed;
272  clib_bihash_16_8_t in2out_ed;
273 
276 
285 
286  /* Per thread data */
288 
289  /* Find a static mapping by local */
290  clib_bihash_8_8_t static_mapping_by_local;
291 
292  /* Find a static mapping by external */
293  clib_bihash_8_8_t static_mapping_by_external;
294 
295  /* Static mapping pool */
297 
298  /* Interface pool */
301 
302  /* Vector of outside addresses */
303  snat_address_t * addresses;
304 
305  /* sw_if_indices whose intfc addresses should be auto-added */
307 
308  /* vector of interface address static mappings to resolve. */
310 
311  /* Randomize port allocation order */
313 
314  /* Worker handoff index */
318 
319  /* in2out and out2in node index */
323 
324  /* Deterministic NAT */
326 
327  /* Config parameters */
341 
342  /* tenant VRF aware address pool activation flag */
344 
345  /* values of various timeouts */
350 
351  /* API message ID base */
353 
354  /* convenience */
360 } snat_main_t;
361 
362 extern snat_main_t snat_main;
375 
377  u32 thread_index,
378  snat_session_key_t * k,
379  u32 address_index);
380 
382  u32 fib_index,
383  u32 thread_index,
384  snat_session_key_t * k,
385  u32 * address_indexp);
386 
388  snat_session_key_t match,
389  snat_session_key_t * mapping,
390  u8 by_external,
391  u8 *is_addr_only);
392 
394  u8 p_len,
395  u32 sw_if_index,
396  int is_add);
397 
399 
400 typedef struct {
404 
405 /** \brief Check if SNAT session is created from static mapping.
406  @param s SNAT session
407  @return 1 if SNAT session is created from static mapping otherwise 0
408 */
409 #define snat_is_session_static(s) s->flags & SNAT_SESSION_FLAG_STATIC_MAPPING
410 
411 /** \brief Check if SNAT session for unknown protocol.
412  @param s SNAT session
413  @return 1 if SNAT session for unknown protocol otherwise 0
414 */
415 #define snat_is_unk_proto_session(s) s->flags & SNAT_SESSION_FLAG_UNKNOWN_PROTO
416 
417 /*
418  * Why is this here? Because we don't need to touch this layer to
419  * simply reply to an icmp. We need to change id to a unique
420  * value to NAT an echo request/reply.
421  */
422 
423 typedef struct {
427 
430 {
431  u32 snat_proto = ~0;
432 
433  snat_proto = (ip_proto == IP_PROTOCOL_UDP) ? SNAT_PROTOCOL_UDP : snat_proto;
434  snat_proto = (ip_proto == IP_PROTOCOL_TCP) ? SNAT_PROTOCOL_TCP : snat_proto;
435  snat_proto = (ip_proto == IP_PROTOCOL_ICMP) ? SNAT_PROTOCOL_ICMP : snat_proto;
436  snat_proto = (ip_proto == IP_PROTOCOL_ICMP6) ? SNAT_PROTOCOL_ICMP : snat_proto;
437 
438  return snat_proto;
439 }
440 
442 snat_proto_to_ip_proto (snat_protocol_t snat_proto)
443 {
444  u8 ip_proto = ~0;
445 
446  ip_proto = (snat_proto == SNAT_PROTOCOL_UDP) ? IP_PROTOCOL_UDP : ip_proto;
447  ip_proto = (snat_proto == SNAT_PROTOCOL_TCP) ? IP_PROTOCOL_TCP : ip_proto;
448  ip_proto = (snat_proto == SNAT_PROTOCOL_ICMP) ? IP_PROTOCOL_ICMP : ip_proto;
449 
450  return ip_proto;
451 }
452 
453 typedef struct {
454  u16 src_port, dst_port;
456 
458  u32 thread_index, vlib_buffer_t *b0,
459  ip4_header_t *ip0, u8 *p_proto,
460  snat_session_key_t *p_value,
461  u8 *p_dont_translate, void *d, void *e);
463  u32 thread_index, vlib_buffer_t *b0,
464  ip4_header_t *ip0, u8 *p_proto,
465  snat_session_key_t *p_value,
466  u8 *p_dont_translate, void *d, void *e);
468  u32 thread_index, vlib_buffer_t *b0,
469  ip4_header_t *ip0, u8 *p_proto,
470  snat_session_key_t *p_value,
471  u8 *p_dont_translate, void *d, void *e);
473  u32 thread_index, vlib_buffer_t *b0,
474  ip4_header_t *ip0, u8 *p_proto,
475  snat_session_key_t *p_value,
476  u8 *p_dont_translate, void *d, void *e);
478  u32 thread_index, vlib_buffer_t *b0,
479  ip4_header_t *ip0, u8 *p_proto,
480  snat_session_key_t *p_value,
481  u8 *p_dont_translate, void *d, void *e);
483  u32 thread_index, vlib_buffer_t *b0,
484  ip4_header_t *ip0, u8 *p_proto,
485  snat_session_key_t *p_value,
486  u8 *p_dont_translate, void *d, void *e);
489 int snat_del_address(snat_main_t *sm, ip4_address_t addr, u8 delete_sm);
491  u16 l_port, u16 e_port, u32 vrf_id, int addr_only,
492  u32 sw_if_index, snat_protocol_t proto, int is_add);
494 int snat_set_workers (uword * bitmap);
495 int snat_interface_add_del(u32 sw_if_index, u8 is_inside, int is_del);
496 int snat_interface_add_del_output_feature(u32 sw_if_index, u8 is_inside,
497  int is_del);
498 int snat_add_interface_address(snat_main_t *sm, u32 sw_if_index, int is_del);
499 uword unformat_snat_protocol(unformat_input_t * input, va_list * args);
500 u8 * format_snat_protocol(u8 * s, va_list * args);
502  snat_protocol_t proto, u32 vrf_id,
503  nat44_lb_addr_port_t *locals, u8 is_add);
504 
506 icmp_is_error_message (icmp46_header_t * icmp)
507 {
508  switch(icmp->type)
509  {
510  case ICMP4_destination_unreachable:
511  case ICMP4_time_exceeded:
512  case ICMP4_parameter_problem:
513  case ICMP4_source_quench:
514  case ICMP4_redirect:
515  case ICMP4_alternate_host_address:
516  return 1;
517  }
518  return 0;
519 }
520 
523  u32 ip4_addr)
524 {
526  ip4_address_t * first_int_addr;
527 
528  if (PREDICT_FALSE(rt->cached_sw_if_index != sw_if_index0))
529  {
530  first_int_addr =
531  ip4_interface_first_address (sm->ip4_main, sw_if_index0,
532  0 /* just want the address */);
533  rt->cached_sw_if_index = sw_if_index0;
534  if (first_int_addr)
535  rt->cached_ip4_address = first_int_addr->as_u32;
536  else
537  rt->cached_ip4_address = 0;
538  }
539 
540  if (PREDICT_FALSE(ip4_addr == rt->cached_ip4_address))
541  return 1;
542  else
543  return 0;
544 }
545 
548 {
549  if (pool_elts (sm->per_thread_data[thread_index].sessions) >= sm->max_translations)
550  return 1;
551 
552  return 0;
553 }
554 
555 #endif /* __included_nat_h__ */
ip4_address_t external_addr
Definition: nat.h:207
u32 user_memory_size
Definition: nat.h:335
clib_error_t * snat_api_init(vlib_main_t *vm, snat_main_t *sm)
Definition: nat_api.c:3367
vlib_node_registration_t snat_hairpin_src_node
(constructor) VLIB_REGISTER_NODE (snat_hairpin_src_node)
Definition: in2out.c:95
u32 sessions_per_user_list_head_index
Definition: nat.h:163
clib_bihash_16_8_t out2in_ed
Definition: nat.h:271
int snat_interface_add_del(u32 sw_if_index, u8 is_inside, int is_del)
Definition: nat.c:943
u16 ext_host_port
Definition: nat.h:79
u16 out_port
Definition: nat.h:80
a
Definition: bitmap.h:516
u32 icmp_timeout
Definition: nat.h:349
u8 runtime_data[0]
Function dependent node-runtime data.
Definition: node.h:464
int snat_static_mapping_match(snat_main_t *sm, snat_session_key_t match, snat_session_key_t *mapping, u8 by_external, u8 *is_addr_only)
Match NAT44 static mapping.
Definition: nat.c:1257
u32 fq_in2out_output_index
Definition: nat.h:316
u32 icmp_match_in2out_det(snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
Get address and port values to be used for ICMP packet translation and create session if needed...
Definition: in2out.c:2914
u64 as_u64
Definition: bihash_doc.h:63
u32 nsessions
Definition: nat.h:164
#define foreach_snat_session_state
Definition: nat.h:111
ip4_address_t addr
Definition: nat.h:199
snat_protocol_t proto
Definition: nat.h:213
ip4_address_t * ip4_interface_first_address(ip4_main_t *im, u32 sw_if_index, ip_interface_address_t **result_ia)
Definition: ip4_forward.c:684
u16 port_per_thread
Definition: nat.h:283
u32 nstaticsessions
Definition: nat.h:165
struct _vlib_node_registration vlib_node_registration_t
u32 icmp_match_out2in_slow(snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
Get address and port values to be used for ICMP packet translation and create session if needed...
Definition: out2in.c:299
vlib_node_registration_t snat_det_out2in_node
(constructor) VLIB_REGISTER_NODE (snat_det_out2in_node)
Definition: out2in.c:2001
u32 fib_index
Definition: nat.h:162
clib_bihash_16_8_t in2out_ed
Definition: nat.h:272
u8 *( format_function_t)(u8 *s, va_list *args)
Definition: format.h:48
snat_det_map_t * det_maps
Definition: nat.h:325
u8 vrf_mode
Definition: nat.h:343
u32 num_snat_thread
Definition: nat.h:284
#define foreach_snat_protocol
Definition: nat.h:99
dlist_elt_t * list_pool
Definition: nat.h:249
u8 in_plen
Definition: nat.h:188
u8 deterministic
Definition: nat.h:330
u16 l_port
Definition: nat.h:65
nat44_lb_addr_port_t * locals
Definition: nat.h:215
int snat_set_workers(uword *bitmap)
Definition: nat.c:1102
u32 user_buckets
Definition: nat.h:334
clib_bihash_8_8_t user_hash
Definition: nat.h:240
u32 cached_sw_if_index
Definition: nat.h:401
u16 identifier
Definition: nat.h:424
u32 snat_icmp_match_function_t(struct snat_main_s *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
Definition: nat.h:256
u32 max_translations_per_user
Definition: nat.h:336
u32( snat_get_worker_function_t)(ip4_header_t *ip, u32 rx_fib_index)
Definition: nat.h:267
clib_bihash_8_8_t in2out
Definition: nat.h:237
u32 in2out_output_node_index
Definition: nat.h:321
#define static_always_inline
Definition: clib.h:85
vlib_node_registration_t snat_out2in_node
(constructor) VLIB_REGISTER_NODE (snat_out2in_node)
Definition: out2in.c:1514
ip4_address_t ext_host_addr
Definition: nat.h:78
#define always_inline
Definition: clib.h:84
u32 translation_buckets
Definition: nat.h:331
ip4_address_t addr
Definition: nat.h:161
ip4_main_t * ip4_main
Definition: nat.h:357
unsigned long u64
Definition: types.h:89
vlib_node_registration_t snat_in2out_output_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_output_node)
Definition: in2out.c:91
ip4_address_t local_addr
Definition: nat.h:206
vlib_node_registration_t snat_in2out_output_worker_handoff_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_output_worker_handoff_node)
Definition: in2out.c:93
int snat_del_address(snat_main_t *sm, ip4_address_t addr, u8 delete_sm)
Definition: nat.c:804
uword unformat_snat_protocol(unformat_input_t *input, va_list *args)
Definition: nat.c:1611
snat_protocol_t proto
Definition: nat.h:229
u32 icmp_match_out2in_det(snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
Get address and port values to be used for ICMP packet translation and create session if needed...
Definition: out2in.c:2038
vlib_node_registration_t snat_out2in_fast_node
(constructor) VLIB_REGISTER_NODE (snat_out2in_fast_node)
Definition: out2in.c:2493
u32 max_translations
Definition: nat.h:333
u32 fib_index
Definition: nat.h:64
vlib_node_registration_t snat_hairpin_dst_node
(constructor) VLIB_REGISTER_NODE (snat_hairpin_dst_node)
Definition: in2out.c:94
typedef CLIB_PACKED(struct{snat_session_key_t out2in;snat_session_key_t in2out;u32 flags;u32 per_user_index;u32 per_user_list_head_index;f64 last_heard;u64 total_bytes;u32 total_pkts;u32 outside_address_index;ip4_address_t ext_host_addr;}) snat_session_t
snat_det_session_t * sessions
Definition: nat.h:195
vlib_main_t * vlib_main
Definition: nat.h:355
struct _unformat_input_t unformat_input_t
snat_static_mapping_t * static_mappings
Definition: nat.h:296
u32 inside_fib_index
Definition: nat.h:340
u32 udp_timeout
Definition: nat.h:346
u8 static_mapping_only
Definition: nat.h:328
#define PREDICT_FALSE(x)
Definition: clib.h:97
void snat_add_del_addr_to_fib(ip4_address_t *addr, u8 p_len, u32 sw_if_index, int is_add)
Add/del NAT address to FIB.
Definition: nat.c:119
clib_bihash_8_8_t static_mapping_by_external
Definition: nat.h:293
void snat_add_address(snat_main_t *sm, ip4_address_t *addr, u32 vrf_id)
Definition: nat.c:151
struct snat_main_s snat_main_t
api_main_t * api_main
Definition: nat.h:359
u8 out_plen
Definition: nat.h:190
vnet_main_t * vnet_main
Definition: nat.h:356
u32 inside_vrf_id
Definition: nat.h:339
u32 fq_out2in_index
Definition: nat.h:317
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:182
snat_interface_t * output_feature_interfaces
Definition: nat.h:300
int snat_alloc_outside_address_and_port(snat_main_t *sm, u32 fib_index, u32 thread_index, snat_session_key_t *k, u32 *address_indexp)
Definition: nat.c:1339
u16 src_port
Definition: nat.h:454
snat_main_t snat_main
Definition: nat.c:31
vlib_node_registration_t snat_det_in2out_node
(constructor) VLIB_REGISTER_NODE (snat_det_in2out_node)
Definition: in2out.c:90
snat_session_state_t
Definition: nat.h:121
snat_user_t * users
Definition: nat.h:243
int nat44_add_del_lb_static_mapping(ip4_address_t e_addr, u16 e_port, snat_protocol_t proto, u32 vrf_id, nat44_lb_addr_port_t *locals, u8 is_add)
Definition: nat.c:582
u32 random_seed
Definition: nat.h:312
clib_bihash_8_8_t out2in
Definition: nat.h:236
vlib_main_t * vm
Definition: buffer.c:283
u32 outside_vrf_id
Definition: nat.h:337
ip4_address_t l_addr
Definition: nat.h:62
u8 static_mapping_connection_tracking
Definition: nat.h:329
snat_get_worker_function_t * worker_in2out_cb
Definition: nat.h:281
u32 sharing_ratio
Definition: nat.h:191
ip4_address_t out_addr
Definition: nat.h:189
u32 outside_fib_index
Definition: nat.h:338
ip4_address_t addr
Definition: nat.h:48
u32 sw_if_index
Definition: nat.h:219
void increment_v4_address(ip4_address_t *a)
Definition: nat.c:214
u32 tcp_transitory_timeout
Definition: nat.h:348
ip4_address_t r_addr
Definition: nat.h:63
u32 * auto_add_sw_if_indices
Definition: nat.h:306
u32 icmp_match_in2out_slow(snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
Get address and port values to be used for ICMP packet translation and create session if needed...
Definition: in2out.c:525
u32 num_workers
Definition: nat.h:277
unsigned int u32
Definition: types.h:88
u32 first_worker_index
Definition: nat.h:278
snat_get_worker_function_t * worker_out2in_cb
Definition: nat.h:282
ip4_address_t l_addr
Definition: nat.h:224
static u32 ip_proto_to_snat_proto(u8 ip_proto)
Definition: nat.h:429
snat_icmp_match_function_t * icmp_match_out2in_cb
Definition: nat.h:275
IPv4 main type.
Definition: ip4.h:95
u64 as_u64
Definition: nat.h:94
vlib_node_registration_t snat_out2in_worker_handoff_node
(constructor) VLIB_REGISTER_NODE (snat_out2in_worker_handoff_node)
Definition: out2in.c:2310
ip4_address_t addr
Definition: nat.h:91
ip4_address_t in_addr
Definition: nat.h:187
u32 fq_in2out_index
Definition: nat.h:315
u32 out2in_node_index
Definition: nat.h:322
ip4_address_t addr
Definition: nat.h:169
u64 uword
Definition: types.h:112
u32 icmp_match_out2in_fast(snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
Get address and port values to be used for ICMP packet translation.
Definition: out2in.c:409
unsigned short u16
Definition: types.h:57
double f64
Definition: types.h:142
unsigned char u8
Definition: types.h:56
u16 msg_id_base
Definition: nat.h:352
u16 ports_per_host
Definition: nat.h:192
static_always_inline u8 is_interface_addr(snat_main_t *sm, vlib_node_runtime_t *node, u32 sw_if_index0, u32 ip4_addr)
Definition: nat.h:522
u32 * workers
Definition: nat.h:280
snat_main_per_thread_data_t * per_thread_data
Definition: nat.h:287
u8 is_inside
Definition: nat.h:220
snat_protocol_t
Definition: nat.h:104
snat_det_out_key_t out
Definition: nat.h:181
u32 fib_index
Definition: nat.h:92
snat_address_t * addresses
Definition: nat.h:303
u32 in2out_node_index
Definition: nat.h:320
format_function_t format_snat_user
Definition: nat.h:398
snat_static_map_resolve_t * to_resolve
Definition: nat.h:309
vlib_node_registration_t snat_in2out_worker_handoff_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_worker_handoff_node)
Definition: in2out.c:89
vlib_node_registration_t snat_in2out_fast_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_fast_node)
Definition: in2out.c:88
u32 translation_memory_size
Definition: nat.h:332
int snat_interface_add_del_output_feature(u32 sw_if_index, u8 is_inside, int is_del)
Definition: nat.c:1017
int snat_add_interface_address(snat_main_t *sm, u32 sw_if_index, int is_del)
Definition: nat.c:2719
u32 ses_num
Definition: nat.h:193
u32 next_worker
Definition: nat.h:279
vhost_vring_addr_t addr
Definition: vhost-user.h:83
vlib_node_registration_t snat_in2out_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_node)
Definition: in2out.c:86
u8 * format_snat_protocol(u8 *s, va_list *args)
Definition: nat.c:1625
u32 flags
Definition: vhost-user.h:77
void snat_free_outside_address_and_port(snat_main_t *sm, u32 thread_index, snat_session_key_t *k, u32 address_index)
Definition: nat.c:1214
ip_lookup_main_t * ip4_lookup_main
Definition: nat.h:358
u32 icmp_match_in2out_fast(snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
Get address and port values to be used for ICMP packet translation.
Definition: in2out.c:618
static u8 maximum_sessions_exceeded(snat_main_t *sm, u32 thread_index)
Definition: nat.h:547
snat_session_t * sessions
Definition: nat.h:246
u32 cached_ip4_address
Definition: nat.h:402
snat_icmp_match_function_t * icmp_match_in2out_cb
Definition: nat.h:274
int snat_add_static_mapping(ip4_address_t l_addr, ip4_address_t e_addr, u16 l_port, u16 e_port, u32 vrf_id, int addr_only, u32 sw_if_index, snat_protocol_t proto, int is_add)
Add static mapping.
Definition: nat.c:262
clib_bihash_8_8_t static_mapping_by_local
Definition: nat.h:290
u32 fib_index
Definition: nat.h:170
snat_interface_t * interfaces
Definition: nat.h:299
static_always_inline u8 icmp_is_error_message(icmp46_header_t *icmp)
Definition: nat.h:506
static u8 snat_proto_to_ip_proto(snat_protocol_t snat_proto)
Definition: nat.h:442
u32 tcp_established_timeout
Definition: nat.h:347
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:128