FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
nat44_ed_out2in.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 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
17  * @brief NAT44 endpoint-dependent outside to inside network translation
18  */
19 
20 #include <vlib/vlib.h>
21 #include <vnet/vnet.h>
22 #include <vnet/ip/ip.h>
23 #include <vnet/ethernet/ethernet.h>
24 #include <vnet/fib/ip4_fib.h>
25 #include <vnet/udp/udp_local.h>
26 #include <vppinfra/error.h>
27 
28 #include <nat/lib/nat_syslog.h>
29 #include <nat/lib/ipfix_logging.h>
30 
31 #include <nat/nat44-ed/nat44_ed.h>
33 
34 static char *nat_out2in_ed_error_strings[] = {
35 #define _(sym,string) string,
37 #undef _
38 };
39 
40 typedef enum
41 {
48 
49 typedef struct
50 {
63 
64 static u8 *
65 format_slow_path_reason (u8 *s, va_list *args)
66 {
67  nat_slow_path_reason_e reason = va_arg (*args, nat_slow_path_reason_e);
68  switch (reason)
69  {
71  return format (s, "no reason for slow path");
73  return format (s, "slow path because lookup failed");
75  return format (s, "slow path because vrf expired");
77  return format (s, "slow path because tcp closed");
79  return format (s, "slow path because session expired");
80  }
81  return format (s, "invalid reason value");
82 }
83 
84 static u8 *
85 format_nat44_ed_out2in_trace (u8 * s, va_list * args)
86 {
87  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
88  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
89  nat44_ed_out2in_trace_t *t = va_arg (*args, nat44_ed_out2in_trace_t *);
90  char *tag;
91 
92  tag =
93  t->is_slow_path ? "NAT44_OUT2IN_ED_SLOW_PATH" :
94  "NAT44_OUT2IN_ED_FAST_PATH";
95 
96  s = format (s, "%s: sw_if_index %d, next index %d", tag, t->sw_if_index,
97  t->next_index);
98  if (~0 != t->session_index)
99  {
100  s = format (s, ", session %d, translation result '%U' via %s",
103  t->translation_via_i2of ? "i2of" : "o2if");
104  s = format (s, "\n i2of %U", format_nat_6t_flow, &t->i2of);
105  s = format (s, "\n o2if %U", format_nat_6t_flow, &t->o2if);
106  }
107  if (!t->is_slow_path)
108  {
109  if (t->lookup_skipped)
110  {
111  s = format (s, "\n lookup skipped - cached session index used");
112  }
113  else
114  {
115  s = format (s, "\n search key %U", format_ed_session_kvp,
116  &t->search_key);
117  }
118  s = format (s, "\n %U", format_slow_path_reason, t->slow_path_reason);
119  }
120 
121  return s;
122 }
123 
124 static int
126  u32 rx_fib_index)
127 {
129 
130  init_ed_k (&kv, ip->src_address, src_port, ip->dst_address, dst_port,
131  rx_fib_index, ip->protocol);
132  if (!clib_bihash_search_16_8 (&sm->flow_hash, &kv, &value))
133  return 1;
134 
135  return 0;
136 }
137 
139  snat_session_t *s, ip4_header_t *ip,
140  u32 rx_fib_index, u32 thread_index);
141 
142 static snat_session_t *create_session_for_static_mapping_ed (
143  snat_main_t *sm, vlib_buffer_t *b, ip4_address_t i2o_addr, u16 i2o_port,
144  u32 i2o_fib_index, ip4_address_t o2i_addr, u16 o2i_port, u32 o2i_fib_index,
145  nat_protocol_t nat_proto, vlib_node_runtime_t *node, u32 rx_fib_index,
147  snat_static_mapping_t *mapping);
148 
149 static inline u32
151  icmp46_header_t *icmp, u32 sw_if_index,
152  u32 rx_fib_index, vlib_node_runtime_t *node,
154  snat_session_t **s_p)
155 {
157 
158  ip_csum_t sum;
159  u16 checksum;
160 
161  snat_session_t *s = 0;
162  u8 is_addr_only, identity_nat;
163  ip4_address_t sm_addr;
164  u16 sm_port;
165  u32 sm_fib_index;
167  u8 lookup_protocol;
168  ip4_address_t lookup_saddr, lookup_daddr;
169  u16 lookup_sport, lookup_dport;
170 
171  sw_if_index = vnet_buffer (b)->sw_if_index[VLIB_RX];
173 
174  if (nat_get_icmp_session_lookup_values (b, ip, &lookup_saddr, &lookup_sport,
175  &lookup_daddr, &lookup_dport,
176  &lookup_protocol))
177  {
178  b->error = node->errors[NAT_OUT2IN_ED_ERROR_UNSUPPORTED_PROTOCOL];
180  goto out;
181  }
182 
184  vm, sm, ip->dst_address, lookup_sport, rx_fib_index,
185  ip_proto_to_nat_proto (ip->protocol), &sm_addr, &sm_port,
186  &sm_fib_index, 1, &is_addr_only, 0, 0, 0, &identity_nat, &m))
187  {
188  // static mapping not matched
189  if (!sm->forwarding_enabled)
190  {
191  /* Don't NAT packet aimed at the intfc address */
193  ip->dst_address.as_u32))
194  {
195  b->error = node->errors[NAT_OUT2IN_ED_ERROR_NO_TRANSLATION];
197  }
198  }
199  else
200  {
201  if (next_src_nat (sm, ip, lookup_sport, lookup_dport, rx_fib_index))
202  {
204  }
205  else
206  {
207  create_bypass_for_fwd (sm, b, s, ip, rx_fib_index, thread_index);
208  }
209  }
210  goto out;
211  }
212 
213  if (PREDICT_FALSE (vnet_buffer (b)->ip.reass.icmp_type_or_tcp_flags !=
214  ICMP4_echo_reply &&
215  (vnet_buffer (b)->ip.reass.icmp_type_or_tcp_flags !=
216  ICMP4_echo_request ||
217  !is_addr_only)))
218  {
219  b->error = node->errors[NAT_OUT2IN_ED_ERROR_BAD_ICMP_TYPE];
221  goto out;
222  }
223 
224  if (PREDICT_FALSE (identity_nat))
225  {
226  goto out;
227  }
228 
229  /* Create session initiated by host from external network */
231  sm, b, sm_addr, sm_port, sm_fib_index, ip->dst_address, lookup_sport,
232  rx_fib_index, ip_proto_to_nat_proto (lookup_protocol), node, rx_fib_index,
233  thread_index, 0, 0, vlib_time_now (vm), m);
234  if (!s)
236 
238  {
240  vm, b, (u8 *) icmp - (u8 *) vlib_buffer_get_current (b),
241  ntohs (ip->length) - ip4_header_bytes (ip), 0);
242  checksum = ~ip_csum_fold (sum);
243  if (checksum != 0 && checksum != 0xffff)
244  {
246  goto out;
247  }
248  }
249 
250  if (PREDICT_TRUE (next != NAT_NEXT_DROP && s))
251  {
252  /* Accounting */
255  /* Per-user LRU list maintenance */
257  }
258 out:
259  if (NAT_NEXT_DROP == next && s)
260  {
262  s = 0;
263  }
264  *s_p = s;
265  return next;
266 }
267 
268 // allocate exact address based on preference
274  u16 * port,
275  u16 port_per_thread, u32 snat_thread_index)
276 {
277  snat_main_t *sm = &snat_main;
278  u32 portnum;
279 
280  switch (proto)
281  {
282 #define _(N, j, n, s) \
283  case NAT_PROTOCOL_##N: \
284  if (a->busy_##n##_ports_per_thread[thread_index] < port_per_thread) \
285  { \
286  while (1) \
287  { \
288  portnum = (port_per_thread * \
289  snat_thread_index) + \
290  snat_random_port(0, port_per_thread - 1) + 1024; \
291  if (a->busy_##n##_port_refcounts[portnum]) \
292  continue; \
293  --a->busy_##n##_port_refcounts[portnum]; \
294  a->busy_##n##_ports_per_thread[thread_index]++; \
295  a->busy_##n##_ports++; \
296  *addr = a->addr; \
297  *port = clib_host_to_net_u16(portnum); \
298  return 0; \
299  } \
300  } \
301  break;
303 #undef _
304  default : nat_elog_info (sm, "unknown protocol");
305  return 1;
306  }
307 
308  /* Totally out of translations to use... */
310  return 1;
311 }
312 
317  u16 port_per_thread,
318  u32 snat_thread_index)
319 {
320  snat_main_t *sm = &snat_main;
321  snat_address_t *a, *ga = 0;
322  u32 portnum;
323  int i;
324 
325  for (i = 0; i < vec_len (addresses); i++)
326  {
327  a = addresses + i;
328  switch (proto)
329  {
330 #define _(N, j, n, s) \
331  case NAT_PROTOCOL_##N: \
332  if (a->busy_##n##_ports_per_thread[thread_index] < port_per_thread) \
333  { \
334  if (a->fib_index == fib_index) \
335  { \
336  while (1) \
337  { \
338  portnum = (port_per_thread * snat_thread_index) + \
339  snat_random_port (0, port_per_thread - 1) + 1024; \
340  if (a->busy_##n##_port_refcounts[portnum]) \
341  continue; \
342  --a->busy_##n##_port_refcounts[portnum]; \
343  a->busy_##n##_ports_per_thread[thread_index]++; \
344  a->busy_##n##_ports++; \
345  *addr = a->addr; \
346  *port = clib_host_to_net_u16 (portnum); \
347  return 0; \
348  } \
349  } \
350  else if (a->fib_index == ~0) \
351  { \
352  ga = a; \
353  } \
354  } \
355  break;
357 #undef _
358  default : nat_elog_info (sm, "unknown protocol");
359  return 1;
360  }
361  }
362 
363  if (ga)
364  {
365  a = ga;
366  switch (proto)
367  {
368 #define _(N, j, n, s) \
369  case NAT_PROTOCOL_##N: \
370  while (1) \
371  { \
372  portnum = (port_per_thread * snat_thread_index) + \
373  snat_random_port (0, port_per_thread - 1) + 1024; \
374  if (a->busy_##n##_port_refcounts[portnum]) \
375  continue; \
376  ++a->busy_##n##_port_refcounts[portnum]; \
377  a->busy_##n##_ports_per_thread[thread_index]++; \
378  a->busy_##n##_ports++; \
379  *addr = a->addr; \
380  *port = clib_host_to_net_u16 (portnum); \
381  return 0; \
382  }
383  break;
385 #undef _
386  default : nat_elog_info (sm, "unknown protocol");
387  return 1;
388  }
389  }
390 
391  /* Totally out of translations to use... */
393  return 1;
394 }
395 
396 static snat_session_t *
398  snat_main_t *sm, vlib_buffer_t *b, ip4_address_t i2o_addr, u16 i2o_port,
399  u32 i2o_fib_index, ip4_address_t o2i_addr, u16 o2i_port, u32 o2i_fib_index,
400  nat_protocol_t nat_proto, vlib_node_runtime_t *node, u32 rx_fib_index,
402  snat_static_mapping_t *mapping)
403 {
404  snat_session_t *s;
405  ip4_header_t *ip;
407 
408  if (PREDICT_FALSE
409  (nat44_ed_maximum_sessions_exceeded (sm, rx_fib_index, thread_index)))
410  {
411  b->error = node->errors[NAT_OUT2IN_ED_ERROR_MAX_SESSIONS_EXCEEDED];
412  nat_elog_notice (sm, "maximum sessions exceeded");
413  return 0;
414  }
415 
416  s = nat_ed_session_alloc (sm, thread_index, now, nat_proto);
417  if (!s)
418  {
419  b->error = node->errors[NAT_OUT2IN_ED_ERROR_MAX_SESSIONS_EXCEEDED];
420  nat_elog_warn (sm, "create NAT session failed");
421  return 0;
422  }
423 
425 
426  s->ext_host_addr.as_u32 = ip->src_address.as_u32;
427  s->ext_host_port =
428  nat_proto == NAT_PROTOCOL_ICMP ? 0 : vnet_buffer (b)->ip.reass.l4_src_port;
430  if (lb_nat)
432  if (lb_nat == AFFINITY_LB_NAT)
433  s->flags |= SNAT_SESSION_FLAG_AFFINITY;
434  s->out2in.addr = o2i_addr;
435  s->out2in.port = o2i_port;
436  s->out2in.fib_index = o2i_fib_index;
437  s->in2out.addr = i2o_addr;
438  s->in2out.port = i2o_port;
439  s->in2out.fib_index = i2o_fib_index;
440  s->nat_proto = nat_proto;
441 
442  if (NAT_PROTOCOL_ICMP == nat_proto)
443  {
444  nat_6t_o2i_flow_init (sm, thread_index, s, s->ext_host_addr, o2i_port,
445  o2i_addr, o2i_port, o2i_fib_index, ip->protocol);
446  nat_6t_flow_icmp_id_rewrite_set (&s->o2i, i2o_port);
447  }
448  else
449  {
450  nat_6t_o2i_flow_init (sm, thread_index, s, s->ext_host_addr,
451  s->ext_host_port, o2i_addr, o2i_port,
452  o2i_fib_index, ip->protocol);
453  nat_6t_flow_dport_rewrite_set (&s->o2i, i2o_port);
454  }
455  nat_6t_flow_daddr_rewrite_set (&s->o2i, i2o_addr.as_u32);
456  nat_6t_flow_txfib_rewrite_set (&s->o2i, i2o_fib_index);
457 
459  {
460  b->error = node->errors[NAT_OUT2IN_ED_ERROR_HASH_ADD_FAILED];
462  nat_elog_warn (sm, "out2in flow hash add failed");
463  return 0;
464  }
465 
466  if (twice_nat == TWICE_NAT || (twice_nat == TWICE_NAT_SELF &&
467  ip->src_address.as_u32 == i2o_addr.as_u32))
468  {
469  int rc = 0;
470  snat_address_t *filter = 0;
471 
472  // if exact address is specified use this address
473  if (is_sm_exact_address (mapping->flags))
474  {
475  snat_address_t *ap;
477  {
478  if (mapping->pool_addr.as_u32 == ap->addr.as_u32)
479  {
480  filter = ap;
481  break;
482  }
483  }
484  }
485 
486  if (filter)
487  {
488  rc = nat_alloc_addr_and_port_exact (filter,
489  thread_index,
490  nat_proto,
491  &s->ext_host_nat_addr,
492  &s->ext_host_nat_port,
493  sm->port_per_thread,
494  tsm->snat_thread_index);
496  }
497  else
498  {
500  sm->twice_nat_addresses, 0, thread_index, nat_proto,
501  &s->ext_host_nat_addr, &s->ext_host_nat_port, sm->port_per_thread,
502  tsm->snat_thread_index);
503  }
504 
505  if (rc)
506  {
507  b->error = node->errors[NAT_OUT2IN_ED_ERROR_OUT_OF_PORTS];
509  {
510  nat_elog_warn (sm, "out2in flow hash del failed");
511  }
513  sm->twice_nat_addresses, thread_index, &s->ext_host_nat_addr,
514  s->ext_host_nat_port, s->nat_proto);
516  return 0;
517  }
518 
519  s->flags |= SNAT_SESSION_FLAG_TWICE_NAT;
520 
521  nat_6t_flow_saddr_rewrite_set (&s->o2i, s->ext_host_nat_addr.as_u32);
522  if (NAT_PROTOCOL_ICMP == nat_proto)
523  {
524  nat_6t_flow_icmp_id_rewrite_set (&s->o2i, s->ext_host_nat_port);
525  }
526  else
527  {
528  nat_6t_flow_sport_rewrite_set (&s->o2i, s->ext_host_nat_port);
529  }
530 
531  nat_6t_l3_l4_csum_calc (&s->o2i);
532 
533  nat_6t_i2o_flow_init (sm, thread_index, s, i2o_addr, i2o_port,
534  s->ext_host_nat_addr, s->ext_host_nat_port,
535  i2o_fib_index, ip->protocol);
536  nat_6t_flow_daddr_rewrite_set (&s->i2o, s->ext_host_addr.as_u32);
537  if (NAT_PROTOCOL_ICMP == nat_proto)
538  {
539  nat_6t_flow_icmp_id_rewrite_set (&s->i2o, s->ext_host_port);
540  }
541  else
542  {
543  nat_6t_flow_dport_rewrite_set (&s->i2o, s->ext_host_port);
544  }
545  }
546  else
547  {
548  if (NAT_PROTOCOL_ICMP == nat_proto)
549  {
550  nat_6t_i2o_flow_init (sm, thread_index, s, i2o_addr, i2o_port,
551  s->ext_host_addr, i2o_port, i2o_fib_index,
552  ip->protocol);
553  }
554  else
555  {
556  nat_6t_i2o_flow_init (sm, thread_index, s, i2o_addr, i2o_port,
557  s->ext_host_addr, s->ext_host_port,
558  i2o_fib_index, ip->protocol);
559  }
560  }
561 
562  nat_6t_flow_saddr_rewrite_set (&s->i2o, o2i_addr.as_u32);
563  if (NAT_PROTOCOL_ICMP == nat_proto)
564  {
565  nat_6t_flow_icmp_id_rewrite_set (&s->i2o, o2i_port);
566  }
567  else
568  {
569  nat_6t_flow_sport_rewrite_set (&s->i2o, o2i_port);
570  }
571 
573  {
574  nat_elog_notice (sm, "in2out flow hash add failed");
576  {
577  nat_elog_warn (sm, "out2in flow hash del failed");
578  }
580  return 0;
581  }
582 
584  s->in2out.addr.as_u32,
585  s->out2in.addr.as_u32,
586  s->nat_proto,
587  s->in2out.port,
588  s->out2in.port, s->in2out.fib_index);
589 
590  nat_syslog_nat44_sadd (0, s->in2out.fib_index, &s->in2out.addr,
591  s->in2out.port, &s->ext_host_nat_addr,
592  s->ext_host_nat_port, &s->out2in.addr, s->out2in.port,
593  &s->ext_host_addr, s->ext_host_port, s->nat_proto,
595 
597 
598  return s;
599 }
600 
601 static void
603  ip4_header_t *ip, u32 rx_fib_index, u32 thread_index)
604 {
608  f64 now = vlib_time_now (vm);
609  u16 lookup_sport, lookup_dport;
610  u8 lookup_protocol;
611  ip4_address_t lookup_saddr, lookup_daddr;
612 
613  if (ip->protocol == IP_PROTOCOL_ICMP)
614  {
615  if (nat_get_icmp_session_lookup_values (b, ip, &lookup_daddr,
616  &lookup_sport, &lookup_saddr,
617  &lookup_dport, &lookup_protocol))
618  return;
619  }
620  else
621  {
622  if (ip->protocol == IP_PROTOCOL_UDP || ip->protocol == IP_PROTOCOL_TCP)
623  {
624  lookup_sport = vnet_buffer (b)->ip.reass.l4_dst_port;
625  lookup_dport = vnet_buffer (b)->ip.reass.l4_src_port;
626  }
627  else
628  {
629  lookup_sport = 0;
630  lookup_dport = 0;
631  }
632  lookup_saddr.as_u32 = ip->dst_address.as_u32;
633  lookup_daddr.as_u32 = ip->src_address.as_u32;
634  lookup_protocol = ip->protocol;
635  }
636 
637  init_ed_k (&kv, lookup_saddr, lookup_sport, lookup_daddr, lookup_dport,
638  rx_fib_index, lookup_protocol);
639 
640  if (!clib_bihash_search_16_8 (&sm->flow_hash, &kv, &value))
641  {
643  s =
646  }
647  else if (ip->protocol == IP_PROTOCOL_ICMP &&
649  (vnet_buffer (b)->ip.reass.icmp_type_or_tcp_flags))
650  {
651  return;
652  }
653  else
654  {
655  u32 proto;
656 
657  if (PREDICT_FALSE
659  (sm, rx_fib_index, thread_index)))
660  return;
661 
662  s = nat_ed_session_alloc (sm, thread_index, now, ip->protocol);
663  if (!s)
664  {
665  nat_elog_warn (sm, "create NAT session failed");
666  return;
667  }
668 
669  proto = ip_proto_to_nat_proto (ip->protocol);
670 
671  s->ext_host_addr = ip->src_address;
672  s->ext_host_port = lookup_dport;
673  s->flags |= SNAT_SESSION_FLAG_FWD_BYPASS;
674  s->out2in.addr = ip->dst_address;
675  s->out2in.port = lookup_sport;
676  s->nat_proto = proto;
677  if (proto == NAT_PROTOCOL_OTHER)
678  {
680  s->out2in.port = ip->protocol;
681  }
682  s->out2in.fib_index = rx_fib_index;
683  s->in2out.addr = s->out2in.addr;
684  s->in2out.port = s->out2in.port;
685  s->in2out.fib_index = s->out2in.fib_index;
686 
687  nat_6t_i2o_flow_init (sm, thread_index, s, ip->dst_address, lookup_sport,
688  ip->src_address, lookup_dport, rx_fib_index,
689  ip->protocol);
690  nat_6t_flow_txfib_rewrite_set (&s->i2o, rx_fib_index);
692  {
693  nat_elog_notice (sm, "in2out flow add failed");
695  return;
696  }
697 
699  }
700 
701  if (ip->protocol == IP_PROTOCOL_TCP)
702  {
704  nat44_set_tcp_session_state_o2i (sm, now, s, tcp->flags,
705  tcp->ack_number, tcp->seq_number,
706  thread_index);
707  }
708 
709  /* Accounting */
711  /* Per-user LRU list maintenance */
713 }
714 
715 static snat_session_t *
717  ip4_header_t *ip, u32 rx_fib_index,
719  vlib_main_t *vm,
721 {
724  snat_session_t *s;
725 
726  if (PREDICT_FALSE (
728  {
729  b->error = node->errors[NAT_OUT2IN_ED_ERROR_MAX_SESSIONS_EXCEEDED];
730  nat_elog_notice (sm, "maximum sessions exceeded");
731  return 0;
732  }
733 
734  init_nat_k (&kv, ip->dst_address, 0, 0, 0);
735  if (clib_bihash_search_8_8 (&sm->static_mapping_by_external, &kv, &value))
736  {
737  b->error = node->errors[NAT_OUT2IN_ED_ERROR_NO_TRANSLATION];
738  return 0;
739  }
740 
741  m = pool_elt_at_index (sm->static_mappings, value.value);
742 
743  /* Create a new session */
744  s = nat_ed_session_alloc (sm, thread_index, now, ip->protocol);
745  if (!s)
746  {
747  b->error = node->errors[NAT_OUT2IN_ED_ERROR_MAX_SESSIONS_EXCEEDED];
748  nat_elog_warn (sm, "create NAT session failed");
749  return 0;
750  }
751 
752  s->ext_host_addr.as_u32 = ip->src_address.as_u32;
755  s->out2in.addr.as_u32 = ip->dst_address.as_u32;
756  s->out2in.fib_index = rx_fib_index;
757  s->in2out.addr.as_u32 = m->local_addr.as_u32;
758  s->in2out.fib_index = m->fib_index;
759  s->in2out.port = s->out2in.port = ip->protocol;
760 
761  nat_6t_o2i_flow_init (sm, thread_index, s, ip->dst_address, 0,
762  ip->src_address, 0, m->fib_index, ip->protocol);
763  nat_6t_flow_saddr_rewrite_set (&s->i2o, ip->dst_address.as_u32);
765  {
766  nat_elog_notice (sm, "in2out key add failed");
768  return NULL;
769  }
770 
771  nat_6t_o2i_flow_init (sm, thread_index, s, ip->src_address, 0,
772  ip->dst_address, 0, rx_fib_index, ip->protocol);
776  {
777  nat_elog_notice (sm, "out2in flow hash add failed");
779  return NULL;
780  }
781 
783 
784  /* Accounting */
786  thread_index);
787  /* Per-user LRU list maintenance */
789 
790  return s;
791 }
792 
793 static inline uword
797  int is_multi_worker)
798 {
799  u32 n_left_from, *from;
800  snat_main_t *sm = &snat_main;
801  f64 now = vlib_time_now (vm);
804 
806  n_left_from = frame->n_vectors;
807 
811 
812  while (n_left_from > 0)
813  {
814  vlib_buffer_t *b0;
815  u32 sw_if_index0, rx_fib_index0;
816  nat_protocol_t proto0;
817  ip4_header_t *ip0;
818  snat_session_t *s0 = 0;
819  clib_bihash_kv_16_8_t kv0, value0;
822  nat_6t_flow_t *f = 0;
824  int lookup_skipped = 0;
825 
826  b0 = *b;
827  b++;
828 
829  /* Prefetch next iteration. */
830  if (PREDICT_TRUE (n_left_from >= 2))
831  {
832  vlib_buffer_t *p2;
833 
834  p2 = *b;
835 
836  vlib_prefetch_buffer_header (p2, LOAD);
837 
838  clib_prefetch_load (p2->data);
839  }
840 
841  next[0] = vnet_buffer2 (b0)->nat.arc_next;
842 
843  lookup.sport = vnet_buffer (b0)->ip.reass.l4_src_port;
844  lookup.dport = vnet_buffer (b0)->ip.reass.l4_dst_port;
845 
846  vnet_buffer (b0)->snat.flags = 0;
847  ip0 = vlib_buffer_get_current (b0);
848 
849  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
850  rx_fib_index0 =
852 
853  lookup.fib_index = rx_fib_index0;
854 
855  if (PREDICT_FALSE (ip0->ttl == 1))
856  {
857  vnet_buffer (b0)->sw_if_index[VLIB_TX] = (u32) ~ 0;
858  icmp4_error_set_vnet_buffer (b0, ICMP4_time_exceeded,
859  ICMP4_time_exceeded_ttl_exceeded_in_transit,
860  0);
862  goto trace0;
863  }
864 
865  proto0 = ip_proto_to_nat_proto (ip0->protocol);
866 
867  if (PREDICT_FALSE (proto0 == NAT_PROTOCOL_ICMP))
868  {
869  if (vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags !=
870  ICMP4_echo_request &&
871  vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags !=
872  ICMP4_echo_reply &&
874  vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags))
875  {
876  b0->error = node->errors[NAT_OUT2IN_ED_ERROR_BAD_ICMP_TYPE];
877  next[0] = NAT_NEXT_DROP;
878  goto trace0;
879  }
881  b0, ip0, &lookup.saddr, &lookup.sport, &lookup.daddr,
882  &lookup.dport, &lookup.proto);
883  if (err != 0)
884  {
885  b0->error = node->errors[err];
886  next[0] = NAT_NEXT_DROP;
887  goto trace0;
888  }
889  }
890  else
891  {
892  lookup.saddr.as_u32 = ip0->src_address.as_u32;
893  lookup.daddr.as_u32 = ip0->dst_address.as_u32;
894  lookup.proto = ip0->protocol;
895  }
896 
897  /* there might be a stashed index in vnet_buffer2 from handoff or
898  * classify node, see if it can be used */
899  if (is_multi_worker &&
901  vnet_buffer2 (b0)->nat.cached_session_index))
902  {
903  s0 = pool_elt_at_index (tsm->sessions,
904  vnet_buffer2 (b0)->nat.cached_session_index);
905  if (PREDICT_TRUE (nat_6t_t_eq (&s0->o2i.match, &lookup)) ||
906  (s0->flags & SNAT_SESSION_FLAG_TWICE_NAT &&
907  nat_6t_t_eq (&s0->i2o.match, &lookup)))
908  {
909  /* yes, this is the droid we're looking for */
910  lookup_skipped = 1;
911  goto skip_lookup;
912  }
913  s0 = NULL;
914  }
915 
916  init_ed_k (&kv0, lookup.saddr, lookup.sport, lookup.daddr, lookup.dport,
917  lookup.fib_index, lookup.proto);
918 
919  // lookup flow
920  if (clib_bihash_search_16_8 (&sm->flow_hash, &kv0, &value0))
921  {
922  // flow does not exist go slow path
923  slow_path_reason = NAT_ED_SP_REASON_LOOKUP_FAILED;
925  goto trace0;
926  }
928  s0 =
930  ed_value_get_session_index (&value0));
931  skip_lookup:
932 
933  ASSERT (thread_index == s0->thread_index);
934 
936  {
937  // session is closed, go slow path
938  nat_free_session_data (sm, s0, thread_index, 0);
939  nat_ed_session_delete (sm, s0, thread_index, 1);
940  slow_path_reason = NAT_ED_SP_REASON_VRF_EXPIRED;
942  goto trace0;
943  }
944 
945  if (s0->tcp_closed_timestamp)
946  {
947  if (now >= s0->tcp_closed_timestamp)
948  {
949  // session is closed, go slow path, freed in slow path
950  slow_path_reason = NAT_ED_SP_TCP_CLOSED;
952  }
953  else
954  {
955  // session in transitory timeout, drop
956  b0->error = node->errors[NAT_OUT2IN_ED_ERROR_TCP_CLOSED];
957  next[0] = NAT_NEXT_DROP;
958  }
959  goto trace0;
960  }
961 
962  // drop if session expired
963  u64 sess_timeout_time;
964  sess_timeout_time =
965  s0->last_heard + (f64) nat44_session_get_timeout (sm, s0);
966  if (now >= sess_timeout_time)
967  {
968  // session is closed, go slow path
969  nat_free_session_data (sm, s0, thread_index, 0);
970  nat_ed_session_delete (sm, s0, thread_index, 1);
971  slow_path_reason = NAT_ED_SP_SESS_EXPIRED;
973  goto trace0;
974  }
975 
976  if (nat_6t_t_eq (&s0->o2i.match, &lookup))
977  {
978  f = &s0->o2i;
979  }
980  else if (s0->flags & SNAT_SESSION_FLAG_TWICE_NAT &&
981  nat_6t_t_eq (&s0->i2o.match, &lookup))
982  {
983  f = &s0->i2o;
984  }
985  else
986  {
987  /*
988  * Send DHCP packets to the ipv4 stack, or we won't
989  * be able to use dhcp client on the outside interface
990  */
991  if (PREDICT_FALSE (
992  proto0 == NAT_PROTOCOL_UDP &&
993  (vnet_buffer (b0)->ip.reass.l4_dst_port ==
994  clib_host_to_net_u16 (UDP_DST_PORT_dhcp_to_client))))
995  {
996  goto trace0;
997  }
998 
999  if (!sm->forwarding_enabled)
1000  {
1001  b0->error = node->errors[NAT_OUT2IN_ED_ERROR_NO_TRANSLATION];
1002  next[0] = NAT_NEXT_DROP;
1003  goto trace0;
1004  }
1005  else
1006  {
1007  if (nat_6t_t_eq (&s0->i2o.match, &lookup))
1008  {
1009  f = &s0->i2o;
1010  }
1011  else
1012  {
1013  // FIXME TODO bypass ???
1014  // create_bypass_for_fwd (sm, b0, s0, ip0, rx_fib_index0,
1015  // thread_index);
1016  translation_error = NAT_ED_TRNSL_ERR_FLOW_MISMATCH;
1017  nat_free_session_data (sm, s0, thread_index, 0);
1018  nat_ed_session_delete (sm, s0, thread_index, 1);
1019  next[0] = NAT_NEXT_DROP;
1020  b0->error = node->errors[NAT_OUT2IN_ED_ERROR_TRNSL_FAILED];
1021  goto trace0;
1022  }
1023  }
1024  }
1025 
1027  (translation_error = nat_6t_flow_buf_translate_o2i (
1028  vm, sm, b0, ip0, f, proto0, 0 /* is_output_feature */)))
1029  {
1030  next[0] = NAT_NEXT_DROP;
1031  b0->error = node->errors[NAT_OUT2IN_ED_ERROR_TRNSL_FAILED];
1032  goto trace0;
1033  }
1034 
1035  switch (proto0)
1036  {
1037  case NAT_PROTOCOL_TCP:
1039  thread_index, sw_if_index0, 1);
1041  vnet_buffer (b0)->ip.
1042  reass.icmp_type_or_tcp_flags,
1043  vnet_buffer (b0)->ip.
1044  reass.tcp_ack_number,
1045  vnet_buffer (b0)->ip.
1046  reass.tcp_seq_number,
1047  thread_index);
1048  break;
1049  case NAT_PROTOCOL_UDP:
1051  thread_index, sw_if_index0, 1);
1052  break;
1053  case NAT_PROTOCOL_ICMP:
1055  thread_index, sw_if_index0, 1);
1056  break;
1057  case NAT_PROTOCOL_OTHER:
1058  vlib_increment_simple_counter (&sm->counters.fastpath.out2in.other,
1059  thread_index, sw_if_index0, 1);
1060  break;
1061  }
1062 
1063  /* Accounting */
1066  thread_index);
1067  /* Per-user LRU list maintenance */
1069 
1070  trace0:
1071  if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
1072  && (b0->flags & VLIB_BUFFER_IS_TRACED)))
1073  {
1075  vlib_add_trace (vm, node, b0, sizeof (*t));
1076  t->sw_if_index = sw_if_index0;
1077  t->next_index = next[0];
1078  t->is_slow_path = 0;
1079  t->translation_error = translation_error;
1080  clib_memcpy (&t->search_key, &kv0, sizeof (t->search_key));
1081  t->lookup_skipped = lookup_skipped;
1082  t->slow_path_reason = slow_path_reason;
1083 
1084  if (s0)
1085  {
1086  t->session_index = s0 - tsm->sessions;
1087  clib_memcpy (&t->i2of, &s0->i2o, sizeof (t->i2of));
1088  clib_memcpy (&t->o2if, &s0->o2i, sizeof (t->o2if));
1089  t->translation_via_i2of = (&s0->i2o == f);
1090  }
1091  else
1092  {
1093  t->session_index = ~0;
1094  }
1095  }
1096 
1097  if (next[0] == NAT_NEXT_DROP)
1098  {
1099  vlib_increment_simple_counter (&sm->counters.fastpath.out2in.drops,
1100  thread_index, sw_if_index0, 1);
1101  }
1102 
1103  n_left_from--;
1104  next++;
1105  }
1106 
1108  frame->n_vectors);
1109  return frame->n_vectors;
1110 }
1111 
1112 static inline uword
1115  vlib_frame_t * frame)
1116 {
1117  u32 n_left_from, *from;
1118  snat_main_t *sm = &snat_main;
1119  f64 now = vlib_time_now (vm);
1123 
1125  n_left_from = frame->n_vectors;
1126 
1130 
1131  while (n_left_from > 0)
1132  {
1133  vlib_buffer_t *b0;
1134  u32 sw_if_index0, rx_fib_index0;
1135  nat_protocol_t proto0;
1136  ip4_header_t *ip0;
1137  udp_header_t *udp0;
1138  icmp46_header_t *icmp0;
1139  snat_session_t *s0 = 0;
1140  clib_bihash_kv_16_8_t kv0, value0;
1141  lb_nat_type_t lb_nat0;
1142  twice_nat_type_t twice_nat0;
1143  u8 identity_nat0;
1144  ip4_address_t sm_addr;
1145  u16 sm_port;
1146  u32 sm_fib_index;
1148 
1149  b0 = *b;
1150  next[0] = vnet_buffer2 (b0)->nat.arc_next;
1151 
1152  vnet_buffer (b0)->snat.flags = 0;
1153  ip0 = vlib_buffer_get_current (b0);
1154 
1155  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
1156  rx_fib_index0 =
1158 
1159  if (PREDICT_FALSE (ip0->ttl == 1))
1160  {
1161  vnet_buffer (b0)->sw_if_index[VLIB_TX] = (u32) ~ 0;
1162  icmp4_error_set_vnet_buffer (b0, ICMP4_time_exceeded,
1163  ICMP4_time_exceeded_ttl_exceeded_in_transit,
1164  0);
1166  goto trace0;
1167  }
1168 
1169  udp0 = ip4_next_header (ip0);
1170  icmp0 = (icmp46_header_t *) udp0;
1171  proto0 = ip_proto_to_nat_proto (ip0->protocol);
1172 
1173  if (PREDICT_FALSE (proto0 == NAT_PROTOCOL_OTHER))
1174  {
1176  sm, b0, ip0, rx_fib_index0, thread_index, now, vm, node);
1177  if (!sm->forwarding_enabled)
1178  {
1179  if (!s0)
1180  next[0] = NAT_NEXT_DROP;
1181  }
1182  if (NAT_NEXT_DROP != next[0] && s0 &&
1184  (translation_error = nat_6t_flow_buf_translate_o2i (
1185  vm, sm, b0, ip0, &s0->o2i, proto0,
1186  0 /* is_output_feature */)))
1187  {
1188  next[0] = NAT_NEXT_DROP;
1189  b0->error = node->errors[NAT_OUT2IN_ED_ERROR_TRNSL_FAILED];
1190  goto trace0;
1191  }
1192 
1193  vlib_increment_simple_counter (&sm->counters.slowpath.out2in.other,
1194  thread_index, sw_if_index0, 1);
1195  goto trace0;
1196  }
1197 
1198  if (PREDICT_FALSE (proto0 == NAT_PROTOCOL_ICMP))
1199  {
1201  (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
1202  next[0], now, thread_index, &s0);
1203 
1204  if (NAT_NEXT_DROP != next[0] && s0 &&
1206  (translation_error = nat_6t_flow_buf_translate_o2i (
1207  vm, sm, b0, ip0, &s0->o2i, proto0,
1208  0 /* is_output_feature */)))
1209  {
1210  next[0] = NAT_NEXT_DROP;
1211  b0->error = node->errors[NAT_OUT2IN_ED_ERROR_TRNSL_FAILED];
1212  goto trace0;
1213  }
1214 
1216  thread_index, sw_if_index0, 1);
1217  goto trace0;
1218  }
1219 
1220  init_ed_k (&kv0, ip0->src_address,
1221  vnet_buffer (b0)->ip.reass.l4_src_port, ip0->dst_address,
1222  vnet_buffer (b0)->ip.reass.l4_dst_port, rx_fib_index0,
1223  ip0->protocol);
1224 
1225  s0 = NULL;
1226  if (!clib_bihash_search_16_8 (&sm->flow_hash, &kv0, &value0))
1227  {
1229  s0 =
1231  ed_value_get_session_index (&value0));
1232 
1233  if (s0->tcp_closed_timestamp && now >= s0->tcp_closed_timestamp)
1234  {
1235  nat_free_session_data (sm, s0, thread_index, 0);
1236  nat_ed_session_delete (sm, s0, thread_index, 1);
1237  s0 = NULL;
1238  }
1239  }
1240 
1241  if (!s0)
1242  {
1243  /* Try to match static mapping by external address and port,
1244  destination address and port in packet */
1245 
1247  vm, sm, ip0->dst_address,
1248  vnet_buffer (b0)->ip.reass.l4_dst_port, rx_fib_index0, proto0,
1249  &sm_addr, &sm_port, &sm_fib_index, 1, 0, &twice_nat0, &lb_nat0,
1250  &ip0->src_address, &identity_nat0, &m))
1251  {
1252  /*
1253  * Send DHCP packets to the ipv4 stack, or we won't
1254  * be able to use dhcp client on the outside interface
1255  */
1256  if (PREDICT_FALSE (proto0 == NAT_PROTOCOL_UDP
1257  && (vnet_buffer (b0)->ip.reass.l4_dst_port ==
1258  clib_host_to_net_u16
1259  (UDP_DST_PORT_dhcp_to_client))))
1260  {
1261  goto trace0;
1262  }
1263 
1264  if (!sm->forwarding_enabled)
1265  {
1266  b0->error =
1267  node->errors[NAT_OUT2IN_ED_ERROR_NO_TRANSLATION];
1268  next[0] = NAT_NEXT_DROP;
1269  }
1270  else
1271  {
1272  if (next_src_nat (
1273  sm, ip0, vnet_buffer (b0)->ip.reass.l4_src_port,
1274  vnet_buffer (b0)->ip.reass.l4_dst_port, rx_fib_index0))
1275  {
1277  }
1278  else
1279  {
1280  create_bypass_for_fwd (sm, b0, s0, ip0, rx_fib_index0,
1281  thread_index);
1282  }
1283  }
1284  goto trace0;
1285  }
1286 
1287  if (PREDICT_FALSE (identity_nat0))
1288  goto trace0;
1289 
1290  if ((proto0 == NAT_PROTOCOL_TCP)
1291  && !tcp_flags_is_init (vnet_buffer (b0)->ip.
1292  reass.icmp_type_or_tcp_flags))
1293  {
1294  b0->error = node->errors[NAT_OUT2IN_ED_ERROR_NON_SYN];
1295  next[0] = NAT_NEXT_DROP;
1296  goto trace0;
1297  }
1298 
1299  /* Create session initiated by host from external network */
1301  sm_addr, sm_port,
1302  sm_fib_index,
1303  ip0->dst_address,
1304  vnet_buffer (b0)->
1305  ip.reass.l4_dst_port,
1306  rx_fib_index0, proto0,
1307  node, rx_fib_index0,
1308  thread_index, twice_nat0,
1309  lb_nat0, now, m);
1310  if (!s0)
1311  {
1312  next[0] = NAT_NEXT_DROP;
1313  goto trace0;
1314  }
1315  }
1316 
1318  (translation_error = nat_6t_flow_buf_translate_o2i (
1319  vm, sm, b0, ip0, &s0->o2i, proto0, 0 /* is_output_feature */)))
1320  {
1321  next[0] = NAT_NEXT_DROP;
1322  goto trace0;
1323  }
1324 
1325  if (PREDICT_TRUE (proto0 == NAT_PROTOCOL_TCP))
1326  {
1328  thread_index, sw_if_index0, 1);
1330  vnet_buffer (b0)->ip.
1331  reass.icmp_type_or_tcp_flags,
1332  vnet_buffer (b0)->ip.
1333  reass.tcp_ack_number,
1334  vnet_buffer (b0)->ip.
1335  reass.tcp_seq_number,
1336  thread_index);
1337  }
1338  else
1339  {
1341  thread_index, sw_if_index0, 1);
1342  }
1343 
1344  /* Accounting */
1347  thread_index);
1348  /* Per-user LRU list maintenance */
1350 
1351  trace0:
1352  if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
1353  && (b0->flags & VLIB_BUFFER_IS_TRACED)))
1354  {
1356  vlib_add_trace (vm, node, b0, sizeof (*t));
1357  t->sw_if_index = sw_if_index0;
1358  t->next_index = next[0];
1359  t->is_slow_path = 1;
1360  t->translation_error = translation_error;
1361  clib_memcpy (&t->search_key, &kv0, sizeof (t->search_key));
1362 
1363  if (s0)
1364  {
1365  t->session_index = s0 - tsm->sessions;
1366  clib_memcpy (&t->i2of, &s0->i2o, sizeof (t->i2of));
1367  clib_memcpy (&t->o2if, &s0->o2i, sizeof (t->o2if));
1368  }
1369  else
1370  {
1371  t->session_index = ~0;
1372  }
1373  }
1374 
1375  if (next[0] == NAT_NEXT_DROP)
1376  {
1377  vlib_increment_simple_counter (&sm->counters.slowpath.out2in.drops,
1378  thread_index, sw_if_index0, 1);
1379  }
1380 
1381  n_left_from--;
1382  next++;
1383  b++;
1384  }
1385 
1387  frame->n_vectors);
1388 
1389  return frame->n_vectors;
1390 }
1391 
1394  vlib_frame_t * frame)
1395 {
1396  if (snat_main.num_workers > 1)
1397  {
1399  }
1400  else
1401  {
1403  }
1404 }
1405 
1407  .name = "nat44-ed-out2in",
1408  .vector_size = sizeof (u32),
1409  .sibling_of = "nat-default",
1410  .format_trace = format_nat44_ed_out2in_trace,
1413  .error_strings = nat_out2in_ed_error_strings,
1414  .runtime_data_bytes = sizeof (snat_runtime_t),
1415 };
1416 
1419  vlib_frame_t * frame)
1420 {
1422 }
1423 
1425  .name = "nat44-ed-out2in-slowpath",
1426  .vector_size = sizeof (u32),
1427  .sibling_of = "nat-default",
1428  .format_trace = format_nat44_ed_out2in_trace,
1431  .error_strings = nat_out2in_ed_error_strings,
1432  .runtime_data_bytes = sizeof (snat_runtime_t),
1433 };
1434 
1435 static u8 *
1436 format_nat_pre_trace (u8 * s, va_list * args)
1437 {
1438  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
1439  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
1440  nat_pre_trace_t *t = va_arg (*args, nat_pre_trace_t *);
1441  return format (s, "out2in next_index %d arc_next_index %d", t->next_index,
1442  t->arc_next_index);
1443 }
1444 
1447  vlib_frame_t * frame)
1448 {
1449  return nat_pre_node_fn_inline (vm, node, frame,
1451 }
1452 
1454  .name = "nat-pre-out2in",
1455  .vector_size = sizeof (u32),
1456  .sibling_of = "nat-default",
1457  .format_trace = format_nat_pre_trace,
1459  .n_errors = 0,
1460  };
1461 
1462 /*
1463  * fd.io coding-style-patch-verification: ON
1464  *
1465  * Local Variables:
1466  * eval: (c-set-style "gnu")
1467  * End:
1468  */
vlib.h
ed_value_get_thread_index
static u32 ed_value_get_thread_index(clib_bihash_kv_16_8_t *value)
Definition: nat44_ed_inlines.h:140
snat_main_s::port_per_thread
u16 port_per_thread
Definition: nat44_ed.h:519
next_src_nat
static int next_src_nat(snat_main_t *sm, ip4_header_t *ip, u16 src_port, u16 dst_port, u32 rx_fib_index)
Definition: nat44_ed_out2in.c:125
snat_main_s::fastpath
struct snat_main_s::@746::@747 fastpath
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
nat44_ed_out2in_trace_t::translation_error
nat_translation_error_e translation_error
Definition: nat44_ed_out2in.c:54
nat44_ed_out2in_trace_t::translation_via_i2of
u8 translation_via_i2of
Definition: nat44_ed_out2in.c:59
nat_elog_notice
#define nat_elog_notice(_pm, nat_elog_str)
Definition: log.h:175
ed_value_get_session_index
static u32 ed_value_get_session_index(clib_bihash_kv_16_8_t *value)
Definition: nat44_ed_inlines.h:146
snat_main_s::static_mappings
snat_static_mapping_t * static_mappings
Definition: nat44_ed.h:531
ntohs
#define ntohs(x)
Definition: af_xdp.bpf.c:29
thread_index
u32 thread_index
Definition: nat44_ei_hairpinning.c:495
nat44_ed_out2in_trace_t::search_key
clib_bihash_kv_16_8_t search_key
Definition: nat44_ed_out2in.c:57
bufs
vlib_buffer_t * bufs[VLIB_FRAME_SIZE]
Definition: nat44_ei_out2in.c:717
snat_main_s::twice_nat_addresses
snat_address_t * twice_nat_addresses
Definition: nat44_ed.h:547
dst_port
vl_api_ip_port_and_mask_t dst_port
Definition: flow_types.api:92
vlib_prefetch_buffer_header
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
Definition: buffer.h:231
frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: nat44_ei.c:3048
NAT_ED_SP_SESS_EXPIRED
@ NAT_ED_SP_SESS_EXPIRED
Definition: nat44_ed_out2in.c:46
nat_elog_warn
#define nat_elog_warn(_pm, nat_elog_str)
Definition: log.h:177
nat_pre_trace_t::arc_next_index
u32 arc_next_index
Definition: nat44_ed.h:91
nat44_ed_out2in_slow_path_node_fn_inline
static uword nat44_ed_out2in_slow_path_node_fn_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: nat44_ed_out2in.c:1113
clib_memcpy
#define clib_memcpy(d, s, n)
Definition: string.h:197
SNAT_SESSION_FLAG_UNKNOWN_PROTO
#define SNAT_SESSION_FLAG_UNKNOWN_PROTO
Definition: nat44_ed.h:175
snat_main_s::counters
struct snat_main_s::@746 counters
f
vlib_frame_t * f
Definition: interface_output.c:1098
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:549
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
nat_get_icmp_session_lookup_values
static_always_inline int nat_get_icmp_session_lookup_values(vlib_buffer_t *b, ip4_header_t *ip0, ip4_address_t *lookup_saddr, u16 *lookup_sport, ip4_address_t *lookup_daddr, u16 *lookup_dport, u8 *lookup_protocol)
Definition: nat44_ed_inlines.h:183
nat44_session_get_timeout
static u32 nat44_session_get_timeout(snat_main_t *sm, snat_session_t *s)
Definition: nat44_ed_inlines.h:239
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
lookup
static hash_pair_t * lookup(void *v, uword key, enum lookup_opcode op, void *new_value, void *old_value)
Definition: hash.c:545
tcp_header_t
struct _tcp_header tcp_header_t
nat_6t_o2i_flow_init
static_always_inline void nat_6t_o2i_flow_init(snat_main_t *sm, u32 thread_idx, snat_session_t *s, ip4_address_t saddr, u16 sport, ip4_address_t daddr, u16 dport, u32 fib_index, u8 proto)
Definition: nat44_ed_inlines.h:590
snat_main_s::slowpath
struct snat_main_s::@746::@748 slowpath
vlib_get_buffers
vlib_get_buffers(vm, from, b, n_left_from)
ip_proto_to_nat_proto
static nat_protocol_t ip_proto_to_nat_proto(u8 ip_proto)
Common NAT inline functions.
Definition: inlines.h:24
next
u16 * next
Definition: nat44_ei_out2in.c:718
VLIB_NODE_TYPE_INTERNAL
@ VLIB_NODE_TYPE_INTERNAL
Definition: node.h:72
nat_6t_flow_t
Definition: nat44_ed.h:226
VLIB_FRAME_SIZE
#define VLIB_FRAME_SIZE
Definition: node.h:368
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
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
AFFINITY_LB_NAT
@ AFFINITY_LB_NAT
Definition: nat44_ed.h:410
ip4_address_t::as_u32
u32 as_u32
Definition: ip4_packet.h:57
nat44_ed_out2in_trace_t::slow_path_reason
nat_slow_path_reason_e slow_path_reason
Definition: nat44_ed_out2in.c:61
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
ip4_fib_table_get_index_for_sw_if_index
u32 ip4_fib_table_get_index_for_sw_if_index(u32 sw_if_index)
Definition: pnat_test_stubs.h:21
u16
unsigned short u16
Definition: types.h:57
SNAT_SESSION_FLAG_STATIC_MAPPING
#define SNAT_SESSION_FLAG_STATIC_MAPPING
Definition: nat44_ed.h:174
ip_incremental_checksum_buffer
static ip_csum_t ip_incremental_checksum_buffer(vlib_main_t *vm, vlib_buffer_t *first_buffer, u32 first_buffer_offset, u32 n_bytes_to_checksum, ip_csum_t sum)
Definition: ip.h:152
NAT_ED_SP_TCP_CLOSED
@ NAT_ED_SP_TCP_CLOSED
Definition: nat44_ed_out2in.c:45
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
VLIB_RX
@ VLIB_RX
Definition: defs.h:46
port
u16 port
Definition: lb_types.api:73
nat44_ed_maximum_sessions_exceeded
static_always_inline u8 nat44_ed_maximum_sessions_exceeded(snat_main_t *sm, u32 fib_index, u32 thread_index)
Definition: nat44_ed_inlines.h:262
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
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
nat44_ed_out2in_trace_t::is_slow_path
u8 is_slow_path
Definition: nat44_ed_out2in.c:58
vlib_buffer_enqueue_to_next
vlib_buffer_enqueue_to_next(vm, node, from,(u16 *) nexts, frame->n_vectors)
vnet_buffer2
#define vnet_buffer2(b)
Definition: buffer.h:505
snat_static_mapping_t::local_addr
ip4_address_t local_addr
Definition: nat44_ed.h:418
addr
vhost_vring_addr_t addr
Definition: vhost_user.h:130
vlib_frame_t
Definition: node.h:372
icmp_type_is_error_message
static_always_inline u8 icmp_type_is_error_message(u8 icmp_type)
Definition: cnat_node.h:109
snat_main_s::static_mapping_by_external
clib_bihash_8_8_t static_mapping_by_external
Definition: nat44_ed.h:528
vlib_buffer_length_in_chain
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
Definition: buffer_funcs.h:433
snat_static_mapping_t::flags
u32 flags
Definition: nat44_ed.h:441
udp_header_t
Definition: udp_packet.h:45
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_ipfix_logging_addresses_exhausted
void nat_ipfix_logging_addresses_exhausted(u32 thread_index, u32 pool_id)
Generate NAT addresses exhausted event.
Definition: ipfix_logging.c:1367
snat_main_s::forwarding_enabled
u8 forwarding_enabled
Definition: nat44_ed.h:590
nat_6t_i2o_flow_init
static_always_inline void nat_6t_i2o_flow_init(snat_main_t *sm, u32 thread_idx, snat_session_t *s, ip4_address_t saddr, u16 sport, ip4_address_t daddr, u16 dport, u32 fib_index, u8 proto)
Definition: nat44_ed_inlines.h:579
nat44_ed_out2in_slowpath_unknown_proto
static snat_session_t * nat44_ed_out2in_slowpath_unknown_proto(snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip, u32 rx_fib_index, u32 thread_index, f64 now, vlib_main_t *vm, vlib_node_runtime_t *node)
Definition: nat44_ed_out2in.c:716
per_vrf_sessions_register_session
static_always_inline void per_vrf_sessions_register_session(snat_session_t *s, u32 thread_index)
Definition: nat44_ed_inlines.h:487
NAT_ED_SP_REASON_NO_REASON
@ NAT_ED_SP_REASON_NO_REASON
Definition: nat44_ed_out2in.c:42
pool_is_free_index
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:302
snat_address_t
Definition: nat44_ed.h:355
foreach_nat_protocol
@ foreach_nat_protocol
Definition: lib.h:66
vlib_increment_simple_counter
static void vlib_increment_simple_counter(vlib_simple_counter_main_t *cm, u32 thread_index, u32 index, u64 increment)
Increment a simple counter.
Definition: counter.h:74
nat_syslog_nat44_sadd
void nat_syslog_nat44_sadd(u32 ssubix, u32 sfibix, ip4_address_t *isaddr, u16 isport, ip4_address_t *idaddr, u16 idport, ip4_address_t *xsaddr, u16 xsport, ip4_address_t *xdaddr, u16 xdport, nat_protocol_t proto, u8 is_twicenat)
Definition: nat_syslog.c:197
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
nat44_set_tcp_session_state_o2i
static void nat44_set_tcp_session_state_o2i(snat_main_t *sm, f64 now, snat_session_t *ses, u8 tcp_flags, u32 tcp_ack_number, u32 tcp_seq_number, u32 thread_index)
Definition: nat44_ed_inlines.h:805
vlib_buffer_t::error
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition: buffer.h:145
snat_main_s::per_thread_data
snat_main_per_thread_data_t * per_thread_data
Definition: nat44_ed.h:522
nat44_ed_out2in_trace_t
Definition: nat44_ed_out2in.c:49
error.h
VLIB_NODE_FN
#define VLIB_NODE_FN(node)
Definition: node.h:202
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
ip4_is_fragment
static int ip4_is_fragment(const ip4_header_t *i)
Definition: ip4_packet.h:168
CLIB_UNUSED
#define CLIB_UNUSED(x)
Definition: clib.h:90
vnet_buffer
#define vnet_buffer(b)
Definition: buffer.h:441
NAT_NEXT_IN2OUT_ED_FAST_PATH
@ NAT_NEXT_IN2OUT_ED_FAST_PATH
Definition: nat44_ed.h:77
nat_6t_l3_l4_csum_calc
void nat_6t_l3_l4_csum_calc(nat_6t_flow_t *f)
Definition: nat44_ed.c:3532
VLIB_NODE_FLAG_TRACE
#define VLIB_NODE_FLAG_TRACE
Definition: node.h:291
nat44_ed_out2in_trace_t::o2if
nat_6t_flow_t o2if
Definition: nat44_ed_out2in.c:56
twice_nat_type_t
twice_nat_type_t
Definition: nat44_ed.h:393
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
NAT_NEXT_OUT2IN_ED_FAST_PATH
@ NAT_NEXT_OUT2IN_ED_FAST_PATH
Definition: nat44_ed.h:81
ARRAY_LEN
#define ARRAY_LEN(x)
Definition: clib.h:70
vlib_frame_vector_args
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:301
static_always_inline
#define static_always_inline
Definition: clib.h:112
format_slow_path_reason
static u8 * format_slow_path_reason(u8 *s, va_list *args)
Definition: nat44_ed_out2in.c:65
udp_local.h
uword
u64 uword
Definition: types.h:112
nat44_ed_out2in_trace_t::session_index
u32 session_index
Definition: nat44_ed_out2in.c:53
nat44_ed_out2in_fast_path_node_fn_inline
static uword nat44_ed_out2in_fast_path_node_fn_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_multi_worker)
Definition: nat44_ed_out2in.c:794
TWICE_NAT_SELF
@ TWICE_NAT_SELF
Definition: nat44_ed.h:400
vlib_main_t::thread_index
u32 thread_index
Definition: main.h:215
init_ed_k
static void init_ed_k(clib_bihash_kv_16_8_t *kv, ip4_address_t l_addr, u16 l_port, ip4_address_t r_addr, u16 r_port, u32 fib_index, u8 proto)
Definition: nat44_ed_inlines.h:122
ipfix_logging.h
src_port
vl_api_ip_port_and_mask_t src_port
Definition: flow_types.api:91
NAT_ED_SP_REASON_VRF_EXPIRED
@ NAT_ED_SP_REASON_VRF_EXPIRED
Definition: nat44_ed_out2in.c:44
nat_alloc_addr_and_port_exact
static_always_inline int nat_alloc_addr_and_port_exact(snat_address_t *a, u32 thread_index, nat_protocol_t proto, ip4_address_t *addr, u16 *port, u16 port_per_thread, u32 snat_thread_index)
Definition: nat44_ed_out2in.c:270
f64
double f64
Definition: types.h:142
nat_pre_node_fn_inline
static uword nat_pre_node_fn_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, u32 def_next)
Definition: nat44_ed_inlines.h:607
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
nat_slow_path_reason_e
nat_slow_path_reason_e
Definition: nat44_ed_out2in.c:40
ip4_address_t
Definition: ip4_packet.h:50
FIB_PROTOCOL_IP4
@ FIB_PROTOCOL_IP4
Definition: fib_types.h:36
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
create_bypass_for_fwd
static void create_bypass_for_fwd(snat_main_t *sm, vlib_buffer_t *b, snat_session_t *s, ip4_header_t *ip, u32 rx_fib_index, u32 thread_index)
Definition: nat44_ed_out2in.c:602
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
ip4_header_t::dst_address
ip4_address_t dst_address
Definition: ip4_packet.h:125
nat_pre_trace_t::next_index
u32 next_index
Definition: nat44_ed.h:90
nat_ed_session_delete
static void nat_ed_session_delete(snat_main_t *sm, snat_session_t *ses, u32 thread_index, int lru_delete)
Definition: nat44_ed_inlines.h:358
icmp4_error_set_vnet_buffer
static_always_inline void icmp4_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)
Definition: icmp4.h:51
nat44_ed_out2in_trace_t::sw_if_index
u32 sw_if_index
Definition: nat44_ed_out2in.c:51
is_interface_addr
static u8 is_interface_addr(snat_main_t *sm, vlib_node_runtime_t *node, u32 sw_if_index0, u32 ip4_addr)
Definition: nat44_ed_inlines.h:723
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
format_nat_ed_translation_error
format_function_t format_nat_ed_translation_error
Definition: nat44_ed.h:1069
nat_6t_t_eq
static_always_inline int nat_6t_t_eq(nat_6t_t *t1, nat_6t_t *t2)
Definition: nat44_ed_inlines.h:601
SNAT_SESSION_FLAG_TWICE_NAT
#define SNAT_SESSION_FLAG_TWICE_NAT
Definition: nat44_ed.h:177
SNAT_SESSION_FLAG_LOAD_BALANCING
#define SNAT_SESSION_FLAG_LOAD_BALANCING
Definition: nat44_ed.h:176
ip4_header_t::src_address
ip4_address_t src_address
Definition: ip4_packet.h:125
icmp
icmp
Definition: map.api:387
nat44_ed_inlines.h
nat_ed_session_alloc
static_always_inline snat_session_t * nat_ed_session_alloc(snat_main_t *sm, u32 thread_index, f64 now, u8 proto)
Definition: nat44_ed_inlines.h:432
clib_bihash_kv_16_8_t
Definition: bihash_16_8.h:40
nat_ipfix_logging_nat44_ses_create
void nat_ipfix_logging_nat44_ses_create(u32 thread_index, u32 src_ip, u32 nat_src_ip, nat_protocol_t nat_proto, u16 src_port, u16 nat_src_port, u32 fib_index)
Generate NAT44 session create event.
Definition: ipfix_logging.c:1320
u64
unsigned long u64
Definition: types.h:89
nat_elog_info
#define nat_elog_info(_pm, nat_elog_str)
Definition: log.h:183
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
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
TWICE_NAT
@ TWICE_NAT
Definition: nat44_ed.h:398
fib_table_get_index_for_sw_if_index
u32 fib_table_get_index_for_sw_if_index(fib_protocol_t proto, u32 sw_if_index)
Get the index of the FIB bound to the interface.
Definition: fib_table.c:1003
icmp_out2in_ed_slow_path
static u32 icmp_out2in_ed_slow_path(snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip, icmp46_header_t *icmp, u32 sw_if_index, u32 rx_fib_index, vlib_node_runtime_t *node, u32 next, f64 now, u32 thread_index, snat_session_t **s_p)
Definition: nat44_ed_out2in.c:150
ip.h
u32
unsigned int u32
Definition: types.h:88
snat_static_mapping_t::fib_index
u32 fib_index
Definition: nat44_ed.h:427
nat44_ed_out2in_trace_t::i2of
nat_6t_flow_t i2of
Definition: nat44_ed_out2in.c:55
format_nat44_ed_out2in_trace
static u8 * format_nat44_ed_out2in_trace(u8 *s, va_list *args)
Definition: nat44_ed_out2in.c:85
ip4_header_t::ttl
u8 ttl
Definition: ip4_packet.h:112
snat_static_mapping_t::pool_addr
ip4_address_t pool_addr
Definition: nat44_ed.h:416
clib_prefetch_load
static_always_inline void clib_prefetch_load(void *p)
Definition: cache.h:92
nat44_session_update_counters
static void nat44_session_update_counters(snat_session_t *s, f64 now, uword bytes, u32 thread_index)
Definition: nat44_ed_inlines.h:848
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
nat44_ed.h
clib_bihash_kv_8_8_t
8 octet key, 8 octet key value pair
Definition: bihash_8_8.h:41
format_ed_session_kvp
format_function_t format_ed_session_kvp
Definition: nat44_ed.h:1071
snat_runtime_t
Definition: nat44_ed.h:686
NAT_NEXT_DROP
@ NAT_NEXT_DROP
Definition: nat44_ed.h:75
value
u8 value
Definition: qos.api:54
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
ip4_fib.h
nat_ed_ses_i2o_flow_hash_add_del
static_always_inline int nat_ed_ses_i2o_flow_hash_add_del(snat_main_t *sm, u32 thread_idx, snat_session_t *s, int is_add)
Definition: nat44_ed_inlines.h:317
per_vrf_sessions_is_expired
static_always_inline u8 per_vrf_sessions_is_expired(snat_session_t *s, u32 thread_index)
Definition: nat44_ed_inlines.h:550
now
f64 now
Definition: nat44_ei_out2in.c:710
nat_pre_trace_t
Definition: nat44_ed.h:88
nat44_ed_alloc_outside_addr_and_port
static_always_inline int nat44_ed_alloc_outside_addr_and_port(snat_address_t *addresses, u32 fib_index, u32 thread_index, nat_protocol_t proto, ip4_address_t *addr, u16 *port, u16 port_per_thread, u32 snat_thread_index)
Definition: nat44_ed_out2in.c:314
vlib_main_t
Definition: main.h:102
snat_main
snat_main_t snat_main
Definition: nat44_ed.c:41
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
vlib_node_t
Definition: node.h:247
vlib_add_trace
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
Definition: trace.c:628
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
vlib_get_main
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:38
b
vlib_buffer_t ** b
Definition: nat44_ei_out2in.c:717
u8
unsigned char u8
Definition: types.h:56
a
a
Definition: bitmap.h:525
vlib_buffer_get_current
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:257
ip
vl_api_address_t ip
Definition: l2.api:558
snat_main_s::num_workers
u32 num_workers
Definition: nat44_ed.h:516
ip_csum_t
uword ip_csum_t
Definition: ip_packet.h:245
create_session_for_static_mapping_ed
static snat_session_t * create_session_for_static_mapping_ed(snat_main_t *sm, vlib_buffer_t *b, ip4_address_t i2o_addr, u16 i2o_port, u32 i2o_fib_index, ip4_address_t o2i_addr, u16 o2i_port, u32 o2i_fib_index, nat_protocol_t nat_proto, vlib_node_runtime_t *node, u32 rx_fib_index, u32 thread_index, twice_nat_type_t twice_nat, lb_nat_type_t lb_nat, f64 now, snat_static_mapping_t *mapping)
Definition: nat44_ed_out2in.c:397
vlib_buffer_t::data
u8 data[]
Packet data.
Definition: buffer.h:204
i
int i
Definition: flowhash_template.h:376
foreach_nat_out2in_ed_error
#define foreach_nat_out2in_ed_error
Definition: nat44_ed.h:144
nexts
u16 nexts[VLIB_FRAME_SIZE]
Definition: nat44_ei_out2in.c:718
ip4_header_bytes
static int ip4_header_bytes(const ip4_header_t *i)
Definition: ip4_packet.h:190
nat44_ed_out2in_trace_t::lookup_skipped
u8 lookup_skipped
Definition: nat44_ed_out2in.c:60
snat_static_mapping_t
Definition: nat44_ed.h:413
vlib_time_now
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:327
is_sm_exact_address
static bool is_sm_exact_address(u32 f)
Definition: nat44_ed.h:858
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
nat_translation_error_e
nat_translation_error_e
Definition: nat44_ed.h:1049
vlib_node_runtime_t
Definition: node.h:454
nat44_ed_out2in_trace_t::next_index
u32 next_index
Definition: nat44_ed_out2in.c:52
proto
vl_api_ip_proto_t proto
Definition: acl_types.api:51
from
from
Definition: nat44_ei_hairpinning.c:415
PREDICT_TRUE
#define PREDICT_TRUE(x)
Definition: clib.h:125
NAT_ED_SP_REASON_LOOKUP_FAILED
@ NAT_ED_SP_REASON_LOOKUP_FAILED
Definition: nat44_ed_out2in.c:43
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
format_nat_pre_trace
static u8 * format_nat_pre_trace(u8 *s, va_list *args)
Definition: nat44_ed_out2in.c:1436
ip_csum_fold
static u16 ip_csum_fold(ip_csum_t c)
Definition: ip_packet.h:301
NAT_ED_TRNSL_ERR_SUCCESS
@ NAT_ED_TRNSL_ERR_SUCCESS
Definition: nat44_ed.h:1051
VLIB_TX
@ VLIB_TX
Definition: defs.h:47
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
init_nat_k
static void init_nat_k(clib_bihash_kv_8_8_t *kv, ip4_address_t addr, u16 port, u32 fib_index, nat_protocol_t proto)
Definition: nat44_ei_inlines.h:56
n_left_from
n_left_from
Definition: nat44_ei_hairpinning.c:416
nat_out2in_ed_error_strings
static char * nat_out2in_ed_error_strings[]
Definition: nat44_ed_out2in.c:34
nat44_ed_out2in_slowpath_node
vlib_node_registration_t nat44_ed_out2in_slowpath_node
(constructor) VLIB_REGISTER_NODE (nat44_ed_out2in_slowpath_node)
Definition: nat44_ed_out2in.c:1424
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
nat44_session_update_lru
static void nat44_session_update_lru(snat_main_t *sm, snat_session_t *s, u32 thread_index)
Per-user LRU list maintenance.
Definition: nat44_ed_inlines.h:858
ip4_header_t::protocol
u8 protocol
Definition: ip4_packet.h:115
nat_syslog.h
NAT syslog logging.
nat_ed_ses_o2i_flow_hash_add_del
static_always_inline int nat_ed_ses_o2i_flow_hash_add_del(snat_main_t *sm, u32 thread_idx, snat_session_t *s, int is_add)
Definition: nat44_ed_inlines.h:338
ip4_next_header
static void * ip4_next_header(ip4_header_t *i)
Definition: ip4_packet.h:196
vlib_buffer_t::flags
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
Definition: buffer.h:133
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
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169