FD.io VPP  v16.09
Vector Packet Processing
decap.c
Go to the documentation of this file.
1 /*
2  * decap.c - decapsulate VXLAN GPE
3  *
4  * Copyright (c) 2013 Cisco and/or its affiliates.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 /**
18  * @file
19  * @brief Functions for decapsulating VXLAN GPE tunnels
20  *
21 */
22 
23 #include <vlib/vlib.h>
24 #include <vnet/pg/pg.h>
26 
28 
29 /**
30  * @brief Struct for VXLAN GPE decap packet tracing
31  *
32  */
33 typedef struct {
38 
39 /**
40  * @brief Tracing function for VXLAN GPE packet decapsulation
41  *
42  * @param *s
43  * @param *args
44  *
45  * @return *s
46  *
47  */
48 static u8 * format_vxlan_gpe_rx_trace (u8 * s, va_list * args)
49 {
50  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
51  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
52  vxlan_gpe_rx_trace_t * t = va_arg (*args, vxlan_gpe_rx_trace_t *);
53 
54  if (t->tunnel_index != ~0)
55  {
56  s = format (s, "VXLAN-GPE: tunnel %d next %d error %d", t->tunnel_index,
57  t->next_index, t->error);
58  }
59  else
60  {
61  s = format (s, "VXLAN-GPE: no tunnel next %d error %d\n", t->next_index,
62  t->error);
63  }
64  return s;
65 }
66 
67 /**
68  * @brief Tracing function for VXLAN GPE packet decapsulation including length
69  *
70  * @param *s
71  * @param *args
72  *
73  * @return *s
74  *
75  */
76 static u8 * format_vxlan_gpe_with_length (u8 * s, va_list * args)
77 {
78  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
79  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
80 
81 
82  return s;
83 }
84 
85 /**
86  * @brief Common processing for IPv4 and IPv6 VXLAN GPE decap dispatch functions
87  *
88  * It is worth noting that other than trivial UDP forwarding (transit), VXLAN GPE
89  * tunnels are "terminate local". This means that there is no "TX" interface for this
90  * decap case, so that field in the buffer_metadata can be "used for something else".
91  * The something else in this case is, for the IPv4/IPv6 inner-packet type case, the
92  * FIB index used to look up the inner-packet's adjacency.
93  *
94  * vnet_buffer(b0)->sw_if_index[VLIB_TX] = t0->decap_fib_index;
95  *
96  * @param *vm
97  * @param *node
98  * @param *from_frame
99  * @param is_ip4
100  *
101  * @return from_frame->n_vectors
102  *
103  */
106  vlib_node_runtime_t * node,
107  vlib_frame_t * from_frame,
108  u8 is_ip4)
109 {
110  u32 n_left_from, next_index, *from, *to_next;
112  vnet_main_t * vnm = ngm->vnet_main;
114  u32 last_tunnel_index = ~0;
115  vxlan4_gpe_tunnel_key_t last_key4;
116  vxlan6_gpe_tunnel_key_t last_key6;
117  u32 pkts_decapsulated = 0;
118  u32 cpu_index = os_get_cpu_number ();
119  u32 stats_sw_if_index, stats_n_packets, stats_n_bytes;
120 
121  if (is_ip4)
122  memset (&last_key4, 0xff, sizeof(last_key4));
123  else
124  memset (&last_key6, 0xff, sizeof(last_key6));
125 
126  from = vlib_frame_vector_args (from_frame);
127  n_left_from = from_frame->n_vectors;
128 
129  next_index = node->cached_next_index;
130  stats_sw_if_index = node->runtime_data[0];
131  stats_n_packets = stats_n_bytes = 0;
132 
133  while (n_left_from > 0)
134  {
135  u32 n_left_to_next;
136 
137  vlib_get_next_frame(vm, node, next_index, to_next, n_left_to_next);
138 
139  while (n_left_from >= 4 && n_left_to_next >= 2)
140  {
141  u32 bi0, bi1;
142  vlib_buffer_t * b0, *b1;
143  u32 next0, next1;
144  ip4_vxlan_gpe_header_t * iuvn4_0, *iuvn4_1;
145  ip6_vxlan_gpe_header_t * iuvn6_0, *iuvn6_1;
146  uword * p0, *p1;
147  u32 tunnel_index0, tunnel_index1;
148  vxlan_gpe_tunnel_t * t0, *t1;
149  vxlan4_gpe_tunnel_key_t key4_0, key4_1;
150  vxlan6_gpe_tunnel_key_t key6_0, key6_1;
151  u32 error0, error1;
152  u32 sw_if_index0, sw_if_index1, len0, len1;
153 
154  /* Prefetch next iteration. */
155  {
156  vlib_buffer_t * p2, *p3;
157 
158  p2 = vlib_get_buffer (vm, from[2]);
159  p3 = vlib_get_buffer (vm, from[3]);
160 
161  vlib_prefetch_buffer_header(p2, LOAD);
162  vlib_prefetch_buffer_header(p3, LOAD);
163 
166  }
167 
168  bi0 = from[0];
169  bi1 = from[1];
170  to_next[0] = bi0;
171  to_next[1] = bi1;
172  from += 2;
173  to_next += 2;
174  n_left_to_next -= 2;
175  n_left_from -= 2;
176 
177  b0 = vlib_get_buffer (vm, bi0);
178  b1 = vlib_get_buffer (vm, bi1);
179 
180  if (is_ip4)
181  {
182  /* udp leaves current_data pointing at the vxlan-gpe header */
183  vlib_buffer_advance (b0, -(word) (sizeof(udp_header_t) + sizeof(ip4_header_t)));
184  vlib_buffer_advance (b1, -(word) (sizeof(udp_header_t) + sizeof(ip4_header_t)));
185 
186  iuvn4_0 = vlib_buffer_get_current (b0);
187  iuvn4_1 = vlib_buffer_get_current (b1);
188 
189  /* pop (ip, udp, vxlan) */
190  vlib_buffer_advance (b0, sizeof(*iuvn4_0));
191  vlib_buffer_advance (b1, sizeof(*iuvn4_1));
192  }
193  else
194  {
195  /* udp leaves current_data pointing at the vxlan-gpe header */
196  vlib_buffer_advance (b0, -(word) (sizeof(udp_header_t) + sizeof(ip6_header_t)));
197  vlib_buffer_advance (b1, -(word) (sizeof(udp_header_t) + sizeof(ip6_header_t)));
198 
199  iuvn6_0 = vlib_buffer_get_current (b0);
200  iuvn6_1 = vlib_buffer_get_current (b1);
201 
202  /* pop (ip, udp, vxlan) */
203  vlib_buffer_advance (b0, sizeof(*iuvn6_0));
204  vlib_buffer_advance (b1, sizeof(*iuvn6_1));
205  }
206 
207  tunnel_index0 = ~0;
208  tunnel_index1 = ~0;
209  error0 = 0;
210  error1 = 0;
211 
212  if (is_ip4)
213  {
214  next0 = (iuvn4_0->vxlan.protocol < node->n_next_nodes) ?
215  iuvn4_0->vxlan.protocol : VXLAN_GPE_INPUT_NEXT_DROP;
216  next1 = (iuvn4_1->vxlan.protocol < node->n_next_nodes) ?
217  iuvn4_1->vxlan.protocol : VXLAN_GPE_INPUT_NEXT_DROP;
218 
219  key4_0.local = iuvn4_0->ip4.dst_address.as_u32;
220  key4_1.local = iuvn4_1->ip4.dst_address.as_u32;
221 
222  key4_0.remote = iuvn4_0->ip4.src_address.as_u32;
223  key4_1.remote = iuvn4_1->ip4.src_address.as_u32;
224 
225  key4_0.vni = iuvn4_0->vxlan.vni_res;
226  key4_1.vni = iuvn4_1->vxlan.vni_res;
227 
228  key4_0.pad = 0;
229  key4_1.pad = 0;
230 
231  /* Processing for key4_0 */
232  if (PREDICT_FALSE((key4_0.as_u64[0] != last_key4.as_u64[0])
233  || (key4_0.as_u64[1] != last_key4.as_u64[1])))
234  {
235  p0 = hash_get_mem(ngm->vxlan4_gpe_tunnel_by_key, &key4_0);
236 
237  if (p0 == 0)
238  {
239  error0 = VXLAN_GPE_ERROR_NO_SUCH_TUNNEL;
240  goto trace0;
241  }
242 
243  last_key4.as_u64[0] = key4_0.as_u64[0];
244  last_key4.as_u64[1] = key4_0.as_u64[1];
245  tunnel_index0 = last_tunnel_index = p0[0];
246  }
247  else
248  tunnel_index0 = last_tunnel_index;
249  }
250  else /* is_ip6 */
251  {
252  next0 = (iuvn6_0->vxlan.protocol < node->n_next_nodes) ?
253  iuvn6_0->vxlan.protocol : VXLAN_GPE_INPUT_NEXT_DROP;
254  next1 = (iuvn6_1->vxlan.protocol < node->n_next_nodes) ?
255  iuvn6_1->vxlan.protocol : VXLAN_GPE_INPUT_NEXT_DROP;
256 
257  key6_0.local.as_u64[0] = iuvn6_0->ip6.dst_address.as_u64[0];
258  key6_0.local.as_u64[1] = iuvn6_0->ip6.dst_address.as_u64[1];
259  key6_1.local.as_u64[0] = iuvn6_1->ip6.dst_address.as_u64[0];
260  key6_1.local.as_u64[1] = iuvn6_1->ip6.dst_address.as_u64[1];
261 
262  key6_0.remote.as_u64[0] = iuvn6_0->ip6.src_address.as_u64[0];
263  key6_0.remote.as_u64[1] = iuvn6_0->ip6.src_address.as_u64[1];
264  key6_1.remote.as_u64[0] = iuvn6_1->ip6.src_address.as_u64[0];
265  key6_1.remote.as_u64[1] = iuvn6_1->ip6.src_address.as_u64[1];
266 
267  key6_0.vni = iuvn6_0->vxlan.vni_res;
268  key6_1.vni = iuvn6_1->vxlan.vni_res;
269 
270  /* Processing for key6_0 */
271  if (PREDICT_FALSE(memcmp (&key6_0, &last_key6, sizeof(last_key6)) != 0))
272  {
273  p0 = hash_get_mem(ngm->vxlan6_gpe_tunnel_by_key, &key6_0);
274 
275  if (p0 == 0)
276  {
277  error0 = VXLAN_GPE_ERROR_NO_SUCH_TUNNEL;
278  goto trace0;
279  }
280 
281  memcpy (&last_key6, &key6_0, sizeof(key6_0));
282  tunnel_index0 = last_tunnel_index = p0[0];
283  }
284  else
285  tunnel_index0 = last_tunnel_index;
286  }
287 
288  t0 = pool_elt_at_index(ngm->tunnels, tunnel_index0);
289 
290  next0 = t0->protocol;
291 
292  sw_if_index0 = t0->sw_if_index;
293  len0 = vlib_buffer_length_in_chain (vm, b0);
294 
295  /* Required to make the l2 tag push / pop code work on l2 subifs */
296  vnet_update_l2_len (b0);
297 
298  /**
299  * ip[46] lookup in the configured FIB
300  */
301  vnet_buffer(b0)->sw_if_index[VLIB_TX] = t0->decap_fib_index;
302 
303  pkts_decapsulated++;
304  stats_n_packets += 1;
305  stats_n_bytes += len0;
306 
307  if (PREDICT_FALSE(sw_if_index0 != stats_sw_if_index))
308  {
309  stats_n_packets -= 1;
310  stats_n_bytes -= len0;
311  if (stats_n_packets)
314  cpu_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
315  stats_n_packets = 1;
316  stats_n_bytes = len0;
317  stats_sw_if_index = sw_if_index0;
318  }
319 
320  trace0: b0->error = error0 ? node->errors[error0] : 0;
321 
323  {
324  vxlan_gpe_rx_trace_t *tr = vlib_add_trace (vm, node, b0, sizeof(*tr));
325  tr->next_index = next0;
326  tr->error = error0;
327  tr->tunnel_index = tunnel_index0;
328  }
329 
330  /* Process packet 1 */
331  if (is_ip4)
332  {
333  /* Processing for key4_1 */
334  if (PREDICT_FALSE(
335  (key4_1.as_u64[0] != last_key4.as_u64[0])
336  || (key4_1.as_u64[1] != last_key4.as_u64[1])))
337  {
338  p1 = hash_get_mem(ngm->vxlan4_gpe_tunnel_by_key, &key4_1);
339 
340  if (p1 == 0)
341  {
342  error1 = VXLAN_GPE_ERROR_NO_SUCH_TUNNEL;
343  goto trace1;
344  }
345 
346  last_key4.as_u64[0] = key4_1.as_u64[0];
347  last_key4.as_u64[1] = key4_1.as_u64[1];
348  tunnel_index1 = last_tunnel_index = p1[0];
349  }
350  else
351  tunnel_index1 = last_tunnel_index;
352  }
353  else /* is_ip6 */
354  {
355  /* Processing for key6_1 */
356  if (PREDICT_FALSE(memcmp (&key6_1, &last_key6, sizeof(last_key6)) != 0))
357  {
358  p1 = hash_get_mem(ngm->vxlan6_gpe_tunnel_by_key, &key6_1);
359 
360  if (p1 == 0)
361  {
362  error1 = VXLAN_GPE_ERROR_NO_SUCH_TUNNEL;
363  goto trace1;
364  }
365 
366  memcpy (&last_key6, &key6_1, sizeof(key6_1));
367  tunnel_index1 = last_tunnel_index = p1[0];
368  }
369  else
370  tunnel_index1 = last_tunnel_index;
371  }
372 
373  t1 = pool_elt_at_index(ngm->tunnels, tunnel_index1);
374 
375  next1 = t1->protocol;
376  sw_if_index1 = t1->sw_if_index;
377  len1 = vlib_buffer_length_in_chain (vm, b1);
378 
379  /* Required to make the l2 tag push / pop code work on l2 subifs */
380  vnet_update_l2_len (b1);
381 
382  /*
383  * ip[46] lookup in the configured FIB
384  */
385  vnet_buffer(b1)->sw_if_index[VLIB_TX] = t1->decap_fib_index;
386 
387  pkts_decapsulated++;
388  stats_n_packets += 1;
389  stats_n_bytes += len1;
390 
391  /* Batch stats increment on the same vxlan tunnel so counter
392  is not incremented per packet */
393  if (PREDICT_FALSE(sw_if_index1 != stats_sw_if_index))
394  {
395  stats_n_packets -= 1;
396  stats_n_bytes -= len1;
397  if (stats_n_packets)
400  cpu_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
401  stats_n_packets = 1;
402  stats_n_bytes = len1;
403  stats_sw_if_index = sw_if_index1;
404  }
405  vnet_buffer(b1)->sw_if_index[VLIB_TX] = t1->decap_fib_index;
406 
407  trace1: b1->error = error1 ? node->errors[error1] : 0;
408 
410  {
411  vxlan_gpe_rx_trace_t *tr = vlib_add_trace (vm, node, b1, sizeof(*tr));
412  tr->next_index = next1;
413  tr->error = error1;
414  tr->tunnel_index = tunnel_index1;
415  }
416 
417  vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next,
418  n_left_to_next, bi0, bi1, next0, next1);
419  }
420 
421  while (n_left_from > 0 && n_left_to_next > 0)
422  {
423  u32 bi0;
424  vlib_buffer_t * b0;
425  u32 next0;
426  ip4_vxlan_gpe_header_t * iuvn4_0;
427  ip6_vxlan_gpe_header_t * iuvn6_0;
428  uword * p0;
429  u32 tunnel_index0;
430  vxlan_gpe_tunnel_t * t0;
431  vxlan4_gpe_tunnel_key_t key4_0;
432  vxlan6_gpe_tunnel_key_t key6_0;
433  u32 error0;
434  u32 sw_if_index0, len0;
435 
436  bi0 = from[0];
437  to_next[0] = bi0;
438  from += 1;
439  to_next += 1;
440  n_left_from -= 1;
441  n_left_to_next -= 1;
442 
443  b0 = vlib_get_buffer (vm, bi0);
444 
445  if (is_ip4)
446  {
447  /* udp leaves current_data pointing at the vxlan-gpe header */
449  b0, -(word) (sizeof(udp_header_t) + sizeof(ip4_header_t)));
450 
451  iuvn4_0 = vlib_buffer_get_current (b0);
452 
453  /* pop (ip, udp, vxlan) */
454  vlib_buffer_advance (b0, sizeof(*iuvn4_0));
455  }
456  else
457  {
458  /* udp leaves current_data pointing at the vxlan-gpe header */
460  b0, -(word) (sizeof(udp_header_t) + sizeof(ip6_header_t)));
461 
462  iuvn6_0 = vlib_buffer_get_current (b0);
463 
464  /* pop (ip, udp, vxlan) */
465  vlib_buffer_advance (b0, sizeof(*iuvn6_0));
466  }
467 
468  tunnel_index0 = ~0;
469  error0 = 0;
470 
471  if (is_ip4)
472  {
473  next0 =
474  (iuvn4_0->vxlan.protocol < node->n_next_nodes) ?
475  iuvn4_0->vxlan.protocol : VXLAN_GPE_INPUT_NEXT_DROP;
476 
477  key4_0.local = iuvn4_0->ip4.dst_address.as_u32;
478  key4_0.remote = iuvn4_0->ip4.src_address.as_u32;
479  key4_0.vni = iuvn4_0->vxlan.vni_res;
480  key4_0.pad = 0;
481 
482  /* Processing for key4_0 */
483  if (PREDICT_FALSE(
484  (key4_0.as_u64[0] != last_key4.as_u64[0])
485  || (key4_0.as_u64[1] != last_key4.as_u64[1])))
486  {
487  p0 = hash_get_mem(ngm->vxlan4_gpe_tunnel_by_key, &key4_0);
488 
489  if (p0 == 0)
490  {
491  error0 = VXLAN_GPE_ERROR_NO_SUCH_TUNNEL;
492  goto trace00;
493  }
494 
495  last_key4.as_u64[0] = key4_0.as_u64[0];
496  last_key4.as_u64[1] = key4_0.as_u64[1];
497  tunnel_index0 = last_tunnel_index = p0[0];
498  }
499  else
500  tunnel_index0 = last_tunnel_index;
501  }
502  else /* is_ip6 */
503  {
504  next0 = (iuvn6_0->vxlan.protocol < node->n_next_nodes) ?
505  iuvn6_0->vxlan.protocol : VXLAN_GPE_INPUT_NEXT_DROP;
506 
507  key6_0.local.as_u64[0] = iuvn6_0->ip6.dst_address.as_u64[0];
508  key6_0.local.as_u64[1] = iuvn6_0->ip6.dst_address.as_u64[1];
509  key6_0.remote.as_u64[0] = iuvn6_0->ip6.src_address.as_u64[0];
510  key6_0.remote.as_u64[1] = iuvn6_0->ip6.src_address.as_u64[1];
511  key6_0.vni = iuvn6_0->vxlan.vni_res;
512 
513  /* Processing for key6_0 */
514  if (PREDICT_FALSE(memcmp (&key6_0, &last_key6, sizeof(last_key6)) != 0))
515  {
516  p0 = hash_get_mem(ngm->vxlan6_gpe_tunnel_by_key, &key6_0);
517 
518  if (p0 == 0)
519  {
520  error0 = VXLAN_GPE_ERROR_NO_SUCH_TUNNEL;
521  goto trace00;
522  }
523 
524  memcpy (&last_key6, &key6_0, sizeof(key6_0));
525  tunnel_index0 = last_tunnel_index = p0[0];
526  }
527  else
528  tunnel_index0 = last_tunnel_index;
529  }
530 
531  t0 = pool_elt_at_index(ngm->tunnels, tunnel_index0);
532 
533  next0 = t0->protocol;
534 
535  sw_if_index0 = t0->sw_if_index;
536  len0 = vlib_buffer_length_in_chain (vm, b0);
537 
538  /* Required to make the l2 tag push / pop code work on l2 subifs */
539  vnet_update_l2_len (b0);
540 
541  /*
542  * ip[46] lookup in the configured FIB
543  */
544  vnet_buffer(b0)->sw_if_index[VLIB_TX] = t0->decap_fib_index;
545 
546  pkts_decapsulated++;
547  stats_n_packets += 1;
548  stats_n_bytes += len0;
549 
550  /* Batch stats increment on the same vxlan-gpe tunnel so counter
551  is not incremented per packet */
552  if (PREDICT_FALSE(sw_if_index0 != stats_sw_if_index))
553  {
554  stats_n_packets -= 1;
555  stats_n_bytes -= len0;
556  if (stats_n_packets)
559  cpu_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
560  stats_n_packets = 1;
561  stats_n_bytes = len0;
562  stats_sw_if_index = sw_if_index0;
563  }
564 
565  trace00: b0->error = error0 ? node->errors[error0] : 0;
566 
568  {
569  vxlan_gpe_rx_trace_t *tr = vlib_add_trace (vm, node, b0, sizeof(*tr));
570  tr->next_index = next0;
571  tr->error = error0;
572  tr->tunnel_index = tunnel_index0;
573  }
574  vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next,
575  n_left_to_next, bi0, next0);
576  }
577 
578  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
579  }
581  VXLAN_GPE_ERROR_DECAPSULATED, pkts_decapsulated);
582  /* Increment any remaining batch stats */
583  if (stats_n_packets)
584  {
587  stats_sw_if_index, stats_n_packets, stats_n_bytes);
588  node->runtime_data[0] = stats_sw_if_index;
589  }
590  return from_frame->n_vectors;
591 }
592 
593 /**
594  * @brief Graph processing dispatch function for IPv4 VXLAN GPE
595  *
596  * @node vxlan4-gpe-input
597  * @param *vm
598  * @param *node
599  * @param *from_frame
600  *
601  * @return from_frame->n_vectors
602  *
603  */
604 static uword
606  vlib_frame_t * from_frame)
607 {
608  return vxlan_gpe_input (vm, node, from_frame, /* is_ip4 */1);
609 }
610 
611 /**
612  * @brief Graph processing dispatch function for IPv6 VXLAN GPE
613  *
614  * @node vxlan6-gpe-input
615  * @param *vm
616  * @param *node
617  * @param *from_frame
618  *
619  * @return from_frame->n_vectors
620  *
621  */
622 static uword
624  vlib_frame_t * from_frame)
625 {
626  return vxlan_gpe_input (vm, node, from_frame, /* is_ip4 */0);
627 }
628 
629 /**
630  * @brief VXLAN GPE error strings
631  */
632 static char * vxlan_gpe_error_strings[] = {
633 #define vxlan_gpe_error(n,s) s,
635 #undef vxlan_gpe_error
636 #undef _
637 };
638 
640  .function = vxlan4_gpe_input,
641  .name = "vxlan4-gpe-input",
642  /* Takes a vector of packets. */
643  .vector_size = sizeof (u32),
645  .n_errors = ARRAY_LEN(vxlan_gpe_error_strings),
646  .error_strings = vxlan_gpe_error_strings,
647 
648  .n_next_nodes = VXLAN_GPE_INPUT_N_NEXT,
649  .next_nodes = {
650 #define _(s,n) [VXLAN_GPE_INPUT_NEXT_##s] = n,
652 #undef _
653  },
654 
655  .format_buffer = format_vxlan_gpe_with_length,
656  .format_trace = format_vxlan_gpe_rx_trace,
657  // $$$$ .unformat_buffer = unformat_vxlan_gpe_header,
658 };
659 
661 
663  .function = vxlan6_gpe_input,
664  .name = "vxlan6-gpe-input",
665  /* Takes a vector of packets. */
666  .vector_size = sizeof (u32),
668  .n_errors = ARRAY_LEN(vxlan_gpe_error_strings),
669  .error_strings = vxlan_gpe_error_strings,
670 
671  .n_next_nodes = VXLAN_GPE_INPUT_N_NEXT,
672  .next_nodes = {
673 #define _(s,n) [VXLAN_GPE_INPUT_NEXT_##s] = n,
675 #undef _
676  },
677 
678  .format_buffer = format_vxlan_gpe_with_length,
679  .format_trace = format_vxlan_gpe_rx_trace,
680  // $$$$ .unformat_buffer = unformat_vxlan_gpe_header,
681 };
682 
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:457
uword * vxlan6_gpe_tunnel_by_key
lookup IPv6 VXLAN GPE tunnel by key
Definition: vxlan_gpe.h:153
#define CLIB_UNUSED(x)
Definition: clib.h:79
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
vlib_node_registration_t vxlan4_gpe_input_node
(constructor) VLIB_REGISTER_NODE (vxlan4_gpe_input_node)
Definition: decap.c:639
vnet_interface_main_t interface_main
Definition: vnet.h:64
Struct for VXLAN GPE decap packet tracing.
Definition: decap.c:33
vlib_node_registration_t vxlan_gpe_input_node
Definition: decap.c:27
VXLAN GPE definitions.
vlib_node_registration_t vxlan6_gpe_input_node
(constructor) VLIB_REGISTER_NODE (vxlan6_gpe_input_node)
Definition: decap.c:662
struct _vlib_node_registration vlib_node_registration_t
vlib_error_t * errors
Definition: node.h:418
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:112
vnet_main_t * vnet_main
State convenience vnet_main_t.
Definition: vxlan_gpe.h:164
static char * vxlan_gpe_error_strings[]
VXLAN GPE error strings.
Definition: decap.c:632
#define always_inline
Definition: clib.h:84
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:187
vlib_combined_counter_main_t * combined_sw_if_counters
Definition: interface.h:501
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:369
static uword vxlan_gpe_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, u8 is_ip4)
Common processing for IPv4 and IPv6 VXLAN GPE decap dispatch functions.
Definition: decap.c:105
Struct for VXLAN GPE tunnel.
Definition: vxlan_gpe.h:90
uword os_get_cpu_number(void)
Definition: unix-misc.c:224
vxlan_gpe_main_t vxlan_gpe_main
Definition: vxlan_gpe.c:23
#define PREDICT_FALSE(x)
Definition: clib.h:97
u8 protocol
encapsulated protocol
Definition: vxlan_gpe.h:95
#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:130
#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:348
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition: buffer.h:118
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1111
u16 n_vectors
Definition: node.h:344
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:82
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:200
static uword vxlan4_gpe_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Graph processing dispatch function for IPv4 VXLAN GPE.
Definition: decap.c:605
#define ARRAY_LEN(x)
Definition: clib.h:59
#define foreach_vxlan_gpe_input_next
next nodes for VXLAN GPE input
Definition: vxlan_gpe.h:123
u16 cached_next_index
Definition: node.h:462
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 cpu_index, u32 index, u32 packet_increment, u32 byte_increment)
Increment a combined counter.
Definition: counter.h:241
unsigned int u32
Definition: types.h:88
static u8 * format_vxlan_gpe_with_length(u8 *s, va_list *args)
Tracing function for VXLAN GPE packet decapsulation including length.
Definition: decap.c:76
#define vnet_buffer(b)
Definition: buffer.h:335
Struct for VXLAN GPE node state.
Definition: vxlan_gpe.h:146
u8 * format(u8 *s, char *fmt,...)
Definition: format.c:418
#define VLIB_BUFFER_IS_TRACED
Definition: buffer.h:93
vxlan_gpe_tunnel_t * tunnels
vector of encap tunnel instances
Definition: vxlan_gpe.h:148
u64 uword
Definition: types.h:112
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:55
Definition: defs.h:47
uword * vxlan4_gpe_tunnel_by_key
lookup IPv4 VXLAN GPE tunnel by key
Definition: vxlan_gpe.h:151
u32 decap_fib_index
FIB indices - inner IP packet lookup here.
Definition: vxlan_gpe.h:105
i64 word
Definition: types.h:111
unsigned char u8
Definition: types.h:56
static void vnet_update_l2_len(vlib_buffer_t *b)
Definition: l2_input.h:230
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:251
#define hash_get_mem(h, key)
Definition: hash.h:268
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
Definition: buffer.h:163
VLIB_NODE_FUNCTION_MULTIARCH(l2t_decap_node, l2t_decap_node_fn)
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:143
u32 sw_if_index
vnet intfc sw_if_index
Definition: vxlan_gpe.h:113
u8 data[0]
Packet data.
Definition: buffer.h:151
static uword vxlan6_gpe_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Graph processing dispatch function for IPv6 VXLAN GPE.
Definition: decap.c:623
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:67
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
Definition: buffer.h:85
static u8 * format_vxlan_gpe_rx_trace(u8 *s, va_list *args)
Tracing function for VXLAN GPE packet decapsulation.
Definition: decap.c:48
uword runtime_data[(128-1 *sizeof(vlib_node_function_t *)-1 *sizeof(vlib_error_t *)-11 *sizeof(u32)-5 *sizeof(u16))/sizeof(uword)]
Definition: node.h:472
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:69