FD.io VPP  v21.01.1
Vector Packet Processing
nat.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 nat.c
17  * NAT plugin global declarations
18  */
19 #ifndef __included_nat_h__
20 #define __included_nat_h__
21 
22 #include <vnet/vnet.h>
23 #include <vnet/ip/ip.h>
24 #include <vnet/ethernet/ethernet.h>
25 #include <vnet/ip/icmp46_packet.h>
26 #include <vnet/api_errno.h>
27 #include <vnet/fib/fib_source.h>
28 #include <vppinfra/elog.h>
29 #include <vppinfra/bihash_8_8.h>
30 #include <vppinfra/bihash_16_8.h>
31 #include <vppinfra/dlist.h>
32 #include <vppinfra/error.h>
33 #include <vlibapi/api.h>
34 #include <vlib/log.h>
35 #include <vppinfra/bihash_16_8.h>
36 #include <nat/lib/lib.h>
37 #include <nat/lib/inlines.h>
38 
39 /* number of worker handoff frame queue elements */
40 #define NAT_FQ_NELTS 64
41 
42 /* NAT buffer flags */
43 #define SNAT_FLAG_HAIRPINNING (1 << 0)
44 
45 /* NAT44 API Configuration flags */
46 #define foreach_nat44_config_flag \
47  _(0x00, IS_ENDPOINT_INDEPENDENT) \
48  _(0x01, IS_ENDPOINT_DEPENDENT) \
49  _(0x02, IS_STATIC_MAPPING_ONLY) \
50  _(0x04, IS_CONNECTION_TRACKING) \
51  _(0x08, IS_OUT2IN_DPO)
52 
54 {
55 #define _(n,f) NAT44_API_##f = n,
57 #undef _
59 
60 typedef struct
61 {
62  /* nat44 plugin features */
67 
70 
71  /* maximum number of users */
73 
74  /* maximum number of sessions */
76 
77  /* maximum number of ssessions per user */
80 
81 typedef enum
82 {
95 } nat_next_t;
96 
97 typedef struct
98 {
102 
103 /* user (internal host) key */
104 typedef struct
105 {
106  union
107  {
108  struct
109  {
112  };
114  };
116 
117 /* External address and port allocation modes */
118 #define foreach_nat_addr_and_port_alloc_alg \
119  _(0, DEFAULT, "default") \
120  _(1, MAPE, "map-e") \
121  _(2, RANGE, "port-range")
122 
123 typedef enum
124 {
125 #define _(v, N, s) NAT_ADDR_AND_PORT_ALLOC_ALG_##N = v,
127 #undef _
129 
130 /* Session state */
131 #define foreach_snat_session_state \
132  _(0, UNKNOWN, "unknown") \
133  _(1, UDP_ACTIVE, "udp-active") \
134  _(2, TCP_SYN_SENT, "tcp-syn-sent") \
135  _(3, TCP_ESTABLISHED, "tcp-established") \
136  _(4, TCP_FIN_WAIT, "tcp-fin-wait") \
137  _(5, TCP_CLOSE_WAIT, "tcp-close-wait") \
138  _(6, TCP_CLOSING, "tcp-closing") \
139  _(7, TCP_LAST_ACK, "tcp-last-ack") \
140  _(8, TCP_CLOSED, "tcp-closed") \
141  _(9, ICMP_ACTIVE, "icmp-active")
142 
143 typedef enum
144 {
145 #define _(v, N, s) SNAT_SESSION_##N = v,
147 #undef _
149 
150 #define foreach_nat_in2out_ed_error \
151 _(UNSUPPORTED_PROTOCOL, "unsupported protocol") \
152 _(OUT_OF_PORTS, "out of ports") \
153 _(BAD_ICMP_TYPE, "unsupported ICMP type") \
154 _(MAX_SESSIONS_EXCEEDED, "maximum sessions exceeded") \
155 _(NON_SYN, "non-SYN packet try to create session") \
156 _(TCP_CLOSED, "drops due to TCP in transitory timeout")
157 
158 typedef enum
159 {
160 #define _(sym,str) NAT_IN2OUT_ED_ERROR_##sym,
162 #undef _
165 
166 #define foreach_nat44_handoff_error \
167 _(CONGESTION_DROP, "congestion drop") \
168 _(SAME_WORKER, "same worker") \
169 _(DO_HANDOFF, "do handoff")
170 
171 typedef enum
172 {
173 #define _(sym,str) NAT44_HANDOFF_ERROR_##sym,
175 #undef _
178 
179 #define foreach_nat_out2in_ed_error \
180 _(UNSUPPORTED_PROTOCOL, "unsupported protocol") \
181 _(OUT_OF_PORTS, "out of ports") \
182 _(BAD_ICMP_TYPE, "unsupported ICMP type") \
183 _(NO_TRANSLATION, "no translation") \
184 _(MAX_SESSIONS_EXCEEDED, "maximum sessions exceeded") \
185 _(MAX_USER_SESS_EXCEEDED, "max user sessions exceeded") \
186 _(CANNOT_CREATE_USER, "cannot create NAT user") \
187 _(NON_SYN, "non-SYN packet try to create session") \
188 _(TCP_CLOSED, "drops due to TCP in transitory timeout")
189 
190 typedef enum
191 {
192 #define _(sym,str) NAT_OUT2IN_ED_ERROR_##sym,
194 #undef _
197 
198 
199 /* Endpoint dependent TCP session state */
200 #define NAT44_SES_I2O_FIN 1
201 #define NAT44_SES_O2I_FIN 2
202 #define NAT44_SES_I2O_FIN_ACK 4
203 #define NAT44_SES_O2I_FIN_ACK 8
204 #define NAT44_SES_I2O_SYN 16
205 #define NAT44_SES_O2I_SYN 32
206 #define NAT44_SES_RST 64
207 
208 /* Session flags */
209 #define SNAT_SESSION_FLAG_STATIC_MAPPING 1
210 #define SNAT_SESSION_FLAG_UNKNOWN_PROTO 2
211 #define SNAT_SESSION_FLAG_LOAD_BALANCING 4
212 #define SNAT_SESSION_FLAG_TWICE_NAT 8
213 #define SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT 16
214 #define SNAT_SESSION_FLAG_FWD_BYPASS 32
215 #define SNAT_SESSION_FLAG_AFFINITY 64
216 #define SNAT_SESSION_FLAG_EXACT_ADDRESS 128
217 
218 /* NAT interface flags */
219 #define NAT_INTERFACE_FLAG_IS_INSIDE 1
220 #define NAT_INTERFACE_FLAG_IS_OUTSIDE 2
221 
222 /* Static mapping flags */
223 #define NAT_STATIC_MAPPING_FLAG_ADDR_ONLY 1
224 #define NAT_STATIC_MAPPING_FLAG_OUT2IN_ONLY 2
225 #define NAT_STATIC_MAPPING_FLAG_IDENTITY_NAT 4
226 #define NAT_STATIC_MAPPING_FLAG_LB 8
227 #define NAT_STATIC_MAPPING_FLAG_EXACT_ADDRESS 16
228 
229 /* *INDENT-OFF* */
230 typedef CLIB_PACKED(struct
231 {
232  // number of sessions in this vrf
233  u32 ses_count;
234 
235  u32 rx_fib_index;
236  u32 tx_fib_index;
237 
238  // is this vrf expired
239  u8 expired;
240 }) per_vrf_sessions_t;
241 /* *INDENT-ON* */
242 
243 /* *INDENT-OFF* */
244 typedef CLIB_PACKED(struct
245 {
246  /* Outside network tuple */
247  struct
248  {
250  u32 fib_index;
251  u16 port;
252  } out2in;
253 
254  /* Inside network tuple */
255  struct
256  {
258  u32 fib_index;
259  u16 port;
260  } in2out;
261 
262  nat_protocol_t nat_proto;
263 
264  /* Flags */
265  u32 flags;
266 
267  /* Per-user translations */
268  u32 per_user_index;
269  u32 per_user_list_head_index;
270 
271  /* head of LRU list in which this session is tracked */
272  u32 lru_head_index;
273  /* index in global LRU list */
274  u32 lru_index;
275  f64 last_lru_update;
276 
277  /* Last heard timer */
278  f64 last_heard;
279 
280  /* Last HA refresh */
281  f64 ha_last_refreshed;
282 
283  /* Counters */
284  u64 total_bytes;
285  u32 total_pkts;
286 
287  /* External host address and port */
288  ip4_address_t ext_host_addr;
289  u16 ext_host_port;
290 
291  /* External host address and port after translation */
292  ip4_address_t ext_host_nat_addr;
293  u16 ext_host_nat_port;
294 
295  /* TCP session state */
296  u8 state;
297  u32 i2o_fin_seq;
298  u32 o2i_fin_seq;
299  u64 tcp_closed_timestamp;
300 
301  /* user index */
302  u32 user_index;
303 
304  /* per vrf sessions index */
305  u32 per_vrf_sessions_index;
306 
307 }) snat_session_t;
308 /* *INDENT-ON* */
309 
310 typedef struct
311 {
317 } snat_user_t;
318 
319 typedef struct
320 {
323 /* *INDENT-OFF* */
324 #define _(N, i, n, s) \
325  u32 busy_##n##_ports; \
326  u32 * busy_##n##_ports_per_thread; \
327  u32 busy_##n##_port_refcounts[65535];
329 #undef _
330 /* *INDENT-ON* */
331 } snat_address_t;
332 
333 typedef struct
334 {
337 } nat_fib_t;
338 
339 typedef struct
340 {
344 
345 typedef struct
346 {
347  /* backend IP address */
349  /* backend port number */
351  /* probability of the backend to be randomly matched */
354  /* backend FIB table */
358 
359 typedef enum
360 {
361  /* twice-nat disabled */
363  /* twice-nat enabled */
365  /* twice-nat only when src IP equals dst IP after translation */
368 
369 typedef enum
370 {
371  /* no load-balancing */
373  /* load-balancing */
375  /* load-balancing with affinity */
377 } lb_nat_type_t;
378 
379 typedef struct
380 {
381  /* prefered pool address */
383  /* local IP address */
385  /* external IP address */
387  /* local port */
389  /* external port */
391  /* is twice-nat */
392  twice_nat_type_t twice_nat;
393  /* local FIB table */
396  /* protocol */
398  /* 0 = disabled, otherwise client IP affinity sticky time in seconds */
400  /* worker threads used by backends/local host */
402  /* opaque string tag */
403  u8 *tag;
404  /* backends for load-balancing mode */
406  /* affinity per service lis */
408  /* flags */
411 
412 typedef struct
413 {
417 
418 typedef struct
419 {
430  int is_add;
433  int exact;
434  u8 *tag;
436 
437 typedef struct
438 {
439  /* Main lookup tables */
440  clib_bihash_8_8_t out2in;
441  clib_bihash_8_8_t in2out;
442 
443  /* Endpoint dependent sessions lookup tables */
444  clib_bihash_16_8_t in2out_ed;
445 
446  /* Find-a-user => src address lookup */
447  clib_bihash_8_8_t user_hash;
448 
449  /* User pool */
451 
452  /* Session pool */
453  snat_session_t *sessions;
454 
455  /* Pool of doubly-linked list elements */
457 
458  /* LRU session list - head is stale, tail is fresh */
465 
466  /* NAT thread index */
468 
469  /* real thread index */
471 
472  per_vrf_sessions_t *per_vrf_sessions_vec;
473 
475 
476 struct snat_main_s;
477 
478 /* ICMP session match function */
481  u32 thread_index,
482  vlib_buffer_t * b0,
483  ip4_header_t * ip0,
485  u16 * port,
486  u32 * fib_index,
488  void *d, void *e,
489  u8 * dont_translate);
490 
491 /* Return worker thread index for given packet */
493  u32 rx_fib_index,
494  u8 is_output);
495 
497  ip4_header_t * ip,
498  u32 rx_fib_index,
499  u8 is_output);
500 
501 /* NAT address and port allocation function */
502 typedef int (nat_alloc_out_addr_and_port_function_t) (snat_address_t *
503  addresses,
504  u32 fib_index,
505  u32 thread_index,
508  u16 * port,
510  u32 snat_thread_index);
511 
512 #define foreach_nat_counter _ (tcp) _ (udp) _ (icmp) _ (other) _ (drops)
513 
514 typedef struct snat_main_s
515 {
516  /* ICMP session match functions */
519 
520  /* Thread settings */
527 
528  /* Per thread data */
530 
531  /* Find a static mapping by local */
532  clib_bihash_8_8_t static_mapping_by_local;
533 
534  /* Find a static mapping by external */
535  clib_bihash_8_8_t static_mapping_by_external;
536 
537  /* Static mapping pool */
539 
540  /* Endpoint-dependent out2in mappings */
541  clib_bihash_16_8_t out2in_ed;
542 
543  /* Interface pool */
546 
547  /* Vector of outside addresses */
548  snat_address_t *addresses;
549  /* Address and port allocation function */
551  /* Address and port allocation type */
552  nat_addr_and_port_alloc_alg_t addr_and_port_alloc_alg;
553  /* Port set parameters (MAP-E) */
557  /* Port range parameters */
560 
561  /* vector of fibs */
563 
564  /* vector of outside fibs */
566 
567  /* Vector of twice NAT addresses for external hosts */
568  snat_address_t *twice_nat_addresses;
569 
570  /* sw_if_indices whose intfc addresses should be auto-added */
573 
574  /* vector of interface address static mappings to resolve. */
576 
577  /* Randomize port allocation order */
579 
580  /* Worker handoff frame-queue index */
584 
585  /* node indexes */
587 
588  /* handoff fq nodes */
592 
593  /* respect feature arc nodes */
596 
600 
605 
609 
613 
616 
623 
625  //nat44_config_t cconfig;
626 
627  /* If forwarding is enabled */
629 
630  /* Config parameters */
632 
634  /* static mapping config */
637 
638  /* Is translation memory size calculated or user defined */
640 
647 
652 
654 
655  /* TCP MSS clamping */
657 
658  /* counters */
662 
663 #define _(x) vlib_simple_counter_main_t x;
664  struct
665  {
666  struct
667  {
668  struct
669  {
671  } in2out;
672 
673  struct
674  {
676  } out2in;
677 
678  struct
679  {
681  } in2out_ed;
682 
683  struct
684  {
686  } out2in_ed;
687  } fastpath;
688 
689  struct
690  {
691  struct
692  {
694  } in2out;
695 
696  struct
697  {
699  } out2in;
700 
701  struct
702  {
704  } in2out_ed;
705 
706  struct
707  {
709  } out2in_ed;
710  } slowpath;
711 
713  } counters;
714 #undef _
715 
716  /* API message ID base */
718 
719  /* log class */
721  /* logging level */
723 
724  /* convenience */
728 
731 
732  /* nat44 plugin enabled */
734 
736 } snat_main_t;
737 
738 typedef struct
739 {
743 
744 typedef struct
745 {
749 
750 extern snat_main_t snat_main;
751 
752 // nat pre ed next_node feature classification
756 
766 
769 
770 /* format functions */
779 /* unformat functions */
781 
782 /** \brief Check if SNAT session is created from static mapping.
783  @param s SNAT session
784  @return 1 if SNAT session is created from static mapping otherwise 0
785 */
786 #define snat_is_session_static(s) (s->flags & SNAT_SESSION_FLAG_STATIC_MAPPING)
787 
788 /** \brief Check if SNAT session for unknown protocol.
789  @param s SNAT session
790  @return 1 if SNAT session for unknown protocol otherwise 0
791 */
792 #define snat_is_unk_proto_session(s) (s->flags & SNAT_SESSION_FLAG_UNKNOWN_PROTO)
793 
794 /** \brief Check if NAT session is twice NAT.
795  @param s NAT session
796  @return 1 if NAT session is twice NAT
797 */
798 #define is_twice_nat_session(s) (s->flags & SNAT_SESSION_FLAG_TWICE_NAT)
799 
800 /** \brief Check if NAT session is load-balancing.
801  @param s NAT session
802  @return 1 if NAT session is load-balancing
803 */
804 #define is_lb_session(s) (s->flags & SNAT_SESSION_FLAG_LOAD_BALANCING)
805 
806 /** \brief Check if NAT session is forwarding bypass.
807  @param s NAT session
808  @return 1 if NAT session is load-balancing
809 */
810 #define is_fwd_bypass_session(s) (s->flags & SNAT_SESSION_FLAG_FWD_BYPASS)
811 
812 /** \brief Check if NAT session is endpoint dependent.
813  @param s NAT session
814  @return 1 if NAT session is endpoint dependent
815 */
816 #define is_ed_session(s) (s->flags & SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT)
817 
818 /** \brief Check if NAT session has affinity record.
819  @param s NAT session
820  @return 1 if NAT session has affinity record
821 */
822 #define is_affinity_sessions(s) (s->flags & SNAT_SESSION_FLAG_AFFINITY)
823 
824 /** \brief Check if exact pool address should be used.
825  @param s SNAT session
826  @return 1 if exact pool address or 0
827 */
828 #define is_exact_address_session(s) (s->flags & SNAT_SESSION_FLAG_EXACT_ADDRESS)
829 
830 /** \brief Check if NAT interface is inside.
831  @param i NAT interface
832  @return 1 if inside interface
833 */
834 #define nat_interface_is_inside(i) i->flags & NAT_INTERFACE_FLAG_IS_INSIDE
835 
836 /** \brief Check if NAT interface is outside.
837  @param i NAT interface
838  @return 1 if outside interface
839 */
840 #define nat_interface_is_outside(i) i->flags & NAT_INTERFACE_FLAG_IS_OUTSIDE
841 
842 /** \brief Check if NAT44 endpoint-dependent TCP session is closed.
843  @param s NAT session
844  @return 1 if session is closed
845 */
846 #define nat44_is_ses_closed(s) s->state == 0xf
847 
848 /** \brief Check if NAT static mapping is address only (1:1NAT).
849  @param sm NAT static mapping
850  @return 1 if 1:1NAT, 0 if 1:1NAPT
851 */
852 #define is_addr_only_static_mapping(sm) (sm->flags & NAT_STATIC_MAPPING_FLAG_ADDR_ONLY)
853 
854 /** \brief Check if NAT static mapping match only out2in direction.
855  @param sm NAT static mapping
856  @return 1 if rule match only out2in direction
857 */
858 #define is_out2in_only_static_mapping(sm) (sm->flags & NAT_STATIC_MAPPING_FLAG_OUT2IN_ONLY)
859 
860 /** \brief Check if NAT static mapping is identity NAT.
861  @param sm NAT static mapping
862  @return 1 if identity NAT
863 */
864 #define is_identity_static_mapping(sm) (sm->flags & NAT_STATIC_MAPPING_FLAG_IDENTITY_NAT)
865 
866 /** \brief Check if NAT static mapping is load-balancing.
867  @param sm NAT static mapping
868  @return 1 if load-balancing
869 */
870 #define is_lb_static_mapping(sm) (sm->flags & NAT_STATIC_MAPPING_FLAG_LB)
871 
872 /** \brief Check if exact pool address should be used.
873  @param s SNAT session
874  @return 1 if exact pool address or 0
875 */
876 #define is_exact_address(s) (s->flags & NAT_STATIC_MAPPING_FLAG_EXACT_ADDRESS)
877 
878 /** \brief Check if client initiating TCP connection (received SYN from client)
879  @param t TCP header
880  @return 1 if client initiating TCP connection
881 */
882 always_inline bool
884 {
885  return (f & TCP_FLAG_SYN) && !(f & TCP_FLAG_ACK);
886 }
887 
888 /* logging */
889 #define nat_log_err(...) \
890  vlib_log(VLIB_LOG_LEVEL_ERR, snat_main.log_class, __VA_ARGS__)
891 #define nat_log_warn(...) \
892  vlib_log(VLIB_LOG_LEVEL_WARNING, snat_main.log_class, __VA_ARGS__)
893 #define nat_log_notice(...) \
894  vlib_log(VLIB_LOG_LEVEL_NOTICE, snat_main.log_class, __VA_ARGS__)
895 #define nat_log_info(...) \
896  vlib_log(VLIB_LOG_LEVEL_INFO, snat_main.log_class, __VA_ARGS__)
897 #define nat_log_debug(...)\
898  vlib_log(VLIB_LOG_LEVEL_DEBUG, snat_main.log_class, __VA_ARGS__)
899 
900 /* NAT API Logging Levels */
901 #define foreach_nat_log_level \
902  _(0x00, LOG_NONE) \
903  _(0x01, LOG_ERROR) \
904  _(0x02, LOG_WARNING) \
905  _(0x03, LOG_NOTICE) \
906  _(0x04, LOG_INFO) \
907  _(0x05, LOG_DEBUG)
908 
909 typedef enum nat_log_level_t_
910 {
911 #define _(n,f) SNAT_##f = n,
913 #undef _
915 
916 #define nat_elog(_level, _str) \
917 do \
918  { \
919  snat_main_t *sm = &snat_main; \
920  if (PREDICT_FALSE (sm->log_level >= _level)) \
921  { \
922  ELOG_TYPE_DECLARE (e) = \
923  { \
924  .format = "nat-msg " _str, \
925  .format_args = "", \
926  }; \
927  ELOG_DATA (&vlib_global_main.elog_main, e); \
928  } \
929  } while (0);
930 
931 #define nat_elog_addr(_level, _str, _addr) \
932 do \
933  { \
934  if (PREDICT_FALSE (sm->log_level >= _level)) \
935  { \
936  ELOG_TYPE_DECLARE (e) = \
937  { \
938  .format = "nat-msg " _str " %d.%d.%d.%d", \
939  .format_args = "i1i1i1i1", \
940  }; \
941  CLIB_PACKED(struct \
942  { \
943  u8 oct1; \
944  u8 oct2; \
945  u8 oct3; \
946  u8 oct4; \
947  }) *ed; \
948  ed = ELOG_DATA (&vlib_global_main.elog_main, e); \
949  ed->oct4 = _addr >> 24; \
950  ed->oct3 = _addr >> 16; \
951  ed->oct2 = _addr >> 8; \
952  ed->oct1 = _addr; \
953  } \
954  } while (0);
955 
956 #define nat_elog_debug_handoff(_str, _tid, _fib, _src, _dst) \
957 do \
958  { \
959  if (PREDICT_FALSE (sm->log_level >= SNAT_LOG_DEBUG)) \
960  { \
961  ELOG_TYPE_DECLARE (e) = \
962  { \
963  .format = "nat-msg " _str " ip src: %d.%d.%d.%d dst: %d.%d.%d.%d" \
964  " tid from: %d to: %d fib: %d", \
965  .format_args = "i1i1i1i1i1i1i1i1i4i4i4", \
966  }; \
967  CLIB_PACKED(struct \
968  { \
969  u8 src_oct1; \
970  u8 src_oct2; \
971  u8 src_oct3; \
972  u8 src_oct4; \
973  u8 dst_oct1; \
974  u8 dst_oct2; \
975  u8 dst_oct3; \
976  u8 dst_oct4; \
977  u32 ftid; \
978  u32 ttid; \
979  u32 fib; \
980  }) *ed; \
981  ed = ELOG_DATA (&vlib_global_main.elog_main, e); \
982  ed->src_oct1 = _src >> 24; \
983  ed->src_oct2 = _src >> 16; \
984  ed->src_oct3 = _src >> 8; \
985  ed->src_oct4 = _src; \
986  ed->dst_oct1 = _dst >> 24; \
987  ed->dst_oct2 = _dst >> 16; \
988  ed->dst_oct3 = _dst >> 8; \
989  ed->dst_oct4 = _dst; \
990  ed->ftid = vlib_get_thread_index (); \
991  ed->ttid = _tid; \
992  ed->fib = _fib; \
993  } \
994  } while (0);
995 
996 #define nat_elog_debug_handoff_v2(_str, _prt, _fib, _src, _dst) \
997 do \
998  { \
999  if (PREDICT_FALSE (sm->log_level >= SNAT_LOG_DEBUG)) \
1000  { \
1001  ELOG_TYPE_DECLARE (e) = \
1002  { \
1003  .format = "nat-msg " _str " ip_src:%d.%d.%d.%d ip_dst:%d.%d.%d.%d" \
1004  " tid:%d prt:%d fib:%d", \
1005  .format_args = "i1i1i1i1i1i1i1i1i4i4i4", \
1006  }; \
1007  CLIB_PACKED(struct \
1008  { \
1009  u8 src_oct1; \
1010  u8 src_oct2; \
1011  u8 src_oct3; \
1012  u8 src_oct4; \
1013  u8 dst_oct1; \
1014  u8 dst_oct2; \
1015  u8 dst_oct3; \
1016  u8 dst_oct4; \
1017  u32 tid; \
1018  u32 prt; \
1019  u32 fib; \
1020  }) *ed; \
1021  ed = ELOG_DATA (&vlib_global_main.elog_main, e); \
1022  ed->src_oct1 = _src >> 24; \
1023  ed->src_oct2 = _src >> 16; \
1024  ed->src_oct3 = _src >> 8; \
1025  ed->src_oct4 = _src; \
1026  ed->dst_oct1 = _dst >> 24; \
1027  ed->dst_oct2 = _dst >> 16; \
1028  ed->dst_oct3 = _dst >> 8; \
1029  ed->dst_oct4 = _dst; \
1030  ed->tid = vlib_get_thread_index (); \
1031  ed->prt = _prt; \
1032  ed->fib = _fib; \
1033  } \
1034  } while (0);
1035 
1036 #define nat_elog_X1(_level, _fmt, _arg, _val1) \
1037 do \
1038  { \
1039  snat_main_t *sm = &snat_main; \
1040  if (PREDICT_FALSE (sm->log_level >= _level)) \
1041  { \
1042  ELOG_TYPE_DECLARE (e) = \
1043  { \
1044  .format = "nat-msg " _fmt, \
1045  .format_args = _arg, \
1046  }; \
1047  CLIB_PACKED(struct \
1048  { \
1049  typeof (_val1) val1; \
1050  }) *ed; \
1051  ed = ELOG_DATA (&vlib_global_main.elog_main, e); \
1052  ed->val1 = _val1; \
1053  } \
1054  } while (0);
1055 
1056 #define nat_elog_notice(nat_elog_str) \
1057  nat_elog(SNAT_LOG_INFO, "[notice] " nat_elog_str)
1058 #define nat_elog_warn(nat_elog_str) \
1059  nat_elog(SNAT_LOG_WARNING, "[warning] " nat_elog_str)
1060 #define nat_elog_err(nat_elog_str) \
1061  nat_elog(SNAT_LOG_ERROR, "[error] " nat_elog_str)
1062 #define nat_elog_debug(nat_elog_str) \
1063  nat_elog(SNAT_LOG_DEBUG, "[debug] " nat_elog_str)
1064 #define nat_elog_info(nat_elog_str) \
1065  nat_elog(SNAT_LOG_INFO, "[info] " nat_elog_str)
1066 
1067 #define nat_elog_notice_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) \
1068  nat_elog_X1(SNAT_LOG_NOTICE, "[notice] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1)
1069 #define nat_elog_warn_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) \
1070  nat_elog_X1(SNAT_LOG_WARNING, "[warning] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1)
1071 #define nat_elog_err_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) \
1072  nat_elog_X1(SNAT_LOG_ERROR, "[error] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1)
1073 #define nat_elog_debug_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) \
1074  nat_elog_X1(SNAT_LOG_DEBUG, "[debug] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1)
1075 #define nat_elog_info_X1(nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1) \
1076  nat_elog_X1(SNAT_LOG_INFO, "[info] " nat_elog_fmt_str, nat_elog_fmt_arg, nat_elog_val1)
1077 
1078 /* ICMP session match functions */
1080  u32 thread_index, vlib_buffer_t * b0,
1081  ip4_header_t * ip0, ip4_address_t * addr,
1082  u16 * port, u32 * fib_index,
1083  nat_protocol_t * proto, void *d, void *e,
1084  u8 * dont_translate);
1086  u32 thread_index, vlib_buffer_t * b0,
1087  ip4_header_t * ip0, ip4_address_t * addr,
1088  u16 * port, u32 * fib_index,
1089  nat_protocol_t * proto, void *d, void *e,
1090  u8 * dont_translate);
1092  u32 thread_index, vlib_buffer_t * b0,
1093  ip4_header_t * ip0, ip4_address_t * addr,
1094  u16 * port, u32 * fib_index,
1095  nat_protocol_t * proto, void *d, void *e,
1096  u8 * dont_translate);
1098  u32 thread_index, vlib_buffer_t * b0,
1099  ip4_header_t * ip0, ip4_address_t * addr,
1100  u16 * port, u32 * fib_index,
1101  nat_protocol_t * proto, void *d, void *e,
1102  u8 * dont_translate);
1103 
1104 /* ICMP endpoint-dependent session match functions */
1106  u32 thread_index, vlib_buffer_t * b0,
1107  ip4_header_t * ip0, ip4_address_t * addr,
1108  u16 * port, u32 * fib_index, nat_protocol_t * proto,
1109  void *d, void *e, u8 * dont_translate);
1111  u32 thread_index, vlib_buffer_t * b0,
1112  ip4_header_t * ip0, ip4_address_t * addr,
1113  u16 * port, u32 * fib_index, nat_protocol_t * proto,
1114  void *d, void *e, u8 * dont_translate);
1115 
1117  icmp46_header_t * icmp0, u32 sw_if_index0, u32 rx_fib_index0,
1118  vlib_node_runtime_t * node, u32 next0, u32 thread_index,
1119  void *d, void *e);
1120 
1122  icmp46_header_t * icmp0, u32 sw_if_index0, u32 rx_fib_index0,
1123  vlib_node_runtime_t * node, u32 next0, u32 thread_index,
1124  void *d, void *e);
1125 
1126 /* hairpinning functions */
1128  ip4_header_t * ip0, icmp46_header_t * icmp0,
1129  int is_ed);
1131  ip4_header_t * ip);
1133  ip4_header_t * ip);
1135  snat_main_t * sm, vlib_buffer_t * b0,
1136  ip4_header_t * ip0, udp_header_t * udp0,
1137  tcp_header_t * tcp0, u32 proto0, int is_ed,
1138  int do_trace);
1139 
1140 /* Call back functions for clib_bihash_add_or_overwrite_stale */
1145 
1146 
1147 /**
1148  * @brief Enable NAT44 plugin
1149  *
1150  * @param c nat44_config_t
1151  *
1152  * @return 0 on success, non-zero value otherwise
1153  */
1155 
1156 /**
1157  * @brief Disable NAT44 plugin
1158  *
1159  * @return 0 on success, non-zero value otherwise
1160  */
1161 int nat44_plugin_disable ();
1162 
1163 /**
1164  * @brief Add external address to NAT44 pool
1165  *
1166  * @param sm snat global configuration data
1167  * @param addr IPv4 address
1168  * @param vrf_id VRF id of tenant, ~0 means independent of VRF
1169  * @param twice_nat 1 if twice NAT address
1170  *
1171  * @return 0 on success, non-zero value otherwise
1172  */
1174  u8 twice_nat);
1175 
1176 /**
1177  * @brief Delete external address from NAT44 pool
1178  *
1179  * @param sm snat global configuration data
1180  * @param addr IPv4 address
1181  * @param delete_sm 1 if delete static mapping using address
1182  * @param twice_nat 1 if twice NAT address
1183  *
1184  * @return 0 on success, non-zero value otherwise
1185  */
1186 int snat_del_address (snat_main_t * sm, ip4_address_t addr, u8 delete_sm,
1187  u8 twice_nat);
1188 
1189 /**
1190  * @brief Add/delete external address to FIB DPO (out2in DPO mode)
1191  *
1192  * @param addr IPv4 address
1193  * @param is_add 1 = add, 0 = delete
1194  *
1195  * @return 0 on success, non-zero value otherwise
1196  */
1197 void nat44_add_del_address_dpo (ip4_address_t addr, u8 is_add);
1198 
1199 /**
1200  * @brief Add/delete NAT44 static mapping
1201  *
1202  * @param l_addr local IPv4 address
1203  * @param e_addr external IPv4 address
1204  * @param l_port local port number
1205  * @param e_port external port number
1206  * @param vrf_id local VRF ID
1207  * @param addr_only 1 = 1:1NAT, 0 = 1:1NAPT
1208  * @param sw_if_index use interface address as external IPv4 address
1209  * @param proto L4 protocol
1210  * @param is_add 1 = add, 0 = delete
1211  * @param twice_nat twice-nat mode
1212  * @param out2in_only if 1 rule match only out2in direction
1213  * @param tag opaque string tag
1214  * @param identity_nat identity NAT
1215  * @param pool_addr pool IPv4 address
1216  * @param exact 1 = exact pool address
1217  *
1218  * @return 0 on success, non-zero value otherwise
1219  */
1221  u16 l_port, u16 e_port, u32 vrf_id,
1222  int addr_only, u32 sw_if_index,
1223  nat_protocol_t proto, int is_add,
1224  twice_nat_type_t twice_nat, u8 out2in_only,
1225  u8 * tag, u8 identity_nat,
1226  ip4_address_t pool_addr, int exact);
1227 
1228 /**
1229  * @brief Add/delete static mapping with load-balancing (multiple backends)
1230  *
1231  * @param e_addr external IPv4 address
1232  * @param e_port external port number
1233  * @param proto L4 protocol
1234  * @param locals list of local backends
1235  * @param is_add 1 = add, 0 = delete
1236  * @param twice_nat twice-nat mode
1237  * @param out2in_only if 1 rule match only out2in direction
1238  * @param tag opaque string tag
1239  * @param affinity 0 = disabled, otherwise client IP affinity sticky time
1240  *
1241  * @return 0 on success, non-zero value otherwise
1242  */
1244  nat_protocol_t proto,
1245  nat44_lb_addr_port_t * locals, u8 is_add,
1246  twice_nat_type_t twice_nat,
1247  u8 out2in_only, u8 * tag, u32 affinity);
1248 
1250  ip4_address_t l_addr, u16 l_port,
1251  nat_protocol_t proto, u32 vrf_id,
1252  u8 probability, u8 is_add);
1253 
1255 
1256 /**
1257  * @brief Set NAT plugin workers
1258  *
1259  * @param bitmap NAT workers bitmap
1260  *
1261  * @return 0 on success, non-zero value otherwise
1262  */
1263 int snat_set_workers (uword * bitmap);
1264 
1265 /**
1266  * @brief Enable/disable NAT44 feature on the interface
1267  *
1268  * @param sw_if_index software index of the interface
1269  * @param is_inside 1 = inside, 0 = outside
1270  * @param is_del 1 = delete, 0 = add
1271  *
1272  * @return 0 on success, non-zero value otherwise
1273  */
1274 int snat_interface_add_del (u32 sw_if_index, u8 is_inside, int is_del);
1275 
1276 /**
1277  * @brief Enable/disable NAT44 output feature on the interface (postrouting NAT)
1278  *
1279  * @param sw_if_index software index of the interface
1280  * @param is_inside 1 = inside, 0 = outside
1281  * @param is_del 1 = delete, 0 = add
1282  *
1283  * @return 0 on success, non-zero value otherwise
1284  */
1286  int is_del);
1287 
1288 /**
1289  * @brief Add/delete NAT44 pool address from specific interface
1290  *
1291  * @param sw_if_index software index of the interface
1292  * @param is_del 1 = delete, 0 = add
1293  * @param twice_nat 1 = twice NAT address for external hosts
1294  *
1295  * @return 0 on success, non-zero value otherwise
1296  */
1297 int snat_add_interface_address (snat_main_t * sm, u32 sw_if_index, int is_del,
1298  u8 twice_nat);
1299 
1300 /**
1301  * @brief Delete NAT44 session
1302  *
1303  * @param addr IPv4 address
1304  * @param port L4 port number
1305  * @param proto L4 protocol
1306  * @param vrf_id VRF ID
1307  * @param is_in 1 = inside network address and port pair, 0 = outside
1308  *
1309  * @return 0 on success, non-zero value otherwise
1310  */
1311 int nat44_del_session (snat_main_t * sm, ip4_address_t * addr, u16 port,
1312  nat_protocol_t proto, u32 vrf_id, int is_in);
1313 
1314 /**
1315  * @brief Delete NAT44 endpoint-dependent session
1316  *
1317  * @param sm snat global configuration data
1318  * @param addr IPv4 address
1319  * @param port L4 port number
1320  * @param proto L4 protocol
1321  * @param vrf_id VRF ID
1322  * @param is_in 1 = inside network address and port pair, 0 = outside
1323  *
1324  * @return 0 on success, non-zero value otherwise
1325  */
1326 int nat44_del_ed_session (snat_main_t * sm, ip4_address_t * addr, u16 port,
1327  ip4_address_t * eh_addr, u16 eh_port, u8 proto,
1328  u32 vrf_id, int is_in);
1329 
1330 /**
1331  * @brief Free NAT44 session data (lookup keys, external address port)
1332  *
1333  * @param sm snat global configuration data
1334  * @param s NAT session
1335  * @param thread_index thread index
1336  * @param is_ha is HA event
1337  */
1338 void nat_free_session_data (snat_main_t * sm, snat_session_t * s,
1339  u32 thread_index, u8 is_ha);
1340 
1341 /**
1342  * @brief Set NAT44 session limit (session limit, vrf id)
1343  *
1344  * @param session_limit Session limit
1345  * @param vrf_id VRF id
1346  * @return 0 on success, non-zero value otherwise
1347  */
1348 int nat44_set_session_limit (u32 session_limit, u32 vrf_id);
1349 
1350 /**
1351  * @brief Update NAT44 session limit flushing all data (session limit, vrf id)
1352  *
1353  * @param session_limit Session limit
1354  * @param vrf_id VRF id
1355  * @return 0 on success, non-zero value otherwise
1356  */
1357 int nat44_update_session_limit (u32 session_limit, u32 vrf_id);
1358 
1359 /**
1360  * @brief Initialize NAT44 data
1361  *
1362  * @param tsm per thread data
1363  */
1365 
1366 /**
1367  * @brief Free NAT44 data
1368  *
1369  * @param tsm per thread data
1370  */
1372 
1373 /**
1374  * @brief Delete specific NAT44 EI user and his sessions
1375  *
1376  * @param addr IPv4 address
1377  * @param fib_index FIB table index
1378  */
1379 int nat44_ei_user_del (ip4_address_t * addr, u32 fib_index);
1380 
1381 /**
1382  * @brief Free all NAT44 sessions
1383  */
1384 void nat44_sessions_clear ();
1385 
1386 /**
1387  * @brief Find or create NAT user
1388  *
1389  * @param sm snat global configuration data
1390  * @param addr IPv4 address
1391  * @param fib_index FIB table index
1392  * @param thread_index thread index
1393  *
1394  * @return NAT user data structure on success otherwise zero value
1395  */
1397  ip4_address_t * addr, u32 fib_index,
1398  u32 thread_index);
1399 
1400 /**
1401  * @brief Allocate new NAT session or recycle last used
1402  *
1403  * @param sm snat global configuration data
1404  * @param u NAT user
1405  * @param thread_index thread index
1406  * @param now time now
1407  *
1408  * @return session data structure on success otherwise zero value
1409  */
1410 snat_session_t *nat_session_alloc_or_recycle (snat_main_t * sm,
1411  snat_user_t * u,
1412  u32 thread_index, f64 now);
1413 
1414 /**
1415  * @brief Set address and port assignment algorithm for MAP-E CE
1416  *
1417  * @param psid Port Set Identifier value
1418  * @param psid_offset number of offset bits
1419  * @param psid_length length of PSID
1420  */
1422  u16 psid_length);
1423 
1424 /**
1425  * @brief Set address and port assignment algorithm for port range
1426  *
1427  * @param start_port beginning of the port range
1428  * @param end_port end of the port range
1429  */
1431 
1432 /**
1433  * @brief Set address and port assignment algorithm to default/standard
1434  */
1436 
1437 /**
1438  * @brief Free outside address and port pair
1439  *
1440  * @param addresses vector of outside addresses
1441  * @param thread_index thread index
1442  * @param key address, port and protocol
1443  */
1444 void
1445 snat_free_outside_address_and_port (snat_address_t * addresses,
1446  u32 thread_index,
1447  ip4_address_t * addr,
1448  u16 port, nat_protocol_t protocol);
1449 
1450 /**
1451  * @brief Alloc outside address and port
1452  *
1453  * @param addresses vector of outside addresses
1454  * @param fib_index FIB table index
1455  * @param thread_index thread index
1456  * @param port_per_thread number of ports per thread
1457  * @param snat_thread_index NAT thread index
1458  *
1459  * @return 0 on success, non-zero value otherwise
1460  */
1461 int snat_alloc_outside_address_and_port (snat_address_t * addresses,
1462  u32 fib_index,
1463  u32 thread_index,
1464  nat_protocol_t proto,
1465  ip4_address_t * addr,
1466  u16 * port,
1467  u16 port_per_thread,
1468  u32 snat_thread_index);
1469 
1470 void expire_per_vrf_sessions (u32 fib_index);
1471 
1472 /**
1473  * @brief Match NAT44 static mapping.
1474  *
1475  * @param key address and port to match
1476  * @param addr external/local address of the matched mapping
1477  * @param port port of the matched mapping
1478  * @param fib_index fib index of the matched mapping
1479  * @param by_external if 0 match by local address otherwise match by external
1480  * address
1481  * @param is_addr_only 1 if matched mapping is address only
1482  * @param twice_nat matched mapping is twice NAT type
1483  * @param lb 1 if matched mapping is load-balanced
1484  * @param ext_host_addr external host address
1485  * @param is_identity_nat 1 if indentity mapping
1486  * @param out if !=0 set to pointer of the mapping structure
1487  *
1488  * @returns 0 if match found otherwise 1.
1489  */
1491  ip4_address_t match_addr,
1492  u16 match_port,
1493  u32 match_fib_index,
1494  nat_protocol_t match_protocol,
1495  ip4_address_t * mapping_addr,
1496  u16 * mapping_port,
1497  u32 * mapping_fib_index,
1498  u8 by_external,
1499  u8 * is_addr_only,
1500  twice_nat_type_t * twice_nat,
1501  lb_nat_type_t * lb,
1502  ip4_address_t * ext_host_addr,
1503  u8 * is_identity_nat,
1504  snat_static_mapping_t ** out);
1505 
1506 /**
1507  * @brief Add/del NAT address to FIB.
1508  *
1509  * Add the external NAT address to the FIB as receive entries. This ensures
1510  * that VPP will reply to ARP for this address and we don't need to enable
1511  * proxy ARP on the outside interface.
1512  *
1513  * @param addr IPv4 address
1514  * @param plen address prefix length
1515  * @param sw_if_index software index of the outside interface
1516  * @param is_add 0 = delete, 1 = add.
1517  */
1519  u8 p_len, u32 sw_if_index, int is_add);
1520 
1521 void
1522 nat_ha_sadd_cb (ip4_address_t * in_addr, u16 in_port,
1523  ip4_address_t * out_addr, u16 out_port,
1524  ip4_address_t * eh_addr, u16 eh_port,
1525  ip4_address_t * ehn_addr, u16 ehn_port, u8 proto,
1526  u32 fib_index, u16 flags, u32 thread_index);
1527 
1528 void
1529 nat_ha_sdel_cb (ip4_address_t * out_addr, u16 out_port,
1530  ip4_address_t * eh_addr, u16 eh_port, u8 proto, u32 fib_index,
1531  u32 ti);
1532 
1533 void
1534 nat_ha_sref_cb (ip4_address_t * out_addr, u16 out_port,
1535  ip4_address_t * eh_addr, u16 eh_port, u8 proto, u32 fib_index,
1536  u32 total_pkts, u64 total_bytes, u32 thread_index);
1537 
1538 void
1539 nat_ha_sadd_ed_cb (ip4_address_t * in_addr, u16 in_port,
1540  ip4_address_t * out_addr, u16 out_port,
1541  ip4_address_t * eh_addr, u16 eh_port,
1542  ip4_address_t * ehn_addr, u16 ehn_port, u8 proto,
1543  u32 fib_index, u16 flags, u32 thread_index);
1544 
1545 void
1546 nat_ha_sdel_ed_cb (ip4_address_t * out_addr, u16 out_port,
1547  ip4_address_t * eh_addr, u16 eh_port, u8 proto,
1548  u32 fib_index, u32 ti);
1549 
1550 void
1551 nat_ha_sdel_ed_cb (ip4_address_t * out_addr, u16 out_port,
1552  ip4_address_t * eh_addr, u16 eh_port, u8 proto,
1553  u32 fib_index, u32 ti);
1554 
1555 void
1556 nat_ha_sref_ed_cb (ip4_address_t * out_addr, u16 out_port,
1557  ip4_address_t * eh_addr, u16 eh_port, u8 proto,
1558  u32 fib_index, u32 total_pkts, u64 total_bytes,
1559  u32 thread_index);
1560 
1561 /*
1562  * Why is this here? Because we don't need to touch this layer to
1563  * simply reply to an icmp. We need to change id to a unique
1564  * value to NAT an echo request/reply.
1565  */
1566 
1567 typedef struct
1568 {
1569  u16 identifier;
1570  u16 sequence;
1572 
1573 typedef struct
1574 {
1577 
1578 u8 *format_user_kvp (u8 * s, va_list * args);
1579 
1580 #endif /* __included_nat_h__ */
1581 /*
1582  * fd.io coding-style-patch-verification: ON
1583  *
1584  * Local Variables:
1585  * eval: (c-set-style "gnu")
1586  * End:
1587  */
ip4_address_t external_addr
Definition: nat.h:386
int snat_del_address(snat_main_t *sm, ip4_address_t addr, u8 delete_sm, u8 twice_nat)
Delete external address from NAT44 pool.
Definition: nat.c:1750
int snat_static_mapping_match(snat_main_t *sm, 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, twice_nat_type_t *twice_nat, lb_nat_type_t *lb, ip4_address_t *ext_host_addr, u8 *is_identity_nat, snat_static_mapping_t **out)
Match NAT44 static mapping.
Definition: nat.c:3183
#define foreach_nat_addr_and_port_alloc_alg
Definition: nat.h:118
void nat_ha_sref_cb(ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, u8 proto, u32 fib_index, u32 total_pkts, u64 total_bytes, u32 thread_index)
Definition: nat.c:4050
u32 sessions
Definition: nat.h:75
nat_outside_fib_t * outside_fibs
Definition: nat.h:565
vlib_node_registration_t nat_default_node
(constructor) VLIB_REGISTER_NODE (nat_default_node)
Definition: nat.c:4737
enum fib_source_t_ fib_source_t
The different sources that can create a route.
u32 * max_translations_per_fib
Definition: nat.h:643
nat_addr_and_port_alloc_alg_t
Definition: nat.h:123
dlist_elt_t * lru_pool
Definition: nat.h:459
u32 sessions_per_user_list_head_index
Definition: nat.h:314
clib_bihash_16_8_t out2in_ed
Definition: nat.h:541
int snat_interface_add_del(u32 sw_if_index, u8 is_inside, int is_del)
Enable/disable NAT44 feature on the interface.
Definition: nat.c:1976
u32 icmp_out2in(snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, icmp46_header_t *icmp0, u32 sw_if_index0, u32 rx_fib_index0, vlib_node_runtime_t *node, u32 next0, u32 thread_index, void *d, void *e)
Definition: out2in.c:519
u32 hairpin_dst_node_index
Definition: nat.h:618
void snat_free_outside_address_and_port(snat_address_t *addresses, u32 thread_index, ip4_address_t *addr, u16 port, nat_protocol_t protocol)
Free outside address and port pair.
Definition: nat.c:3108
u32 arc_next_index
Definition: nat.h:100
u32 ed_hairpinning_node_index
Definition: nat.h:620
u32 icmp_match_out2in_ed(snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
Definition: out2in_ed.c:543
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105
nat_timeouts_t timeouts
Definition: nat.h:653
int nat44_add_del_lb_static_mapping(ip4_address_t e_addr, u16 e_port, nat_protocol_t proto, nat44_lb_addr_port_t *locals, u8 is_add, twice_nat_type_t twice_nat, u8 out2in_only, u8 *tag, u32 affinity)
Add/delete static mapping with load-balancing (multiple backends)
Definition: nat.c:1365
u32 fq_in2out_output_index
Definition: nat.h:582
u16 start_port
Definition: nat.h:558
#define TCP_FLAG_SYN
Definition: fa_node.h:13
u32 ed_out2in_node_index
Definition: nat.h:610
int() nat_alloc_out_addr_and_port_function_t(snat_address_t *addresses, u32 fib_index, u32 thread_index, nat_protocol_t proto, ip4_address_t *addr, u16 *port, u16 port_per_thread, u32 snat_thread_index)
Definition: nat.h:502
u32 ei_in2out_output_node_index
Definition: nat.h:608
snat_session_t * nat_session_alloc_or_recycle(snat_main_t *sm, snat_user_t *u, u32 thread_index, f64 now)
Allocate new NAT session or recycle last used.
Definition: nat.c:574
u32 nsessions
Definition: nat.h:315
#define foreach_snat_session_state
Definition: nat.h:131
unsigned long u64
Definition: types.h:89
vl_api_ip_port_and_mask_t dst_port
Definition: flow_types.api:92
ip4_address_t addr
Definition: nat.h:348
vl_api_ip_proto_t protocol
Definition: lb_types.api:72
int snat_add_interface_address(snat_main_t *sm, u32 sw_if_index, int is_del, u8 twice_nat)
Add/delete NAT44 pool address from specific interface.
Definition: nat.c:4554
enum nat_log_level_t_ nat_log_level_t
per_vrf_sessions_t * per_vrf_sessions_vec
Definition: nat.h:472
u16 port_per_thread
Definition: nat.h:526
format_function_t format_nat_protocol
Definition: nat.h:777
u32 nstaticsessions
Definition: nat.h:316
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, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
Get address and port values to be used for ICMP packet translation.
Definition: in2out.c:572
u32 ed_out2in_slowpath_node_index
Definition: nat.h:615
vlib_node_registration_t nat44_ed_in2out_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_node)
Definition: in2out_ed.c:1496
u32 vrf_id
Definition: nat44.api:1029
#define foreach_nat_in2out_ed_error
Definition: nat.h:150
nat_protocol_t proto
Definition: nat.h:397
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, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
Definition: nat.h:479
vlib_main_t * vm
Definition: in2out_ed.c:1580
int nat44_i2o_ed_is_idle_session_cb(clib_bihash_kv_16_8_t *kv, void *arg)
Definition: in2out_ed.c:75
u32 fib_index
Definition: nat.h:313
format_function_t format_snat_static_mapping
Definition: nat.h:772
format_function_t format_snat_key
Definition: nat.h:775
nat_protocol_t
Definition: lib.h:63
nat_log_level_t_
Definition: nat.h:909
nat_alloc_out_addr_and_port_function_t * alloc_addr_and_port
Definition: nat.h:550
NAT port/address allocation lib.
dlist_elt_t * list_pool
Definition: nat.h:456
struct _tcp_header tcp_header_t
int snat_hairpinning(vlib_main_t *vm, vlib_node_runtime_t *node, snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, udp_header_t *udp0, tcp_header_t *tcp0, u32 proto0, int is_ed, int do_trace)
u32 max_translations_per_thread
Definition: nat.h:642
vhost_vring_addr_t addr
Definition: vhost_user.h:111
vlib_simple_counter_main_t hairpinning
Definition: nat.h:712
#define foreach_nat44_config_flag
Definition: nat.h:46
unsigned char u8
Definition: types.h:56
u8 enabled
Definition: nat.h:733
struct snat_main_s::@91::@92::@95 out2in
u32 handoff_in2out_index
Definition: nat.h:590
nat44_lb_addr_port_t * locals
Definition: nat.h:405
int snat_set_workers(uword *bitmap)
Set NAT plugin workers.
Definition: nat.c:2457
nat_fib_t * fibs
Definition: nat.h:562
u32 user_buckets
Definition: nat.h:645
double f64
Definition: types.h:142
clib_bihash_8_8_t user_hash
Definition: nat.h:447
u32 cached_sw_if_index
Definition: nat.h:746
u32 ed_in2out_output_node_index
Definition: nat.h:612
u32 next_index
Definition: nat.h:99
void nat_set_alloc_addr_and_port_mape(u16 psid, u16 psid_offset, u16 psid_length)
Set address and port assignment algorithm for MAP-E CE.
Definition: nat.c:4698
u8 *() format_function_t(u8 *s, va_list *args)
Definition: format.h:48
u32 max_translations_per_user
Definition: nat.h:646
clib_bihash_8_8_t in2out
Definition: nat.h:441
fib_source_t fib_src_hi
Definition: nat.h:729
Definition: nat.h:94
u32 in2out_output_node_index
Definition: nat.h:599
u32 ed_in2out_node_index
Definition: nat.h:611
u32 vlib_log_class_t
Definition: vlib.h:51
snat_get_worker_out2in_function_t * worker_out2in_cb
Definition: nat.h:525
vlib_node_registration_t snat_out2in_node
(constructor) VLIB_REGISTER_NODE (snat_out2in_node)
Definition: out2in.c:1374
#define TCP_FLAG_ACK
Definition: fa_node.h:16
int nat44_set_session_limit(u32 session_limit, u32 vrf_id)
Set NAT44 session limit (session limit, vrf id)
Definition: nat.c:4253
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, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
Get address and port values to be used for ICMP packet translation and create session if needed...
Definition: in2out.c:453
fib_source_t nat_fib_src_hi
Definition: dslite.c:22
u32 translation_buckets
Definition: nat.h:641
lb_nat_type_t
Definition: nat.h:369
ip4_address_t addr
Definition: nat.h:312
void nat44_db_free(snat_main_per_thread_data_t *tsm)
Free NAT44 data.
Definition: nat.c:4347
struct snat_main_s::@91::@92::@94 in2out
int snat_add_address(snat_main_t *sm, ip4_address_t *addr, u32 vrf_id, u8 twice_nat)
Add external address to NAT44 pool.
Definition: nat.c:680
const cJSON *const b
Definition: cJSON.h:255
ip4_main_t * ip4_main
Definition: nat.h:726
void nat44_sessions_clear()
Free all NAT44 sessions.
Definition: nat.c:4372
unsigned int u32
Definition: types.h:88
#define foreach_nat44_handoff_error
Definition: nat.h:166
A collection of simple counters.
Definition: counter.h:57
vlib_node_registration_t snat_in2out_output_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_output_node)
Definition: in2out.c:1674
ip4_address_t local_addr
Definition: nat.h:384
vlib_node_registration_t snat_in2out_output_worker_handoff_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_output_worker_handoff_node)
u32 inside_vrf
Definition: nat.h:68
fib_source_t nat_fib_src_low
u32() snat_get_worker_out2in_function_t(vlib_buffer_t *b, ip4_header_t *ip, u32 rx_fib_index, u8 is_output)
Definition: nat.h:496
twice_nat_type_t twice_nat
Definition: nat.h:392
void nat_ha_sadd_cb(ip4_address_t *in_addr, u16 in_port, ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, ip4_address_t *ehn_addr, u16 ehn_port, u8 proto, u32 fib_index, u16 flags, u32 thread_index)
Definition: nat.c:3932
u32 * auto_add_sw_if_indices_twice_nat
Definition: nat.h:572
vlib_node_registration_t nat44_ed_out2in_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_out2in_node)
Definition: out2in_ed.c:1511
u32 fib_index
Definition: nat.h:341
u32 handoff_in2out_output_index
Definition: nat.h:591
nat_addr_and_port_alloc_alg_t addr_and_port_alloc_alg
Definition: nat.h:552
#define foreach_nat_out2in_ed_error
Definition: nat.h:179
vl_api_ip_proto_t proto
Definition: acl_types.api:51
u16 mss_clamping
Definition: nat.h:656
unsigned short u16
Definition: types.h:57
u32 pre_in2out_node_index
Definition: nat.h:595
u8 out2in_dpo
Definition: nat.h:633
u8 out2in_dpo
Definition: nat.h:66
snat_static_mapping_t * static_mappings
Definition: nat.h:538
nat44_config_flags_t_
Definition: nat.h:53
u32 inside_fib_index
Definition: nat.h:651
struct snat_main_s::@91 counters
enum nat44_config_flags_t_ nat44_config_flags_t
u8 static_mapping_only
Definition: nat.h:635
int nat44_del_ed_session(snat_main_t *sm, ip4_address_t *addr, u16 port, ip4_address_t *eh_addr, u16 eh_port, u8 proto, u32 vrf_id, int is_in)
Delete NAT44 endpoint-dependent session.
Definition: nat.c:4660
int nat44_plugin_disable()
Disable NAT44 plugin.
Definition: nat.c:3009
nat_next_t
Definition: nat.h:81
void nat_free_session_data(snat_main_t *sm, snat_session_t *s, u32 thread_index, u8 is_ha)
Free NAT44 session data (lookup keys, external address port)
Definition: nat.c:376
void nat_set_alloc_addr_and_port_default(void)
Set address and port assignment algorithm to default/standard.
Definition: nat.c:4721
#define always_inline
Definition: ipsec.h:28
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:651
u32 hairpin_src_node_index
Definition: nat.h:619
clib_bihash_8_8_t static_mapping_by_external
Definition: nat.h:535
u32 in2out_slowpath_output_node_index
Definition: nat.h:603
u8 psid_offset
Definition: nat.h:554
struct snat_main_s snat_main_t
struct snat_main_s::@91::@93 slowpath
uword() unformat_function_t(unformat_input_t *input, va_list *args)
Definition: format.h:232
u32 handoff_out2in_index
Definition: nat.h:589
nat44_handoff_error_t
Definition: nat.h:171
api_main_t * api_main
Definition: nat.h:725
u8 psid_length
Definition: nat.h:555
u32 refcount
Definition: nat.h:342
vnet_main_t * vnet_main
Definition: nat.h:735
u32 inside_vrf_id
Definition: nat.h:650
Definition: nat.h:374
u32 snat_icmp_hairpinning(snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, icmp46_header_t *icmp0, int is_ed)
u8 translation_memory_size_set
Definition: nat.h:639
void nat_ha_sref_ed_cb(ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, u8 proto, u32 fib_index, u32 total_pkts, u64 total_bytes, u32 thread_index)
Definition: nat.c:4197
u8 log_level
Definition: nat.h:722
u32 fq_out2in_index
Definition: nat.h:583
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:227
int nat44_o2i_is_idle_session_cb(clib_bihash_kv_8_8_t *kv, void *arg)
Definition: out2in.c:104
snat_interface_t * output_feature_interfaces
Definition: nat.h:545
u32 pre_out2in_node_index
Definition: nat.h:594
u32 ed_hairpin_src_node_index
Definition: nat.h:622
The fine-grained event logger allows lightweight, thread-safe event logging at minimum cost...
snat_main_t snat_main
Definition: nat.c:39
vl_api_ip_port_and_mask_t src_port
Definition: flow_types.api:91
snat_session_state_t
Definition: nat.h:143
snat_user_t * users
Definition: nat.h:450
foreach_nat_counter
Definition: nat.h:670
u32 max_users_per_thread
Definition: nat.h:644
u32 random_seed
Definition: nat.h:578
u32 fib_index
Definition: nat.h:335
svmdb_client_t * c
clib_bihash_8_8_t out2in
Definition: nat.h:440
int nat44_o2i_ed_is_idle_session_cb(clib_bihash_kv_16_8_t *kv, void *arg)
Definition: out2in_ed.c:98
u32 outside_vrf_id
Definition: nat.h:648
u8 static_mapping_connection_tracking
Definition: nat.h:636
u16 end_port
Definition: nat.h:559
format_function_t format_snat_static_map_to_resolve
Definition: nat.h:773
u32 ed_in2out_slowpath_node_index
Definition: nat.h:614
u32 error_node_index
Definition: nat.h:586
u16 psid
Definition: nat.h:556
int nat44_lb_static_mapping_add_del_local(ip4_address_t e_addr, u16 e_port, ip4_address_t l_addr, u16 l_port, nat_protocol_t proto, u32 vrf_id, u8 probability, u8 is_add)
Definition: nat.c:1599
u32 outside_fib_index
Definition: nat.h:649
u32 ei_out2in_node_index
Definition: nat.h:606
format_function_t format_nat_addr_and_port_alloc_alg
Definition: nat.h:778
void nat44_db_init(snat_main_per_thread_data_t *tsm)
Initialize NAT44 data.
Definition: nat.c:4288
8 octet key, 8 octet key value pair
Definition: bihash_8_8.h:41
void nat_ha_sadd_ed_cb(ip4_address_t *in_addr, u16 in_port, ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, ip4_address_t *ehn_addr, u16 ehn_port, u8 proto, u32 fib_index, u16 flags, u32 thread_index)
Definition: nat.c:4071
u32 ed_hairpin_dst_node_index
Definition: nat.h:621
u32 sw_if_index
Definition: nat.h:414
snat_user_t * nat_user_get_or_create(snat_main_t *sm, ip4_address_t *addr, u32 fib_index, u32 thread_index)
Find or create NAT user.
Definition: nat.c:514
u32() snat_get_worker_in2out_function_t(ip4_header_t *ip, u32 rx_fib_index, u8 is_output)
Definition: nat.h:492
nat_out2in_ed_error_t
Definition: nat.h:190
typedef CLIB_PACKED(struct { u32 ses_count;u32 rx_fib_index;u32 tx_fib_index;u8 expired;}) per_vrf_sessions_t
vlib_main_t vlib_node_runtime_t * node
Definition: in2out_ed.c:1580
void nat_ha_sdel_cb(ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, u8 proto, u32 fib_index, u32 ti)
Definition: nat.c:4021
u32 * auto_add_sw_if_indices
Definition: nat.h:571
u32 in2out_fast_node_index
Definition: nat.h:601
nat44_config_t rconfig
Definition: nat.h:624
void nat44_add_del_address_dpo(ip4_address_t addr, u8 is_add)
Add/delete external address to FIB DPO (out2in DPO mode)
Definition: nat.c:3545
unformat_function_t unformat_nat_protocol
Definition: nat.h:780
u32 num_workers
Definition: nat.h:521
Definition: nat.h:364
void nat_ha_sdel_ed_cb(ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, u8 proto, u32 fib_index, u32 ti)
Definition: nat.c:4168
u32 first_worker_index
Definition: nat.h:522
ip4_address_t l_addr
Definition: nat.h:420
u32 in2out_slowpath_node_index
Definition: nat.h:602
snat_icmp_match_function_t * icmp_match_out2in_cb
Definition: nat.h:518
IPv4 main type.
Definition: ip4.h:107
vlib_log_class_t log_class
Definition: nat.h:720
u64 as_u64
Definition: nat.h:113
u32 users
Definition: nat.h:72
vlib_node_registration_t snat_out2in_worker_handoff_node
(constructor) VLIB_REGISTER_NODE (snat_out2in_worker_handoff_node)
ip4_address_t addr
Definition: nat.h:110
int nat44_plugin_enable(nat44_config_t c)
Enable NAT44 plugin.
Definition: nat.c:2843
u32 fq_in2out_index
Definition: nat.h:581
u32 icmp_match_in2out_ed(snat_main_t *sm, vlib_node_runtime_t *node, u32 thread_index, vlib_buffer_t *b0, ip4_header_t *ip0, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
Definition: in2out_ed.c:646
u32 out2in_node_index
Definition: nat.h:597
ip4_address_t addr
Definition: nat.h:321
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, nat_protocol_t proto, int is_add, twice_nat_type_t twice_nat, u8 out2in_only, u8 *tag, u8 identity_nat, ip4_address_t pool_addr, int exact)
Add/delete NAT44 static mapping.
Definition: nat.c:920
snat_address_t * twice_nat_addresses
Definition: nat.h:568
u8 static_mapping_only
Definition: nat.h:63
Definition: nat.h:333
format_function_t format_snat_session
Definition: nat.h:774
struct _vlib_node_registration vlib_node_registration_t
u8 endpoint_dependent
Definition: nat.h:65
Definition: nat.h:372
u8 connection_tracking
Definition: nat.h:64
vlib_simple_counter_main_t total_users
Definition: nat.h:659
int nat44_del_session(snat_main_t *sm, ip4_address_t *addr, u16 port, nat_protocol_t proto, u32 vrf_id, int is_in)
Delete NAT44 session.
Definition: nat.c:4622
struct snat_main_s::@91::@92 fastpath
void nat_hairpinning_sm_unknown_proto(snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip)
vl_api_address_t ip
Definition: l2.api:501
format_function_t format_static_mapping_key
Definition: nat.h:776
clib_error_t * nat44_api_hookup(vlib_main_t *vm)
Definition: nat44_api.c:1706
u32 ref_count
Definition: nat.h:336
twice_nat_type_t
Definition: nat.h:359
u32 hairpinning_node_index
Definition: nat.h:617
u16 msg_id_base
Definition: nat.h:717
vlib_node_registration_t nat_pre_in2out_node
(constructor) VLIB_REGISTER_NODE (nat_pre_in2out_node)
Definition: in2out_ed.c:1594
int nat44_ei_user_del(ip4_address_t *addr, u32 fib_index)
Delete specific NAT44 EI user and his sessions.
Definition: nat.c:328
VLIB buffer representation.
Definition: buffer.h:102
u32 * workers
Definition: nat.h:523
u64 uword
Definition: types.h:112
snat_main_per_thread_data_t * per_thread_data
Definition: nat.h:529
void expire_per_vrf_sessions(u32 fib_index)
Definition: nat.c:1917
int nat44_update_session_limit(u32 session_limit, u32 vrf_id)
Update NAT44 session limit flushing all data (session limit, vrf id)
Definition: nat.c:4272
int nat44_i2o_is_idle_session_cb(clib_bihash_kv_8_8_t *kv, void *arg)
Definition: in2out.c:188
u32 outside_vrf
Definition: nat.h:69
ip4_address_t pool_addr
Definition: nat.h:382
u32 affinity_per_service_list_head_index
Definition: nat.h:407
u32 fib_index
Definition: nat.h:111
snat_address_t * addresses
Definition: nat.h:548
u16 port
Definition: lb_types.api:73
u32 out2in_fast_node_index
Definition: nat.h:604
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, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
Get address and port values to be used for ICMP packet translation and create session if needed...
Definition: out2in.c:318
void nat_set_alloc_addr_and_port_range(u16 start_port, u16 end_port)
Set address and port assignment algorithm for port range.
Definition: nat.c:4710
u32 in2out_node_index
Definition: nat.h:598
format_function_t format_snat_user
Definition: nat.h:771
snat_get_worker_in2out_function_t * worker_in2out_cb
Definition: nat.h:524
snat_static_map_resolve_t * to_resolve
Definition: nat.h:575
u32 user_sessions
Definition: nat.h:78
u8 * format_user_kvp(u8 *s, va_list *args)
Definition: nat.c:222
void nat44_ed_hairpinning_unknown_proto(snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip)
vl_api_dhcp_client_state_t state
Definition: dhcp.api:201
vlib_node_registration_t snat_in2out_worker_handoff_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_worker_handoff_node)
u8 forwarding_enabled
Definition: nat.h:628
int snat_interface_add_del_output_feature(u32 sw_if_index, u8 is_inside, int is_del)
Enable/disable NAT44 output feature on the interface (postrouting NAT)
Definition: nat.c:2242
nat_protocol_t proto
Definition: nat.h:426
u32 icmp_in2out(snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, icmp46_header_t *icmp0, u32 sw_if_index0, u32 rx_fib_index0, vlib_node_runtime_t *node, u32 next0, u32 thread_index, void *d, void *e)
Definition: in2out.c:642
clib_bihash_16_8_t in2out_ed
Definition: nat.h:444
u32 ei_in2out_node_index
Definition: nat.h:607
u8 endpoint_dependent
Definition: nat.h:631
struct snat_main_s::@91::@92::@96 in2out_ed
vlib_node_registration_t snat_in2out_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_node)
Definition: in2out.c:1642
vlib_node_registration_t nat44_ed_in2out_output_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_output_node)
Definition: in2out_ed.c:1516
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, ip4_address_t *addr, u16 *port, u32 *fib_index, nat_protocol_t *proto, void *d, void *e, u8 *dont_translate)
Get address and port values to be used for ICMP packet translation.
Definition: out2in.c:459
vlib_simple_counter_main_t total_sessions
Definition: nat.h:660
ip_lookup_main_t * ip4_lookup_main
Definition: nat.h:727
fib_source_t fib_src_low
Definition: nat.h:730
snat_session_t * sessions
Definition: nat.h:453
u32 cached_ip4_address
Definition: nat.h:747
snat_icmp_match_function_t * icmp_match_in2out_cb
Definition: nat.h:517
#define foreach_nat_log_level
Definition: nat.h:901
u8 probability
Definition: nat44.api:1028
ip4_address_t pool_addr
Definition: nat.h:421
clib_bihash_8_8_t static_mapping_by_local
Definition: nat.h:532
u32 fib_index
Definition: nat.h:322
nat_in2out_ed_error_t
Definition: nat.h:158
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
snat_interface_t * interfaces
Definition: nat.h:544
int snat_alloc_outside_address_and_port(snat_address_t *addresses, u32 fib_index, u32 thread_index, nat_protocol_t proto, ip4_address_t *addr, u16 *port, u16 port_per_thread, u32 snat_thread_index)
Alloc outside address and port.
Definition: nat.c:3343
vlib_node_registration_t nat_pre_out2in_node
(constructor) VLIB_REGISTER_NODE (nat_pre_out2in_node)
Definition: out2in_ed.c:1591
vlib_simple_counter_main_t user_limit_reached
Definition: nat.h:661
static bool tcp_flags_is_init(u8 f)
Check if client initiating TCP connection (received SYN from client)
Definition: nat.h:883