FD.io VPP  v18.10-34-gcce845e
Vector Packet Processing
nat.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 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 plugin global declarations
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 #include <vlib/log.h>
32 
33 /* default session timeouts */
34 #define SNAT_UDP_TIMEOUT 300
35 #define SNAT_TCP_TRANSITORY_TIMEOUT 240
36 #define SNAT_TCP_ESTABLISHED_TIMEOUT 7440
37 #define SNAT_ICMP_TIMEOUT 60
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 /* session key (4-tuple) */
46 typedef struct
47 {
48  union
49  {
50  struct
51  {
54  u16 protocol:3, fib_index:13;
55  };
57  };
59 
60 /* endpoint-dependent session key (6-tuple) */
61 typedef struct
62 {
63  union
64  {
65  struct
66  {
69  u32 proto:8, fib_index:24;
72  };
73  u64 as_u64[2];
74  };
76 
77 /* deterministic session outside key */
78 typedef struct
79 {
80  union
81  {
82  struct
83  {
87  };
89  };
91 
92 /* user (internal host) key */
93 typedef struct
94 {
95  union
96  {
97  struct
98  {
101  };
103  };
105 
106 typedef struct
107 {
112 
113 /* External address and port allocation modes */
114 #define foreach_nat_addr_and_port_alloc_alg \
115  _(0, DEFAULT, "default") \
116  _(1, MAPE, "map-e") \
117  _(2, RANGE, "port-range")
118 
119 typedef enum
120 {
121 #define _(v, N, s) NAT_ADDR_AND_PORT_ALLOC_ALG_##N = v,
123 #undef _
125 
126 
127 /* Supported L4 protocols */
128 #define foreach_snat_protocol \
129  _(UDP, 0, udp, "udp") \
130  _(TCP, 1, tcp, "tcp") \
131  _(ICMP, 2, icmp, "icmp")
132 
133 typedef enum
134 {
135 #define _(N, i, n, s) SNAT_PROTOCOL_##N = i,
137 #undef _
139 
140 
141 /* Session state */
142 #define foreach_snat_session_state \
143  _(0, UNKNOWN, "unknown") \
144  _(1, UDP_ACTIVE, "udp-active") \
145  _(2, TCP_SYN_SENT, "tcp-syn-sent") \
146  _(3, TCP_ESTABLISHED, "tcp-established") \
147  _(4, TCP_FIN_WAIT, "tcp-fin-wait") \
148  _(5, TCP_CLOSE_WAIT, "tcp-close-wait") \
149  _(6, TCP_CLOSING, "tcp-closing") \
150  _(7, TCP_LAST_ACK, "tcp-last-ack") \
151  _(8, TCP_CLOSED, "tcp-closed") \
152  _(9, ICMP_ACTIVE, "icmp-active")
153 
154 typedef enum
155 {
156 #define _(v, N, s) SNAT_SESSION_##N = v,
158 #undef _
160 
161 /* Endpoint dependent TCP session state */
162 #define NAT44_SES_I2O_FIN 1
163 #define NAT44_SES_O2I_FIN 2
164 #define NAT44_SES_I2O_FIN_ACK 4
165 #define NAT44_SES_O2I_FIN_ACK 8
166 #define NAT44_SES_I2O_SYN 16
167 #define NAT44_SES_O2I_SYN 32
168 #define NAT44_SES_RST 64
169 
170 /* Session flags */
171 #define SNAT_SESSION_FLAG_STATIC_MAPPING 1
172 #define SNAT_SESSION_FLAG_UNKNOWN_PROTO 2
173 #define SNAT_SESSION_FLAG_LOAD_BALANCING 4
174 #define SNAT_SESSION_FLAG_TWICE_NAT 8
175 #define SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT 16
176 #define SNAT_SESSION_FLAG_FWD_BYPASS 32
177 #define SNAT_SESSION_FLAG_AFFINITY 64
178 #define SNAT_SESSION_FLAG_OUTPUT_FEATURE 128
179 
180 /* NAT interface flags */
181 #define NAT_INTERFACE_FLAG_IS_INSIDE 1
182 #define NAT_INTERFACE_FLAG_IS_OUTSIDE 2
183 
184 /* Static mapping flags */
185 #define NAT_STATIC_MAPPING_FLAG_ADDR_ONLY 1
186 #define NAT_STATIC_MAPPING_FLAG_OUT2IN_ONLY 2
187 #define NAT_STATIC_MAPPING_FLAG_IDENTITY_NAT 4
188 #define NAT_STATIC_MAPPING_FLAG_LB 8
189 
190 /* *INDENT-OFF* */
191 typedef CLIB_PACKED(struct
192 {
193  /* Outside network key */
194  snat_session_key_t out2in;
195 
196  /* Inside network key */
197  snat_session_key_t in2out;
198 
199  /* Flags */
200  u32 flags;
201 
202  /* Per-user translations */
203  u32 per_user_index;
204  u32 per_user_list_head_index;
205 
206  /* Last heard timer */
207  f64 last_heard;
208 
209  /* Counters */
210  u64 total_bytes;
211  u32 total_pkts;
212 
213  /* External host address and port */
214  ip4_address_t ext_host_addr;
215  u16 ext_host_port;
216 
217  /* External host address and port after translation */
218  ip4_address_t ext_host_nat_addr;
219  u16 ext_host_nat_port;
220 
221  /* TCP session state */
222  u8 state;
223  u32 i2o_fin_seq;
224  u32 o2i_fin_seq;
225 }) snat_session_t;
226 /* *INDENT-ON* */
227 
228 
229 typedef struct
230 {
236 } snat_user_t;
237 
238 typedef struct
239 {
242 /* *INDENT-OFF* */
243 #define _(N, i, n, s) \
244  u16 busy_##n##_ports; \
245  u16 * busy_##n##_ports_per_thread; \
246  uword * busy_##n##_port_bitmap;
248 #undef _
249 /* *INDENT-ON* */
250 } snat_address_t;
251 
252 typedef struct
253 {
257 
258 typedef struct
259 {
260  /* Inside network port */
262  /* Outside network address and port */
264  /* Session state */
266  /* Expire timeout */
269 
270 typedef struct
271 {
272  /* inside IP address range */
275  /* outside IP address range */
278  /* inside IP addresses / outside IP addresses */
280  /* number of ports available to internal host */
282  /* session counter */
284  /* vector of sessions */
287 
288 typedef struct
289 {
290  /* backend IP address */
292  /* backend port number */
294  /* probability of the backend to be randomly matched */
297  /* backend FIB table */
301 
302 typedef enum
303 {
304  /* twice-nat disabled */
306  /* twice-nat enabled */
308  /* twice-nat only when src IP equals dst IP after translation */
311 
312 typedef enum
313 {
314  /* no load-balancing */
316  /* load-balancing */
318  /* load-balancing with affinity */
320 } lb_nat_type_t;
321 
322 typedef struct
323 {
324  /* local IP address */
326  /* external IP address */
328  /* local port */
330  /* external port */
332  /* is twice-nat */
333  twice_nat_type_t twice_nat;
334  /* local FIB table */
337  /* protocol */
338  snat_protocol_t proto;
339  /* 0 = disabled, otherwise client IP affinity sticky time in seconds */
341  /* worker threads used by backends/local host */
343  /* opaque string tag */
344  u8 *tag;
345  /* backends for load-balancing mode */
347  /* affinity per service lis */
349  /* flags */
352 
353 typedef struct
354 {
358 
359 typedef struct
360 {
366  snat_protocol_t proto;
370  int is_add;
373  u8 *tag;
375 
376 typedef struct
377 {
378  /* Main lookup tables */
379  clib_bihash_8_8_t out2in;
380  clib_bihash_8_8_t in2out;
381 
382  /* Endpoint dependent sessions lookup tables */
383  clib_bihash_16_8_t out2in_ed;
384  clib_bihash_16_8_t in2out_ed;
385 
386  /* Find-a-user => src address lookup */
387  clib_bihash_8_8_t user_hash;
388 
389  /* User pool */
391 
392  /* Session pool */
393  snat_session_t *sessions;
394 
395  /* Pool of doubly-linked list elements */
397 
398  /* NAT thread index */
401 
402 struct snat_main_s;
403 
404 /* ICMP session match function */
406  vlib_node_runtime_t * node,
407  u32 thread_index,
408  vlib_buffer_t * b0,
409  ip4_header_t * ip0, u8 * p_proto,
410  snat_session_key_t * p_value,
411  u8 * p_dont_translate, void *d,
412  void *e);
413 
414 /* Return worker thread index for given packet */
416  u32 rx_fib_index);
417 
418 /* NAT address and port allacotaion function */
419 typedef int (nat_alloc_out_addr_and_port_function_t) (snat_address_t *
420  addresses,
421  u32 fib_index,
422  u32 thread_index,
423  snat_session_key_t * k,
425  u32 snat_thread_index);
426 
427 typedef struct snat_main_s
428 {
429  /* ICMP session match functions */
432 
433  /* Thread settings */
441 
442  /* Per thread data */
444 
445  /* Find a static mapping by local */
446  clib_bihash_8_8_t static_mapping_by_local;
447 
448  /* Find a static mapping by external */
449  clib_bihash_8_8_t static_mapping_by_external;
450 
451  /* Static mapping pool */
453 
454  /* Interface pool */
457 
458  /* Vector of outside addresses */
459  snat_address_t *addresses;
460  /* Address and port allocation function */
462  /* Address and port allocation type */
463  nat_addr_and_port_alloc_alg_t addr_and_port_alloc_alg;
464  /* Port set parameters (MAP-E) */
468  /* Port range parameters */
471 
472  /* vector of outside fibs */
474 
475  /* Vector of twice NAT addresses for extenal hosts */
476  snat_address_t *twice_nat_addresses;
477 
478  /* sw_if_indices whose intfc addresses should be auto-added */
481 
482  /* vector of interface address static mappings to resolve. */
484 
485  /* Randomize port allocation order */
487 
488  /* Worker handoff frame-queue index */
492 
493  /* in2out and out2in node index */
498 
499  /* Deterministic NAT mappings */
501 
502  /* If forwarding is enabled */
504 
505  /* Config parameters */
521 
522  /* values of various timeouts */
527 
528  /* TCP MSS clamping */
531 
532  /* API message ID base */
534 
535  /* log class */
537 
538  /* convenience */
544 } snat_main_t;
545 
546 typedef struct
547 {
551 
552 typedef struct
553 {
557 
558 extern snat_main_t snat_main;
579 
580 /* format functions */
591 /* unformat functions */
593 
594 /** \brief Check if SNAT session is created from static mapping.
595  @param s SNAT session
596  @return 1 if SNAT session is created from static mapping otherwise 0
597 */
598 #define snat_is_session_static(s) (s->flags & SNAT_SESSION_FLAG_STATIC_MAPPING)
599 
600 /** \brief Check if SNAT session for unknown protocol.
601  @param s SNAT session
602  @return 1 if SNAT session for unknown protocol otherwise 0
603 */
604 #define snat_is_unk_proto_session(s) (s->flags & SNAT_SESSION_FLAG_UNKNOWN_PROTO)
605 
606 /** \brief Check if NAT session is twice NAT.
607  @param s NAT session
608  @return 1 if NAT session is twice NAT
609 */
610 #define is_twice_nat_session(s) (s->flags & SNAT_SESSION_FLAG_TWICE_NAT)
611 
612 /** \brief Check if NAT session is load-balancing.
613  @param s NAT session
614  @return 1 if NAT session is load-balancing
615 */
616 #define is_lb_session(s) (s->flags & SNAT_SESSION_FLAG_LOAD_BALANCING)
617 
618 /** \brief Check if NAT session is forwarding bypass.
619  @param s NAT session
620  @return 1 if NAT session is load-balancing
621 */
622 #define is_fwd_bypass_session(s) (s->flags & SNAT_SESSION_FLAG_FWD_BYPASS)
623 
624 /** \brief Check if NAT session is endpoint dependent.
625  @param s NAT session
626  @return 1 if NAT session is endpoint dependent
627 */
628 #define is_ed_session(s) (s->flags & SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT)
629 
630 /** \brief Check if NAT session has affinity record.
631  @param s NAT session
632  @return 1 if NAT session has affinity record
633 */
634 #define is_affinity_sessions(s) (s->flags & SNAT_SESSION_FLAG_AFFINITY)
635 
636 /** \brief Check if NAT interface is inside.
637  @param i NAT interfce
638  @return 1 if inside interface
639 */
640 #define nat_interface_is_inside(i) i->flags & NAT_INTERFACE_FLAG_IS_INSIDE
641 
642 /** \brief Check if NAT interface is outside.
643  @param i NAT interfce
644  @return 1 if outside interface
645 */
646 #define nat_interface_is_outside(i) i->flags & NAT_INTERFACE_FLAG_IS_OUTSIDE
647 
648 /** \brief Check if NAT44 endpoint-dependent TCP session is closed.
649  @param s NAT session
650  @return 1 if session is closed
651 */
652 #define nat44_is_ses_closed(s) s->state == 0xf
653 
654 /** \brief Check if NAT static mapping is address only (1:1NAT).
655  @param sm NAT static mapping
656  @return 1 if 1:1NAT, 0 if 1:1NAPT
657 */
658 #define is_addr_only_static_mapping(sm) (sm->flags & NAT_STATIC_MAPPING_FLAG_ADDR_ONLY)
659 
660 /** \brief Check if NAT static mapping match only out2in direction.
661  @param sm NAT static mapping
662  @return 1 if rule match only out2in direction
663 */
664 #define is_out2in_only_static_mapping(sm) (sm->flags & NAT_STATIC_MAPPING_FLAG_OUT2IN_ONLY)
665 
666 /** \brief Check if NAT static mapping is identity NAT.
667  @param sm NAT static mapping
668  @return 1 if identity NAT
669 */
670 #define is_identity_static_mapping(sm) (sm->flags & NAT_STATIC_MAPPING_FLAG_IDENTITY_NAT)
671 
672 /** \brief Check if NAT static mapping is load-balancing.
673  @param sm NAT static mapping
674  @return 1 if load-balancing
675 */
676 #define is_lb_static_mapping(sm) (sm->flags & NAT_STATIC_MAPPING_FLAG_LB)
677 
678 /** \brief Check if client initiating TCP connection (received SYN from client)
679  @param t TCP header
680  @return 1 if client initiating TCP connection
681 */
682 #define tcp_is_init(t) ((t->flags & TCP_FLAG_SYN) && !(t->flags & TCP_FLAG_ACK))
683 
684 /* logging */
685 #define nat_log_err(...) \
686  vlib_log(VLIB_LOG_LEVEL_ERR, snat_main.log_class, __VA_ARGS__)
687 #define nat_log_warn(...) \
688  vlib_log(VLIB_LOG_LEVEL_WARNING, snat_main.log_class, __VA_ARGS__)
689 #define nat_log_notice(...) \
690  vlib_log(VLIB_LOG_LEVEL_NOTICE, snat_main.log_class, __VA_ARGS__)
691 #define nat_log_info(...) \
692  vlib_log(VLIB_LOG_LEVEL_INFO, snat_main.log_class, __VA_ARGS__)
693 #define nat_log_debug(...)\
694  vlib_log(VLIB_LOG_LEVEL_DEBUG, snat_main.log_class, __VA_ARGS__)
695 
696 /* ICMP session match functions */
698  u32 thread_index, vlib_buffer_t * b0,
699  ip4_header_t * ip0, u8 * p_proto,
700  snat_session_key_t * p_value,
701  u8 * p_dont_translate, void *d, void *e);
703  u32 thread_index, vlib_buffer_t * b0,
704  ip4_header_t * ip0, u8 * p_proto,
705  snat_session_key_t * p_value,
706  u8 * p_dont_translate, void *d, void *e);
708  u32 thread_index, vlib_buffer_t * b0,
709  ip4_header_t * ip0, u8 * p_proto,
710  snat_session_key_t * p_value,
711  u8 * p_dont_translate, void *d, void *e);
713  u32 thread_index, vlib_buffer_t * b0,
714  ip4_header_t * ip0, u8 * p_proto,
715  snat_session_key_t * p_value,
716  u8 * p_dont_translate, void *d, void *e);
717 
718 /* ICMP deterministic NAT session match functions */
720  u32 thread_index, vlib_buffer_t * b0,
721  ip4_header_t * ip0, u8 * p_proto,
722  snat_session_key_t * p_value,
723  u8 * p_dont_translate, void *d, void *e);
725  u32 thread_index, vlib_buffer_t * b0,
726  ip4_header_t * ip0, u8 * p_proto,
727  snat_session_key_t * p_value,
728  u8 * p_dont_translate, void *d, void *e);
729 
730 /* ICMP endpoint-dependent session match functions */
732  u32 thread_index, vlib_buffer_t * b0,
733  ip4_header_t * ip0, u8 * p_proto,
734  snat_session_key_t * p_value,
735  u8 * p_dont_translate, void *d, void *e);
737  u32 thread_index, vlib_buffer_t * b0,
738  ip4_header_t * ip0, u8 * p_proto,
739  snat_session_key_t * p_value,
740  u8 * p_dont_translate, void *d, void *e);
741 
743  icmp46_header_t * icmp0, u32 sw_if_index0, u32 rx_fib_index0,
744  vlib_node_runtime_t * node, u32 next0, u32 thread_index,
745  void *d, void *e);
746 
748  icmp46_header_t * icmp0, u32 sw_if_index0, u32 rx_fib_index0,
749  vlib_node_runtime_t * node, u32 next0, u32 thread_index,
750  void *d, void *e);
751 
752 /* hairpinning functions */
754  ip4_header_t * ip0, icmp46_header_t * icmp0,
755  int is_ed);
757  ip4_header_t * ip);
759  ip4_header_t * ip);
761  ip4_header_t * ip0, udp_header_t * udp0,
762  tcp_header_t * tcp0, u32 proto0, int is_ed);
764  ip4_header_t * ip0, u16 sport, u16 dport,
765  u32 proto0, int is_ed);
766 
767 /* Call back functions for clib_bihash_add_or_overwrite_stale */
772 
773 /**
774  * @brief Increment IPv4 address
775  */
777 
778 /**
779  * @brief Add external address to NAT44 pool
780  *
781  * @param addr IPv4 address
782  * @param vrf_id VRF id of tenant, ~0 means independent of VRF
783  * @param twice_nat 1 if twice NAT address
784  *
785  * @return 0 on success, non-zero value otherwise
786  */
787 int snat_add_address (snat_main_t * sm, ip4_address_t * addr, u32 vrf_id,
788  u8 twice_nat);
789 
790 /**
791  * @brief Delete external address from NAT44 pool
792  *
793  * @param addr IPv4 address
794  * @param delete_sm 1 if delete static mapping using address
795  * @param twice_nat 1 if twice NAT address
796  *
797  * @return 0 on success, non-zero value otherwise
798  */
799 int snat_del_address (snat_main_t * sm, ip4_address_t addr, u8 delete_sm,
800  u8 twice_nat);
801 
802 /**
803  * @brief Add/delete external address to FIB DPO (out2in DPO mode)
804  *
805  * @param addr IPv4 address
806  * @param is_add 1 = add, 0 = delete
807  *
808  * @return 0 on success, non-zero value otherwise
809  */
811 
812 /**
813  * @brief Add/delete NAT44 static mapping
814  *
815  * @param l_addr local IPv4 address
816  * @param e_addr external IPv4 address
817  * @param l_port local port number
818  * @param e_port external port number
819  * @param vrf_id local VRF ID
820  * @param addr_only 1 = 1:1NAT, 0 = 1:1NAPT
821  * @param sw_if_index use interface address as external IPv4 address
822  * @param proto L4 protocol
823  * @param is_add 1 = add, 0 = delete
824  * @param twice_nat twice-nat mode
825  * @param out2in_only if 1 rule match only out2in direction
826  * @param tag opaque string tag
827  * @param identity_nat identity NAT
828  *
829  * @return 0 on success, non-zero value otherwise
830  */
832  u16 l_port, u16 e_port, u32 vrf_id,
833  int addr_only, u32 sw_if_index,
834  snat_protocol_t proto, int is_add,
835  twice_nat_type_t twice_nat, u8 out2in_only,
836  u8 * tag, u8 identity_nat);
837 
838 /**
839  * @brief Add/delete static mapping with load-balancing (multiple backends)
840  *
841  * @param e_addr external IPv4 address
842  * @param e_port external port number
843  * @param proto L4 protocol
844  * @param locals list of local backends
845  * @param is_add 1 = add, 0 = delete
846  * @param twice_nat twice-nat mode
847  * @param out2in_only if 1 rule match only out2in direction
848  * @param tag opaque string tag
849  * @param affinity 0 = disabled, otherwise client IP affinity sticky time
850  *
851  * @return 0 on success, non-zero value otherwise
852  */
854  snat_protocol_t proto,
855  nat44_lb_addr_port_t * locals, u8 is_add,
856  twice_nat_type_t twice_nat,
857  u8 out2in_only, u8 * tag, u32 affinity);
858 
860 
861 /**
862  * @brief Set NAT plugin workers
863  *
864  * @param bitmap NAT workers bitmap
865  *
866  * @return 0 on success, non-zero value otherwise
867  */
868 int snat_set_workers (uword * bitmap);
869 
870 /**
871  * @brief Enable/disable NAT44 feature on the interface
872  *
873  * @param sw_if_index software index of the interface
874  * @param is_inside 1 = inside, 0 = outside
875  * @param is_del 1 = delete, 0 = add
876  *
877  * @return 0 on success, non-zero value otherwise
878  */
879 int snat_interface_add_del (u32 sw_if_index, u8 is_inside, int is_del);
880 
881 /**
882  * @brief Enable/disable NAT44 output feature on the interface (postrouting NAT)
883  *
884  * @param sw_if_index software index of the interface
885  * @param is_inside 1 = inside, 0 = outside
886  * @param is_del 1 = delete, 0 = add
887  *
888  * @return 0 on success, non-zero value otherwise
889  */
891  int is_del);
892 
893 /**
894  * @brief Add/delete NAT44 pool address from specific interfce
895  *
896  * @param sw_if_index software index of the interface
897  * @param is_del 1 = delete, 0 = add
898  * @param twice_nat 1 = twice NAT address for extenal hosts
899  *
900  * @return 0 on success, non-zero value otherwise
901  */
903  u8 twice_nat);
904 
905 /**
906  * @brief Delete NAT44 session
907  *
908  * @param addr IPv4 address
909  * @param port L4 port number
910  * @param proto L4 protocol
911  * @param vrf_id VRF ID
912  * @param is_in 1 = inside network addres and por pair, 0 = outside
913  *
914  * @return 0 on success, non-zero value otherwise
915  */
917  snat_protocol_t proto, u32 vrf_id, int is_in);
918 
919 /**
920  * @brief Delete NAT44 endpoint-dependent session
921  *
922  * @param addr IPv4 address
923  * @param port L4 port number
924  * @param proto L4 protocol
925  * @param vrf_id VRF ID
926  * @param is_in 1 = inside network addres and por pair, 0 = outside
927  *
928  * @return 0 on success, non-zero value otherwise
929  */
931  ip4_address_t * eh_addr, u16 eh_port, u8 proto,
932  u32 vrf_id, int is_in);
933 
934 /**
935  * @brief Free NAT44 session data (lookup keys, external addrres port)
936  *
937  * @param s NAT session
938  * @param thread_index thread index
939  */
940 void nat_free_session_data (snat_main_t * sm, snat_session_t * s,
941  u32 thread_index);
942 
943 /**
944  * @brief Find or create NAT user
945  *
946  * @param addr IPv4 address
947  * @param fib_index FIB table index
948  * @param thread_index thread index
949  *
950  * @return NAT user data structure on success otherwise zero value
951  */
953  u32 fib_index, u32 thread_index);
954 
955 /**
956  * @brief Allocate new NAT session or recycle last used
957  *
958  * @param u NAT user
959  * @param thread_index thread index
960  *
961  * @return session data structure on success otherwise zero value
962  */
963 snat_session_t *nat_session_alloc_or_recycle (snat_main_t * sm,
964  snat_user_t * u,
965  u32 thread_index);
966 
967 /**
968  * @brief Allocate NAT endpoint-dependent session
969  *
970  * @param u NAT user
971  * @param thread_index thread index
972  *
973  * @return session data structure on success otherwise zero value
974  */
975 snat_session_t *nat_ed_session_alloc (snat_main_t * sm, snat_user_t * u,
976  u32 thread_index, f64 now);
977 
978 /**
979  * @brief Set address and port assignment algorithm for MAP-E CE
980  *
981  * @param psid Port Set Identifier value
982  * @param psid_offset number of offset bits
983  * @param psid_length length of PSID
984  */
986  u16 psid_length);
987 
988 /**
989  * @brief Set address and port assignment algorithm for port range
990  *
991  * @param start_port beginning of the port range
992  * @param end_port end of the port range
993  */
995 
996 /**
997  * @brief Set address and port assignment algorithm to default/standard
998  */
1000 
1001 /**
1002  * @brief Free outside address and port pair
1003  *
1004  * @param addresses vector of outside addresses
1005  * @param thread_index thread index
1006  * @param k adddress, port and protocol
1007  */
1008 void snat_free_outside_address_and_port (snat_address_t * addresses,
1009  u32 thread_index,
1010  snat_session_key_t * k);
1011 
1012 /**
1013  * @brief Alloc outside address and port
1014  *
1015  * @param addresses vector of outside addresses
1016  * @param fib_index FIB table index
1017  * @param thread_index thread index
1018  * @param k allocated address and port pair
1019  * @param port_per_thread number of ports per threead
1020  * @param snat_thread_index NAT thread index
1021  *
1022  * @return 0 on success, non-zero value otherwise
1023  */
1024 int snat_alloc_outside_address_and_port (snat_address_t * addresses,
1025  u32 fib_index,
1026  u32 thread_index,
1027  snat_session_key_t * k,
1028  u16 port_per_thread,
1029  u32 snat_thread_index);
1030 
1031 /**
1032  * @brief Match NAT44 static mapping.
1033  *
1034  * @param match address and port to match
1035  * @param mapping external/local address and port of the matched mapping
1036  * @param by_external if 0 match by local address otherwise match by external
1037  * address
1038  * @param is_addr_only 1 if matched mapping is address only
1039  * @param twice_nat matched mapping is twice NAT type
1040  * @param lb 1 if matched mapping is load-balanced
1041  * @param ext_host_addr external host address
1042  *
1043  * @returns 0 if match found otherwise 1.
1044  */
1046  snat_session_key_t match,
1047  snat_session_key_t * mapping,
1048  u8 by_external,
1049  u8 * is_addr_only,
1050  twice_nat_type_t * twice_nat,
1051  lb_nat_type_t * lb,
1052  ip4_address_t * ext_host_addr,
1053  u8 * is_identity_nat);
1054 
1055 /**
1056  * @brief Add/del NAT address to FIB.
1057  *
1058  * Add the external NAT address to the FIB as receive entries. This ensures
1059  * that VPP will reply to ARP for this address and we don't need to enable
1060  * proxy ARP on the outside interface.
1061  *
1062  * @param addr IPv4 address
1063  * @param plen address prefix length
1064  * @param sw_if_index software index of the outside interface
1065  * @param is_add 0 = delete, 1 = add.
1066  */
1068  u8 p_len, u32 sw_if_index, int is_add);
1069 
1070 
1071 /*
1072  * Why is this here? Because we don't need to touch this layer to
1073  * simply reply to an icmp. We need to change id to a unique
1074  * value to NAT an echo request/reply.
1075  */
1076 
1077 typedef struct
1078 {
1082 
1083 typedef struct
1084 {
1087 
1088 #endif /* __included_nat_h__ */
1089 
1090 /*
1091  * fd.io coding-style-patch-verification: ON
1092  *
1093  * Local Variables:
1094  * eval: (c-set-style "gnu")
1095  * End:
1096  */
ip4_address_t external_addr
Definition: nat.h:327
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:1394
u32 user_memory_size
Definition: nat.h:515
clib_error_t * snat_api_init(vlib_main_t *vm, snat_main_t *sm)
Definition: nat_api.c:3237
#define foreach_nat_addr_and_port_alloc_alg
Definition: nat.h:114
nat_outside_fib_t * outside_fibs
Definition: nat.h:473
vlib_node_registration_t snat_hairpin_src_node
(constructor) VLIB_REGISTER_NODE (snat_hairpin_src_node)
nat_addr_and_port_alloc_alg_t
Definition: nat.h:119
uword( unformat_function_t)(unformat_input_t *input, va_list *args)
Definition: format.h:232
void nat_free_session_data(snat_main_t *sm, snat_session_t *s, u32 thread_index)
Free NAT44 session data (lookup keys, external addrres port)
Definition: nat.c:177
u32 sessions_per_user_list_head_index
Definition: nat.h:233
u32 vlib_log_class_t
Definition: log.h:21
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:1508
u16 ext_host_port
Definition: nat.h:85
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:484
u16 out_port
Definition: nat.h:86
a
Definition: bitmap.h:538
u32 icmp_timeout
Definition: nat.h:526
u32 fq_in2out_output_index
Definition: nat.h:490
u16 start_port
Definition: nat.h:469
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...
u64 as_u64
Definition: bihash_doc.h:63
u32 nsessions
Definition: nat.h:234
#define foreach_snat_session_state
Definition: nat.h:142
unsigned long u64
Definition: types.h:89
ip4_address_t addr
Definition: nat.h:291
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 interfce.
Definition: nat.c:3070
snat_protocol_t proto
Definition: nat.h:338
u16 port_per_thread
Definition: nat.h:439
u32 nstaticsessions
Definition: nat.h:235
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:295
vlib_node_registration_t nat44_ed_in2out_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_node)
Definition: in2out_ed.c:75
format_function_t format_det_map_ses
Definition: nat.h:585
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:405
vlib_node_registration_t snat_det_out2in_node
(constructor) VLIB_REGISTER_NODE (snat_det_out2in_node)
int nat44_i2o_ed_is_idle_session_cb(clib_bihash_kv_16_8_t *kv, void *arg)
Definition: in2out_ed.c:149
vlib_node_registration_t nat44_ed_hairpin_src_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_hairpin_src_node)
u32 fib_index
Definition: nat.h:232
format_function_t format_snat_static_mapping
Definition: nat.h:582
format_function_t format_snat_key
Definition: nat.h:586
u8 *( format_function_t)(u8 *s, va_list *args)
Definition: format.h:48
snat_det_map_t * det_maps
Definition: nat.h:500
nat_alloc_out_addr_and_port_function_t * alloc_addr_and_port
Definition: nat.h:461
u32 num_snat_thread
Definition: nat.h:440
#define foreach_snat_protocol
Definition: nat.h:128
dlist_elt_t * list_pool
Definition: nat.h:396
u8 in_plen
Definition: nat.h:274
struct _tcp_header tcp_header_t
int snat_hairpinning(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)
vhost_vring_addr_t addr
Definition: vhost_user.h:121
unsigned char u8
Definition: types.h:56
u8 deterministic
Definition: nat.h:508
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, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
Definition: out2in_ed.c:464
u16 l_port
Definition: nat.h:70
nat44_lb_addr_port_t * locals
Definition: nat.h:346
int snat_set_workers(uword *bitmap)
Set NAT plugin workers.
Definition: nat.c:1880
u32 user_buckets
Definition: nat.h:514
double f64
Definition: types.h:142
clib_bihash_8_8_t user_hash
Definition: nat.h:387
u32 cached_sw_if_index
Definition: nat.h:554
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:3225
u32 max_translations_per_user
Definition: nat.h:516
u32( snat_get_worker_function_t)(ip4_header_t *ip, u32 rx_fib_index)
Definition: nat.h:415
clib_bihash_8_8_t in2out
Definition: nat.h:380
u32 in2out_output_node_index
Definition: nat.h:495
u16 r_port
Definition: nat.h:71
vlib_node_registration_t snat_out2in_node
(constructor) VLIB_REGISTER_NODE (snat_out2in_node)
Definition: out2in.c:1278
ip4_address_t ext_host_addr
Definition: nat.h:84
u32 sw_if_index
Definition: vxlan_gbp.api:39
u32 translation_buckets
Definition: nat.h:511
lb_nat_type_t
Definition: nat.h:312
ip4_address_t addr
Definition: nat.h:231
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:493
ip4_main_t * ip4_main
Definition: nat.h:541
vhost_vring_state_t state
Definition: vhost_user.h:120
unsigned int u32
Definition: types.h:88
vlib_node_registration_t snat_in2out_output_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_output_node)
Definition: in2out.c:77
ip4_address_t local_addr
Definition: nat.h:325
vlib_node_registration_t snat_in2out_output_worker_handoff_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_output_worker_handoff_node)
snat_protocol_t proto
Definition: nat.h:366
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...
vlib_node_registration_t snat_out2in_fast_node
(constructor) VLIB_REGISTER_NODE (snat_out2in_fast_node)
Definition: out2in.c:1805
twice_nat_type_t twice_nat
Definition: nat.h:333
u32 max_translations
Definition: nat.h:513
u32 * auto_add_sw_if_indices_twice_nat
Definition: nat.h:480
vlib_node_registration_t nat44_ed_out2in_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_out2in_node)
Definition: out2in_ed.c:1498
vlib_node_registration_t snat_hairpin_dst_node
(constructor) VLIB_REGISTER_NODE (snat_hairpin_dst_node)
u32 fib_index
Definition: nat.h:254
u16 mss_value_net
Definition: nat.h:530
nat_addr_and_port_alloc_alg_t addr_and_port_alloc_alg
Definition: nat.h:463
clib_bihash_16_8_t out2in_ed
Definition: nat.h:383
snat_det_session_t * sessions
Definition: nat.h:285
u16 mss_clamping
Definition: nat.h:529
vlib_main_t * vlib_main
Definition: nat.h:539
unsigned short u16
Definition: types.h:57
u8 out2in_dpo
Definition: nat.h:509
snat_static_mapping_t * static_mappings
Definition: nat.h:452
u32 inside_fib_index
Definition: nat.h:520
u32 udp_timeout
Definition: nat.h:523
u8 static_mapping_only
Definition: nat.h:506
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:3181
vlib_node_registration_t nat44_ed_out2in_worker_handoff_node
void nat_set_alloc_addr_and_port_default(void)
Set address and port assignment algorithm to default/standard.
Definition: nat.c:3248
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:465
clib_bihash_8_8_t static_mapping_by_external
Definition: nat.h:449
u8 psid_offset
Definition: nat.h:465
struct snat_main_s snat_main_t
snat_session_t * nat_session_alloc_or_recycle(snat_main_t *sm, snat_user_t *u, u32 thread_index)
Allocate new NAT session or recycle last used.
Definition: nat.c:322
api_main_t * api_main
Definition: nat.h:543
u8 out_plen
Definition: nat.h:277
u8 psid_length
Definition: nat.h:466
u32 refcount
Definition: nat.h:255
vnet_main_t * vnet_main
Definition: nat.h:540
u32 inside_vrf_id
Definition: nat.h:519
vlib_node_registration_t nat44_ed_in2out_worker_handoff_node
Definition: nat.h:317
u32 snat_icmp_hairpinning(snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, icmp46_header_t *icmp0, int is_ed)
u32 fq_out2in_index
Definition: nat.h:491
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:201
int nat44_o2i_is_idle_session_cb(clib_bihash_kv_8_8_t *kv, void *arg)
Definition: out2in.c:110
u32 flags
Definition: vhost_user.h:115
snat_interface_t * output_feature_interfaces
Definition: nat.h:456
u16 src_port
Definition: nat.h:1085
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, twice_nat_type_t twice_nat, u8 out2in_only, u8 *tag, u8 identity_nat)
Add/delete NAT44 static mapping.
Definition: nat.c:629
snat_main_t snat_main
Definition: nat.c:37
vlib_node_registration_t snat_det_in2out_node
(constructor) VLIB_REGISTER_NODE (snat_det_in2out_node)
snat_session_state_t
Definition: nat.h:154
snat_user_t * users
Definition: nat.h:390
int( nat_alloc_out_addr_and_port_function_t)(snat_address_t *addresses, u32 fib_index, u32 thread_index, snat_session_key_t *k, u16 port_per_thread, u32 snat_thread_index)
Definition: nat.h:419
u32 random_seed
Definition: nat.h:486
clib_bihash_8_8_t out2in
Definition: nat.h:379
int nat44_o2i_ed_is_idle_session_cb(clib_bihash_kv_16_8_t *kv, void *arg)
Definition: out2in_ed.c:123
vlib_main_t * vm
Definition: buffer.c:294
u32 outside_vrf_id
Definition: nat.h:517
ip4_address_t l_addr
Definition: nat.h:67
u8 static_mapping_connection_tracking
Definition: nat.h:507
snat_get_worker_function_t * worker_in2out_cb
Definition: nat.h:437
u16 end_port
Definition: nat.h:470
format_function_t format_snat_static_map_to_resolve
Definition: nat.h:583
u32 error_node_index
Definition: nat.h:497
u32 sharing_ratio
Definition: nat.h:279
ip4_address_t out_addr
Definition: nat.h:276
u16 psid
Definition: nat.h:467
u32 outside_fib_index
Definition: nat.h:518
format_function_t format_nat_addr_and_port_alloc_alg
Definition: nat.h:589
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, twice_nat_type_t *twice_nat, lb_nat_type_t *lb, ip4_address_t *ext_host_addr, u8 *is_identity_nat)
Match NAT44 static mapping.
Definition: nat.c:2070
8 octet key, 8 octet key value pair
Definition: bihash_8_8.h:31
ip4_address_t addr
Definition: nat.h:52
u32 sw_if_index
Definition: nat.h:355
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:278
void increment_v4_address(ip4_address_t *a)
Increment IPv4 address.
Definition: nat.c:577
u32 tcp_transitory_timeout
Definition: nat.h:525
ip4_address_t r_addr
Definition: nat.h:68
u32 * auto_add_sw_if_indices
Definition: nat.h:479
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:2403
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:431
u32 num_workers
Definition: nat.h:434
Definition: nat.h:307
unformat_function_t unformat_snat_protocol
Definition: nat.h:592
u32 first_worker_index
Definition: nat.h:435
void snat_free_outside_address_and_port(snat_address_t *addresses, u32 thread_index, snat_session_key_t *k)
Free outside address and port pair.
Definition: nat.c:2032
snat_get_worker_function_t * worker_out2in_cb
Definition: nat.h:438
ip4_address_t l_addr
Definition: nat.h:361
snat_icmp_match_function_t * icmp_match_out2in_cb
Definition: nat.h:431
IPv4 main type.
Definition: ip4.h:96
vlib_log_class_t log_class
Definition: nat.h:536
u64 as_u64
Definition: nat.h:102
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:99
ip4_address_t in_addr
Definition: nat.h:273
u32 fq_in2out_index
Definition: nat.h:489
u32 out2in_node_index
Definition: nat.h:496
format_function_t format_snat_protocol
Definition: nat.h:588
ip4_address_t addr
Definition: nat.h:240
snat_address_t * twice_nat_addresses
Definition: nat.h:476
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:423
format_function_t format_snat_session
Definition: nat.h:584
struct _vlib_node_registration vlib_node_registration_t
Definition: nat.h:315
format_function_t format_nat44_reass_trace
Definition: nat.h:590
vlib_node_registration_t nat44_ed_hairpin_dst_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_hairpin_dst_node)
void nat_hairpinning_sm_unknown_proto(snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip)
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;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;}) snat_session_t
format_function_t format_static_mapping_key
Definition: nat.h:587
twice_nat_type_t
Definition: nat.h:302
u16 msg_id_base
Definition: nat.h:533
u16 ports_per_host
Definition: nat.h:281
u32 * workers
Definition: nat.h:436
u64 uword
Definition: types.h:112
snat_main_per_thread_data_t * per_thread_data
Definition: nat.h:443
int nat44_i2o_is_idle_session_cb(clib_bihash_kv_8_8_t *kv, void *arg)
Definition: in2out.c:194
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, u8 *p_proto, snat_session_key_t *p_value, u8 *p_dont_translate, void *d, void *e)
Definition: in2out_ed.c:565
snat_protocol_t
Definition: nat.h:133
snat_det_out_key_t out
Definition: nat.h:263
u32 affinity_per_service_list_head_index
Definition: nat.h:348
u32 fib_index
Definition: nat.h:100
snat_address_t * addresses
Definition: nat.h:459
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:3237
u32 in2out_node_index
Definition: nat.h:494
format_function_t format_snat_user
Definition: nat.h:581
snat_static_map_resolve_t * to_resolve
Definition: nat.h:483
void nat44_ed_hairpinning_unknown_proto(snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip)
int nat44_add_del_lb_static_mapping(ip4_address_t e_addr, u16 e_port, snat_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:1119
vlib_node_registration_t snat_in2out_worker_handoff_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_worker_handoff_node)
vlib_node_registration_t snat_in2out_fast_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_fast_node)
Definition: in2out.c:76
u8 forwarding_enabled
Definition: nat.h:503
u32 translation_memory_size
Definition: nat.h:512
int snat_alloc_outside_address_and_port(snat_address_t *addresses, u32 fib_index, u32 thread_index, snat_session_key_t *k, u16 port_per_thread, u32 snat_thread_index)
Alloc outside address and port.
Definition: nat.c:2204
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:1757
u32 ses_num
Definition: nat.h:283
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:617
vlib_node_registration_t nat44_ed_in2out_output_worker_handoff_node
clib_bihash_16_8_t in2out_ed
Definition: nat.h:384
u8 endpoint_dependent
Definition: nat.h:510
u16 dst_port
Definition: udp.api:42
vlib_node_registration_t snat_in2out_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_node)
Definition: in2out.c:74
vlib_node_registration_t nat44_ed_in2out_output_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_output_node)
Definition: in2out_ed.c:77
ip_lookup_main_t * ip4_lookup_main
Definition: nat.h:542
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:548
snat_session_t * sessions
Definition: nat.h:393
u32 cached_ip4_address
Definition: nat.h:555
snat_icmp_match_function_t * icmp_match_in2out_cb
Definition: nat.h:430
snat_session_t * nat_ed_session_alloc(snat_main_t *sm, snat_user_t *u, u32 thread_index, f64 now)
Allocate NAT endpoint-dependent session.
Definition: nat.c:391
clib_bihash_8_8_t static_mapping_by_local
Definition: nat.h:446
int nat44_del_session(snat_main_t *sm, ip4_address_t *addr, u16 port, snat_protocol_t proto, u32 vrf_id, int is_in)
Delete NAT44 session.
Definition: nat.c:3138
u32 fib_index
Definition: nat.h:241
void nat44_reass_hairpinning(snat_main_t *sm, vlib_buffer_t *b0, ip4_header_t *ip0, u16 sport, u16 dport, u32 proto0, int is_ed)
snat_interface_t * interfaces
Definition: nat.h:455
u32 tcp_established_timeout
Definition: nat.h:524