Fix dual-loop issue in vxlan_gpe decap
[vpp.git] / vnet / vnet / vxlan-gpe / decap.c
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>
25 #include <vnet/vxlan-gpe/vxlan_gpe.h>
26
27 vlib_node_registration_t vxlan_gpe_input_node;
28
29 /**
30  * @brief Struct for VXLAN GPE decap packet tracing
31  *
32  */
33 typedef struct {
34   u32 next_index;
35   u32 tunnel_index;
36   u32 error;
37 } vxlan_gpe_rx_trace_t;
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  */
104 always_inline uword
105 vxlan_gpe_input (vlib_main_t * vm,
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;
111   vxlan_gpe_main_t * ngm = &vxlan_gpe_main;
112   vnet_main_t * vnm = ngm->vnet_main;
113   vnet_interface_main_t * im = &vnm->interface_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
164         CLIB_PREFETCH(p2->data, 2*CLIB_CACHE_LINE_BYTES, LOAD);
165         CLIB_PREFETCH(p3->data, 2*CLIB_CACHE_LINE_BYTES, LOAD);
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       else /* is_ip6 */
232       {
233         next0 = (iuvn6_0->vxlan.protocol < node->n_next_nodes) ?
234                 iuvn6_0->vxlan.protocol : VXLAN_GPE_INPUT_NEXT_DROP;
235         next1 = (iuvn6_1->vxlan.protocol < node->n_next_nodes) ?
236                 iuvn6_1->vxlan.protocol : VXLAN_GPE_INPUT_NEXT_DROP;
237
238         key6_0.local.as_u64[0] = iuvn6_0->ip6.dst_address.as_u64[0];
239         key6_0.local.as_u64[1] = iuvn6_0->ip6.dst_address.as_u64[1];
240         key6_1.local.as_u64[0] = iuvn6_1->ip6.dst_address.as_u64[0];
241         key6_1.local.as_u64[1] = iuvn6_1->ip6.dst_address.as_u64[1];
242
243         key6_0.remote.as_u64[0] = iuvn6_0->ip6.src_address.as_u64[0];
244         key6_0.remote.as_u64[1] = iuvn6_0->ip6.src_address.as_u64[1];
245         key6_1.remote.as_u64[0] = iuvn6_1->ip6.src_address.as_u64[0];
246         key6_1.remote.as_u64[1] = iuvn6_1->ip6.src_address.as_u64[1];
247
248         key6_0.vni = iuvn6_0->vxlan.vni_res;
249         key6_1.vni = iuvn6_1->vxlan.vni_res;
250       }
251
252       /* Processing packet 0*/
253       if (is_ip4)
254       {
255         /* Processing for key4_0 */
256         if (PREDICT_FALSE((key4_0.as_u64[0] != last_key4.as_u64[0])
257                 || (key4_0.as_u64[1] != last_key4.as_u64[1])))
258         {
259           p0 = hash_get_mem(ngm->vxlan4_gpe_tunnel_by_key, &key4_0);
260
261           if (p0 == 0)
262           {
263             error0 = VXLAN_GPE_ERROR_NO_SUCH_TUNNEL;
264             goto trace0;
265           }
266
267           last_key4.as_u64[0] = key4_0.as_u64[0];
268           last_key4.as_u64[1] = key4_0.as_u64[1];
269           tunnel_index0 = last_tunnel_index = p0[0];
270         }
271         else
272           tunnel_index0 = last_tunnel_index;
273       }
274       else /* is_ip6 */
275       {
276         /* Processing for key6_0 */
277         if (PREDICT_FALSE(memcmp (&key6_0, &last_key6, sizeof(last_key6)) != 0))
278         {
279           p0 = hash_get_mem(ngm->vxlan6_gpe_tunnel_by_key, &key6_0);
280
281           if (p0 == 0)
282           {
283             error0 = VXLAN_GPE_ERROR_NO_SUCH_TUNNEL;
284             goto trace0;
285           }
286
287           memcpy (&last_key6, &key6_0, sizeof(key6_0));
288           tunnel_index0 = last_tunnel_index = p0[0];
289         }
290         else
291           tunnel_index0 = last_tunnel_index;
292       }
293
294       t0 = pool_elt_at_index(ngm->tunnels, tunnel_index0);
295
296       next0 = t0->protocol;
297
298       sw_if_index0 = t0->sw_if_index;
299       len0 = vlib_buffer_length_in_chain (vm, b0);
300
301       /* Required to make the l2 tag push / pop code work on l2 subifs */
302       vnet_update_l2_len (b0);
303
304       /**
305        * ip[46] lookup in the configured FIB
306        */
307       vnet_buffer(b0)->sw_if_index[VLIB_TX] = t0->decap_fib_index;
308
309       pkts_decapsulated++;
310       stats_n_packets += 1;
311       stats_n_bytes += len0;
312
313       if (PREDICT_FALSE(sw_if_index0 != stats_sw_if_index))
314       {
315         stats_n_packets -= 1;
316         stats_n_bytes -= len0;
317         if (stats_n_packets)
318           vlib_increment_combined_counter (
319               im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX,
320               cpu_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
321         stats_n_packets = 1;
322         stats_n_bytes = len0;
323         stats_sw_if_index = sw_if_index0;
324       }
325
326       trace0: b0->error = error0 ? node->errors[error0] : 0;
327
328       if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
329       {
330         vxlan_gpe_rx_trace_t *tr = vlib_add_trace (vm, node, b0, sizeof(*tr));
331         tr->next_index = next0;
332         tr->error = error0;
333         tr->tunnel_index = tunnel_index0;
334       }
335
336       /* Process packet 1 */
337       if (is_ip4)
338       {
339         /* Processing for key4_1 */
340         if (PREDICT_FALSE(
341             (key4_1.as_u64[0] != last_key4.as_u64[0])
342                 || (key4_1.as_u64[1] != last_key4.as_u64[1])))
343         {
344           p1 = hash_get_mem(ngm->vxlan4_gpe_tunnel_by_key, &key4_1);
345
346           if (p1 == 0)
347           {
348             error1 = VXLAN_GPE_ERROR_NO_SUCH_TUNNEL;
349             goto trace1;
350           }
351
352           last_key4.as_u64[0] = key4_1.as_u64[0];
353           last_key4.as_u64[1] = key4_1.as_u64[1];
354           tunnel_index1 = last_tunnel_index = p1[0];
355         }
356         else
357           tunnel_index1 = last_tunnel_index;
358       }
359       else /* is_ip6 */
360       {
361         /* Processing for key6_1 */
362         if (PREDICT_FALSE(memcmp (&key6_1, &last_key6, sizeof(last_key6)) != 0))
363         {
364           p1 = hash_get_mem(ngm->vxlan6_gpe_tunnel_by_key, &key6_1);
365
366           if (p1 == 0)
367           {
368             error1 = VXLAN_GPE_ERROR_NO_SUCH_TUNNEL;
369             goto trace1;
370           }
371
372           memcpy (&last_key6, &key6_1, sizeof(key6_1));
373           tunnel_index1 = last_tunnel_index = p1[0];
374         }
375         else
376           tunnel_index1 = last_tunnel_index;
377       }
378
379       t1 = pool_elt_at_index(ngm->tunnels, tunnel_index1);
380
381       next1 = t1->protocol;
382       sw_if_index1 = t1->sw_if_index;
383       len1 = vlib_buffer_length_in_chain (vm, b1);
384
385       /* Required to make the l2 tag push / pop code work on l2 subifs */
386       vnet_update_l2_len (b1);
387
388       /*
389        * ip[46] lookup in the configured FIB
390        */
391       vnet_buffer(b1)->sw_if_index[VLIB_TX] = t1->decap_fib_index;
392
393       pkts_decapsulated++;
394       stats_n_packets += 1;
395       stats_n_bytes += len1;
396
397       /* Batch stats increment on the same vxlan tunnel so counter
398        is not incremented per packet */
399       if (PREDICT_FALSE(sw_if_index1 != stats_sw_if_index))
400       {
401         stats_n_packets -= 1;
402         stats_n_bytes -= len1;
403         if (stats_n_packets)
404           vlib_increment_combined_counter (
405               im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX,
406               cpu_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
407         stats_n_packets = 1;
408         stats_n_bytes = len1;
409         stats_sw_if_index = sw_if_index1;
410       }
411       vnet_buffer(b1)->sw_if_index[VLIB_TX] = t1->decap_fib_index;
412
413       trace1: b1->error = error1 ? node->errors[error1] : 0;
414
415       if (PREDICT_FALSE(b1->flags & VLIB_BUFFER_IS_TRACED))
416       {
417         vxlan_gpe_rx_trace_t *tr = vlib_add_trace (vm, node, b1, sizeof(*tr));
418         tr->next_index = next1;
419         tr->error = error1;
420         tr->tunnel_index = tunnel_index1;
421       }
422
423       vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next,
424                                       n_left_to_next, bi0, bi1, next0, next1);
425     }
426
427     while (n_left_from > 0 && n_left_to_next > 0)
428     {
429       u32 bi0;
430       vlib_buffer_t * b0;
431       u32 next0;
432       ip4_vxlan_gpe_header_t * iuvn4_0;
433       ip6_vxlan_gpe_header_t * iuvn6_0;
434       uword * p0;
435       u32 tunnel_index0;
436       vxlan_gpe_tunnel_t * t0;
437       vxlan4_gpe_tunnel_key_t key4_0;
438       vxlan6_gpe_tunnel_key_t key6_0;
439       u32 error0;
440       u32 sw_if_index0, len0;
441
442       bi0 = from[0];
443       to_next[0] = bi0;
444       from += 1;
445       to_next += 1;
446       n_left_from -= 1;
447       n_left_to_next -= 1;
448
449       b0 = vlib_get_buffer (vm, bi0);
450
451       if (is_ip4)
452       {
453         /* udp leaves current_data pointing at the vxlan-gpe header */
454         vlib_buffer_advance (
455             b0, -(word) (sizeof(udp_header_t) + sizeof(ip4_header_t)));
456
457         iuvn4_0 = vlib_buffer_get_current (b0);
458
459         /* pop (ip, udp, vxlan) */
460         vlib_buffer_advance (b0, sizeof(*iuvn4_0));
461       }
462       else
463       {
464         /* udp leaves current_data pointing at the vxlan-gpe header */
465         vlib_buffer_advance (
466             b0, -(word) (sizeof(udp_header_t) + sizeof(ip6_header_t)));
467
468         iuvn6_0 = vlib_buffer_get_current (b0);
469
470         /* pop (ip, udp, vxlan) */
471         vlib_buffer_advance (b0, sizeof(*iuvn6_0));
472       }
473
474       tunnel_index0 = ~0;
475       error0 = 0;
476
477       if (is_ip4)
478       {
479         next0 =
480             (iuvn4_0->vxlan.protocol < node->n_next_nodes) ?
481                 iuvn4_0->vxlan.protocol : VXLAN_GPE_INPUT_NEXT_DROP;
482
483         key4_0.local = iuvn4_0->ip4.dst_address.as_u32;
484         key4_0.remote = iuvn4_0->ip4.src_address.as_u32;
485         key4_0.vni = iuvn4_0->vxlan.vni_res;
486         key4_0.pad = 0;
487
488         /* Processing for key4_0 */
489         if (PREDICT_FALSE(
490             (key4_0.as_u64[0] != last_key4.as_u64[0])
491                 || (key4_0.as_u64[1] != last_key4.as_u64[1])))
492         {
493           p0 = hash_get_mem(ngm->vxlan4_gpe_tunnel_by_key, &key4_0);
494
495           if (p0 == 0)
496           {
497             error0 = VXLAN_GPE_ERROR_NO_SUCH_TUNNEL;
498             goto trace00;
499           }
500
501           last_key4.as_u64[0] = key4_0.as_u64[0];
502           last_key4.as_u64[1] = key4_0.as_u64[1];
503           tunnel_index0 = last_tunnel_index = p0[0];
504         }
505         else
506           tunnel_index0 = last_tunnel_index;
507       }
508       else /* is_ip6 */
509       {
510         next0 = (iuvn6_0->vxlan.protocol < node->n_next_nodes) ?
511                 iuvn6_0->vxlan.protocol : VXLAN_GPE_INPUT_NEXT_DROP;
512
513         key6_0.local.as_u64[0] = iuvn6_0->ip6.dst_address.as_u64[0];
514         key6_0.local.as_u64[1] = iuvn6_0->ip6.dst_address.as_u64[1];
515         key6_0.remote.as_u64[0] = iuvn6_0->ip6.src_address.as_u64[0];
516         key6_0.remote.as_u64[1] = iuvn6_0->ip6.src_address.as_u64[1];
517         key6_0.vni = iuvn6_0->vxlan.vni_res;
518
519         /* Processing for key6_0 */
520         if (PREDICT_FALSE(memcmp (&key6_0, &last_key6, sizeof(last_key6)) != 0))
521         {
522           p0 = hash_get_mem(ngm->vxlan6_gpe_tunnel_by_key, &key6_0);
523
524           if (p0 == 0)
525           {
526             error0 = VXLAN_GPE_ERROR_NO_SUCH_TUNNEL;
527             goto trace00;
528           }
529
530           memcpy (&last_key6, &key6_0, sizeof(key6_0));
531           tunnel_index0 = last_tunnel_index = p0[0];
532         }
533         else
534           tunnel_index0 = last_tunnel_index;
535       }
536
537       t0 = pool_elt_at_index(ngm->tunnels, tunnel_index0);
538
539       next0 = t0->protocol;
540
541       sw_if_index0 = t0->sw_if_index;
542       len0 = vlib_buffer_length_in_chain (vm, b0);
543
544       /* Required to make the l2 tag push / pop code work on l2 subifs */
545       vnet_update_l2_len (b0);
546
547       /*
548        * ip[46] lookup in the configured FIB
549        */
550       vnet_buffer(b0)->sw_if_index[VLIB_TX] = t0->decap_fib_index;
551
552       pkts_decapsulated++;
553       stats_n_packets += 1;
554       stats_n_bytes += len0;
555
556       /* Batch stats increment on the same vxlan-gpe tunnel so counter
557        is not incremented per packet */
558       if (PREDICT_FALSE(sw_if_index0 != stats_sw_if_index))
559       {
560         stats_n_packets -= 1;
561         stats_n_bytes -= len0;
562         if (stats_n_packets)
563           vlib_increment_combined_counter (
564               im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX,
565               cpu_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
566         stats_n_packets = 1;
567         stats_n_bytes = len0;
568         stats_sw_if_index = sw_if_index0;
569       }
570
571       trace00: b0->error = error0 ? node->errors[error0] : 0;
572
573       if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
574       {
575         vxlan_gpe_rx_trace_t *tr = vlib_add_trace (vm, node, b0, sizeof(*tr));
576         tr->next_index = next0;
577         tr->error = error0;
578         tr->tunnel_index = tunnel_index0;
579       }
580       vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next,
581                                       n_left_to_next, bi0, next0);
582     }
583
584     vlib_put_next_frame (vm, node, next_index, n_left_to_next);
585   }
586   vlib_node_increment_counter (vm, vxlan_gpe_input_node.index,
587                                VXLAN_GPE_ERROR_DECAPSULATED, pkts_decapsulated);
588   /* Increment any remaining batch stats */
589   if (stats_n_packets)
590   {
591     vlib_increment_combined_counter (
592         im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, cpu_index,
593         stats_sw_if_index, stats_n_packets, stats_n_bytes);
594     node->runtime_data[0] = stats_sw_if_index;
595   }
596   return from_frame->n_vectors;
597 }
598
599 /**
600  * @brief Graph processing dispatch function for IPv4 VXLAN GPE
601  *
602  * @node vxlan4-gpe-input
603  * @param *vm
604  * @param *node
605  * @param *from_frame
606  *
607  * @return from_frame->n_vectors
608  *
609  */
610 static uword
611 vxlan4_gpe_input (vlib_main_t * vm, vlib_node_runtime_t * node,
612                   vlib_frame_t * from_frame)
613 {
614   return vxlan_gpe_input (vm, node, from_frame, /* is_ip4 */1);
615 }
616
617 /**
618  * @brief Graph processing dispatch function for IPv6 VXLAN GPE
619  *
620  * @node vxlan6-gpe-input
621  * @param *vm
622  * @param *node
623  * @param *from_frame
624  *
625  * @return from_frame->n_vectors - uword
626  *
627  */
628 static uword
629 vxlan6_gpe_input (vlib_main_t * vm, vlib_node_runtime_t * node,
630                   vlib_frame_t * from_frame)
631 {
632   return vxlan_gpe_input (vm, node, from_frame, /* is_ip4 */0);
633 }
634
635 /**
636  * @brief VXLAN GPE error strings
637  */
638 static char * vxlan_gpe_error_strings[] = {
639 #define vxlan_gpe_error(n,s) s,
640 #include <vnet/vxlan-gpe/vxlan_gpe_error.def>
641 #undef vxlan_gpe_error
642 #undef _
643 };
644
645 VLIB_REGISTER_NODE (vxlan4_gpe_input_node) = {
646   .function = vxlan4_gpe_input,
647   .name = "vxlan4-gpe-input",
648   /* Takes a vector of packets. */
649   .vector_size = sizeof (u32),
650   .type = VLIB_NODE_TYPE_INTERNAL,
651   .n_errors = ARRAY_LEN(vxlan_gpe_error_strings),
652   .error_strings = vxlan_gpe_error_strings,
653
654   .n_next_nodes = VXLAN_GPE_INPUT_N_NEXT,
655   .next_nodes = {
656 #define _(s,n) [VXLAN_GPE_INPUT_NEXT_##s] = n,
657     foreach_vxlan_gpe_input_next
658 #undef _
659   },
660
661   .format_buffer = format_vxlan_gpe_with_length,
662   .format_trace = format_vxlan_gpe_rx_trace,
663   // $$$$ .unformat_buffer = unformat_vxlan_gpe_header,
664 };
665
666 VLIB_NODE_FUNCTION_MULTIARCH (vxlan4_gpe_input_node, vxlan4_gpe_input);
667
668 VLIB_REGISTER_NODE (vxlan6_gpe_input_node) = {
669   .function = vxlan6_gpe_input,
670   .name = "vxlan6-gpe-input",
671   /* Takes a vector of packets. */
672   .vector_size = sizeof (u32),
673   .type = VLIB_NODE_TYPE_INTERNAL,
674   .n_errors = ARRAY_LEN(vxlan_gpe_error_strings),
675   .error_strings = vxlan_gpe_error_strings,
676
677   .n_next_nodes = VXLAN_GPE_INPUT_N_NEXT,
678   .next_nodes = {
679 #define _(s,n) [VXLAN_GPE_INPUT_NEXT_##s] = n,
680     foreach_vxlan_gpe_input_next
681 #undef _
682   },
683
684   .format_buffer = format_vxlan_gpe_with_length,
685   .format_trace = format_vxlan_gpe_rx_trace,
686   // $$$$ .unformat_buffer = unformat_vxlan_gpe_header,
687 };
688
689 VLIB_NODE_FUNCTION_MULTIARCH (vxlan6_gpe_input_node, vxlan6_gpe_input);