2 * Copyright (c) 2020 Doc.ai and/or its affiliates.
3 * Copyright (c) 2020 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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include <vlib/vlib.h>
18 #include <vnet/vnet.h>
19 #include <vppinfra/error.h>
21 #include <wireguard/wireguard.h>
22 #include <wireguard/wireguard_send.h>
24 #define foreach_wg_output_error \
25 _ (NONE, "No error") \
26 _ (PEER, "Peer error") \
27 _ (KEYPAIR, "Keypair error") \
28 _ (TOO_BIG, "packet too big") \
29 _ (CRYPTO_ENGINE_ERROR, "crypto engine error (packet dropped)")
33 #define _(sym,str) WG_OUTPUT_ERROR_##sym,
34 foreach_wg_output_error
39 static char *wg_output_error_strings[] = {
40 #define _(sym,string) string,
41 foreach_wg_output_error
48 WG_OUTPUT_NEXT_HANDOFF,
49 WG_OUTPUT_NEXT_INTERFACE_OUTPUT,
56 u8 header[sizeof (ip6_udp_header_t)];
58 } wg_output_tun_trace_t;
64 } wg_output_tun_post_trace_t;
67 format_ip4_udp_header (u8 * s, va_list * args)
69 ip4_udp_header_t *hdr4 = va_arg (*args, ip4_udp_header_t *);
71 s = format (s, "%U:$U", format_ip4_header, &hdr4->ip4, format_udp_header,
77 format_ip6_udp_header (u8 *s, va_list *args)
79 ip6_udp_header_t *hdr6 = va_arg (*args, ip6_udp_header_t *);
81 s = format (s, "%U:$U", format_ip6_header, &hdr6->ip6, format_udp_header,
86 /* packet trace format function */
88 format_wg_output_tun_trace (u8 * s, va_list * args)
90 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
91 CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
93 wg_output_tun_trace_t *t = va_arg (*args, wg_output_tun_trace_t *);
95 s = format (s, "peer: %d\n", t->peer);
96 s = format (s, " Encrypted packet: ");
98 s = t->is_ip4 ? format (s, "%U", format_ip4_udp_header, t->header) :
99 format (s, "%U", format_ip6_udp_header, t->header);
103 /* post node - packet trace format function */
105 format_wg_output_tun_post_trace (u8 *s, va_list *args)
107 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
108 CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
110 wg_output_tun_post_trace_t *t = va_arg (*args, wg_output_tun_post_trace_t *);
112 s = format (s, "peer: %d\n", t->peer);
113 s = format (s, " wg-post: next node index %u", t->next_index);
117 static_always_inline void
118 wg_prepare_sync_enc_op (vlib_main_t *vm, vnet_crypto_op_t **crypto_ops,
119 u8 *src, u32 src_len, u8 *dst, u8 *aad, u32 aad_len,
120 u64 nonce, vnet_crypto_key_index_t key_index, u32 bi,
123 vnet_crypto_op_t _op, *op = &_op;
126 clib_memset (iv, 0, 4);
127 clib_memcpy (iv + 4, &nonce, sizeof (nonce));
129 vec_add2_aligned (crypto_ops[0], op, 1, CLIB_CACHE_LINE_BYTES);
130 vnet_crypto_op_init (op, VNET_CRYPTO_OP_CHACHA20_POLY1305_ENC);
132 op->tag_len = NOISE_AUTHTAG_LEN;
133 op->tag = dst + src_len;
134 op->src = !src ? src_ : src;
137 op->key_index = key_index;
139 op->aad_len = aad_len;
144 static_always_inline void
145 wg_output_process_ops (vlib_main_t *vm, vlib_node_runtime_t *node,
146 vnet_crypto_op_t *ops, vlib_buffer_t *b[], u16 *nexts,
149 u32 n_fail, n_ops = vec_len (ops);
150 vnet_crypto_op_t *op = ops;
155 n_fail = n_ops - vnet_crypto_process_ops (vm, op, n_ops);
159 ASSERT (op - ops < n_ops);
161 if (op->status != VNET_CRYPTO_OP_STATUS_COMPLETED)
163 u32 bi = op->user_data;
164 b[bi]->error = node->errors[WG_OUTPUT_ERROR_CRYPTO_ENGINE_ERROR];
165 nexts[bi] = drop_next;
172 static_always_inline void
173 wg_output_tun_add_to_frame (vlib_main_t *vm, vnet_crypto_async_frame_t *f,
174 u32 key_index, u32 crypto_len,
175 i16 crypto_start_offset, u32 buffer_index,
176 u16 next_node, u8 *iv, u8 *tag, u8 flags)
178 vnet_crypto_async_frame_elt_t *fe;
181 ASSERT (f->n_elts < VNET_CRYPTO_FRAME_SIZE);
184 fe = &f->elts[index];
186 fe->key_index = key_index;
187 fe->crypto_total_length = crypto_len;
188 fe->crypto_start_offset = crypto_start_offset;
192 f->buffer_indices[index] = buffer_index;
193 f->next_node_index[index] = next_node;
196 static_always_inline enum noise_state_crypt
197 wq_output_tun_process (vlib_main_t *vm, vnet_crypto_op_t **crypto_ops,
198 noise_remote_t *r, uint32_t *r_idx, uint64_t *nonce,
199 uint8_t *src, size_t srclen, uint8_t *dst, u32 bi,
203 enum noise_state_crypt ret = SC_FAILED;
205 if ((kp = r->r_current) == NULL)
208 /* We confirm that our values are within our tolerances. We want:
210 * - our keypair to be less than REJECT_AFTER_TIME seconds old
211 * - our receive counter to be less than REJECT_AFTER_MESSAGES
212 * - our send counter to be less than REJECT_AFTER_MESSAGES
215 wg_birthdate_has_expired_opt (kp->kp_birthdate, REJECT_AFTER_TIME,
217 kp->kp_ctr.c_recv >= REJECT_AFTER_MESSAGES ||
218 ((*nonce = noise_counter_send (&kp->kp_ctr)) > REJECT_AFTER_MESSAGES))
221 /* We encrypt into the same buffer, so the caller must ensure that buf
222 * has NOISE_AUTHTAG_LEN bytes to store the MAC. The nonce and index
223 * are passed back out to the caller through the provided data pointer. */
224 *r_idx = kp->kp_remote_index;
226 wg_prepare_sync_enc_op (vm, crypto_ops, src, srclen, dst, NULL, 0, *nonce,
227 kp->kp_send_index, bi, iv);
229 /* If our values are still within tolerances, but we are approaching
230 * the tolerances, we notify the caller with ESTALE that they should
231 * establish a new keypair. The current keypair can continue to be used
232 * until the tolerances are hit. We notify if:
233 * - our send counter is valid and not less than REKEY_AFTER_MESSAGES
234 * - we're the initiator and our keypair is older than
235 * REKEY_AFTER_TIME seconds */
236 ret = SC_KEEP_KEY_FRESH;
237 if ((kp->kp_valid && *nonce >= REKEY_AFTER_MESSAGES) ||
238 (kp->kp_is_initiator && wg_birthdate_has_expired_opt (
239 kp->kp_birthdate, REKEY_AFTER_TIME, time)))
247 static_always_inline enum noise_state_crypt
248 wg_add_to_async_frame (vlib_main_t *vm, wg_per_thread_data_t *ptd,
249 vnet_crypto_async_frame_t *async_frame,
250 vlib_buffer_t *b, u8 *payload, u32 payload_len, u32 bi,
251 u16 next, u16 async_next, noise_remote_t *r,
252 uint32_t *r_idx, uint64_t *nonce, u8 *iv, f64 time)
254 wg_post_data_t *post = wg_post_data (b);
258 post->next_index = next;
261 enum noise_state_crypt ret = SC_FAILED;
263 if ((kp = r->r_current) == NULL)
266 /* We confirm that our values are within our tolerances. We want:
268 * - our keypair to be less than REJECT_AFTER_TIME seconds old
269 * - our receive counter to be less than REJECT_AFTER_MESSAGES
270 * - our send counter to be less than REJECT_AFTER_MESSAGES
273 wg_birthdate_has_expired_opt (kp->kp_birthdate, REJECT_AFTER_TIME,
275 kp->kp_ctr.c_recv >= REJECT_AFTER_MESSAGES ||
276 ((*nonce = noise_counter_send (&kp->kp_ctr)) > REJECT_AFTER_MESSAGES))
279 /* We encrypt into the same buffer, so the caller must ensure that buf
280 * has NOISE_AUTHTAG_LEN bytes to store the MAC. The nonce and index
281 * are passed back out to the caller through the provided data pointer. */
282 *r_idx = kp->kp_remote_index;
284 clib_memset (iv, 0, 4);
285 clib_memcpy (iv + 4, nonce, sizeof (*nonce));
287 /* this always succeeds because we know the frame is not full */
288 wg_output_tun_add_to_frame (vm, async_frame, kp->kp_send_index, payload_len,
289 payload - b->data, bi, async_next, iv,
290 payload + payload_len, flag);
292 /* If our values are still within tolerances, but we are approaching
293 * the tolerances, we notify the caller with ESTALE that they should
294 * establish a new keypair. The current keypair can continue to be used
295 * until the tolerances are hit. We notify if:
296 * - our send counter is valid and not less than REKEY_AFTER_MESSAGES
297 * - we're the initiator and our keypair is older than
298 * REKEY_AFTER_TIME seconds */
299 ret = SC_KEEP_KEY_FRESH;
300 if ((kp->kp_valid && *nonce >= REKEY_AFTER_MESSAGES) ||
301 (kp->kp_is_initiator && wg_birthdate_has_expired_opt (
302 kp->kp_birthdate, REKEY_AFTER_TIME, time)))
310 static_always_inline void
311 wg_calc_checksum (vlib_main_t *vm, vlib_buffer_t *b)
314 u8 ip_ver_out = (*((u8 *) vlib_buffer_get_current (b)) >> 4);
316 /* IPv6 UDP checksum is mandatory */
320 (ip6_header_t *) ((u8 *) vlib_buffer_get_current (b));
321 udp_header_t *udp = ip6_next_header (ip6);
322 udp->checksum = ip6_tcp_udp_icmp_compute_checksum (vm, b, ip6, &bogus);
326 /* is_ip4 - inner header flag */
328 wg_output_tun_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
329 vlib_frame_t *frame, u8 is_ip4, u16 async_next_node)
331 wg_main_t *wmp = &wg_main;
332 wg_per_thread_data_t *ptd =
333 vec_elt_at_index (wmp->per_thread_data, vm->thread_index);
334 u32 *from = vlib_frame_vector_args (frame);
335 u32 n_left_from = frame->n_vectors;
336 ip4_udp_wg_header_t *hdr4_out = NULL;
337 ip6_udp_wg_header_t *hdr6_out = NULL;
338 message_data_t *message_data_wg = NULL;
339 vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b = bufs;
340 vnet_crypto_op_t **crypto_ops = &ptd->crypto_ops;
341 u16 nexts[VLIB_FRAME_SIZE], *next = nexts;
342 vlib_buffer_t *sync_bufs[VLIB_FRAME_SIZE];
343 u32 thread_index = vm->thread_index;
345 const u16 drop_next = WG_OUTPUT_NEXT_ERROR;
346 const u8 is_async = wg_op_mode_is_set_ASYNC ();
347 vnet_crypto_async_frame_t *async_frame = NULL;
349 u16 noop_nexts[VLIB_FRAME_SIZE], *noop_next = noop_nexts, n_noop = 0;
351 u32 sync_bi[VLIB_FRAME_SIZE];
352 u32 noop_bi[VLIB_FRAME_SIZE];
354 vlib_get_buffers (vm, from, bufs, n_left_from);
355 vec_reset_length (ptd->crypto_ops);
356 vec_reset_length (ptd->async_frames);
358 wg_peer_t *peer = NULL;
360 u32 last_adj_index = ~0;
361 index_t peeri = INDEX_INVALID;
363 f64 time = clib_time_now (&vm->clib_time) + vm->time_offset;
365 while (n_left_from > 0)
375 vlib_prefetch_buffer_header (b[2], LOAD);
376 p = vlib_buffer_get_current (b[1]);
377 CLIB_PREFETCH (p, CLIB_CACHE_LINE_BYTES, LOAD);
378 CLIB_PREFETCH (vlib_buffer_get_tail (b[1]), CLIB_CACHE_LINE_BYTES,
382 noop_next[0] = WG_OUTPUT_NEXT_ERROR;
383 err = WG_OUTPUT_NEXT_ERROR;
385 adj_index = vnet_buffer (b[0])->ip.adj_index[VLIB_TX];
387 if (PREDICT_FALSE (last_adj_index != adj_index))
389 peeri = wg_peer_get_by_adj_index (adj_index);
390 if (peeri == INDEX_INVALID)
392 b[0]->error = node->errors[WG_OUTPUT_ERROR_PEER];
395 peer = wg_peer_get (peeri);
398 if (!peer || wg_peer_is_dead (peer))
400 b[0]->error = node->errors[WG_OUTPUT_ERROR_PEER];
403 if (PREDICT_FALSE (~0 == peer->output_thread_index))
405 /* this is the first packet to use this peer, claim the peer
408 clib_atomic_cmp_and_swap (&peer->output_thread_index, ~0,
409 wg_peer_assign_thread (thread_index));
412 if (PREDICT_FALSE (thread_index != peer->output_thread_index))
414 noop_next[0] = WG_OUTPUT_NEXT_HANDOFF;
415 err = WG_OUTPUT_NEXT_HANDOFF;
419 if (PREDICT_FALSE (!peer->remote.r_current))
421 wg_send_handshake_from_mt (peeri, false);
422 b[0]->error = node->errors[WG_OUTPUT_ERROR_KEYPAIR];
426 is_ip4_out = ip46_address_is_ip4 (&peer->src.addr);
429 hdr4_out = vlib_buffer_get_current (b[0]);
430 message_data_wg = &hdr4_out->wg;
434 hdr6_out = vlib_buffer_get_current (b[0]);
435 message_data_wg = &hdr6_out->wg;
438 iph_offset = vnet_buffer (b[0])->ip.save_rewrite_length;
439 plain_data = vlib_buffer_get_current (b[0]) + iph_offset;
440 plain_data_len = vlib_buffer_length_in_chain (vm, b[0]) - iph_offset;
441 u8 *iv_data = b[0]->pre_data;
443 size_t encrypted_packet_len = message_data_len (plain_data_len);
446 * Ensure there is enough space to write the encrypted data
449 if (PREDICT_FALSE (encrypted_packet_len >= WG_DEFAULT_DATA_SIZE) ||
450 PREDICT_FALSE ((b[0]->current_data + encrypted_packet_len) >=
451 vlib_buffer_get_default_data_size (vm)))
453 b[0]->error = node->errors[WG_OUTPUT_ERROR_TOO_BIG];
457 if (PREDICT_FALSE (last_adj_index != adj_index))
459 wg_timers_any_authenticated_packet_sent_opt (peer, time);
460 wg_timers_data_sent_opt (peer, time);
461 wg_timers_any_authenticated_packet_traversal (peer);
462 last_adj_index = adj_index;
465 /* Here we are sure that can send packet to next node */
466 next[0] = WG_OUTPUT_NEXT_INTERFACE_OUTPUT;
468 enum noise_state_crypt state;
472 /* get a frame for this op if we don't yet have one or it's full */
473 if (NULL == async_frame ||
474 vnet_crypto_async_frame_is_full (async_frame))
476 async_frame = vnet_crypto_async_get_frame (
477 vm, VNET_CRYPTO_OP_CHACHA20_POLY1305_TAG16_AAD0_ENC);
478 /* Save the frame to the list we'll submit at the end */
479 vec_add1 (ptd->async_frames, async_frame);
481 state = wg_add_to_async_frame (
482 vm, ptd, async_frame, b[0], plain_data, plain_data_len,
483 from[b - bufs], next[0], async_next_node, &peer->remote,
484 &message_data_wg->receiver_index, &message_data_wg->counter,
489 state = wq_output_tun_process (
490 vm, crypto_ops, &peer->remote, &message_data_wg->receiver_index,
491 &message_data_wg->counter, plain_data, plain_data_len, plain_data,
492 n_sync, iv_data, time);
495 if (PREDICT_FALSE (state == SC_KEEP_KEY_FRESH))
497 wg_send_handshake_from_mt (peeri, false);
499 else if (PREDICT_FALSE (state == SC_FAILED))
502 wg_send_handshake_from_mt (peeri, false);
503 wg_peer_update_flags (peeri, WG_PEER_ESTABLISHED, false);
504 noop_next[0] = WG_OUTPUT_NEXT_ERROR;
508 err = WG_OUTPUT_NEXT_INTERFACE_OUTPUT;
512 hdr4_out->wg.header.type = MESSAGE_DATA;
513 hdr4_out->udp.length = clib_host_to_net_u16 (encrypted_packet_len +
514 sizeof (udp_header_t));
515 b[0]->current_length =
516 (encrypted_packet_len + sizeof (ip4_udp_header_t));
517 ip4_header_set_len_w_chksum (
518 &hdr4_out->ip4, clib_host_to_net_u16 (b[0]->current_length));
522 hdr6_out->wg.header.type = MESSAGE_DATA;
523 hdr6_out->ip6.payload_length = hdr6_out->udp.length =
524 clib_host_to_net_u16 (encrypted_packet_len +
525 sizeof (udp_header_t));
526 b[0]->current_length =
527 (encrypted_packet_len + sizeof (ip6_udp_header_t));
531 if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
532 && (b[0]->flags & VLIB_BUFFER_IS_TRACED)))
534 wg_output_tun_trace_t *t =
535 vlib_add_trace (vm, node, b[0], sizeof (*t));
538 t->is_ip4 = is_ip4_out;
540 clib_memcpy (t->header, hdr4_out, sizeof (ip4_udp_header_t));
542 clib_memcpy (t->header, hdr6_out, sizeof (ip6_udp_header_t));
546 if (PREDICT_FALSE (err != WG_OUTPUT_NEXT_INTERFACE_OUTPUT))
548 noop_bi[n_noop] = from[b - bufs];
555 sync_bi[n_sync] = from[b - bufs];
556 sync_bufs[n_sync] = b[0];
571 /* wg-output-process-ops */
572 wg_output_process_ops (vm, node, ptd->crypto_ops, sync_bufs, nexts,
575 int n_left_from_sync_bufs = n_sync;
576 while (n_left_from_sync_bufs > 0)
578 n_left_from_sync_bufs--;
579 wg_calc_checksum (vm, sync_bufs[n_left_from_sync_bufs]);
582 vlib_buffer_enqueue_to_next (vm, node, sync_bi, nexts, n_sync);
586 /* submit all of the open frames */
587 vnet_crypto_async_frame_t **async_frame;
589 vec_foreach (async_frame, ptd->async_frames)
592 vnet_crypto_async_submit_open_frame (vm, *async_frame) < 0))
594 u32 n_drop = (*async_frame)->n_elts;
595 u32 *bi = (*async_frame)->buffer_indices;
599 noop_bi[index] = bi[0];
600 vlib_buffer_t *b = vlib_get_buffer (vm, bi[0]);
601 noop_nexts[index] = drop_next;
602 b->error = node->errors[WG_OUTPUT_ERROR_CRYPTO_ENGINE_ERROR];
606 n_noop += (*async_frame)->n_elts;
608 vnet_crypto_async_reset_frame (*async_frame);
609 vnet_crypto_async_free_frame (vm, *async_frame);
615 vlib_buffer_enqueue_to_next (vm, node, noop_bi, noop_nexts, n_noop);
618 return frame->n_vectors;
622 wg_output_tun_post (vlib_main_t *vm, vlib_node_runtime_t *node,
625 vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b = bufs;
626 u16 nexts[VLIB_FRAME_SIZE], *next = nexts;
627 u32 *from = vlib_frame_vector_args (frame);
628 u32 n_left = frame->n_vectors;
632 vlib_get_buffers (vm, from, b, n_left);
636 vlib_prefetch_buffer_header (b[0], LOAD);
637 vlib_prefetch_buffer_header (b[1], LOAD);
638 vlib_prefetch_buffer_header (b[2], LOAD);
639 vlib_prefetch_buffer_header (b[3], LOAD);
644 vlib_prefetch_buffer_header (b[4], LOAD);
645 vlib_prefetch_buffer_header (b[5], LOAD);
646 vlib_prefetch_buffer_header (b[6], LOAD);
647 vlib_prefetch_buffer_header (b[7], LOAD);
649 next[0] = (wg_post_data (b[0]))->next_index;
650 next[1] = (wg_post_data (b[1]))->next_index;
651 next[2] = (wg_post_data (b[2]))->next_index;
652 next[3] = (wg_post_data (b[3]))->next_index;
654 wg_calc_checksum (vm, b[0]);
655 wg_calc_checksum (vm, b[1]);
656 wg_calc_checksum (vm, b[2]);
657 wg_calc_checksum (vm, b[3]);
659 if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE))
661 if (b[0]->flags & VLIB_BUFFER_IS_TRACED)
663 wg_output_tun_post_trace_t *tr =
664 vlib_add_trace (vm, node, b[0], sizeof (*tr));
665 peeri = wg_peer_get_by_adj_index (
666 vnet_buffer (b[0])->ip.adj_index[VLIB_TX]);
668 tr->next_index = next[0];
670 if (b[1]->flags & VLIB_BUFFER_IS_TRACED)
672 wg_output_tun_post_trace_t *tr =
673 vlib_add_trace (vm, node, b[1], sizeof (*tr));
674 peeri = wg_peer_get_by_adj_index (
675 vnet_buffer (b[1])->ip.adj_index[VLIB_TX]);
676 tr->next_index = next[1];
678 if (b[2]->flags & VLIB_BUFFER_IS_TRACED)
680 wg_output_tun_post_trace_t *tr =
681 vlib_add_trace (vm, node, b[2], sizeof (*tr));
682 peeri = wg_peer_get_by_adj_index (
683 vnet_buffer (b[2])->ip.adj_index[VLIB_TX]);
684 tr->next_index = next[2];
686 if (b[3]->flags & VLIB_BUFFER_IS_TRACED)
688 wg_output_tun_post_trace_t *tr =
689 vlib_add_trace (vm, node, b[3], sizeof (*tr));
690 peeri = wg_peer_get_by_adj_index (
691 vnet_buffer (b[3])->ip.adj_index[VLIB_TX]);
692 tr->next_index = next[3];
703 wg_calc_checksum (vm, b[0]);
705 next[0] = (wg_post_data (b[0]))->next_index;
706 if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) &&
707 (b[0]->flags & VLIB_BUFFER_IS_TRACED)))
709 wg_output_tun_post_trace_t *tr =
710 vlib_add_trace (vm, node, b[0], sizeof (*tr));
711 peeri = wg_peer_get_by_adj_index (
712 vnet_buffer (b[0])->ip.adj_index[VLIB_TX]);
713 tr->next_index = next[0];
721 vlib_buffer_enqueue_to_next (vm, node, from, nexts, frame->n_vectors);
722 return frame->n_vectors;
725 VLIB_REGISTER_NODE (wg4_output_tun_post_node) = {
726 .name = "wg4-output-tun-post-node",
727 .vector_size = sizeof (u32),
728 .format_trace = format_wg_output_tun_post_trace,
729 .type = VLIB_NODE_TYPE_INTERNAL,
730 .sibling_of = "wg4-output-tun",
731 .n_errors = ARRAY_LEN (wg_output_error_strings),
732 .error_strings = wg_output_error_strings,
735 VLIB_REGISTER_NODE (wg6_output_tun_post_node) = {
736 .name = "wg6-output-tun-post-node",
737 .vector_size = sizeof (u32),
738 .format_trace = format_wg_output_tun_post_trace,
739 .type = VLIB_NODE_TYPE_INTERNAL,
740 .sibling_of = "wg6-output-tun",
741 .n_errors = ARRAY_LEN (wg_output_error_strings),
742 .error_strings = wg_output_error_strings,
745 VLIB_NODE_FN (wg4_output_tun_post_node)
746 (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
748 return wg_output_tun_post (vm, node, from_frame);
751 VLIB_NODE_FN (wg6_output_tun_post_node)
752 (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
754 return wg_output_tun_post (vm, node, from_frame);
757 VLIB_NODE_FN (wg4_output_tun_node)
758 (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
760 return wg_output_tun_inline (vm, node, frame, /* is_ip4 */ 1,
761 wg_encrypt_async_next.wg4_post_next);
764 VLIB_NODE_FN (wg6_output_tun_node)
765 (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
767 return wg_output_tun_inline (vm, node, frame, /* is_ip4 */ 0,
768 wg_encrypt_async_next.wg6_post_next);
772 VLIB_REGISTER_NODE (wg4_output_tun_node) =
774 .name = "wg4-output-tun",
775 .vector_size = sizeof (u32),
776 .format_trace = format_wg_output_tun_trace,
777 .type = VLIB_NODE_TYPE_INTERNAL,
778 .n_errors = ARRAY_LEN (wg_output_error_strings),
779 .error_strings = wg_output_error_strings,
780 .n_next_nodes = WG_OUTPUT_N_NEXT,
782 [WG_OUTPUT_NEXT_HANDOFF] = "wg4-output-tun-handoff",
783 [WG_OUTPUT_NEXT_INTERFACE_OUTPUT] = "adj-midchain-tx",
784 [WG_OUTPUT_NEXT_ERROR] = "error-drop",
788 VLIB_REGISTER_NODE (wg6_output_tun_node) =
790 .name = "wg6-output-tun",
791 .vector_size = sizeof (u32),
792 .format_trace = format_wg_output_tun_trace,
793 .type = VLIB_NODE_TYPE_INTERNAL,
794 .n_errors = ARRAY_LEN (wg_output_error_strings),
795 .error_strings = wg_output_error_strings,
796 .n_next_nodes = WG_OUTPUT_N_NEXT,
798 [WG_OUTPUT_NEXT_HANDOFF] = "wg6-output-tun-handoff",
799 [WG_OUTPUT_NEXT_INTERFACE_OUTPUT] = "adj-midchain-tx",
800 [WG_OUTPUT_NEXT_ERROR] = "error-drop",
806 * fd.io coding-style-patch-verification: ON
809 * eval: (c-set-style "gnu")