blob: 107e66e43359d05d2aa4f36030fe898ff78d4265 [file] [log] [blame]
Eyal Bari3ce0b082018-01-17 12:06:32 +02001
Ed Warnickecb9cada2015-12-08 15:45:58 -07002/*
3 * Copyright (c) 2015 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#include <vppinfra/error.h>
17#include <vppinfra/hash.h>
18#include <vnet/vnet.h>
19#include <vnet/ip/ip.h>
20#include <vnet/ethernet/ethernet.h>
21#include <vnet/vxlan/vxlan.h>
22
23/* Statistics (not all errors) */
24#define foreach_vxlan_encap_error \
John Lo3ef822e2016-06-07 09:14:07 -040025_(ENCAPSULATED, "good packets encapsulated")
Ed Warnickecb9cada2015-12-08 15:45:58 -070026
27static char * vxlan_encap_error_strings[] = {
28#define _(sym,string) string,
29 foreach_vxlan_encap_error
30#undef _
31};
32
33typedef enum {
34#define _(sym,str) VXLAN_ENCAP_ERROR_##sym,
35 foreach_vxlan_encap_error
36#undef _
37 VXLAN_ENCAP_N_ERROR,
38} vxlan_encap_error_t;
39
40typedef enum {
Ed Warnickecb9cada2015-12-08 15:45:58 -070041 VXLAN_ENCAP_NEXT_DROP,
42 VXLAN_ENCAP_N_NEXT,
43} vxlan_encap_next_t;
44
45typedef struct {
46 u32 tunnel_index;
47 u32 vni;
48} vxlan_encap_trace_t;
49
50u8 * format_vxlan_encap_trace (u8 * s, va_list * args)
51{
52 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
53 CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
54 vxlan_encap_trace_t * t
55 = va_arg (*args, vxlan_encap_trace_t *);
56
John Loc42912d2016-11-07 18:30:47 -050057 s = format (s, "VXLAN encap to vxlan_tunnel%d vni %d",
58 t->tunnel_index, t->vni);
Ed Warnickecb9cada2015-12-08 15:45:58 -070059 return s;
60}
61
John Loc42912d2016-11-07 18:30:47 -050062always_inline uword
63vxlan_encap_inline (vlib_main_t * vm,
64 vlib_node_runtime_t * node,
65 vlib_frame_t * from_frame,
John Lof4215a62017-09-18 00:20:05 -040066 u8 is_ip4, u8 csum_offload)
Ed Warnickecb9cada2015-12-08 15:45:58 -070067{
68 u32 n_left_from, next_index, * from, * to_next;
69 vxlan_main_t * vxm = &vxlan_main;
70 vnet_main_t * vnm = vxm->vnet_main;
71 vnet_interface_main_t * im = &vnm->interface_main;
John Lo25d417f2018-02-15 15:47:53 -050072 vlib_combined_counter_main_t * tx_counter =
73 im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX;
Ed Warnickecb9cada2015-12-08 15:45:58 -070074 u32 pkts_encapsulated = 0;
Damjan Marion586afd72017-04-05 19:18:20 +020075 u32 thread_index = vlib_get_thread_index();
John Loc42912d2016-11-07 18:30:47 -050076 u32 sw_if_index0 = 0, sw_if_index1 = 0;
77 u32 next0 = 0, next1 = 0;
John Loc42912d2016-11-07 18:30:47 -050078 vxlan_tunnel_t * t0 = NULL, * t1 = NULL;
John Lo25d417f2018-02-15 15:47:53 -050079 index_t dpoi_idx0 = INDEX_INVALID, dpoi_idx1 = INDEX_INVALID;
Ed Warnickecb9cada2015-12-08 15:45:58 -070080
81 from = vlib_frame_vector_args (from_frame);
82 n_left_from = from_frame->n_vectors;
83
84 next_index = node->cached_next_index;
Ed Warnickecb9cada2015-12-08 15:45:58 -070085
Eyal Bari3ce0b082018-01-17 12:06:32 +020086 STATIC_ASSERT_SIZEOF(ip6_vxlan_header_t, 56);
87 STATIC_ASSERT_SIZEOF(ip4_vxlan_header_t, 36);
88
89 word const underlay_hdr_len = is_ip4 ?
90 sizeof(ip4_vxlan_header_t) : sizeof(ip6_vxlan_header_t);
91 u16 const l3_len = is_ip4 ? sizeof(ip4_header_t) : sizeof(ip6_header_t);
92 u32 const csum_flags = is_ip4 ?
93 VNET_BUFFER_F_OFFLOAD_IP_CKSUM | VNET_BUFFER_F_IS_IP4 |
94 VNET_BUFFER_F_OFFLOAD_UDP_CKSUM :
95 VNET_BUFFER_F_OFFLOAD_UDP_CKSUM;
96
Ed Warnickecb9cada2015-12-08 15:45:58 -070097 while (n_left_from > 0)
98 {
99 u32 n_left_to_next;
100
101 vlib_get_next_frame (vm, node, next_index,
102 to_next, n_left_to_next);
103
104 while (n_left_from >= 4 && n_left_to_next >= 2)
105 {
Ed Warnickecb9cada2015-12-08 15:45:58 -0700106 /* Prefetch next iteration. */
107 {
108 vlib_buffer_t * p2, * p3;
109
110 p2 = vlib_get_buffer (vm, from[2]);
111 p3 = vlib_get_buffer (vm, from[3]);
112
113 vlib_prefetch_buffer_header (p2, LOAD);
114 vlib_prefetch_buffer_header (p3, LOAD);
115
116 CLIB_PREFETCH (p2->data, 2*CLIB_CACHE_LINE_BYTES, LOAD);
117 CLIB_PREFETCH (p3->data, 2*CLIB_CACHE_LINE_BYTES, LOAD);
118 }
119
Eyal Bari3ce0b082018-01-17 12:06:32 +0200120 u32 bi0 = from[0];
121 u32 bi1 = from[1];
122
123 vlib_buffer_t * b0 = vlib_get_buffer (vm, bi0);
124 vlib_buffer_t * b1 = vlib_get_buffer (vm, bi1);
125 u32 flow_hash0 = vnet_l2_compute_flow_hash (b0);
126 u32 flow_hash1 = vnet_l2_compute_flow_hash (b1);
127
Ed Warnickecb9cada2015-12-08 15:45:58 -0700128 to_next[0] = bi0;
129 to_next[1] = bi1;
130 from += 2;
131 to_next += 2;
132 n_left_to_next -= 2;
133 n_left_from -= 2;
134
John Loc42912d2016-11-07 18:30:47 -0500135 /* Get next node index and adj index from tunnel next_dpo */
136 if (sw_if_index0 != vnet_buffer(b0)->sw_if_index[VLIB_TX])
137 {
138 sw_if_index0 = vnet_buffer(b0)->sw_if_index[VLIB_TX];
John Lo25d417f2018-02-15 15:47:53 -0500139 vnet_hw_interface_t *hi0 =
140 vnet_get_sup_hw_interface (vnm, sw_if_index0);
John Loc42912d2016-11-07 18:30:47 -0500141 t0 = &vxm->tunnels[hi0->dev_instance];
John Lo25d417f2018-02-15 15:47:53 -0500142 /* Note: change to always set next0 if it may set to drop */
John Loc42912d2016-11-07 18:30:47 -0500143 next0 = t0->next_dpo.dpoi_next_node;
John Lo25d417f2018-02-15 15:47:53 -0500144 dpoi_idx0 = t0->next_dpo.dpoi_index;
John Loc42912d2016-11-07 18:30:47 -0500145 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700146
John Loc42912d2016-11-07 18:30:47 -0500147 /* Get next node index and adj index from tunnel next_dpo */
148 if (sw_if_index1 != vnet_buffer(b1)->sw_if_index[VLIB_TX])
149 {
John Lo25d417f2018-02-15 15:47:53 -0500150 if (sw_if_index0 == vnet_buffer(b1)->sw_if_index[VLIB_TX])
151 {
152 sw_if_index1 = sw_if_index0;
153 t1 = t0;
154 next1 = next0;
155 dpoi_idx1 = dpoi_idx0;
156 }
157 else
158 {
159 sw_if_index1 = vnet_buffer(b1)->sw_if_index[VLIB_TX];
160 vnet_hw_interface_t *hi1 =
161 vnet_get_sup_hw_interface (vnm, sw_if_index1);
162 t1 = &vxm->tunnels[hi1->dev_instance];
163 /* Note: change to always set next1 if it may set to drop */
164 next1 = t1->next_dpo.dpoi_next_node;
165 dpoi_idx1 = t1->next_dpo.dpoi_index;
166 }
John Loc42912d2016-11-07 18:30:47 -0500167 }
John Lo25d417f2018-02-15 15:47:53 -0500168
169 vnet_buffer(b0)->ip.adj_index[VLIB_TX] = dpoi_idx0;
170 vnet_buffer(b1)->ip.adj_index[VLIB_TX] = dpoi_idx1;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700171
Eyal Bari3ce0b082018-01-17 12:06:32 +0200172 ASSERT(vec_len(t0->rewrite) == underlay_hdr_len);
173 ASSERT(vec_len(t1->rewrite) == underlay_hdr_len);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700174
Eyal Bari3ce0b082018-01-17 12:06:32 +0200175 vlib_buffer_advance (b0, -underlay_hdr_len);
176 vlib_buffer_advance (b1, -underlay_hdr_len);
177
178 u32 len0 = vlib_buffer_length_in_chain (vm, b0);
179 u32 len1 = vlib_buffer_length_in_chain (vm, b1);
180 u16 payload_l0 = clib_host_to_net_u16 (len0 - l3_len);
181 u16 payload_l1 = clib_host_to_net_u16 (len1 - l3_len);
182
183 ip4_header_t * ip4_0, * ip4_1;
184 ip6_header_t * ip6_0, * ip6_1;
185 udp_header_t * udp0, * udp1;
186 u8 * l3_0, * l3_1;
John Loc42912d2016-11-07 18:30:47 -0500187 if (is_ip4)
188 {
Eyal Bari3ce0b082018-01-17 12:06:32 +0200189 ip4_vxlan_header_t * hdr0 = vlib_buffer_get_current(b0);
190 ip4_vxlan_header_t * rewrite0 = (void *)t0->rewrite;
191 ip4_vxlan_header_t * hdr1 = vlib_buffer_get_current(b1);
192 ip4_vxlan_header_t * rewrite1 = (void *)t1->rewrite;
193 *hdr0 = *rewrite0;
194 *hdr1 = *rewrite1;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700195
John Loc42912d2016-11-07 18:30:47 -0500196 /* Fix the IP4 checksum and length */
Eyal Bari3ce0b082018-01-17 12:06:32 +0200197 ip4_0 = &hdr0->ip4;
198 ip4_1 = &hdr1->ip4;
199 ip4_0->length = clib_host_to_net_u16 (len0);
200 ip4_1->length = clib_host_to_net_u16 (len1);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700201
Eyal Bari3ce0b082018-01-17 12:06:32 +0200202 l3_0 = (u8 *)ip4_0;
203 l3_1 = (u8 *)ip4_1;
204 udp0 = &hdr0->udp;
205 udp1 = &hdr1->udp;
John Loc42912d2016-11-07 18:30:47 -0500206 }
207 else /* ipv6 */
208 {
Eyal Bari3ce0b082018-01-17 12:06:32 +0200209 ip6_vxlan_header_t * hdr0 = vlib_buffer_get_current(b0);
210 ip6_vxlan_header_t * rewrite0 = (void *) t0->rewrite;
211 ip6_vxlan_header_t * hdr1 = vlib_buffer_get_current(b0);
212 ip6_vxlan_header_t * rewrite1 = (void *) t1->rewrite;
213 *hdr0 = *rewrite0;
214 *hdr1 = *rewrite1;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700215
John Loc42912d2016-11-07 18:30:47 -0500216 /* Fix IP6 payload length */
Eyal Bari3ce0b082018-01-17 12:06:32 +0200217 ip6_0 = &hdr0->ip6;
218 ip6_1 = &hdr1->ip6;
219 ip6_0->payload_length = payload_l0;
220 ip6_1->payload_length = payload_l1;
John Loc42912d2016-11-07 18:30:47 -0500221
Eyal Bari3ce0b082018-01-17 12:06:32 +0200222 l3_0 = (u8 *)ip6_0;
223 l3_1 = (u8 *)ip6_1;
224 udp0 = &hdr0->udp;
225 udp1 = &hdr1->udp;
John Loc42912d2016-11-07 18:30:47 -0500226 }
Chris Luke99cb3352016-04-26 10:49:53 -0400227
Eyal Bari3ce0b082018-01-17 12:06:32 +0200228 /* Fix UDP length and set source port */
229 udp0->length = payload_l0;
230 udp0->src_port = flow_hash0;
231 udp1->length = payload_l1;
232 udp1->src_port = flow_hash1;
233
234 if (csum_offload)
235 {
236 b0->flags |= csum_flags;
237 vnet_buffer (b0)->l3_hdr_offset = l3_0 - b0->data;
238 vnet_buffer (b0)->l4_hdr_offset = (u8 *) udp0 - b0->data;
239 b1->flags |= csum_flags;
240 vnet_buffer (b1)->l3_hdr_offset = l3_1 - b1->data;
241 vnet_buffer (b1)->l4_hdr_offset = (u8 *) udp1 - b1->data;
242 }
243 /* IPv4 UDP checksum only if checksum offload is used */
244 else if (is_ip4)
245 {
246 ip_csum_t sum0 = ip4_0->checksum;
247 sum0 = ip_csum_update (sum0, 0, ip4_0->length, ip4_header_t,
248 length /* changed member */);
249 ip4_0->checksum = ip_csum_fold (sum0);
250 ip_csum_t sum1 = ip4_1->checksum;
251 sum1 = ip_csum_update (sum1, 0, ip4_1->length, ip4_header_t,
252 length /* changed member */);
253 ip4_1->checksum = ip_csum_fold (sum1);
254 }
255 /* IPv6 UDP checksum is mandatory */
256 else
257 {
258 int bogus = 0;
259
260 udp0->checksum = ip6_tcp_udp_icmp_compute_checksum
261 (vm, b0, ip6_0, &bogus);
262 ASSERT(bogus == 0);
263 if (udp0->checksum == 0)
264 udp0->checksum = 0xffff;
265 udp1->checksum = ip6_tcp_udp_icmp_compute_checksum
266 (vm, b1, ip6_1, &bogus);
267 ASSERT(bogus == 0);
268 if (udp1->checksum == 0)
269 udp1->checksum = 0xffff;
270 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700271
Eyal Bari0f4b1842018-04-12 12:39:51 +0300272 vlib_increment_combined_counter (tx_counter, thread_index,
273 sw_if_index0, 1, len0);
274 vlib_increment_combined_counter (tx_counter, thread_index,
275 sw_if_index1, 1, len1);
Eyal Bari3ce0b082018-01-17 12:06:32 +0200276 pkts_encapsulated += 2;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700277
278 if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
279 {
280 vxlan_encap_trace_t *tr =
281 vlib_add_trace (vm, node, b0, sizeof (*tr));
282 tr->tunnel_index = t0 - vxm->tunnels;
283 tr->vni = t0->vni;
284 }
285
286 if (PREDICT_FALSE(b1->flags & VLIB_BUFFER_IS_TRACED))
287 {
288 vxlan_encap_trace_t *tr =
289 vlib_add_trace (vm, node, b1, sizeof (*tr));
290 tr->tunnel_index = t1 - vxm->tunnels;
291 tr->vni = t1->vni;
292 }
293
294 vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
295 to_next, n_left_to_next,
296 bi0, bi1, next0, next1);
297 }
298
299 while (n_left_from > 0 && n_left_to_next > 0)
300 {
Eyal Bari3ce0b082018-01-17 12:06:32 +0200301 u32 bi0 = from[0];
302 vlib_buffer_t * b0 = vlib_get_buffer (vm, bi0);
303 u32 flow_hash0 = vnet_l2_compute_flow_hash(b0);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700304
Ed Warnickecb9cada2015-12-08 15:45:58 -0700305 to_next[0] = bi0;
306 from += 1;
307 to_next += 1;
308 n_left_from -= 1;
309 n_left_to_next -= 1;
310
John Loc42912d2016-11-07 18:30:47 -0500311 /* Get next node index and adj index from tunnel next_dpo */
312 if (sw_if_index0 != vnet_buffer(b0)->sw_if_index[VLIB_TX])
313 {
314 sw_if_index0 = vnet_buffer(b0)->sw_if_index[VLIB_TX];
John Lo25d417f2018-02-15 15:47:53 -0500315 vnet_hw_interface_t *hi0 =
316 vnet_get_sup_hw_interface (vnm, sw_if_index0);
John Loc42912d2016-11-07 18:30:47 -0500317 t0 = &vxm->tunnels[hi0->dev_instance];
318 /* Note: change to always set next0 if it may be set to drop */
319 next0 = t0->next_dpo.dpoi_next_node;
John Lo25d417f2018-02-15 15:47:53 -0500320 dpoi_idx0 = t0->next_dpo.dpoi_index;
John Loc42912d2016-11-07 18:30:47 -0500321 }
John Lo25d417f2018-02-15 15:47:53 -0500322 vnet_buffer(b0)->ip.adj_index[VLIB_TX] = dpoi_idx0;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700323
Eyal Bari3ce0b082018-01-17 12:06:32 +0200324 ASSERT(vec_len(t0->rewrite) == underlay_hdr_len);
325 vlib_buffer_advance (b0, -underlay_hdr_len);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700326
Eyal Bari3ce0b082018-01-17 12:06:32 +0200327 u32 len0 = vlib_buffer_length_in_chain (vm, b0);
328 u16 payload_l0 = clib_host_to_net_u16 (len0 - l3_len);
329
330 udp_header_t * udp0;
331 ip4_header_t * ip4_0;
332 ip6_header_t * ip6_0;
333 u8 * l3_0;
John Loc42912d2016-11-07 18:30:47 -0500334 if (is_ip4)
335 {
Eyal Bari3ce0b082018-01-17 12:06:32 +0200336 ip4_vxlan_header_t * rewrite = (void *)t0->rewrite;
337 ip4_vxlan_header_t * hdr = vlib_buffer_get_current(b0);
338 *hdr = *rewrite;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700339
John Loc42912d2016-11-07 18:30:47 -0500340 /* Fix the IP4 checksum and length */
Eyal Bari3ce0b082018-01-17 12:06:32 +0200341 ip4_0 = &hdr->ip4;
342 ip4_0->length = clib_host_to_net_u16 (len0);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700343
Eyal Bari3ce0b082018-01-17 12:06:32 +0200344 l3_0 = (u8*)ip4_0;
345 udp0 = &hdr->udp;
John Loc42912d2016-11-07 18:30:47 -0500346 }
John Loc42912d2016-11-07 18:30:47 -0500347 else /* ip6 path */
348 {
Eyal Bari3ce0b082018-01-17 12:06:32 +0200349 ip6_vxlan_header_t * hdr = vlib_buffer_get_current(b0);
350 ip6_vxlan_header_t * rewrite = (void *) t0->rewrite;
351 *hdr = *rewrite;
Chris Luke99cb3352016-04-26 10:49:53 -0400352
John Loc42912d2016-11-07 18:30:47 -0500353 /* Fix IP6 payload length */
Eyal Bari3ce0b082018-01-17 12:06:32 +0200354 ip6_0 = &hdr->ip6;
355 ip6_0->payload_length = payload_l0;
Chris Luke99cb3352016-04-26 10:49:53 -0400356
Eyal Bari3ce0b082018-01-17 12:06:32 +0200357 l3_0 = (u8 *)ip6_0;
358 udp0 = &hdr->udp;
John Loc42912d2016-11-07 18:30:47 -0500359 }
360
Eyal Bari3ce0b082018-01-17 12:06:32 +0200361 /* Fix UDP length and set source port */
362 udp0->length = payload_l0;
363 udp0->src_port = flow_hash0;
364
365 if (csum_offload)
366 {
367 b0->flags |= csum_flags;
368 vnet_buffer (b0)->l3_hdr_offset = l3_0 - b0->data;
369 vnet_buffer (b0)->l4_hdr_offset = (u8 *) udp0 - b0->data;
370 }
371 /* IPv4 UDP checksum only if checksum offload is used */
372 else if (is_ip4)
373 {
374 ip_csum_t sum0 = ip4_0->checksum;
375 sum0 = ip_csum_update (sum0, 0, ip4_0->length, ip4_header_t,
376 length /* changed member */);
377 ip4_0->checksum = ip_csum_fold (sum0);
378 }
379 /* IPv6 UDP checksum is mandatory */
380 else
381 {
382 int bogus = 0;
383
384 udp0->checksum = ip6_tcp_udp_icmp_compute_checksum
385 (vm, b0, ip6_0, &bogus);
386 ASSERT(bogus == 0);
387 if (udp0->checksum == 0)
388 udp0->checksum = 0xffff;
389 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700390
Eyal Bari0f4b1842018-04-12 12:39:51 +0300391 vlib_increment_combined_counter (tx_counter, thread_index,
392 sw_if_index0, 1, len0);
Eyal Bari3ce0b082018-01-17 12:06:32 +0200393 pkts_encapsulated ++;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700394
395 if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
396 {
397 vxlan_encap_trace_t *tr =
398 vlib_add_trace (vm, node, b0, sizeof (*tr));
399 tr->tunnel_index = t0 - vxm->tunnels;
400 tr->vni = t0->vni;
401 }
402 vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
403 to_next, n_left_to_next,
404 bi0, next0);
405 }
406
407 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
408 }
409
410 /* Do we still need this now that tunnel tx stats is kept? */
411 vlib_node_increment_counter (vm, node->node_index,
412 VXLAN_ENCAP_ERROR_ENCAPSULATED,
413 pkts_encapsulated);
414
Ed Warnickecb9cada2015-12-08 15:45:58 -0700415 return from_frame->n_vectors;
416}
417
John Loc42912d2016-11-07 18:30:47 -0500418static uword
419vxlan4_encap (vlib_main_t * vm,
420 vlib_node_runtime_t * node,
421 vlib_frame_t * from_frame)
422{
John Lof4215a62017-09-18 00:20:05 -0400423 /* Disable chksum offload as setup overhead in tx node is not worthwhile
424 for ip4 header checksum only, unless udp checksum is also required */
425 return vxlan_encap_inline (vm, node, from_frame, /* is_ip4 */ 1,
426 /* csum_offload */ 0);
John Loc42912d2016-11-07 18:30:47 -0500427}
428
429static uword
430vxlan6_encap (vlib_main_t * vm,
431 vlib_node_runtime_t * node,
432 vlib_frame_t * from_frame)
433{
John Lof4215a62017-09-18 00:20:05 -0400434 /* Enable checksum offload for ip6 as udp checksum is mandatory, */
435 return vxlan_encap_inline (vm, node, from_frame, /* is_ip4 */ 0,
436 /* csum_offload */ 1);
John Loc42912d2016-11-07 18:30:47 -0500437}
438
439VLIB_REGISTER_NODE (vxlan4_encap_node) = {
440 .function = vxlan4_encap,
441 .name = "vxlan4-encap",
Ed Warnickecb9cada2015-12-08 15:45:58 -0700442 .vector_size = sizeof (u32),
443 .format_trace = format_vxlan_encap_trace,
444 .type = VLIB_NODE_TYPE_INTERNAL,
Ed Warnickecb9cada2015-12-08 15:45:58 -0700445 .n_errors = ARRAY_LEN(vxlan_encap_error_strings),
446 .error_strings = vxlan_encap_error_strings,
Ed Warnickecb9cada2015-12-08 15:45:58 -0700447 .n_next_nodes = VXLAN_ENCAP_N_NEXT,
Ed Warnickecb9cada2015-12-08 15:45:58 -0700448 .next_nodes = {
Ed Warnickecb9cada2015-12-08 15:45:58 -0700449 [VXLAN_ENCAP_NEXT_DROP] = "error-drop",
450 },
451};
Damjan Marion1c80e832016-05-11 23:07:18 +0200452
John Loc42912d2016-11-07 18:30:47 -0500453VLIB_NODE_FUNCTION_MULTIARCH (vxlan4_encap_node, vxlan4_encap)
454
455VLIB_REGISTER_NODE (vxlan6_encap_node) = {
456 .function = vxlan6_encap,
457 .name = "vxlan6-encap",
458 .vector_size = sizeof (u32),
459 .format_trace = format_vxlan_encap_trace,
460 .type = VLIB_NODE_TYPE_INTERNAL,
461 .n_errors = ARRAY_LEN(vxlan_encap_error_strings),
462 .error_strings = vxlan_encap_error_strings,
463 .n_next_nodes = VXLAN_ENCAP_N_NEXT,
464 .next_nodes = {
465 [VXLAN_ENCAP_NEXT_DROP] = "error-drop",
466 },
467};
468
469VLIB_NODE_FUNCTION_MULTIARCH (vxlan6_encap_node, vxlan6_encap)
Damjan Marion1c80e832016-05-11 23:07:18 +0200470