FD.io VPP  v17.01.1-3-gc6833f8
Vector Packet Processing
cnat_ipv4_udp_outside_input.c
Go to the documentation of this file.
1 
2 /*
3  *---------------------------------------------------------------------------
4  * cnat_ipv4_udp_outside_input_stages.c - cnat_ipv4_udp_outside_input node pipeline stage functions
5  *
6  *
7  * Copyright (c) 2008-2014 Cisco and/or its affiliates.
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at:
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *---------------------------------------------------------------------------
20  */
21 
22 #include <vlib/vlib.h>
23 #include <vnet/vnet.h>
24 #include <vppinfra/error.h>
25 #include <vnet/buffer.h>
26 
27 #include "cnat_ipv4_udp.h"
28 #include "dslite_db.h"
29 #include "cnat_db.h"
30 #include "cnat_v4_functions.h"
31 
32 //#include <dslite_v6_functions.h>
33 //#include <pool.h>
34 //#include "cnat_va_db.h"
35 
36 #define foreach_cnat_ipv4_udp_outside_input_error \
37 _(CNAT_V4_UDP_O2I_T_PKT, "v4 udp o2i transmit") \
38 _(CNAT_V4_DSLITE_ENCAP_CTR, "to dslite encap") \
39 _(CNAT_V4_UDP_O2I_MISS_PKT, "v4 udp o2i db miss drop") \
40 _(CNAT_V4_UDP_O2I_TTL_GEN, "v4 udp o2i TTL gen") \
41 _(CNAT_V4_UDP_O2I_TTL_DROP, "v4 udp o2i TTL drop") \
42 _(CNAT_V4_UDP_O2I_PTB_GEN, "v4 ptb gen") \
43 _(CNAT_V4_UDP_O2I_PTB_DROP, "v4 ptb throttle drop") \
44 _(CNAT_V4_UDP_O2I_SESSION_DROP, "v4 udp o2i session drop") \
45 _(CNAT_V4_UDP_O2I_FILTER_DROP, "v4 udp o2i drop: end point filtering") \
46 _(CNAT_V4_UDP_O2I_SUB_FRAG_NO_DB_DROP, "v4 udp o2i subsequent frag no DB drop") \
47 _(CNAT_V4_UDP_O2I_1ST_FRAG_FILTER_DROP, "v4 udp i2o 1st frag filter drop")
48 
49 typedef enum {
50 #define _(sym,str) sym,
52 #undef _
55 
57 #define _(sym,string) string,
59 #undef _
60 };
61 
62 typedef struct {
64  /* $$$$ add data here */
65 
66  /* convenience variables */
70 
71 typedef enum {
72  //CNAT_V4_O2I_FIXME,
77 
78 //#define CNAT_V4_DSLITE_ENCAP CNAT_V4_O2I_FIXME
79 //#define CNAT_V4_UDP_O2I_E CNAT_V4_O2I_FIXME
80 
83 
84 #define NSTAGES 6
85 
86 /*
87  * Use the generic buffer metadata + first line of packet data prefetch
88  * stage function from <api/pipeline.h>. This is usually a Good Idea.
89  */
90 #define stage0 generic_stage0
91 
92 
93 #if 0
94 typedef struct cnat_ipv4_udp_outside_input_pipeline_data_ {
95  //spp_node_main_vector_t *nmv;
96  dslite_common_pipeline_data_t common_data;
97  /* Add additional pipeline stage data here... */
98  u32 bucket;
99 #ifdef DSLITE_DEF
100  u32 user_bucket;
101  dslite_v4_to_v6_udp_counter_t *udp_counter;
102  dslite_icmp_gen_counter_t *icmp_gen_counter;
103 
104 #endif
105  cnat_key_t ki;
106  udp_hdr_type_t *udp;
107  u8 frag_pkt;
108 } cnat_ipv4_udp_outside_input_pipeline_data_t;
109 
110 #endif
111 
112 #define CNAT_UDP_OUTSIDE_UPDATE_FLAG_TIMER(db,dslite_nat44_inst_id) \
113  if (PREDICT_FALSE(!(db->flags & CNAT_DB_FLAG_UDP_ACTIVE))) { \
114  db->flags |= CNAT_DB_FLAG_UDP_ACTIVE; \
115  CNAT_DB_TIMEOUT_RST(db); \
116  } else if (PREDICT_FALSE(db->flags & CNAT_DB_DSLITE_FLAG)) { \
117  if (PREDICT_TRUE(dslite_table_db_ptr[dslite_nat44_inst_id].mapping_refresh_both_direction)) { \
118  CNAT_DB_TIMEOUT_RST(db); \
119  } \
120  } else if (PREDICT_TRUE(mapping_refresh_both_direction)) { \
121  CNAT_DB_TIMEOUT_RST(db); \
122  } \
123 
124 #if 0
125 static cnat_ipv4_udp_outside_input_pipeline_data_t pctx_data[SPP_MAXDISPATCH];
126 #define EXTRA_PIPELINE_ARGS_PROTO , cnat_ipv4_udp_outside_input_pipeline_data_t *pctx
127 #define EXTRA_PIPELINE_ARGS , pctx
128 
129 #endif
130 
131 /*inline u32
132 is_static_dest_nat_enabled(u16 vrf)
133 {
134  if(static_dest_vrf_map_array[vrf] == 1) {
135  return CNAT_SUCCESS;
136  }
137  return CNAT_NO_CONFIG;
138 }*/
139 
140 static inline void __attribute__((unused))
142 {
143 
145  /*
146  * calculate checksum
147  */
148  CNAT_UPDATE_L3_CHECKSUM(((u16)(db->out2in_key.k.ipv4)),
149  ((u16)(db->out2in_key.k.ipv4 >> 16)),
150  (clib_host_to_net_u16(ip->checksum)),
151  ((u16)(db->in2out_key.k.ipv4)),
152  ((u16)(db->in2out_key.k.ipv4 >> 16)))
153  //set ip header
154  ip->dest_addr =
155  clib_host_to_net_u32(db->in2out_key.k.ipv4);
156  ip->checksum =
157  clib_host_to_net_u16(new_l3_c);
158 
159 #if 0
160 
161  if(is_static_dest_nat_enabled(vrf) == CNAT_SUCCESS) {
162  direction = 1;
163  if(cnat_static_dest_db_get_translation(ip->src_addr, &postmap_ip, vrf, direction) == CNAT_SUCCESS) {
164  old_ip = spp_net_to_host_byte_order_32(&(ip->src_addr));
165  old_postmap_ip = spp_net_to_host_byte_order_32(&postmap_ip);
166 
167  CNAT_UPDATE_L3_CHECKSUM(((u16)(old_ip & 0xFFFF)),
168  ((u16)(old_ip >> 16)),
169  (spp_net_to_host_byte_order_16(&(ip->checksum))),
170  ((u16)(old_postmap_ip & 0xFFFF)),
171  ((u16)(old_postmap_ip >> 16)))
172  ip->checksum =
173  clib_host_to_net_u16(new_l3_c);
174  ip->src_addr = postmap_ip;
175  }
176  }
177 #endif
178 }
179 
181  udp_hdr_type_t *udp,
182  cnat_main_db_entry_t *db, u16 vrf)
183 {
184 
185 #define UDP_PACKET_DEBUG 1
186 
187 // Temporary debugs which will be suppressed later
188 #ifdef UDP_PACKET_DEBUG
190  printf("\nOut2In UDP packet before translation");
191  print_udp_pkt(ip);
192  }
193 #endif
194 
195 #if 0
196  if(is_static_dest_nat_enabled(vrf) == CNAT_SUCCESS) {
197  direction = 1;
198  if(cnat_static_dest_db_get_translation(ip->src_addr, &postmap_ip, vrf, direction) == CNAT_SUCCESS) {
199 
201 
202  old_ip = spp_net_to_host_byte_order_32(&(ip->src_addr));
203  old_postmap_ip = spp_net_to_host_byte_order_32(&postmap_ip);
204 
205  CNAT_UPDATE_L3_L4_CHECKSUM(((u16)(old_ip & 0xFFFF)),
206  ((u16)(old_ip >> 16)),
207  (spp_net_to_host_byte_order_16(&(udp->src_port))),
208  (spp_net_to_host_byte_order_16(&(ip->checksum))),
209  (spp_net_to_host_byte_order_16(&(udp->udp_checksum))),
210  ((u16)(old_postmap_ip & 0xFFFF)),
211  ((u16)(old_postmap_ip >> 16)),
212  (spp_net_to_host_byte_order_16(&(udp->src_port))))
213 
214  ip->checksum =
215  clib_host_to_net_u16(new_l3_c);
216  ip->src_addr = postmap_ip;
217  if (PREDICT_TRUE(udp->udp_checksum)) {
218  udp->udp_checksum = clib_host_to_net_u16(new_l4_c);
219  }
220  }
221  }
222 #endif
223  /*
224  * declare variable
225  */
227  /*
228  * calculate checksum
229  */
231  ((u16)(db->out2in_key.k.ipv4 >> 16)),
232  (db->out2in_key.k.port),
233  (clib_net_to_host_u16(ip->checksum)),
234  (clib_net_to_host_u16(udp->udp_checksum)),
235  ((u16)(db->in2out_key.k.ipv4)),
236  ((u16)(db->in2out_key.k.ipv4 >> 16)),
237  (db->in2out_key.k.port))
238 
239 
240 
241 
242  //set ip header
243  ip->dest_addr =
244  clib_host_to_net_u32(db->in2out_key.k.ipv4);
245  ip->checksum =
246  clib_host_to_net_u16(new_l3_c);
247 
248  //set udp header
249  udp->dest_port =
250  clib_host_to_net_u16(db->in2out_key.k.port);
251 
252  /*
253  * No easy way to avoid this if check except by using
254  * complex logic - may not be worth it.
255  */
256  if (PREDICT_TRUE(udp->udp_checksum)) {
257  udp->udp_checksum = clib_host_to_net_u16(new_l4_c);
258  }
259 
260 
261 
262 // Temporary debugs which will be suppressed later
263 #ifdef UDP_PACKET_DEBUG
265  printf("\nOut2In UDP checksum 0x%x disabled by force", new_l4_c);
266  udp->udp_checksum = 0;
267  }
269  printf("\nOut2In UDP packet after translation");
270  print_udp_pkt(ip);
271  }
272 #endif
273 }
274 
275 static inline void
276 stage1(vlib_main_t * vm, vlib_node_runtime_t * node, u32 buffer_index)
277 {
278  u64 a, b, c;
279  u32 bucket;
280  u8 *prefetch_target;
281 
282  vlib_buffer_t * b0 = vlib_get_buffer (vm, buffer_index);
284  u8 ipv4_hdr_len = (ip->version_hdr_len_words & 0xf) << 2;
285  udp_hdr_type_t *udp = (udp_hdr_type_t *)((u8*)ip + ipv4_hdr_len);
286 
287  u64 tmp = 0;
288  tmp = vnet_buffer(b0)->vcgn_uii.key.k.ipv4 =
289  clib_net_to_host_u32(ip->dest_addr);
290  vnet_buffer(b0)->vcgn_uii.key.k.port =
291  clib_net_to_host_u16 (udp->dest_port);
292 
293  tmp |= ((u64)vnet_buffer(b0)->vcgn_uii.key.k.port) << 32;
294 
295  PLATFORM_CNAT_SET_RX_VRF(vnet_buffer(b0)->sw_if_index[VLIB_RX],
296  vnet_buffer(b0)->vcgn_uii.key.k.vrf,
297  CNAT_UDP)
298  tmp |= ((u64)vnet_buffer(b0)->vcgn_uii.key.k.vrf) << 48;
299 
301 
302  prefetch_target = (u8 *)(&cnat_out2in_hash[bucket]);
303  vnet_buffer(b0)->vcgn_uii.bucket = bucket;
304 
305  /* Prefetch the hash bucket */
306  CLIB_PREFETCH(prefetch_target, CLIB_CACHE_LINE_BYTES, LOAD);
307 }
308 
309 static inline void
310 stage2(vlib_main_t * vm, vlib_node_runtime_t * node, u32 buffer_index)
311 { /* nothing */ }
312 
313 #define SPP_LOG2_CACHE_LINE_BYTES 6
314 #define SPP_CACHE_LINE_BYTES (1 << SPP_LOG2_CACHE_LINE_BYTES)
315 
316 static inline void
317 stage3(vlib_main_t * vm, vlib_node_runtime_t * node, u32 buffer_index)
318 {
319  vlib_buffer_t * b0 = vlib_get_buffer(vm, buffer_index);
320  uword prefetch_target0, prefetch_target1;
321  u32 bucket = vnet_buffer(b0)->vcgn_uii.bucket;
322 
323  /* read the hash bucket */
324  u32 db_index = vnet_buffer(b0)->vcgn_uii.bucket
325  = cnat_out2in_hash[bucket].next;
326 
327  if (PREDICT_TRUE(db_index != EMPTY)) {
328  /*
329  * Prefetch database keys. We save space by not cache-line
330  * aligning the DB entries. We don't want to waste LSU
331  * bandwidth prefetching stuff we won't need.
332  */
333  prefetch_target0 = (uword)(cnat_main_db + db_index);
334  CLIB_PREFETCH((void*)prefetch_target0, CLIB_CACHE_LINE_BYTES, STORE);
335  /* Just beyond DB key #2 */
336  prefetch_target1 = prefetch_target0 +
338  /* If the targets are in different lines, do the second prefetch */
339  if (PREDICT_FALSE((prefetch_target0 & ~(SPP_CACHE_LINE_BYTES-1)) !=
340  (prefetch_target1 & ~(SPP_CACHE_LINE_BYTES-1)))) {
341  CLIB_PREFETCH((void *)prefetch_target1, CLIB_CACHE_LINE_BYTES, STORE);
342  }
343  }
344 }
345 
346 static inline void
347 stage4(vlib_main_t * vm, vlib_node_runtime_t * node, u32 buffer_index)
348 {
350  vlib_buffer_t * b0 = vlib_get_buffer(vm, buffer_index);
351  u32 db_index = vnet_buffer(b0)->vcgn_uii.bucket;
352 
353  /*
354  * Note: if the search already failed (empty bucket),
355  * the answer is already in the pipeline context structure
356  */
357  if (PREDICT_TRUE(db_index != EMPTY)) {
358 
359  /*
360  * Note: hash collisions suck. We can't easily prefetch around them.
361  * The first trip around the track will be fast. After that, maybe
362  * not so much...
363  */
364  do {
365  db = cnat_main_db + db_index;
366  if (PREDICT_TRUE(db->out2in_key.key64 ==
367  vnet_buffer(b0)->vcgn_uii.key.key64)) {
368  break;
369  }
370  db_index = db->out2in_hash.next;
371  } while (db_index != EMPTY);
372 
373  /* Stick the answer back into the pipeline context structure */
374  vnet_buffer(b0)->vcgn_uii.bucket = db_index;
375  }
376 }
377 
378 #if 0
379 
380 ALWAYS_INLINE(
381 static inline void
382 stage5(spp_ctx_t **ctxs, int index, spp_node_t *np,
383  u8 *disp_used EXTRA_PIPELINE_ARGS_PROTO))
384 {
385  spp_ctx_t *ctx = ctxs[index];
386  u32 db_index = pctx[index].bucket;
387  /* for nat44, dslite_id will be 1 */
388  u16 dslite_id = *(pctx[index].common_data.dslite_id_ptr);
389 
390  DSLITE_PREFETCH_COUNTER(pctx[index].udp_counter,
391  &dslite_all_counters[dslite_id].v46_udp_counters,
393  v4_to_v6_udp_output_count,
394  "V4_TO_V6_UDP")
395 
396  DSLITE_PREFETCH_COUNTER(pctx[index].icmp_gen_counter,
397  &dslite_all_counters[dslite_id].dslite_icmp_gen_counters,
399  v6_icmp_gen_count,
400  "V4_TO_V6_icmp")
401 
402 if (PREDICT_TRUE(db_index != EMPTY)) {
403  cnat_main_db_entry_t *db = cnat_main_db + db_index;
404 
405  u32 user_db_index = db->user_index;
406  DSLITE_PRINTF(1, "UDP o2i, db entry found %u %u %u\n",
407  db_index, user_db_index,
409  uword prefetch_target0 = (uword)(cnat_user_db + user_db_index);
410  SPP_PREFETCH(prefetch_target0, 0, LOAD);
411  pctx[index].user_bucket = user_db_index;
412  DSLITE_PRINTF(1, "UDP: Done with prefetch..\n");
413 } else {
414  DSLITE_PRINTF(1, "UDP: Stage 5, db_index empty...\n");
415 }
416 }
417 
418 #endif
419 
420 
421 static inline u32 last_stage (vlib_main_t *vm, vlib_node_runtime_t *node,
422  u32 bi)
423 {
424 
425  vlib_buffer_t *b0 = vlib_get_buffer (vm, bi);
426  u32 db_index = vnet_buffer(b0)->vcgn_uii.bucket;
427  //spp_ctx_t *ctx = (spp_ctx_t *) &vnet_buffer(b0)->vcgn_uii;
428  int disposition = CNAT_V4_UDP_O2I_T;
429  int counter = CNAT_V4_UDP_O2I_T_PKT;
431  u8 ipv4_hdr_len = (ip->version_hdr_len_words & 0xf) << 2;
432  udp_hdr_type_t *udp = (udp_hdr_type_t *)((u8*)ip + ipv4_hdr_len);
433  vlib_node_t *n = vlib_get_node (vm, cnat_ipv4_udp_outside_input_node.index);
434  u32 node_counter_base_index = n->error_heap_index;
435  vlib_error_main_t * em = &vm->error_main;
436  cnat_session_entry_t *session_db = NULL;
438  cnat_key_t dest_info;
439  u16 dslite_nat44_inst_id __attribute__((unused)) = 0;
440 
441  dest_info.k.port = clib_net_to_host_u16(udp->src_port);
442  dest_info.k.ipv4 = clib_net_to_host_u32(ip->src_addr);
443 
444  if (PREDICT_TRUE(db_index != EMPTY)) {
445  /* TTL gen was disabled for nat44 earlier
446  * But since dslite has got integrated in this
447  * TTL gen is enabled
448  */
449 
450  db = cnat_main_db + db_index;
452  /*
453  * Decrement TTL and update IPv4 checksum
454  */
456  }
458 
459  /* No DBL support, so just update the destn and proceed */
460  db->dst_ipv4 = dest_info.k.ipv4;
461  db->dst_port = dest_info.k.port;
463  goto update_pkt;
464  }
465 
466 
467  if(PREDICT_TRUE((db->dst_ipv4 == dest_info.k.ipv4) &&
468  (db->dst_port == dest_info.k.port))) {
469 
471  goto update_pkt;
472  } else {
473  /* The session entries belonging to this entry are checked to find
474  * if an entry exist whose destination IP and port match with the
475  * source IP and port of the packet being processed
476  */
477  dest_info.k.vrf = db->in2out_key.k.vrf;
478 
479  if (PREDICT_FALSE(db->nsessions == 0)) {
480  /* Should be a static entry
481  * Note this session as the first session and log
482  */
483  cnat_add_dest_n_log(db, &dest_info);
485 
486  } else if(PREDICT_TRUE(db->nsessions == 1)) {
487 
488  /* Destn is not same as in main db. Multiple session
489  * scenario
490  */
491  dest_info.k.vrf = db->in2out_key.k.vrf;
492  session_db = cnat_handle_1to2_session(db, &dest_info);
493 
494  if(PREDICT_FALSE(session_db == NULL)) {
495  disposition = CNAT_V4_UDP_O2I_E;
496  counter = CNAT_V4_UDP_O2I_SESSION_DROP;
497  goto drop_pkt;
498  }
499 
500  /* update session_db(cur packet) timer */
502  } else {
503  /* More 2 sessions exists */
504 
505  dest_info.k.vrf = db->in2out_key.k.vrf;
506 
507  /* If session already exists,
508  * cnat_create_session_db_entry will return the existing db
509  * else create a new db
510  * If could not create, return NULL
511  */
512  session_db = cnat_create_session_db_entry(&dest_info,
513  db, TRUE);
514 
515  if(PREDICT_FALSE(session_db != NULL)) {
516  /* session exists */
518  } else {
519  /* could not create session db - drop packet */
520  disposition = CNAT_V4_UDP_O2I_E;
521  counter = CNAT_V4_UDP_O2I_SESSION_DROP;
522  goto drop_pkt;
523  }
524  }
525  }
526 
527 update_pkt:
528 
529  /*
530  * 1. update dest ipv4 addr and dest udp port
531  * 2. update ipv4 checksum and udp checksum
532  */
533  //swap_ip_dst(ip, db, db->in2out_key.k.vrf);
534  swap_ip_dst_udp_port(ip, udp, db, db->in2out_key.k.vrf);
535  //DSLITE_PRINTF(1, "Done with swap_ip_dst_udp_port..\n");
536 
537  db->out2in_pkts++;
538 
540 
541  /* #### Temporarily COMMENTED FOR IP ROUTE LOOKUP ISSUE #### */
542 
543  //PLATFORM_CNAT_SET_TX_VRF(vnet_buffer(b0)->sw_if_index[VLIB_TX],
544  // db->in2out_key.k.vrf)
545  } else {
546  disposition = CNAT_V4_UDP_O2I_E;
547  counter = CNAT_V4_UDP_O2I_MISS_PKT;
548  /* for NAT44 dslite_id would be 1 */
550  }
551 
552 drop_pkt:
553 
554  em->counters[node_counter_base_index + counter] += 1;
555  return disposition;
556 }
557 
558 #include <vnet/pipeline.h>
559 
561  vlib_node_runtime_t * node,
562  vlib_frame_t * frame)
563 {
564  return dispatch_pipeline (vm, node, frame);
565 }
566 
567 
568 VLIB_REGISTER_NODE (cnat_ipv4_udp_outside_input_node) = {
570  .name = "vcgn-v4-udp-o2i",
571  .vector_size = sizeof (u32),
573 
574  .n_errors = ARRAY_LEN(cnat_ipv4_udp_outside_input_error_strings),
576 
577  .n_next_nodes = CNAT_V4_UDP_O2I_NEXT,
578 
579  /* edit / add dispositions here */
580 #if 0
581  .next_nodes = {
582  //[CNAT_V4_O2I_FIXME] = "error-drop",
583  //[CNAT_V4_UDP_O2I_E] = "vcgn-v4-udp-o2i-e",
584  [CNAT_V4_UDP_O2I_E] = "vcgn-v4-udp-o2i-e",
585  [CNAT_V4_UDP_O2I_T] = "ip4-input",
586  },
587 #endif
588  .next_nodes = {
589  [CNAT_V4_UDP_O2I_E] = "error-drop",
590  [CNAT_V4_UDP_O2I_T] = "ip4-input",
591  },
592 
593 };
594 
596 {
598 
599  mp->vlib_main = vm;
600  mp->vnet_main = vnet_get_main();
601 
602  return 0;
603 }
604 
u32 error_heap_index
Definition: node.h:278
cnat_main_db_entry_t * cnat_main_db
Definition: cnat_db_v2.c:201
#define DSLITE_PRINTF(level,...)
Definition: dslite_db.h:28
nat44_dslite_global_stats_t nat44_dslite_global_stats[2]
Definition: cnat_db_v2.c:211
cnat_session_entry_t * cnat_create_session_db_entry(cnat_key_t *ko, cnat_main_db_entry_t *bdb, u8 log)
Definition: cnat_db_v2.c:2643
a
Definition: bitmap.h:516
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
u32 user_index
Definition: cnat_db.h:195
#define PREDICT_TRUE(x)
Definition: clib.h:98
void ipv4_decr_ttl_n_calc_csum(ipv4_header *ipv4)
void swap_ip_dst_udp_port(ipv4_header *ip, udp_hdr_type_t *udp, cnat_main_db_entry_t *db, u16 vrf)
#define NULL
Definition: clib.h:55
u64 key64
Definition: cnat_db.h:109
Definition: cnat_db.h:153
struct _vlib_node_registration vlib_node_registration_t
#define STRUCT_OFFSET_OF(t, f)
Definition: clib.h:62
cnat_session_entry_t * cnat_handle_1to2_session(cnat_main_db_entry_t *mdb, cnat_key_t *dest_info)
Definition: cnat_db_v2.c:1027
#define CNAT_UPDATE_L3_L4_CHECKSUM(old_l3_1, old_l3_2, old_l4, old_l3_c, old_l4_c, new_l3_1, new_l3_2, new_l4)
index_slist_t out2in_hash
Definition: cnat_db.h:155
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
clib_error_t * cnat_ipv4_udp_outside_input_init(vlib_main_t *vm)
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:111
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:194
#define SPP_CACHE_LINE_BYTES
static void stage4(vlib_main_t *vm, vlib_node_runtime_t *node, u32 buffer_index)
static void swap_ip_dst(ipv4_header *ip, cnat_main_db_entry_t *db, u16 vrf)
unsigned long u64
Definition: types.h:89
static uword cnat_ipv4_udp_outside_input_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static char * cnat_ipv4_udp_outside_input_error_strings[]
u16 dst_port
Definition: cnat_db.h:257
u32 udp_outside_checksum_disable
static void stage2(vlib_main_t *vm, vlib_node_runtime_t *node, u32 buffer_index)
vlib_node_registration_t cnat_ipv4_udp_outside_input_node
(constructor) VLIB_REGISTER_NODE (cnat_ipv4_udp_outside_input_node)
#define PLATFORM_CNAT_SET_RX_VRF(ctx, rx_vrf, proto)
vlib_error_main_t error_main
Definition: main.h:124
#define PREDICT_FALSE(x)
Definition: clib.h:97
u32 udp_outside_packet_dump_enable
#define CNAT_UDP
Definition: cnat_db.h:93
cnat_user_db_entry_t * cnat_user_db
Definition: cnat_db_v2.c:202
void print_udp_pkt(ipv4_header *ip)
u64 * counters
Definition: error.h:78
svmdb_client_t * c
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:82
#define ARRAY_LEN(x)
Definition: clib.h:59
cnat_db_key_t k
Definition: cnat_db.h:108
cnat_ipv4_udp_outside_input_t
void cnat_add_dest_n_log(cnat_main_db_entry_t *mdb, cnat_key_t *dest_info)
Definition: cnat_db_v2.c:1083
unsigned int u32
Definition: types.h:88
#define CNAT_UPDATE_L3_CHECKSUM_DECLARE
#define vnet_buffer(b)
Definition: buffer.h:361
#define TRUE
Definition: cnat_db.h:78
#define PLATFORM_DBL_SUPPORT
cnat_key_t out2in_key
Definition: cnat_db.h:198
index_slist_t * cnat_out2in_hash
Definition: cnat_db_v2.c:195
static void stage3(vlib_main_t *vm, vlib_node_runtime_t *node, u32 buffer_index)
static u32 last_stage(vlib_main_t *vm, vlib_node_runtime_t *node, u32 bi)
static void stage1(vlib_main_t *vm, vlib_node_runtime_t *node, u32 buffer_index)
u64 uword
Definition: types.h:112
cnat_ipv4_udp_outside_input_main_t cnat_ipv4_udp_outside_input_main
u16 nsessions
Definition: cnat_db.h:266
dslite_counters_t dslite_all_counters[DSLITE_MAX_DSLITE_ENTRIES]
Definition: cnat_db.h:336
unsigned short u16
Definition: types.h:57
u16 dslite_nat44_inst_id
Definition: cnat_db.h:260
#define CNAT_MAIN_HASH_MASK
Definition: cnat_db.h:56
unsigned char u8
Definition: types.h:56
u32 dst_ipv4
Definition: cnat_db.h:254
struct _spp_ctx spp_ctx_t
u32 out2in_pkts
Definition: cnat_db.h:207
#define CNAT_UDP_OUTSIDE_UPDATE_FLAG_TIMER(db, dslite_nat44_inst_id)
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:143
#define foreach_cnat_ipv4_udp_outside_input_error
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
Definition: node_funcs.h:58
#define EMPTY
Definition: index_list.h:24
#define PLATFORM_HANDLE_TTL_DECREMENT
#define CNAT_UPDATE_L3_L4_CHECKSUM_DECLARE
cnat_ipv4_udp_outside_input_next_t
#define CNAT_V4_GET_HASH(key64, hash, mask)
Definition: cnat_db.h:536
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:67
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:57
Definition: defs.h:46
cnat_key_t in2out_key
Definition: cnat_db.h:201
#define CNAT_UPDATE_L3_CHECKSUM(old_l3_1, old_l3_2, old_l3_c,new_l3_1, new_l3_2)
nat44_dslite_common_stats_t nat44_dslite_common_stats[255]
Definition: cnat_db_v2.c:210