FD.io VPP  v19.04.2-12-g66b1689
Vector Packet Processing
encap.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 SUSE LLC.
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 #include <vppinfra/error.h>
16 #include <vppinfra/hash.h>
17 #include <vnet/vnet.h>
18 #include <vnet/ip/ip.h>
19 #include <vnet/ethernet/ethernet.h>
20 #include <vnet/geneve/geneve.h>
21 
22 /* Statistics (not all errors) */
23 #define foreach_geneve_encap_error \
24 _(ENCAPSULATED, "good packets encapsulated")
25 
26 static char *geneve_encap_error_strings[] = {
27 #define _(sym,string) string,
29 #undef _
30 };
31 
32 typedef enum
33 {
34 #define _(sym,str) GENEVE_ENCAP_ERROR_##sym,
36 #undef _
39 
40 typedef enum
41 {
45 
46 #define foreach_fixed_header4_offset \
47  _(0) _(1) _(2) _(3)
48 
49 #define foreach_fixed_header6_offset \
50  _(0) _(1) _(2) _(3) _(4) _(5) _(6)
51 
54  vlib_node_runtime_t * node,
55  vlib_frame_t * from_frame, u32 is_ip4)
56 {
57  u32 n_left_from, next_index, *from, *to_next;
58  geneve_main_t *vxm = &geneve_main;
59  vnet_main_t *vnm = vxm->vnet_main;
61  u32 pkts_encapsulated = 0;
62  u16 old_l0 = 0, old_l1 = 0;
63  u32 thread_index = vm->thread_index;
64  u32 stats_sw_if_index, stats_n_packets, stats_n_bytes;
65  u32 sw_if_index0 = ~0, sw_if_index1 = ~0;
66  u32 next0 = 0, next1 = 0;
67  vnet_hw_interface_t *hi0, *hi1;
68  geneve_tunnel_t *t0 = NULL, *t1 = NULL;
69 
70  from = vlib_frame_vector_args (from_frame);
71  n_left_from = from_frame->n_vectors;
72 
73  next_index = node->cached_next_index;
74  stats_sw_if_index = node->runtime_data[0];
75  stats_n_packets = stats_n_bytes = 0;
76 
77  while (n_left_from > 0)
78  {
79  u32 n_left_to_next;
80 
81  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
82 
83  while (n_left_from >= 4 && n_left_to_next >= 2)
84  {
85  u32 bi0, bi1;
86  vlib_buffer_t *b0, *b1;
87  u32 flow_hash0, flow_hash1;
88  u32 len0, len1;
89  ip4_header_t *ip4_0, *ip4_1;
90  ip6_header_t *ip6_0, *ip6_1;
91  udp_header_t *udp0, *udp1;
92  u64 *copy_src0, *copy_dst0;
93  u64 *copy_src1, *copy_dst1;
94  u32 *copy_src_last0, *copy_dst_last0;
95  u32 *copy_src_last1, *copy_dst_last1;
96  u16 new_l0, new_l1;
97  ip_csum_t sum0, sum1;
98 
99  /* Prefetch next iteration. */
100  {
101  vlib_buffer_t *p2, *p3;
102 
103  p2 = vlib_get_buffer (vm, from[2]);
104  p3 = vlib_get_buffer (vm, from[3]);
105 
106  vlib_prefetch_buffer_header (p2, LOAD);
107  vlib_prefetch_buffer_header (p3, LOAD);
108 
109  CLIB_PREFETCH (p2->data, 2 * CLIB_CACHE_LINE_BYTES, LOAD);
110  CLIB_PREFETCH (p3->data, 2 * CLIB_CACHE_LINE_BYTES, LOAD);
111  }
112 
113  bi0 = from[0];
114  bi1 = from[1];
115  to_next[0] = bi0;
116  to_next[1] = bi1;
117  from += 2;
118  to_next += 2;
119  n_left_to_next -= 2;
120  n_left_from -= 2;
121 
122  b0 = vlib_get_buffer (vm, bi0);
123  b1 = vlib_get_buffer (vm, bi1);
124 
125  flow_hash0 = vnet_l2_compute_flow_hash (b0);
126  flow_hash1 = vnet_l2_compute_flow_hash (b1);
127 
128  /* Get next node index and adj index from tunnel next_dpo */
129  if (sw_if_index0 != vnet_buffer (b0)->sw_if_index[VLIB_TX])
130  {
131  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_TX];
132  hi0 = vnet_get_sup_hw_interface (vnm, sw_if_index0);
133  t0 = &vxm->tunnels[hi0->dev_instance];
134  /* Note: change to always set next0 if it may be set to drop */
135  next0 = t0->next_dpo.dpoi_next_node;
136  }
137 
138  ASSERT (t0 != NULL);
139 
140  vnet_buffer (b0)->ip.adj_index[VLIB_TX] = t0->next_dpo.dpoi_index;
141 
142  /* Get next node index and adj index from tunnel next_dpo */
143  if (sw_if_index1 != vnet_buffer (b1)->sw_if_index[VLIB_TX])
144  {
145  sw_if_index1 = vnet_buffer (b1)->sw_if_index[VLIB_TX];
146  hi1 = vnet_get_sup_hw_interface (vnm, sw_if_index1);
147  t1 = &vxm->tunnels[hi1->dev_instance];
148  /* Note: change to always set next1 if it may be set to drop */
149  next1 = t1->next_dpo.dpoi_next_node;
150  }
151 
152  ASSERT (t1 != NULL);
153 
154  vnet_buffer (b1)->ip.adj_index[VLIB_TX] = t1->next_dpo.dpoi_index;
155 
156  /* Apply the rewrite string. $$$$ vnet_rewrite? */
157  vlib_buffer_advance (b0, -(word) _vec_len (t0->rewrite));
158  vlib_buffer_advance (b1, -(word) _vec_len (t1->rewrite));
159 
160  if (is_ip4)
161  {
162  u8 ip4_geneve_base_header_len =
163  sizeof (ip4_header_t) + sizeof (udp_header_t) +
165  u8 ip4_geneve_header_total_len0 = ip4_geneve_base_header_len;
166  u8 ip4_geneve_header_total_len1 = ip4_geneve_base_header_len;
167 #if SUPPORT_OPTIONS_HEADER==1
168  ip4_geneve_header_total_len0 += t0->options_len;
169  ip4_geneve_header_total_len1 += t1->options_len;
170 #endif
171  ASSERT (vec_len (t0->rewrite) == ip4_geneve_header_total_len0);
172  ASSERT (vec_len (t1->rewrite) == ip4_geneve_header_total_len1);
173 
174  ip4_0 = vlib_buffer_get_current (b0);
175  ip4_1 = vlib_buffer_get_current (b1);
176 
177  /* Copy the fixed header */
178  copy_dst0 = (u64 *) ip4_0;
179  copy_src0 = (u64 *) t0->rewrite;
180  copy_dst1 = (u64 *) ip4_1;
181  copy_src1 = (u64 *) t1->rewrite;
182  /* Copy first 32 octets 8-bytes at a time */
183 #define _(offs) copy_dst0[offs] = copy_src0[offs];
185 #undef _
186 #define _(offs) copy_dst1[offs] = copy_src1[offs];
188 #undef _
189  /* Last 4 octets. Hopefully gcc will be our friend */
190  copy_dst_last0 = (u32 *) (&copy_dst0[4]);
191  copy_src_last0 = (u32 *) (&copy_src0[4]);
192  copy_dst_last0[0] = copy_src_last0[0];
193  copy_dst_last1 = (u32 *) (&copy_dst1[4]);
194  copy_src_last1 = (u32 *) (&copy_src1[4]);
195  copy_dst_last1[0] = copy_src_last1[0];
196 
197  /* Fix the IP4 checksum and length */
198  sum0 = ip4_0->checksum;
199  new_l0 = /* old_l0 always 0, see the rewrite setup */
200  clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0));
201  sum0 = ip_csum_update (sum0, old_l0, new_l0, ip4_header_t,
202  length /* changed member */ );
203  ip4_0->checksum = ip_csum_fold (sum0);
204  ip4_0->length = new_l0;
205  sum1 = ip4_1->checksum;
206  new_l1 = /* old_l1 always 0, see the rewrite setup */
207  clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b1));
208  sum1 = ip_csum_update (sum1, old_l1, new_l1, ip4_header_t,
209  length /* changed member */ );
210  ip4_1->checksum = ip_csum_fold (sum1);
211  ip4_1->length = new_l1;
212 
213  /* Fix UDP length and set source port */
214  udp0 = (udp_header_t *) (ip4_0 + 1);
215  new_l0 =
216  clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0) -
217  sizeof (*ip4_0));
218  udp0->length = new_l0;
219  udp0->src_port = flow_hash0;
220  udp1 = (udp_header_t *) (ip4_1 + 1);
221  new_l1 =
222  clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b1) -
223  sizeof (*ip4_1));
224  udp1->length = new_l1;
225  udp1->src_port = flow_hash1;
226  }
227  else /* ipv6 */
228  {
229  int bogus = 0;
230 
231  u8 ip6_geneve_base_header_len =
232  sizeof (ip6_header_t) + sizeof (udp_header_t) +
234  u8 ip6_geneve_header_total_len0 = ip6_geneve_base_header_len;
235  u8 ip6_geneve_header_total_len1 = ip6_geneve_base_header_len;
236 #if SUPPORT_OPTIONS_HEADER==1
237  ip6_geneve_header_total_len0 += t0->options_len;
238  ip6_geneve_header_total_len1 += t1->options_len;
239 #endif
240  ASSERT (vec_len (t0->rewrite) == ip6_geneve_header_total_len0);
241  ASSERT (vec_len (t1->rewrite) == ip6_geneve_header_total_len1);
242 
243  ip6_0 = vlib_buffer_get_current (b0);
244  ip6_1 = vlib_buffer_get_current (b1);
245 
246  /* Copy the fixed header */
247  copy_dst0 = (u64 *) ip6_0;
248  copy_src0 = (u64 *) t0->rewrite;
249  copy_dst1 = (u64 *) ip6_1;
250  copy_src1 = (u64 *) t1->rewrite;
251  /* Copy first 56 (ip6) octets 8-bytes at a time */
252 #define _(offs) copy_dst0[offs] = copy_src0[offs];
254 #undef _
255 #define _(offs) copy_dst1[offs] = copy_src1[offs];
257 #undef _
258  /* Fix IP6 payload length */
259  new_l0 =
260  clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0)
261  - sizeof (*ip6_0));
262  ip6_0->payload_length = new_l0;
263  new_l1 =
264  clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b1)
265  - sizeof (*ip6_1));
266  ip6_1->payload_length = new_l1;
267 
268  /* Fix UDP length and set source port */
269  udp0 = (udp_header_t *) (ip6_0 + 1);
270  udp0->length = new_l0;
271  udp0->src_port = flow_hash0;
272  udp1 = (udp_header_t *) (ip6_1 + 1);
273  udp1->length = new_l1;
274  udp1->src_port = flow_hash1;
275 
276  /* IPv6 UDP checksum is mandatory */
278  ip6_0,
279  &bogus);
280  ASSERT (bogus == 0);
281  if (udp0->checksum == 0)
282  udp0->checksum = 0xffff;
284  ip6_1,
285  &bogus);
286  ASSERT (bogus == 0);
287  if (udp1->checksum == 0)
288  udp1->checksum = 0xffff;
289  }
290 
291  pkts_encapsulated += 2;
292  len0 = vlib_buffer_length_in_chain (vm, b0);
293  len1 = vlib_buffer_length_in_chain (vm, b1);
294  stats_n_packets += 2;
295  stats_n_bytes += len0 + len1;
296 
297  /* Batch stats increment on the same geneve tunnel so counter is not
298  incremented per packet. Note stats are still incremented for deleted
299  and admin-down tunnel where packets are dropped. It is not worthwhile
300  to check for this rare case and affect normal path performance. */
301  if (PREDICT_FALSE ((sw_if_index0 != stats_sw_if_index) ||
302  (sw_if_index1 != stats_sw_if_index)))
303  {
304  stats_n_packets -= 2;
305  stats_n_bytes -= len0 + len1;
306  if (sw_if_index0 == sw_if_index1)
307  {
308  if (stats_n_packets)
311  VNET_INTERFACE_COUNTER_TX, thread_index,
312  stats_sw_if_index, stats_n_packets, stats_n_bytes);
313  stats_sw_if_index = sw_if_index0;
314  stats_n_packets = 2;
315  stats_n_bytes = len0 + len1;
316  }
317  else
318  {
321  thread_index, sw_if_index0, 1, len0);
324  thread_index, sw_if_index1, 1, len1);
325  }
326  }
327 
328  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
329  {
331  vlib_add_trace (vm, node, b0, sizeof (*tr));
332  tr->tunnel_index = t0 - vxm->tunnels;
333  tr->vni = t0->vni;
334  }
335 
336  if (PREDICT_FALSE (b1->flags & VLIB_BUFFER_IS_TRACED))
337  {
339  vlib_add_trace (vm, node, b1, sizeof (*tr));
340  tr->tunnel_index = t1 - vxm->tunnels;
341  tr->vni = t1->vni;
342  }
343 
344  vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
345  to_next, n_left_to_next,
346  bi0, bi1, next0, next1);
347  }
348 
349  while (n_left_from > 0 && n_left_to_next > 0)
350  {
351  u32 bi0;
352  vlib_buffer_t *b0;
353  u32 flow_hash0;
354  u32 len0;
355  ip4_header_t *ip4_0;
356  ip6_header_t *ip6_0;
357  udp_header_t *udp0;
358  u64 *copy_src0, *copy_dst0;
359  u32 *copy_src_last0, *copy_dst_last0;
360  u16 new_l0;
361  ip_csum_t sum0;
362 
363  bi0 = from[0];
364  to_next[0] = bi0;
365  from += 1;
366  to_next += 1;
367  n_left_from -= 1;
368  n_left_to_next -= 1;
369 
370  b0 = vlib_get_buffer (vm, bi0);
371 
372  flow_hash0 = vnet_l2_compute_flow_hash (b0);
373 
374  /* Get next node index and adj index from tunnel next_dpo */
375  if (sw_if_index0 != vnet_buffer (b0)->sw_if_index[VLIB_TX])
376  {
377  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_TX];
378  hi0 = vnet_get_sup_hw_interface (vnm, sw_if_index0);
379  t0 = &vxm->tunnels[hi0->dev_instance];
380  /* Note: change to always set next0 if it may be set to drop */
381  next0 = t0->next_dpo.dpoi_next_node;
382  }
383  vnet_buffer (b0)->ip.adj_index[VLIB_TX] = t0->next_dpo.dpoi_index;
384 
385  /* Apply the rewrite string. $$$$ vnet_rewrite? */
386  vlib_buffer_advance (b0, -(word) _vec_len (t0->rewrite));
387 
388  if (is_ip4)
389  {
390  u8 ip4_geneve_base_header_len =
391  sizeof (ip4_header_t) + sizeof (udp_header_t) +
393  u8 ip4_geneve_header_total_len0 = ip4_geneve_base_header_len;
394 #if SUPPORT_OPTIONS_HEADER==1
395  ip4_geneve_header_total_len0 += t0->options_len;
396 #endif
397  ASSERT (vec_len (t0->rewrite) == ip4_geneve_header_total_len0);
398 
399  ip4_0 = vlib_buffer_get_current (b0);
400 
401  /* Copy the fixed header */
402  copy_dst0 = (u64 *) ip4_0;
403  copy_src0 = (u64 *) t0->rewrite;
404  /* Copy first 32 octets 8-bytes at a time */
405 #define _(offs) copy_dst0[offs] = copy_src0[offs];
407 #undef _
408  /* Last 4 octets. Hopefully gcc will be our friend */
409  copy_dst_last0 = (u32 *) (&copy_dst0[4]);
410  copy_src_last0 = (u32 *) (&copy_src0[4]);
411  copy_dst_last0[0] = copy_src_last0[0];
412 
413  /* Fix the IP4 checksum and length */
414  sum0 = ip4_0->checksum;
415  new_l0 = /* old_l0 always 0, see the rewrite setup */
416  clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0));
417  sum0 = ip_csum_update (sum0, old_l0, new_l0, ip4_header_t,
418  length /* changed member */ );
419  ip4_0->checksum = ip_csum_fold (sum0);
420  ip4_0->length = new_l0;
421 
422  /* Fix UDP length and set source port */
423  udp0 = (udp_header_t *) (ip4_0 + 1);
424  new_l0 =
425  clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0) -
426  sizeof (*ip4_0));
427  udp0->length = new_l0;
428  udp0->src_port = flow_hash0;
429  }
430 
431  else /* ip6 path */
432  {
433  int bogus = 0;
434 
435  u8 ip6_geneve_base_header_len =
436  sizeof (ip6_header_t) + sizeof (udp_header_t) +
438  u8 ip6_geneve_header_total_len0 = ip6_geneve_base_header_len;
439 #if SUPPORT_OPTIONS_HEADER==1
440  ip6_geneve_header_total_len0 += t0->options_len;
441 #endif
442  ASSERT (vec_len (t0->rewrite) == ip6_geneve_header_total_len0);
443 
444  ip6_0 = vlib_buffer_get_current (b0);
445  /* Copy the fixed header */
446  copy_dst0 = (u64 *) ip6_0;
447  copy_src0 = (u64 *) t0->rewrite;
448  /* Copy first 56 (ip6) octets 8-bytes at a time */
449 #define _(offs) copy_dst0[offs] = copy_src0[offs];
451 #undef _
452  /* Fix IP6 payload length */
453  new_l0 =
454  clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0)
455  - sizeof (*ip6_0));
456  ip6_0->payload_length = new_l0;
457 
458  /* Fix UDP length and set source port */
459  udp0 = (udp_header_t *) (ip6_0 + 1);
460  udp0->length = new_l0;
461  udp0->src_port = flow_hash0;
462 
463  /* IPv6 UDP checksum is mandatory */
465  ip6_0,
466  &bogus);
467  ASSERT (bogus == 0);
468  if (udp0->checksum == 0)
469  udp0->checksum = 0xffff;
470  }
471 
472  pkts_encapsulated++;
473  len0 = vlib_buffer_length_in_chain (vm, b0);
474  stats_n_packets += 1;
475  stats_n_bytes += len0;
476 
477  /* Batch stats increment on the same geneve tunnel so counter is not
478  incremented per packet. Note stats are still incremented for deleted
479  and admin-down tunnel where packets are dropped. It is not worthwhile
480  to check for this rare case and affect normal path performance. */
481  if (PREDICT_FALSE (sw_if_index0 != stats_sw_if_index))
482  {
483  stats_n_packets -= 1;
484  stats_n_bytes -= len0;
485  if (stats_n_packets)
488  thread_index, stats_sw_if_index,
489  stats_n_packets, stats_n_bytes);
490  stats_n_packets = 1;
491  stats_n_bytes = len0;
492  stats_sw_if_index = sw_if_index0;
493  }
494 
495  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
496  {
498  vlib_add_trace (vm, node, b0, sizeof (*tr));
499  tr->tunnel_index = t0 - vxm->tunnels;
500  tr->vni = t0->vni;
501  }
502  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
503  to_next, n_left_to_next,
504  bi0, next0);
505  }
506 
507  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
508  }
509 
510  /* Do we still need this now that tunnel tx stats is kept? */
512  GENEVE_ENCAP_ERROR_ENCAPSULATED,
513  pkts_encapsulated);
514 
515  /* Increment any remaining batch stats */
516  if (stats_n_packets)
517  {
520  thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
521  node->runtime_data[0] = stats_sw_if_index;
522  }
523 
524  return from_frame->n_vectors;
525 }
526 
528  vlib_node_runtime_t * node,
529  vlib_frame_t * from_frame)
530 {
531  return geneve_encap_inline (vm, node, from_frame, /* is_ip4 */ 1);
532 }
533 
535  vlib_node_runtime_t * node,
536  vlib_frame_t * from_frame)
537 {
538  return geneve_encap_inline (vm, node, from_frame, /* is_ip4 */ 0);
539 }
540 
541 /* *INDENT-OFF* */
543  .name = "geneve4-encap",
544  .vector_size = sizeof (u32),
545  .format_trace = format_geneve_encap_trace,
546  .type = VLIB_NODE_TYPE_INTERNAL,
548  .error_strings = geneve_encap_error_strings,
549  .n_next_nodes = GENEVE_ENCAP_N_NEXT,
550  .next_nodes = {
551  [GENEVE_ENCAP_NEXT_DROP] = "error-drop",
552  },
553 };
554 
556  .name = "geneve6-encap",
557  .vector_size = sizeof (u32),
558  .format_trace = format_geneve_encap_trace,
559  .type = VLIB_NODE_TYPE_INTERNAL,
561  .error_strings = geneve_encap_error_strings,
562  .n_next_nodes = GENEVE_ENCAP_N_NEXT,
563  .next_nodes = {
564  [GENEVE_ENCAP_NEXT_DROP] = "error-drop",
565  },
566 };
567 /* *INDENT-ON* */
568 
569 /*
570  * fd.io coding-style-patch-verification: ON
571  *
572  * Local Variables:
573  * eval: (c-set-style "gnu")
574  * End:
575  */
u32 sw_if_index
Definition: ipsec_gre.api:37
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
Definition: buffer.h:124
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 thread_index, u32 index, u64 n_packets, u64 n_bytes)
Increment a combined counter.
Definition: counter.h:220
u8 runtime_data[0]
Function dependent node-runtime data.
Definition: node.h:522
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
vnet_interface_main_t interface_main
Definition: vnet.h:56
unsigned long u64
Definition: types.h:89
#define NULL
Definition: clib.h:58
u32 thread_index
Definition: main.h:197
u8 data[0]
Packet data.
Definition: buffer.h:181
uword ip_csum_t
Definition: ip_packet.h:181
dpo_id_t next_dpo
Definition: geneve.h:91
#define VLIB_NODE_FN(node)
Definition: node.h:201
#define foreach_fixed_header6_offset
Definition: encap.c:49
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:366
vlib_node_registration_t geneve6_encap_node
(constructor) VLIB_REGISTER_NODE (geneve6_encap_node)
Definition: encap.c:555
u8 * format_geneve_encap_trace(u8 *s, va_list *args)
Definition: geneve.c:41
unsigned char u8
Definition: types.h:56
#define GENEVE_BASE_HEADER_LENGTH
Definition: geneve_packet.h:95
geneve_tunnel_t * tunnels
Definition: geneve.h:162
i64 word
Definition: types.h:111
u8 * rewrite
Definition: geneve.h:88
#define always_inline
Definition: clib.h:98
vlib_combined_counter_main_t * combined_sw_if_counters
Definition: interface.h:824
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
Definition: buffer.h:203
geneve_encap_next_t
Definition: encap.c:40
unsigned int u32
Definition: types.h:88
static uword geneve_encap_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, u32 is_ip4)
Definition: encap.c:53
unsigned short u16
Definition: types.h:57
static u32 vnet_l2_compute_flow_hash(vlib_buffer_t *b)
Definition: l2_input.h:266
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:229
#define PREDICT_FALSE(x)
Definition: clib.h:111
u32 node_index
Node index.
Definition: node.h:495
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
Finish enqueueing two buffers forward in the graph.
Definition: buffer_node.h:70
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
Definition: buffer_node.h:218
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
Definition: node_funcs.h:368
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1180
geneve_encap_error_t
Definition: encap.c:32
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
u16 n_vectors
Definition: node.h:395
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:80
vlib_main_t * vm
Definition: buffer.c:312
#define ARRAY_LEN(x)
Definition: clib.h:62
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
Definition: main.c:465
u16 ip6_tcp_udp_icmp_compute_checksum(vlib_main_t *vm, vlib_buffer_t *p0, ip6_header_t *ip0, int *bogus_lengthp)
Definition: ip6_forward.c:947
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
Definition: node.h:514
#define ASSERT(truth)
#define foreach_fixed_header4_offset
Definition: encap.c:46
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:248
vnet_main_t * vnet_main
Definition: geneve.h:184
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
Definition: trace_funcs.h:57
Definition: defs.h:47
u16 payload_length
Definition: ip6_packet.h:376
index_t dpoi_index
the index of objects of that type
Definition: dpo.h:184
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
VLIB buffer representation.
Definition: buffer.h:102
u64 uword
Definition: types.h:112
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:274
#define ip_csum_update(sum, old, new, type, field)
Definition: ip_packet.h:231
#define foreach_geneve_encap_error
Definition: encap.c:23
#define vnet_buffer(b)
Definition: buffer.h:369
geneve_main_t geneve_main
Definition: geneve.c:38
vlib_node_registration_t geneve4_encap_node
(constructor) VLIB_REGISTER_NODE (geneve4_encap_node)
Definition: encap.c:542
u16 dpoi_next_node
The next VLIB node to follow.
Definition: dpo.h:180
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
static char * geneve_encap_error_strings[]
Definition: encap.c:26
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:85
static u16 ip_csum_fold(ip_csum_t c)
Definition: ip_packet.h:237