FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
nat44_ed.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_nat44_ed_h__
20 #define __included_nat44_ed_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/hash.h>
32 #include <vppinfra/dlist.h>
33 #include <vppinfra/error.h>
34 #include <vlibapi/api.h>
35 
36 #include <nat/lib/lib.h>
37 #include <nat/lib/inlines.h>
38 
39 /* default number of worker handoff frame queue elements */
40 #define NAT_FQ_NELTS_DEFAULT 64
41 
42 /* 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 
53 {
54 #define _(n,f) NAT44_API_##f = n,
56 #undef _
58 
59 typedef struct
60 {
61  /* nat44 plugin features */
64 
67 
68  /* maximum number of sessions */
70 
72 
73 typedef enum
74 {
86 } nat_next_t;
87 
88 typedef struct
89 {
93 
94 /* External address and port allocation modes */
95 #define foreach_nat_addr_and_port_alloc_alg \
96  _(0, DEFAULT, "default") \
97  _(1, MAPE, "map-e") \
98  _(2, RANGE, "port-range")
99 
100 typedef enum
101 {
102 #define _(v, N, s) NAT_ADDR_AND_PORT_ALLOC_ALG_##N = v,
104 #undef _
106 
107 /* Session state */
108 #define foreach_snat_session_state \
109  _(0, UNKNOWN, "unknown") \
110  _(1, UDP_ACTIVE, "udp-active") \
111  _(2, TCP_SYN_SENT, "tcp-syn-sent") \
112  _(3, TCP_ESTABLISHED, "tcp-established") \
113  _(4, TCP_FIN_WAIT, "tcp-fin-wait") \
114  _(5, TCP_CLOSE_WAIT, "tcp-close-wait") \
115  _(6, TCP_CLOSING, "tcp-closing") \
116  _(7, TCP_LAST_ACK, "tcp-last-ack") \
117  _(8, TCP_CLOSED, "tcp-closed") \
118  _(9, ICMP_ACTIVE, "icmp-active")
119 
120 typedef enum
121 {
122 #define _(v, N, s) SNAT_SESSION_##N = v,
124 #undef _
126 
127 #define foreach_nat_in2out_ed_error \
128  _ (UNSUPPORTED_PROTOCOL, "unsupported protocol") \
129  _ (OUT_OF_PORTS, "out of ports") \
130  _ (BAD_ICMP_TYPE, "unsupported ICMP type") \
131  _ (MAX_SESSIONS_EXCEEDED, "maximum sessions exceeded") \
132  _ (NON_SYN, "non-SYN packet try to create session") \
133  _ (TCP_CLOSED, "drops due to TCP in transitory timeout") \
134  _ (TRNSL_FAILED, "couldn't translate packet")
135 
136 typedef enum
137 {
138 #define _(sym,str) NAT_IN2OUT_ED_ERROR_##sym,
140 #undef _
143 
144 #define foreach_nat_out2in_ed_error \
145  _ (UNSUPPORTED_PROTOCOL, "unsupported protocol") \
146  _ (OUT_OF_PORTS, "out of ports") \
147  _ (BAD_ICMP_TYPE, "unsupported ICMP type") \
148  _ (NO_TRANSLATION, "no translation") \
149  _ (MAX_SESSIONS_EXCEEDED, "maximum sessions exceeded") \
150  _ (NON_SYN, "non-SYN packet try to create session") \
151  _ (TCP_CLOSED, "drops due to TCP in transitory timeout") \
152  _ (HASH_ADD_FAILED, "hash table add failed") \
153  _ (TRNSL_FAILED, "couldn't translate packet")
154 
155 typedef enum
156 {
157 #define _(sym,str) NAT_OUT2IN_ED_ERROR_##sym,
159 #undef _
162 
163 
164 /* Endpoint dependent TCP session state */
165 #define NAT44_SES_I2O_FIN 1
166 #define NAT44_SES_O2I_FIN 2
167 #define NAT44_SES_I2O_FIN_ACK 4
168 #define NAT44_SES_O2I_FIN_ACK 8
169 #define NAT44_SES_I2O_SYN 16
170 #define NAT44_SES_O2I_SYN 32
171 #define NAT44_SES_RST 64
172 
173 /* Session flags */
174 #define SNAT_SESSION_FLAG_STATIC_MAPPING (1 << 0)
175 #define SNAT_SESSION_FLAG_UNKNOWN_PROTO (1 << 1)
176 #define SNAT_SESSION_FLAG_LOAD_BALANCING (1 << 2)
177 #define SNAT_SESSION_FLAG_TWICE_NAT (1 << 3)
178 #define SNAT_SESSION_FLAG_ENDPOINT_DEPENDENT (1 << 4)
179 #define SNAT_SESSION_FLAG_FWD_BYPASS (1 << 5)
180 #define SNAT_SESSION_FLAG_AFFINITY (1 << 6)
181 #define SNAT_SESSION_FLAG_EXACT_ADDRESS (1 << 7)
182 #define SNAT_SESSION_FLAG_HAIRPINNING (1 << 8)
183 
184 /* NAT interface flags */
185 #define NAT_INTERFACE_FLAG_IS_INSIDE 1
186 #define NAT_INTERFACE_FLAG_IS_OUTSIDE 2
187 
188 /* Static mapping flags */
189 #define NAT_SM_FLAG_SELF_TWICE_NAT (1 << 1)
190 #define NAT_SM_FLAG_TWICE_NAT (1 << 2)
191 #define NAT_SM_FLAG_IDENTITY_NAT (1 << 3)
192 #define NAT_SM_FLAG_ADDR_ONLY (1 << 4)
193 #define NAT_SM_FLAG_EXACT_ADDRESS (1 << 5)
194 #define NAT_SM_FLAG_OUT2IN_ONLY (1 << 6)
195 #define NAT_SM_FLAG_LB (1 << 7)
196 #define NAT_SM_FLAG_SWITCH_ADDRESS (1 << 8)
197 
198 typedef CLIB_PACKED(struct
199 {
200  // number of sessions in this vrf
201  u32 ses_count;
202 
203  u32 rx_fib_index;
204  u32 tx_fib_index;
205 
206  // is this vrf expired
207  u8 expired;
208 }) per_vrf_sessions_t;
209 
210 typedef union
211 {
212  struct
213  {
215  u16 sport; // ICMP id for ICMP case
219  };
221  u64x2u as_u128;
222 } nat_6t_t;
223 
224 STATIC_ASSERT_SIZEOF (nat_6t_t, 2 * sizeof (u64));
225 
226 typedef struct
227 {
228 #define NAT_FLOW_OP_SADDR_REWRITE (1 << 1)
229 #define NAT_FLOW_OP_SPORT_REWRITE (1 << 2)
230 #define NAT_FLOW_OP_DADDR_REWRITE (1 << 3)
231 #define NAT_FLOW_OP_DPORT_REWRITE (1 << 4)
232 #define NAT_FLOW_OP_ICMP_ID_REWRITE (1 << 5)
233 #define NAT_FLOW_OP_TXFIB_REWRITE (1 << 6)
234  int ops;
236  struct
237  {
244  } rewrite;
247 } nat_6t_flow_t;
248 
249 void nat44_ed_forwarding_enable_disable (u8 is_enable);
250 
251 always_inline void
253 {
255  f->rewrite.saddr.as_u32 = saddr;
256 }
257 
258 always_inline void
260 {
262  f->rewrite.daddr.as_u32 = daddr;
263 }
264 
265 always_inline void
267 {
269  f->rewrite.sport = sport;
270 }
271 
272 always_inline void
274 {
276  f->rewrite.dport = dport;
277 }
278 
279 always_inline void
281 {
283  f->rewrite.fib_index = tx_fib_index;
284 }
285 
286 always_inline void
288 {
290  f->rewrite.icmp_id = id;
291 }
292 
293 typedef CLIB_PACKED(struct
294 {
295  /* Outside network tuple */
296  struct
297  {
299  u32 fib_index;
300  u16 port;
301  } out2in;
302 
303  /* Inside network tuple */
304  struct
305  {
307  u32 fib_index;
308  u16 port;
309  } in2out;
310 
311  nat_protocol_t nat_proto;
312 
313  nat_6t_flow_t i2o;
314  nat_6t_flow_t o2i;
315 
316  /* Flags */
317  u32 flags;
318 
319  /* head of LRU list in which this session is tracked */
320  u32 lru_head_index;
321  /* index in global LRU list */
322  u32 lru_index;
323  f64 last_lru_update;
324 
325  /* Last heard timer */
326  f64 last_heard;
327 
328  /* Last HA refresh */
329  f64 ha_last_refreshed;
330 
331  /* Counters */
332  u64 total_bytes;
333  u32 total_pkts;
334 
335  /* External host address and port */
336  ip4_address_t ext_host_addr;
337  u16 ext_host_port;
338 
339  /* External host address and port after translation */
340  ip4_address_t ext_host_nat_addr;
341  u16 ext_host_nat_port;
342 
343  /* TCP session state */
344  u8 state;
345  u32 i2o_fin_seq;
346  u32 o2i_fin_seq;
347  u64 tcp_closed_timestamp;
348 
349  /* per vrf sessions index */
350  u32 per_vrf_sessions_index;
351 
353 }) snat_session_t;
354 
355 typedef struct
356 {
359 #define _(N, i, n, s) \
360  u32 busy_##n##_ports; \
361  u32 * busy_##n##_ports_per_thread; \
362  u32 busy_##n##_port_refcounts[65535];
364 #undef _
366 
367 typedef struct
368 {
371 } nat_fib_t;
372 
373 typedef struct
374 {
378 
379 typedef struct
380 {
381  /* backend IP address */
383  /* backend port number */
385  /* probability of the backend to be randomly matched */
388  /* backend FIB table */
392 
393 typedef enum
394 {
395  /* twice-nat disabled */
397  /* twice-nat enabled */
399  /* twice-nat only when src IP equals dst IP after translation */
402 
403 typedef enum
404 {
405  /* no load-balancing */
407  /* load-balancing */
409  /* load-balancing with affinity */
411 } lb_nat_type_t;
412 
413 typedef struct
414 {
415  /* prefered pool address */
417  /* local IP address */
419  /* external IP address */
421  /* local port */
423  /* external port */
425  /* local FIB table */
428  /* protocol */
430  /* 0 = disabled, otherwise client IP affinity sticky time in seconds */
432  /* worker threads used by backends/local host */
434  /* opaque string tag */
435  u8 *tag;
436  /* backends for load-balancing mode */
438  /* affinity per service lis */
440  /* flags */
443 
444 typedef struct
445 {
449 
450 typedef struct
451 {
464  int exact;
465  u8 *tag;
467 
468 typedef struct
469 {
470  /* Session pool */
471  snat_session_t *sessions;
472 
473  /* Pool of doubly-linked list elements */
475 
476  /* LRU session list - head is stale, tail is fresh */
483 
484  /* NAT thread index */
486 
487  /* real thread index */
489 
490  per_vrf_sessions_t *per_vrf_sessions_vec;
491 
493 
494 struct snat_main_s;
495 
497  u32 rx_fib_index, u8 is_output);
499  u32 rx_fib_index, u8 is_output);
500 
501 /* Return worker thread index for given packet */
502 /* NAT address and port allocation function */
504  addresses,
505  u32 fib_index,
509  u16 * port,
511  u32 snat_thread_index);
512 
513 typedef struct snat_main_s
514 {
515  /* Thread settings */
520 
521  /* Per thread data */
523 
524  /* Find a static mapping by local */
525  clib_bihash_8_8_t static_mapping_by_local;
526 
527  /* Find a static mapping by external */
528  clib_bihash_8_8_t static_mapping_by_external;
529 
530  /* Static mapping pool */
532 
533  /* Endpoint independent lookup tables */
534  clib_bihash_8_8_t in2out;
535  clib_bihash_8_8_t out2in;
536 
537  /* Endpoint dependent lookup table */
538  clib_bihash_16_8_t flow_hash;
539 
540  /* Interface pool */
543 
544  /* Vector of outside addresses */
546  /* Vector of twice NAT addresses for external hosts */
548 
549  /* sw_if_indices whose intfc addresses should be auto-added */
552 
553  /* Address and port allocation function */
555  /* Address and port allocation type */
557  /* Port set parameters (MAP-E) */
561  /* Port range parameters */
564 
565  /* vector of fibs */
567 
568  /* vector of outside fibs */
570 
571  /* vector of interface address static mappings to resolve. */
573 
574  /* Randomize port allocation order */
576 
577  /* Worker handoff frame-queue index */
581 
585 
587  //nat44_config_t cconfig;
588 
589  /* If forwarding is enabled */
591 
592  /* static mapping config */
595 
596  /* Is translation memory size calculated or user defined */
598 
602 
607 
609 
610  /* TCP MSS clamping */
612 
613  /* counters */
615  u32 max_cfg_sessions_gauge; /* Index of max configured sessions gauge in
616  stats */
617 
618 #define _(x) vlib_simple_counter_main_t x;
619  struct
620  {
621  struct
622  {
623  struct
624  {
626  } in2out;
627 
628  struct
629  {
631  } out2in;
632  } fastpath;
633 
634  struct
635  {
636  struct
637  {
639  } in2out;
640 
641  struct
642  {
644  } out2in;
645  } slowpath;
646 
648  } counters;
649 #undef _
650 
651  /* API message ID base */
653 
654  /* log class */
656  /* logging level */
658 
659  /* convenience */
663 
666 
667  /* pat - dynamic mapping enabled or conneciton tracking */
669 
670  /* number of worker handoff frame queue elements */
672 
673  /* nat44 plugin enabled */
675 
677 
678 } snat_main_t;
679 
680 typedef struct
681 {
685 
686 typedef struct
687 {
691 
692 extern snat_main_t snat_main;
693 
694 // nat pre ed next_node feature classification
698 
708 
711 
712 /* format functions */
720 /* unformat functions */
722 
723 /** \brief Check if SNAT session is created from static mapping.
724  @param s SNAT session
725  @return true if SNAT session is created from static mapping otherwise 0
726 */
727 always_inline bool
728 nat44_ed_is_session_static (snat_session_t *s)
729 {
730  return s->flags & SNAT_SESSION_FLAG_STATIC_MAPPING;
731 }
732 
733 /** \brief Check if SNAT session for unknown protocol.
734  @param s SNAT session
735  @return true if SNAT session for unknown protocol otherwise 0
736 */
737 always_inline bool
738 snat_is_unk_proto_session (snat_session_t *s)
739 {
740  return s->flags & SNAT_SESSION_FLAG_UNKNOWN_PROTO;
741 }
742 
743 /** \brief Check if NAT session is twice NAT.
744  @param s NAT session
745  @return true if NAT session is twice NAT
746 */
747 always_inline bool
748 nat44_ed_is_twice_nat_session (snat_session_t *s)
749 {
750  return s->flags & SNAT_SESSION_FLAG_TWICE_NAT;
751 }
752 
753 /** \brief Check if NAT session is load-balancing.
754  @param s NAT session
755  @return true if NAT session is load-balancing
756 */
757 always_inline bool
758 nat44_ed_is_lb_session (snat_session_t *s)
759 {
760  return s->flags & SNAT_SESSION_FLAG_LOAD_BALANCING;
761 }
762 
763 /** \brief Check if NAT session is forwarding bypass.
764  @param s NAT session
765  @return true if NAT session is load-balancing
766 */
767 always_inline bool
768 na44_ed_is_fwd_bypass_session (snat_session_t *s)
769 {
770  return s->flags & SNAT_SESSION_FLAG_FWD_BYPASS;
771 }
772 
773 /** \brief Check if NAT session has affinity record.
774  @param s NAT session
775  @return true if NAT session has affinity record
776 */
777 always_inline bool
778 nat44_ed_is_affinity_session (snat_session_t *s)
779 {
780  return s->flags & SNAT_SESSION_FLAG_AFFINITY;
781 }
782 
783 /** \brief Check if exact pool address should be used.
784  @param s SNAT session
785  @return true if exact pool address
786 */
787 always_inline bool
789 {
790  return s->flags & SNAT_SESSION_FLAG_EXACT_ADDRESS;
791 }
792 
793 /** \brief Check if NAT interface is inside.
794  @param i NAT interface
795  @return true if inside interface
796 */
797 always_inline bool
799 {
800  return i->flags & NAT_INTERFACE_FLAG_IS_INSIDE;
801 }
802 
803 /** \brief Check if NAT interface is outside.
804  @param i NAT interface
805  @return true if outside interface
806 */
807 always_inline bool
809 {
810  return i->flags & NAT_INTERFACE_FLAG_IS_OUTSIDE;
811 }
812 
813 /** \brief Check if NAT44 endpoint-dependent TCP session is closed.
814  @param s NAT session
815  @return true if session is closed
816 */
817 always_inline bool
818 nat44_is_ses_closed (snat_session_t *s)
819 {
820  return s->state == 0xf;
821 }
822 
823 /** \brief Check if client initiating TCP connection (received SYN from client)
824  @param t TCP header
825  @return true if client initiating TCP connection
826 */
827 always_inline bool
829 {
830  return (f & TCP_FLAG_SYN) && !(f & TCP_FLAG_ACK);
831 }
832 
833 always_inline bool
835 {
836  return (f & NAT_SM_FLAG_ADDR_ONLY);
837 }
838 
839 always_inline bool
841 {
842  return (f & NAT_SM_FLAG_OUT2IN_ONLY);
843 }
844 
845 always_inline bool
847 {
848  return (f & NAT_SM_FLAG_IDENTITY_NAT);
849 }
850 
851 always_inline bool
853 {
854  return (f & NAT_SM_FLAG_LB);
855 }
856 
857 always_inline bool
859 {
860  return (f & NAT_SM_FLAG_EXACT_ADDRESS);
861 }
862 
863 always_inline bool
865 {
866  return (f & NAT_SM_FLAG_SELF_TWICE_NAT);
867 }
868 
869 always_inline bool
871 {
872  return (f & NAT_SM_FLAG_TWICE_NAT);
873 }
874 
875 always_inline bool
877 {
878  return (f & NAT_SM_FLAG_SWITCH_ADDRESS);
879 }
880 
881 /* logging */
882 #define nat_log_err(...) \
883  vlib_log(VLIB_LOG_LEVEL_ERR, snat_main.log_class, __VA_ARGS__)
884 #define nat_log_warn(...) \
885  vlib_log(VLIB_LOG_LEVEL_WARNING, snat_main.log_class, __VA_ARGS__)
886 #define nat_log_notice(...) \
887  vlib_log(VLIB_LOG_LEVEL_NOTICE, snat_main.log_class, __VA_ARGS__)
888 #define nat_log_info(...) \
889  vlib_log(VLIB_LOG_LEVEL_INFO, snat_main.log_class, __VA_ARGS__)
890 #define nat_log_debug(...)\
891  vlib_log(VLIB_LOG_LEVEL_DEBUG, snat_main.log_class, __VA_ARGS__)
892 
894 
895 int snat_set_workers (uword *bitmap);
896 
898 int nat44_plugin_disable ();
899 
900 int nat44_ed_add_interface (u32 sw_if_index, u8 is_inside);
901 int nat44_ed_del_interface (u32 sw_if_index, u8 is_inside);
904 
906 int nat44_ed_del_address (ip4_address_t addr, u8 delete_sm, u8 twice_nat);
909 
911  u16 l_port, u16 e_port, nat_protocol_t proto,
913  ip4_address_t pool_addr, u8 *tag);
914 
916  u16 l_port, u16 e_port, nat_protocol_t proto,
918 
921  nat44_lb_addr_port_t *locals, u32 flags,
922  u8 *tag, u32 affinity);
923 
926 
928  ip4_address_t l_addr, u16 l_port,
930  u8 probability, u8 is_add);
931 
932 /**
933  * @brief Delete NAT44 endpoint-dependent session
934  *
935  * @param sm snat global configuration data
936  * @param addr IPv4 address
937  * @param port L4 port number
938  * @param proto L4 protocol
939  * @param vrf_id VRF ID
940  * @param is_in 1 = inside network address and port pair, 0 = outside
941  *
942  * @return 0 on success, non-zero value otherwise
943  */
945  ip4_address_t *eh_addr, u16 eh_port, u8 proto,
946  u32 vrf_id, int is_in);
947 
948 /**
949  * @brief Free NAT44 session data (lookup keys, external address port)
950  *
951  * @param sm snat global configuration data
952  * @param s NAT session
953  * @param thread_index thread index
954  * @param is_ha is HA event
955  */
956 void nat_free_session_data (snat_main_t * sm, snat_session_t * s,
957  u32 thread_index, u8 is_ha);
958 
959 /**
960  * @brief Set NAT44 session limit (session limit, vrf id)
961  *
962  * @param session_limit Session limit
963  * @param vrf_id VRF id
964  * @return 0 on success, non-zero value otherwise
965  */
966 int nat44_set_session_limit (u32 session_limit, u32 vrf_id);
967 
968 /**
969  * @brief Update NAT44 session limit flushing all data (session limit, vrf id)
970  *
971  * @param session_limit Session limit
972  * @param vrf_id VRF id
973  * @return 0 on success, non-zero value otherwise
974  */
975 int nat44_update_session_limit (u32 session_limit, u32 vrf_id);
976 
977 /**
978  * @brief Free outside address and port pair
979  *
980  * @param addresses vector of outside addresses
981  * @param thread_index thread index
982  * @param key address, port and protocol
983  */
984 void
989 
990 void expire_per_vrf_sessions (u32 fib_index);
991 
992 /**
993  * @brief Match NAT44 static mapping.
994  *
995  * @param key address and port to match
996  * @param addr external/local address of the matched mapping
997  * @param port port of the matched mapping
998  * @param fib_index fib index of the matched mapping
999  * @param by_external if 0 match by local address otherwise match by external
1000  * address
1001  * @param is_addr_only 1 if matched mapping is address only
1002  * @param twice_nat matched mapping is twice NAT type
1003  * @param lb 1 if matched mapping is load-balanced
1004  * @param ext_host_addr external host address
1005  * @param is_identity_nat 1 if indentity mapping
1006  * @param out if !=0 set to pointer of the mapping structure
1007  *
1008  * @returns 0 if match found otherwise 1.
1009  */
1011  vlib_main_t *vm, snat_main_t *sm, ip4_address_t match_addr, u16 match_port,
1012  u32 match_fib_index, nat_protocol_t match_protocol,
1013  ip4_address_t *mapping_addr, u16 *mapping_port, u32 *mapping_fib_index,
1014  u8 by_external, u8 *is_addr_only, twice_nat_type_t *twice_nat,
1015  lb_nat_type_t *lb, ip4_address_t *ext_host_addr, u8 *is_identity_nat,
1016  snat_static_mapping_t **out);
1017 
1018 /*
1019  * Why is this here? Because we don't need to touch this layer to
1020  * simply reply to an icmp. We need to change id to a unique
1021  * value to NAT an echo request/reply.
1022  */
1023 
1024 typedef struct
1025 {
1026  u16 identifier;
1027  u16 sequence;
1029 
1030 typedef struct
1031 {
1034 
1035 u32 get_thread_idx_by_port (u16 e_port);
1036 
1037 u8 *format_static_mapping_kvp (u8 *s, va_list *args);
1038 
1039 u8 *format_session_kvp (u8 *s, va_list *args);
1040 
1042 
1043 void nat44_addresses_free (snat_address_t **addresses);
1044 
1045 void nat44_ed_sessions_clear ();
1046 
1047 int nat44_ed_set_frame_queue_nelts (u32 frame_queue_nelts);
1048 
1049 typedef enum
1050 {
1058 
1061  nat_6t_flow_t *f, nat_protocol_t proto, int is_output_feature);
1062 
1065  nat_6t_flow_t *f, nat_protocol_t proto, int is_output_feature);
1066 
1068 
1072 
1073 #endif /* __included_nat44_ed_h__ */
1074 /*
1075  * fd.io coding-style-patch-verification: ON
1076  *
1077  * Local Variables:
1078  * eval: (c-set-style "gnu")
1079  * End:
1080  */
nat44_ed_is_interface_outside
static bool nat44_ed_is_interface_outside(snat_interface_t *i)
Check if NAT interface is outside.
Definition: nat44_ed.h:808
snat_main_s::to_resolve
snat_static_map_resolve_t * to_resolve
Definition: nat44_ed.h:572
is_sm_lb
static bool is_sm_lb(u32 f)
Definition: nat44_ed.h:852
fib_source.h
nat44_ed_del_session
int nat44_ed_del_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: nat44_ed.c:3465
lib.h
NAT port/address allocation lib.
snat_main_s::port_per_thread
u16 port_per_thread
Definition: nat44_ed.h:519
snat_is_unk_proto_session
static bool snat_is_unk_proto_session(snat_session_t *s)
Check if SNAT session for unknown protocol.
Definition: nat44_ed.h:738
snat_main_s::ip4_lookup_main
ip_lookup_main_t * ip4_lookup_main
Definition: nat44_ed.h:662
nat_6t_t::proto
u8 proto
Definition: nat44_ed.h:218
unformat_nat_protocol
unformat_function_t unformat_nat_protocol
Definition: nat44_ed.h:721
is_sm_switch_address
static bool is_sm_switch_address(u32 f)
Definition: nat44_ed.h:876
snat_main_per_thread_data_t::unk_proto_lru_head_index
u32 unk_proto_lru_head_index
Definition: nat44_ed.h:482
snat_main_s::fastpath
struct snat_main_s::@746::@747 fastpath
nat_fib_t::fib_index
u32 fib_index
Definition: nat44_ed.h:369
tcp_flags_is_init
static bool tcp_flags_is_init(u8 f)
Check if client initiating TCP connection (received SYN from client)
Definition: nat44_ed.h:828
SNAT_SESSION_FLAG_AFFINITY
#define SNAT_SESSION_FLAG_AFFINITY
Definition: nat44_ed.h:180
nat_6t_flow_saddr_rewrite_set
static void nat_6t_flow_saddr_rewrite_set(nat_6t_flow_t *f, u32 saddr)
Definition: nat44_ed.h:252
snat_in2out_output_worker_handoff_node
vlib_node_registration_t snat_in2out_output_worker_handoff_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_output_worker_handoff_node)
Definition: nat44_ed_handoff.c:315
nat44_config_flags_t
enum nat44_config_flags_t_ nat44_config_flags_t
snat_static_mapping_t::locals
nat44_lb_addr_port_t * locals
Definition: nat44_ed.h:437
snat_main_s::in2out_output_node_index
u32 in2out_output_node_index
Definition: nat44_ed.h:584
snat_main_s::outside_vrf_id
u32 outside_vrf_id
Definition: nat44_ed.h:603
snat_main_s::psid_length
u8 psid_length
Definition: nat44_ed.h:559
snat_main_s::static_mappings
snat_static_mapping_t * static_mappings
Definition: nat44_ed.h:531
snat_main_s::end_port
u16 end_port
Definition: nat44_ed.h:563
thread_index
u32 thread_index
Definition: nat44_ei_hairpinning.c:495
snat_main_s::twice_nat_addresses
snat_address_t * twice_nat_addresses
Definition: nat44_ed.h:547
nat44_config_t::sessions
u32 sessions
Definition: nat44_ed.h:69
dst_port
vl_api_ip_port_and_mask_t dst_port
Definition: flow_types.api:92
nat44_lb_addr_port_t::addr
ip4_address_t addr
Definition: nat44_ed.h:382
format_nat_protocol
format_function_t format_nat_protocol
Definition: nat44_ed.h:718
bihash_8_8.h
nat_outside_fib_t
Definition: nat44_ed.h:373
snat_main_s::total_sessions
vlib_simple_counter_main_t total_sessions
Definition: nat44_ed.h:614
snat_main_s::ip4_main
ip4_main_t * ip4_main
Definition: nat44_ed.h:661
nat_6t_flow_t::saddr
ip4_address_t saddr
Definition: nat44_ed.h:238
nat44_plugin_disable
int nat44_plugin_disable()
Definition: nat44_ed.c:2457
LB_NAT
@ LB_NAT
Definition: nat44_ed.h:408
nat_free_session_data
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: nat44_ed.c:231
format_snat_key
format_function_t format_snat_key
Definition: nat44_ed.h:716
snat_static_mapping_t::vrf_id
u32 vrf_id
Definition: nat44_ed.h:426
nat_calc_bihash_buckets
u32 nat_calc_bihash_buckets(u32 n_elts)
Definition: lib.h:122
nat_pre_trace_t::arc_next_index
u32 arc_next_index
Definition: nat44_ed.h:91
nat44_ed_del_address
int nat44_ed_del_address(ip4_address_t addr, u8 delete_sm, u8 twice_nat)
Definition: nat44_ed.c:449
SNAT_SESSION_FLAG_UNKNOWN_PROTO
#define SNAT_SESSION_FLAG_UNKNOWN_PROTO
Definition: nat44_ed.h:175
snat_main_s::fib_src_hi
fib_source_t fib_src_hi
Definition: nat44_ed.h:664
snat_main_s::counters
struct snat_main_s::@746 counters
elog.h
nat_fib_src_low
fib_source_t nat_fib_src_low
snat_main_s::vnet_main
vnet_main_t * vnet_main
Definition: nat44_ed.h:676
snat_main_per_thread_data_t::udp_lru_head_index
u32 udp_lru_head_index
Definition: nat44_ed.h:480
snat_static_mapping_match
int snat_static_mapping_match(vlib_main_t *vm, 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: nat44_ed.c:2597
snat_main_per_thread_data_t::lru_pool
dlist_elt_t * lru_pool
Definition: nat44_ed.h:477
nat44_ed_add_lb_static_mapping
int nat44_ed_add_lb_static_mapping(ip4_address_t e_addr, u16 e_port, nat_protocol_t proto, nat44_lb_addr_port_t *locals, u32 flags, u8 *tag, u32 affinity)
Definition: nat44_ed.c:1136
f
vlib_frame_t * f
Definition: interface_output.c:1098
snat_main_s::translation_memory_size_set
u8 translation_memory_size_set
Definition: nat44_ed.h:597
nat_outside_fib_t::refcount
u32 refcount
Definition: nat44_ed.h:376
NAT_OUT2IN_ED_N_ERROR
@ NAT_OUT2IN_ED_N_ERROR
Definition: nat44_ed.h:160
format_nat_addr_and_port_alloc_alg
format_function_t format_nat_addr_and_port_alloc_alg
Definition: nat44_ed.h:719
vlib_log_class_t
u32 vlib_log_class_t
Definition: vlib.h:52
NAT_NEXT_IN2OUT_CLASSIFY
@ NAT_NEXT_IN2OUT_CLASSIFY
Definition: nat44_ed.h:83
snat_main_s::start_port
u16 start_port
Definition: nat44_ed.h:562
nat44_ed_is_affinity_session
static bool nat44_ed_is_affinity_session(snat_session_t *s)
Check if NAT session has affinity record.
Definition: nat44_ed.h:778
snat_main_s::slowpath
struct snat_main_s::@746::@748 slowpath
snat_main_s::translation_buckets
u32 translation_buckets
Definition: nat44_ed.h:599
nat44_api_hookup
clib_error_t * nat44_api_hookup(vlib_main_t *vm)
Definition: nat44_ed_api.c:1685
foreach_nat44_config_flag
#define foreach_nat44_config_flag
Definition: nat44_ed.h:46
nat_6t_t::dport
u16 dport
Definition: nat44_ed.h:216
nat_timeouts_t
Definition: lib.h:76
NAT_FLOW_OP_TXFIB_REWRITE
#define NAT_FLOW_OP_TXFIB_REWRITE
Definition: nat44_ed.h:233
nat_6t_flow_t
Definition: nat44_ed.h:226
snat_set_workers
int snat_set_workers(uword *bitmap)
Definition: nat44_ed.c:2032
nat44_ed_add_address
int nat44_ed_add_address(ip4_address_t *addr, u32 vrf_id, u8 twice_nat)
Definition: nat44_ed.c:388
nat_protocol_t
nat_protocol_t
Definition: lib.h:63
lb_nat_type_t
lb_nat_type_t
Definition: nat44_ed.h:403
snat_main_per_thread_data_t::snat_thread_index
u32 snat_thread_index
Definition: nat44_ed.h:485
snat_out2in_node
vlib_node_registration_t snat_out2in_node
nat44_ed_add_static_mapping
int nat44_ed_add_static_mapping(ip4_address_t l_addr, ip4_address_t e_addr, u16 l_port, u16 e_port, nat_protocol_t proto, u32 vrf_id, u32 sw_if_index, u32 flags, ip4_address_t pool_addr, u8 *tag)
Definition: nat44_ed.c:783
snat_main_s::interfaces
snat_interface_t * interfaces
Definition: nat44_ed.h:541
snat_in2out_node
vlib_node_registration_t snat_in2out_node
nat44_ed_del_interface_address
int nat44_ed_del_interface_address(u32 sw_if_index, u8 twice_nat)
Definition: nat44_ed.c:3401
nat_6t_flow_t::match
nat_6t_t match
Definition: nat44_ed.h:235
dlist.h
snat_static_map_resolve_t::l_port
u16 l_port
Definition: nat44_ed.h:454
AFFINITY_LB_NAT
@ AFFINITY_LB_NAT
Definition: nat44_ed.h:410
nat44_ed_add_output_interface
int nat44_ed_add_output_interface(u32 sw_if_index)
Definition: nat44_ed.c:1848
snat_main_s::out2in_node_index
u32 out2in_node_index
Definition: nat44_ed.h:582
probability
u8 probability
Definition: nat44_ed.api:1052
NAT_SM_FLAG_ADDR_ONLY
#define NAT_SM_FLAG_ADDR_ONLY
Definition: nat44_ed.h:192
snat_main_s::log_class
vlib_log_class_t log_class
Definition: nat44_ed.h:655
nat_in2out_ed_error_t
nat_in2out_ed_error_t
Definition: nat44_ed.h:136
u16
unsigned short u16
Definition: types.h:57
SNAT_SESSION_FLAG_STATIC_MAPPING
#define SNAT_SESSION_FLAG_STATIC_MAPPING
Definition: nat44_ed.h:174
nat44_ed_del_lb_static_mapping
int nat44_ed_del_lb_static_mapping(ip4_address_t e_addr, u16 e_port, nat_protocol_t proto, u32 flags)
Definition: nat44_ed.c:1279
nat_6t_t::as_u128
u64x2u as_u128
Definition: nat44_ed.h:221
snat_static_mapping_t::tag
u8 * tag
Definition: nat44_ed.h:435
nat_6t_flow_t::fib_index
u32 fib_index
Definition: nat44_ed.h:241
snat_main_t
struct snat_main_s snat_main_t
snat_runtime_t::cached_sw_if_index
u32 cached_sw_if_index
Definition: nat44_ed.h:688
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
snat_static_map_resolve_t::pool_addr
ip4_address_t pool_addr
Definition: nat44_ed.h:453
api.h
is_sm_out2in_only
static bool is_sm_out2in_only(u32 f)
Definition: nat44_ed.h:840
snat_main_s::workers
u32 * workers
Definition: nat44_ed.h:518
nat44_ed_is_exact_address_session
static bool nat44_ed_is_exact_address_session(snat_session_t *s)
Check if exact pool address should be used.
Definition: nat44_ed.h:788
state
vl_api_dhcp_client_state_t state
Definition: dhcp.api:201
snat_main_s::psid
u16 psid
Definition: nat44_ed.h:560
port
u16 port
Definition: lb_types.api:73
NAT_NEXT_IN2OUT_ED_SLOW_PATH
@ NAT_NEXT_IN2OUT_ED_SLOW_PATH
Definition: nat44_ed.h:78
nat_6t_flow_daddr_rewrite_set
static void nat_6t_flow_daddr_rewrite_set(nat_6t_flow_t *f, u32 daddr)
Definition: nat44_ed.h:259
nat_6t_flow_t::proto
u8 proto
Definition: nat44_ed.h:242
snat_static_mapping_t::proto
nat_protocol_t proto
Definition: nat44_ed.h:429
snat_main_s::timeouts
nat_timeouts_t timeouts
Definition: nat44_ed.h:608
nat44_lb_addr_port_t::port
u16 port
Definition: nat44_ed.h:384
snat_static_mapping_t::local_addr
ip4_address_t local_addr
Definition: nat44_ed.h:418
snat_main_s::addresses
snat_address_t * addresses
Definition: nat44_ed.h:545
addr
vhost_vring_addr_t addr
Definition: vhost_user.h:130
nat_6t_flow_t::ops
int ops
Definition: nat44_ed.h:234
CLIB_PACKED
typedef CLIB_PACKED(struct { u32 ses_count;u32 rx_fib_index;u32 tx_fib_index;u8 expired;}) per_vrf_sessions_t
snat_main_s::static_mapping_by_external
clib_bihash_8_8_t static_mapping_by_external
Definition: nat44_ed.h:528
nat_outside_fib_t::fib_index
u32 fib_index
Definition: nat44_ed.h:375
nat_6t_l3_l4_csum_calc
void nat_6t_l3_l4_csum_calc(nat_6t_flow_t *f)
Definition: nat44_ed.c:3532
snat_free_outside_address_and_port
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: nat44_ed.c:2560
format_snat_static_mapping
format_function_t format_snat_static_mapping
Definition: nat44_ed.h:713
snat_main_s::psid_offset
u8 psid_offset
Definition: nat44_ed.h:558
TWICE_NAT_DISABLED
@ TWICE_NAT_DISABLED
Definition: nat44_ed.h:396
snat_static_mapping_t::flags
u32 flags
Definition: nat44_ed.h:441
NAT_SM_FLAG_OUT2IN_ONLY
#define NAT_SM_FLAG_OUT2IN_ONLY
Definition: nat44_ed.h:194
format_static_mapping_key
format_function_t format_static_mapping_key
Definition: nat44_ed.h:717
ip4_header_t
Definition: ip4_packet.h:87
SNAT_SESSION_FLAG_EXACT_ADDRESS
#define SNAT_SESSION_FLAG_EXACT_ADDRESS
Definition: nat44_ed.h:181
ethernet.h
nat_pre_in2out_node
vlib_node_registration_t nat_pre_in2out_node
(constructor) VLIB_REGISTER_NODE (nat_pre_in2out_node)
Definition: nat44_ed_in2out.c:1639
NAT_SM_FLAG_IDENTITY_NAT
#define NAT_SM_FLAG_IDENTITY_NAT
Definition: nat44_ed.h:191
snat_main_s::log_level
u8 log_level
Definition: nat44_ed.h:657
format_session_kvp
u8 * format_session_kvp(u8 *s, va_list *args)
Definition: nat44_ed.c:186
snat_main_s::outside_fib_index
u32 outside_fib_index
Definition: nat44_ed.h:604
snat_main_s::forwarding_enabled
u8 forwarding_enabled
Definition: nat44_ed.h:590
TCP_FLAG_SYN
#define TCP_FLAG_SYN
Definition: fa_node.h:13
nat_6t_t::fib_index
u32 fib_index
Definition: nat44_ed.h:217
get_thread_idx_by_port
u32 get_thread_idx_by_port(u16 e_port)
Definition: nat44_ed.c:540
nat_6t_flow_buf_translate_i2o
nat_translation_error_e nat_6t_flow_buf_translate_i2o(vlib_main_t *vm, snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip, nat_6t_flow_t *f, nat_protocol_t proto, int is_output_feature)
Definition: nat44_ed.c:3862
nat44_ed_get_out2in_worker_index
u32 nat44_ed_get_out2in_worker_index(vlib_buffer_t *b, ip4_header_t *ip, u32 rx_fib_index, u8 is_output)
Definition: nat44_ed.c:2882
sport
u16 sport
Definition: pnat.api:43
snat_main_per_thread_data_t::icmp_lru_head_index
u32 icmp_lru_head_index
Definition: nat44_ed.h:481
nat44_ed_in2out_output_node
vlib_node_registration_t nat44_ed_in2out_output_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_output_node)
Definition: nat44_ed_in2out.c:1553
nat_next_t
nat_next_t
Definition: nat44_ed.h:73
snat_main_s::addr_and_port_alloc_alg
nat_addr_and_port_alloc_alg_t addr_and_port_alloc_alg
Definition: nat44_ed.h:556
snat_address_t
Definition: nat44_ed.h:355
nat44_ed_del_interface
int nat44_ed_del_interface(u32 sw_if_index, u8 is_inside)
Definition: nat44_ed.c:1743
foreach_nat_protocol
@ foreach_nat_protocol
Definition: lib.h:66
nat44_ed_del_output_interface
int nat44_ed_del_output_interface(u32 sw_if_index)
Definition: nat44_ed.c:1946
snat_main_s::pat
u8 pat
Definition: nat44_ed.h:668
snat_static_map_resolve_t::flags
u32 flags
Definition: nat44_ed.h:459
nat44_is_ses_closed
static bool nat44_is_ses_closed(snat_session_t *s)
Check if NAT44 endpoint-dependent TCP session is closed.
Definition: nat44_ed.h:818
is_sm_twice_nat
static bool is_sm_twice_nat(u32 f)
Definition: nat44_ed.h:870
snat_out2in_worker_handoff_node
vlib_node_registration_t snat_out2in_worker_handoff_node
(constructor) VLIB_REGISTER_NODE (snat_out2in_worker_handoff_node)
Definition: nat44_ed_handoff.c:332
hash.h
NAT_NEXT_IN2OUT_ED_OUTPUT_SLOW_PATH
@ NAT_NEXT_IN2OUT_ED_OUTPUT_SLOW_PATH
Definition: nat44_ed.h:80
NAT_SM_FLAG_LB
#define NAT_SM_FLAG_LB
Definition: nat44_ed.h:195
nat_addr_and_port_alloc_alg_t
nat_addr_and_port_alloc_alg_t
Definition: nat44_ed.h:100
snat_main_s::per_thread_data
snat_main_per_thread_data_t * per_thread_data
Definition: nat44_ed.h:522
nat44_ed_forwarding_enable_disable
void nat44_ed_forwarding_enable_disable(u8 is_enable)
Definition: nat44_ed.c:2524
error.h
NAT_ED_TRNSL_ERR_INVALID_CSUM
@ NAT_ED_TRNSL_ERR_INVALID_CSUM
Definition: nat44_ed.h:1056
snat_main_s::rconfig
nat44_config_t rconfig
Definition: nat44_ed.h:586
NAT_NEXT_ICMP_ERROR
@ NAT_NEXT_ICMP_ERROR
Definition: nat44_ed.h:76
snat_main_s::flow_hash
clib_bihash_16_8_t flow_hash
Definition: nat44_ed.h:538
NAT_NEXT_IN2OUT_ED_FAST_PATH
@ NAT_NEXT_IN2OUT_ED_FAST_PATH
Definition: nat44_ed.h:77
snat_main_s::first_worker_index
u32 first_worker_index
Definition: nat44_ed.h:517
nat44_lb_addr_port_t::probability
u8 probability
Definition: nat44_ed.h:386
nat44_ed_is_lb_session
static bool nat44_ed_is_lb_session(snat_session_t *s)
Check if NAT session is load-balancing.
Definition: nat44_ed.h:758
snat_main_per_thread_data_t::per_vrf_sessions_vec
per_vrf_sessions_t * per_vrf_sessions_vec
Definition: nat44_ed.h:490
twice_nat_type_t
twice_nat_type_t
Definition: nat44_ed.h:393
NAT_FLOW_OP_DADDR_REWRITE
#define NAT_FLOW_OP_DADDR_REWRITE
Definition: nat44_ed.h:230
nat_6t_flow_buf_translate_o2i
nat_translation_error_e nat_6t_flow_buf_translate_o2i(vlib_main_t *vm, snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip, nat_6t_flow_t *f, nat_protocol_t proto, int is_output_feature)
Definition: nat44_ed.c:3872
NAT_NEXT_OUT2IN_ED_FAST_PATH
@ NAT_NEXT_OUT2IN_ED_FAST_PATH
Definition: nat44_ed.h:81
NAT_INTERFACE_FLAG_IS_OUTSIDE
#define NAT_INTERFACE_FLAG_IS_OUTSIDE
Definition: nat44_ed.h:186
snat_main_s::outside_fibs
nat_outside_fib_t * outside_fibs
Definition: nat44_ed.h:569
nat44_ed_sessions_clear
void nat44_ed_sessions_clear()
Definition: nat44_ed.c:3185
nat44_config_t::inside_vrf
u32 inside_vrf
Definition: nat44_ed.h:65
snat_static_mapping_t::affinity_per_service_list_head_index
u32 affinity_per_service_list_head_index
Definition: nat44_ed.h:439
nat44_update_session_limit
int nat44_update_session_limit(u32 session_limit, u32 vrf_id)
Update NAT44 session limit flushing all data (session limit, vrf id)
Definition: nat44_ed.c:3065
foreach_snat_session_state
#define foreach_snat_session_state
Definition: nat44_ed.h:108
is_sm_addr_only
static bool is_sm_addr_only(u32 f)
Definition: nat44_ed.h:834
snat_in2out_worker_handoff_node
vlib_node_registration_t snat_in2out_worker_handoff_node
(constructor) VLIB_REGISTER_NODE (snat_in2out_worker_handoff_node)
Definition: nat44_ed_handoff.c:297
nat_out2in_ed_error_t
nat_out2in_ed_error_t
Definition: nat44_ed.h:155
c
svmdb_client_t * c
Definition: vpp_get_metrics.c:48
expire_per_vrf_sessions
void expire_per_vrf_sessions(u32 fib_index)
Definition: nat44_ed.c:1550
format_static_mapping_kvp
u8 * format_static_mapping_kvp(u8 *s, va_list *args)
Definition: nat44_ed.c:198
NAT_FLOW_OP_ICMP_ID_REWRITE
#define NAT_FLOW_OP_ICMP_ID_REWRITE
Definition: nat44_ed.h:232
uword
u64 uword
Definition: types.h:112
nat_6t_flow_t::l4_csum_delta
uword l4_csum_delta
Definition: nat44_ed.h:246
snat_main_per_thread_data_t::thread_index
u32 thread_index
Definition: nat44_ed.h:488
tcp_udp_header_t
Definition: nat44_ei.h:94
snat_main_s::fq_in2out_output_index
u32 fq_in2out_output_index
Definition: nat44_ed.h:579
snat_main_s::fq_out2in_index
u32 fq_out2in_index
Definition: nat44_ed.h:580
TWICE_NAT_SELF
@ TWICE_NAT_SELF
Definition: nat44_ed.h:400
NAT_SM_FLAG_TWICE_NAT
#define NAT_SM_FLAG_TWICE_NAT
Definition: nat44_ed.h:190
NAT_SM_FLAG_EXACT_ADDRESS
#define NAT_SM_FLAG_EXACT_ADDRESS
Definition: nat44_ed.h:193
nat44_ed_is_session_static
static bool nat44_ed_is_session_static(snat_session_t *s)
Check if SNAT session is created from static mapping.
Definition: nat44_ed.h:728
snat_main_s::fq_in2out_index
u32 fq_in2out_index
Definition: nat44_ed.h:578
src_port
vl_api_ip_port_and_mask_t src_port
Definition: flow_types.api:91
snat_static_mapping_t::workers
u32 * workers
Definition: nat44_ed.h:433
f64
double f64
Definition: types.h:142
nat44_ed_add_del_lb_static_mapping_local
int nat44_ed_add_del_lb_static_mapping_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: nat44_ed.c:1399
nat_6t_t
Definition: nat44_ed.h:210
nat_6t_flow_icmp_id_rewrite_set
static void nat_6t_flow_icmp_id_rewrite_set(nat_6t_flow_t *f, u16 id)
Definition: nat44_ed.h:287
dlist_elt_t
Definition: dlist.h:28
nat44_ed_get_in2out_worker_index
u32 nat44_ed_get_in2out_worker_index(vlib_buffer_t *b, ip4_header_t *ip, u32 rx_fib_index, u8 is_output)
Definition: nat44_ed.c:2757
nat44_lb_addr_port_t
Definition: nat44_ed.h:379
snat_static_mapping_t::external_port
u16 external_port
Definition: nat44_ed.h:424
format_snat_static_map_to_resolve
format_function_t format_snat_static_map_to_resolve
Definition: nat44_ed.h:714
snat_main_s::fib_src_low
fib_source_t fib_src_low
Definition: nat44_ed.h:665
snat_static_map_resolve_t::addr_only
int addr_only
Definition: nat44_ed.h:460
snat_static_map_resolve_t::tag
u8 * tag
Definition: nat44_ed.h:465
ip4_address_t
Definition: ip4_packet.h:50
NAT_INTERFACE_FLAG_IS_INSIDE
#define NAT_INTERFACE_FLAG_IS_INSIDE
Definition: nat44_ed.h:185
inlines.h
snat_main_s
Definition: nat44_ed.h:513
snat_main_per_thread_data_t::sessions
snat_session_t * sessions
Definition: nat44_ed.h:471
NAT_ED_TRNSL_ERR_FLOW_MISMATCH
@ NAT_ED_TRNSL_ERR_FLOW_MISMATCH
Definition: nat44_ed.h:1053
snat_static_map_resolve_t::twice_nat
int twice_nat
Definition: nat44_ed.h:461
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
nat44_ed_out2in_node
vlib_node_registration_t nat44_ed_out2in_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_out2in_node)
Definition: nat44_ed_out2in.c:1406
STATIC_ASSERT_SIZEOF
STATIC_ASSERT_SIZEOF(nat_6t_t, 2 *sizeof(u64))
nat44_config_flags_t_
nat44_config_flags_t_
Definition: nat44_ed.h:52
nat_pre_trace_t::next_index
u32 next_index
Definition: nat44_ed.h:90
NAT_N_NEXT
@ NAT_N_NEXT
Definition: nat44_ed.h:85
snat_static_map_resolve_t::identity_nat
int identity_nat
Definition: nat44_ed.h:463
foreach_nat_in2out_ed_error
#define foreach_nat_in2out_ed_error
Definition: nat44_ed.h:127
nat44_lb_addr_port_t::fib_index
u32 fib_index
Definition: nat44_ed.h:390
nat_6t_flow_t::dport
u16 dport
Definition: nat44_ed.h:240
api_main_t
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:228
snat_main_s::fibs
nat_fib_t * fibs
Definition: nat44_ed.h:566
snat_main_per_thread_data_t::list_pool
dlist_elt_t * list_pool
Definition: nat44_ed.h:474
nat44_ed_is_twice_nat_session
static bool nat44_ed_is_twice_nat_session(snat_session_t *s)
Check if NAT session is twice NAT.
Definition: nat44_ed.h:748
id
u8 id[64]
Definition: dhcp.api:160
format_function_t
u8 *() format_function_t(u8 *s, va_list *args)
Definition: format.h:48
nat44_lb_addr_port_t::prefix
u8 prefix
Definition: nat44_ed.h:387
format_nat_ed_translation_error
format_function_t format_nat_ed_translation_error
Definition: nat44_ed.h:1069
SNAT_SESSION_FLAG_TWICE_NAT
#define SNAT_SESSION_FLAG_TWICE_NAT
Definition: nat44_ed.h:177
snat_main_per_thread_data_t::tcp_trans_lru_head_index
u32 tcp_trans_lru_head_index
Definition: nat44_ed.h:478
vnet_main_t
Definition: vnet.h:76
snat_main_s::msg_id_base
u16 msg_id_base
Definition: nat44_ed.h:652
nat_default_node
vlib_node_registration_t nat_default_node
(constructor) VLIB_REGISTER_NODE (nat_default_node)
Definition: nat44_ed.c:3510
nat44_ed_del_static_mapping
int nat44_ed_del_static_mapping(ip4_address_t l_addr, ip4_address_t e_addr, u16 l_port, u16 e_port, nat_protocol_t proto, u32 vrf_id, u32 sw_if_index, u32 flags)
Definition: nat44_ed.c:983
SNAT_SESSION_FLAG_LOAD_BALANCING
#define SNAT_SESSION_FLAG_LOAD_BALANCING
Definition: nat44_ed.h:176
nat44_is_idle_session_ctx_t
Definition: nat44_ed.h:680
always_inline
#define always_inline
Definition: rdma_mlx5dv.h:23
snat_main_s::frame_queue_nelts
u32 frame_queue_nelts
Definition: nat44_ed.h:671
NAT_FLOW_OP_DPORT_REWRITE
#define NAT_FLOW_OP_DPORT_REWRITE
Definition: nat44_ed.h:231
snat_main_s::max_translations_per_fib
u32 * max_translations_per_fib
Definition: nat44_ed.h:601
NAT_NEXT_IN2OUT_ED_OUTPUT_FAST_PATH
@ NAT_NEXT_IN2OUT_ED_OUTPUT_FAST_PATH
Definition: nat44_ed.h:79
nat_6t_flow_t::sport
u16 sport
Definition: nat44_ed.h:239
nat44_set_session_limit
int nat44_set_session_limit(u32 session_limit, u32 vrf_id)
Set NAT44 session limit (session limit, vrf id)
Definition: nat44_ed.c:3046
nat44_config_t
Definition: nat44_ed.h:59
nat44_lb_addr_port_t::vrf_id
u32 vrf_id
Definition: nat44_ed.h:389
u64
unsigned long u64
Definition: types.h:89
nat_6t_flow_sport_rewrite_set
static void nat_6t_flow_sport_rewrite_set(nat_6t_flow_t *f, u32 sport)
Definition: nat44_ed.h:266
TWICE_NAT
@ TWICE_NAT
Definition: nat44_ed.h:398
is_sm_self_twice_nat
static bool is_sm_self_twice_nat(u32 f)
Definition: nat44_ed.h:864
snat_interface_t::flags
u8 flags
Definition: nat44_ed.h:447
nat44_ed_is_interface_inside
static bool nat44_ed_is_interface_inside(snat_interface_t *i)
Check if NAT interface is inside.
Definition: nat44_ed.h:798
dport
u16 dport
Definition: pnat.api:44
ip.h
is_sm_identity_nat
static bool is_sm_identity_nat(u32 f)
Definition: nat44_ed.h:846
u32
unsigned int u32
Definition: types.h:88
snat_static_mapping_t::fib_index
u32 fib_index
Definition: nat44_ed.h:427
snat_static_mapping_t::pool_addr
ip4_address_t pool_addr
Definition: nat44_ed.h:416
nat44_ed_set_frame_queue_nelts
int nat44_ed_set_frame_queue_nelts(u32 frame_queue_nelts)
Definition: nat44_ed.c:2058
protocol
vl_api_ip_proto_t protocol
Definition: lb_types.api:72
nat_fib_t
Definition: nat44_ed.h:367
snat_main_s::max_cfg_sessions_gauge
u32 max_cfg_sessions_gauge
Definition: nat44_ed.h:615
NAT_ED_TRNSL_ERR_PACKET_TRUNCATED
@ NAT_ED_TRNSL_ERR_PACKET_TRUNCATED
Definition: nat44_ed.h:1054
nat44_config_t::static_mapping_only
u8 static_mapping_only
Definition: nat44_ed.h:62
snat_main_s::auto_add_sw_if_indices
u32 * auto_add_sw_if_indices
Definition: nat44_ed.h:550
snat_main_s::mss_clamping
u16 mss_clamping
Definition: nat44_ed.h:611
NAT_FLOW_OP_SADDR_REWRITE
#define NAT_FLOW_OP_SADDR_REWRITE
Definition: nat44_ed.h:228
snat_main_s::static_mapping_by_local
clib_bihash_8_8_t static_mapping_by_local
Definition: nat44_ed.h:525
format_ed_session_kvp
format_function_t format_ed_session_kvp
Definition: nat44_ed.h:1071
snat_main_s::max_translations_per_thread
u32 max_translations_per_thread
Definition: nat44_ed.h:600
as_u64
u64 as_u64
Definition: bihash_doc.h:63
snat_runtime_t
Definition: nat44_ed.h:686
unformat_function_t
uword() unformat_function_t(unformat_input_t *input, va_list *args)
Definition: format.h:225
snat_static_map_resolve_t::vrf_id
u32 vrf_id
Definition: nat44_ed.h:457
nat_6t_flow_t::icmp_id
u16 icmp_id
Definition: nat44_ed.h:243
NAT_NEXT_DROP
@ NAT_NEXT_DROP
Definition: nat44_ed.h:75
snat_main_s::inside_vrf_id
u32 inside_vrf_id
Definition: nat44_ed.h:605
bihash_16_8.h
NAT_NEXT_OUT2IN_ED_SLOW_PATH
@ NAT_NEXT_OUT2IN_ED_SLOW_PATH
Definition: nat44_ed.h:82
format_nat_6t_flow
format_function_t format_nat_6t_flow
Definition: nat44_ed.h:1070
icmp_echo_header_t
Definition: nat44_ei.h:88
ip_lookup_main_t
Definition: lookup.h:121
NAT_SM_FLAG_SWITCH_ADDRESS
#define NAT_SM_FLAG_SWITCH_ADDRESS
Definition: nat44_ed.h:196
nat_pre_trace_t
Definition: nat44_ed.h:88
snat_main_s::inside_fib_index
u32 inside_fib_index
Definition: nat44_ed.h:606
snat_main_s::foreach_nat_counter
foreach_nat_counter
Definition: nat44_ed.h:625
vlib_main_t
Definition: main.h:102
snat_static_map_resolve_t::proto
nat_protocol_t proto
Definition: nat44_ed.h:458
NAT_ED_TRNSL_ERR_INNER_IP_CORRUPT
@ NAT_ED_TRNSL_ERR_INNER_IP_CORRUPT
Definition: nat44_ed.h:1055
snat_static_map_resolve_t::sw_if_index
u32 sw_if_index
Definition: nat44_ed.h:456
nat44_is_idle_session_ctx_t::now
f64 now
Definition: nat44_ed.h:683
nat_fib_src_hi
fib_source_t nat_fib_src_hi
Definition: dslite.c:22
NAT_NEXT_OUT2IN_CLASSIFY
@ NAT_NEXT_OUT2IN_CLASSIFY
Definition: nat44_ed.h:84
nat44_plugin_enable
int nat44_plugin_enable(nat44_config_t c)
Definition: nat44_ed.c:2364
vlib_simple_counter_main_t
A collection of simple counters.
Definition: counter.h:57
NAT_SM_FLAG_SELF_TWICE_NAT
#define NAT_SM_FLAG_SELF_TWICE_NAT
Definition: nat44_ed.h:189
snat_static_map_resolve_t::out2in_only
int out2in_only
Definition: nat44_ed.h:462
nat_pre_out2in_node
vlib_node_registration_t nat_pre_out2in_node
(constructor) VLIB_REGISTER_NODE (nat_pre_out2in_node)
Definition: nat44_ed_out2in.c:1453
TCP_FLAG_ACK
#define TCP_FLAG_ACK
Definition: fa_node.h:16
b
vlib_buffer_t ** b
Definition: nat44_ei_out2in.c:717
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
NAT_IN2OUT_ED_N_ERROR
@ NAT_IN2OUT_ED_N_ERROR
Definition: nat44_ed.h:141
ip
vl_api_address_t ip
Definition: l2.api:558
snat_main_s::num_workers
u32 num_workers
Definition: nat44_ed.h:516
snat_main_s::hairpinning
vlib_simple_counter_main_t hairpinning
Definition: nat44_ed.h:647
icmp46_packet.h
NO_LB_NAT
@ NO_LB_NAT
Definition: nat44_ed.h:406
snat_interface_t
Definition: nat44_ed.h:444
snat_address_t::fib_index
u32 fib_index
Definition: nat44_ed.h:358
snat_main
snat_main_t snat_main
Definition: nat44_ed.c:41
i
int i
Definition: flowhash_template.h:376
foreach_nat_addr_and_port_alloc_alg
#define foreach_nat_addr_and_port_alloc_alg
Definition: nat44_ed.h:95
snat_static_mapping_t::external_addr
ip4_address_t external_addr
Definition: nat44_ed.h:420
NAT_FLOW_OP_SPORT_REWRITE
#define NAT_FLOW_OP_SPORT_REWRITE
Definition: nat44_ed.h:229
foreach_nat_out2in_ed_error
#define foreach_nat_out2in_ed_error
Definition: nat44_ed.h:144
nat44_config_t::connection_tracking
u8 connection_tracking
Definition: nat44_ed.h:63
snat_main_s::out2in
clib_bihash_8_8_t out2in
Definition: nat44_ed.h:535
fib_source_t
enum fib_source_t_ fib_source_t
The different sources that can create a route.
snat_interface_t::sw_if_index
u32 sw_if_index
Definition: nat44_ed.h:446
snat_main_s::alloc_addr_and_port
nat_alloc_out_addr_and_port_function_t * alloc_addr_and_port
Definition: nat44_ed.h:554
snat_static_mapping_t
Definition: nat44_ed.h:413
nat44_ed_add_interface
int nat44_ed_add_interface(u32 sw_if_index, u8 is_inside)
Definition: nat44_ed.c:1635
vrf_id
u32 vrf_id
Definition: nat44_ed.api:1053
nat_6t_t::saddr
ip4_address_t saddr
Definition: nat44_ed.h:214
nat44_config_t::outside_vrf
u32 outside_vrf
Definition: nat44_ed.h:66
nat44_ed_in2out_node
vlib_node_registration_t nat44_ed_in2out_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_in2out_node)
Definition: nat44_ed_in2out.c:1528
snat_static_map_resolve_t
Definition: nat44_ed.h:450
is_sm_exact_address
static bool is_sm_exact_address(u32 f)
Definition: nat44_ed.h:858
snat_in2out_output_node
vlib_node_registration_t snat_in2out_output_node
nat_6t_flow_t::l3_csum_delta
uword l3_csum_delta
Definition: nat44_ed.h:245
snat_address_t::addr
ip4_address_t addr
Definition: nat44_ed.h:357
SNAT_SESSION_FLAG_FWD_BYPASS
#define SNAT_SESSION_FLAG_FWD_BYPASS
Definition: nat44_ed.h:179
vnet.h
snat_main_per_thread_data_t
Definition: nat44_ed.h:468
api_errno.h
nat_translation_error_e
nat_translation_error_e
Definition: nat44_ed.h:1049
snat_runtime_t::cached_presence_by_ip4_address
uword * cached_presence_by_ip4_address
Definition: nat44_ed.h:689
nat_6t_t::sport
u16 sport
Definition: nat44_ed.h:215
proto
vl_api_ip_proto_t proto
Definition: acl_types.api:51
ip4_main_t
IPv4 main type.
Definition: ip4.h:107
snat_static_mapping_t::local_port
u16 local_port
Definition: nat44_ed.h:422
snat_static_mapping_t::affinity
u32 affinity
Definition: nat44_ed.h:431
nat44_is_idle_session_ctx_t::thread_index
u32 thread_index
Definition: nat44_ed.h:682
snat_main_per_thread_data_t::tcp_estab_lru_head_index
u32 tcp_estab_lru_head_index
Definition: nat44_ed.h:479
snat_main_s::static_mapping_only
u8 static_mapping_only
Definition: nat44_ed.h:593
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
rewrite
rewrite
Definition: pnat.api:158
snat_static_map_resolve_t::e_port
u16 e_port
Definition: nat44_ed.h:455
nat44_addresses_free
void nat44_addresses_free(snat_address_t **addresses)
Definition: nat44_ed.c:2442
NAT_ED_TRNSL_ERR_SUCCESS
@ NAT_ED_TRNSL_ERR_SUCCESS
Definition: nat44_ed.h:1051
nat_6t_flow_dport_rewrite_set
static void nat_6t_flow_dport_rewrite_set(nat_6t_flow_t *f, u32 dport)
Definition: nat44_ed.h:273
NAT_ED_TRNSL_ERR_TRANSLATION_FAILED
@ NAT_ED_TRNSL_ERR_TRANSLATION_FAILED
Definition: nat44_ed.h:1052
nat_alloc_out_addr_and_port_function_t
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: nat44_ed.h:503
snat_static_map_resolve_t::l_addr
ip4_address_t l_addr
Definition: nat44_ed.h:452
snat_main_s::static_mapping_connection_tracking
u8 static_mapping_connection_tracking
Definition: nat44_ed.h:594
nat_fib_t::ref_count
u32 ref_count
Definition: nat44_ed.h:370
snat_main_s::in2out_node_index
u32 in2out_node_index
Definition: nat44_ed.h:583
snat_main_s::auto_add_sw_if_indices_twice_nat
u32 * auto_add_sw_if_indices_twice_nat
Definition: nat44_ed.h:551
format_snat_session
format_function_t format_snat_session
Definition: nat44_ed.h:715
snat_main_s::api_main
api_main_t * api_main
Definition: nat44_ed.h:660
snat_session_state_t
snat_session_state_t
Definition: nat44_ed.h:120
snat_main_s::enabled
u8 enabled
Definition: nat44_ed.h:674
snat_main_s::random_seed
u32 random_seed
Definition: nat44_ed.h:575
snat_main_s::in2out
clib_bihash_8_8_t in2out
Definition: nat44_ed.h:534
na44_ed_is_fwd_bypass_session
static bool na44_ed_is_fwd_bypass_session(snat_session_t *s)
Check if NAT session is forwarding bypass.
Definition: nat44_ed.h:768
nat_6t_flow_txfib_rewrite_set
static void nat_6t_flow_txfib_rewrite_set(nat_6t_flow_t *f, u32 tx_fib_index)
Definition: nat44_ed.h:280
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
snat_static_map_resolve_t::exact
int exact
Definition: nat44_ed.h:464
snat_main_s::output_feature_interfaces
snat_interface_t * output_feature_interfaces
Definition: nat44_ed.h:542
nat44_ed_add_interface_address
int nat44_ed_add_interface_address(u32 sw_if_index, u8 twice_nat)
Definition: nat44_ed.c:3362
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105