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 /* get a frame for this op if we don't yet have one or it's full */
288 if (NULL == *async_frame || vnet_crypto_async_frame_is_full (*async_frame))
290 *async_frame = vnet_crypto_async_get_frame (
291 vm, VNET_CRYPTO_OP_CHACHA20_POLY1305_TAG16_AAD0_ENC);
292 /* Save the frame to the list we'll submit at the end */
293 vec_add1 (ptd->async_frames, *async_frame);
296 /* this always succeeds because we know the frame is not full */
297 wg_output_tun_add_to_frame (vm, *async_frame, kp->kp_send_index, payload_len,
298 payload - b->data, bi, async_next, iv,
299 payload + payload_len, flag);
301 /* If our values are still within tolerances, but we are approaching
302 * the tolerances, we notify the caller with ESTALE that they should
303 * establish a new keypair. The current keypair can continue to be used
304 * until the tolerances are hit. We notify if:
305 * - our send counter is valid and not less than REKEY_AFTER_MESSAGES
306 * - we're the initiator and our keypair is older than
307 * REKEY_AFTER_TIME seconds */
308 ret = SC_KEEP_KEY_FRESH;
309 if ((kp->kp_valid && *nonce >= REKEY_AFTER_MESSAGES) ||
310 (kp->kp_is_initiator && wg_birthdate_has_expired_opt (
311 kp->kp_birthdate, REKEY_AFTER_TIME, time)))
319 static_always_inline void
320 wg_calc_checksum (vlib_main_t *vm, vlib_buffer_t *b)
323 u8 ip_ver_out = (*((u8 *) vlib_buffer_get_current (b)) >> 4);
325 /* IPv6 UDP checksum is mandatory */
329 (ip6_header_t *) ((u8 *) vlib_buffer_get_current (b));
330 udp_header_t *udp = ip6_next_header (ip6);
331 udp->checksum = ip6_tcp_udp_icmp_compute_checksum (vm, b, ip6, &bogus);
335 /* is_ip4 - inner header flag */
337 wg_output_tun_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
338 vlib_frame_t *frame, u8 is_ip4, u16 async_next_node)
340 wg_main_t *wmp = &wg_main;
341 wg_per_thread_data_t *ptd =
342 vec_elt_at_index (wmp->per_thread_data, vm->thread_index);
343 u32 *from = vlib_frame_vector_args (frame);
344 u32 n_left_from = frame->n_vectors;
345 ip4_udp_wg_header_t *hdr4_out = NULL;
346 ip6_udp_wg_header_t *hdr6_out = NULL;
347 message_data_t *message_data_wg = NULL;
348 vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b = bufs;
349 vnet_crypto_op_t **crypto_ops = &ptd->crypto_ops;
350 u16 nexts[VLIB_FRAME_SIZE], *next = nexts;
351 vlib_buffer_t *sync_bufs[VLIB_FRAME_SIZE];
352 u32 thread_index = vm->thread_index;
354 const u16 drop_next = WG_OUTPUT_NEXT_ERROR;
355 const u8 is_async = wg_op_mode_is_set_ASYNC ();
356 vnet_crypto_async_frame_t *async_frame = NULL;
358 u16 noop_nexts[VLIB_FRAME_SIZE], *noop_next = noop_nexts, n_noop = 0;
360 u32 sync_bi[VLIB_FRAME_SIZE];
361 u32 noop_bi[VLIB_FRAME_SIZE];
363 vlib_get_buffers (vm, from, bufs, n_left_from);
364 vec_reset_length (ptd->crypto_ops);
365 vec_reset_length (ptd->async_frames);
367 wg_peer_t *peer = NULL;
369 u32 last_adj_index = ~0;
370 index_t peeri = INDEX_INVALID;
372 f64 time = clib_time_now (&vm->clib_time) + vm->time_offset;
374 while (n_left_from > 0)
384 vlib_prefetch_buffer_header (b[2], LOAD);
385 p = vlib_buffer_get_current (b[1]);
386 CLIB_PREFETCH (p, CLIB_CACHE_LINE_BYTES, LOAD);
387 CLIB_PREFETCH (vlib_buffer_get_tail (b[1]), CLIB_CACHE_LINE_BYTES,
391 noop_next[0] = WG_OUTPUT_NEXT_ERROR;
392 err = WG_OUTPUT_NEXT_ERROR;
394 adj_index = vnet_buffer (b[0])->ip.adj_index[VLIB_TX];
396 if (PREDICT_FALSE (last_adj_index != adj_index))
398 peeri = wg_peer_get_by_adj_index (adj_index);
399 if (peeri == INDEX_INVALID)
401 b[0]->error = node->errors[WG_OUTPUT_ERROR_PEER];
404 peer = wg_peer_get (peeri);
407 if (!peer || wg_peer_is_dead (peer))
409 b[0]->error = node->errors[WG_OUTPUT_ERROR_PEER];
412 if (PREDICT_FALSE (~0 == peer->output_thread_index))
414 /* this is the first packet to use this peer, claim the peer
417 clib_atomic_cmp_and_swap (&peer->output_thread_index, ~0,
418 wg_peer_assign_thread (thread_index));
421 if (PREDICT_FALSE (thread_index != peer->output_thread_index))
423 noop_next[0] = WG_OUTPUT_NEXT_HANDOFF;
424 err = WG_OUTPUT_NEXT_HANDOFF;
428 if (PREDICT_FALSE (!peer->remote.r_current))
430 wg_send_handshake_from_mt (peeri, false);
431 b[0]->error = node->errors[WG_OUTPUT_ERROR_KEYPAIR];
435 iph_offset = vnet_buffer (b[0])->ip.save_rewrite_length;
436 plain_data_len = vlib_buffer_length_in_chain (vm, b[0]) - iph_offset;
437 u8 *iv_data = b[0]->pre_data;
439 size_t encrypted_packet_len = message_data_len (plain_data_len);
442 * Ensure there is enough space to write the encrypted data
445 if (PREDICT_FALSE (encrypted_packet_len >= WG_DEFAULT_DATA_SIZE) ||
446 PREDICT_FALSE ((iph_offset + encrypted_packet_len) >=
447 vlib_buffer_get_default_data_size (vm)))
449 b[0]->error = node->errors[WG_OUTPUT_ERROR_TOO_BIG];
454 * Move the buffer to fit ethernet header
456 if (b[0]->current_data + VLIB_BUFFER_PRE_DATA_SIZE <
457 sizeof (ethernet_header_t))
459 vlib_buffer_move (vm, b[0], 0);
462 plain_data = vlib_buffer_get_current (b[0]) + iph_offset;
464 is_ip4_out = ip46_address_is_ip4 (&peer->src.addr);
467 hdr4_out = vlib_buffer_get_current (b[0]);
468 message_data_wg = &hdr4_out->wg;
472 hdr6_out = vlib_buffer_get_current (b[0]);
473 message_data_wg = &hdr6_out->wg;
476 if (PREDICT_FALSE (last_adj_index != adj_index))
478 wg_timers_any_authenticated_packet_sent_opt (peer, time);
479 wg_timers_data_sent_opt (peer, time);
480 wg_timers_any_authenticated_packet_traversal (peer);
481 last_adj_index = adj_index;
484 /* Here we are sure that can send packet to next node */
485 next[0] = WG_OUTPUT_NEXT_INTERFACE_OUTPUT;
487 enum noise_state_crypt state;
491 state = wg_add_to_async_frame (
492 vm, ptd, &async_frame, b[0], plain_data, plain_data_len,
493 from[b - bufs], next[0], async_next_node, &peer->remote,
494 &message_data_wg->receiver_index, &message_data_wg->counter,
499 state = wq_output_tun_process (
500 vm, crypto_ops, &peer->remote, &message_data_wg->receiver_index,
501 &message_data_wg->counter, plain_data, plain_data_len, plain_data,
502 n_sync, iv_data, time);
505 if (PREDICT_FALSE (state == SC_KEEP_KEY_FRESH))
507 wg_send_handshake_from_mt (peeri, false);
509 else if (PREDICT_FALSE (state == SC_FAILED))
512 wg_send_handshake_from_mt (peeri, false);
513 wg_peer_update_flags (peeri, WG_PEER_ESTABLISHED, false);
514 noop_next[0] = WG_OUTPUT_NEXT_ERROR;
518 err = WG_OUTPUT_NEXT_INTERFACE_OUTPUT;
522 hdr4_out->wg.header.type = MESSAGE_DATA;
523 hdr4_out->udp.length = clib_host_to_net_u16 (encrypted_packet_len +
524 sizeof (udp_header_t));
525 b[0]->current_length =
526 (encrypted_packet_len + sizeof (ip4_udp_header_t));
527 ip4_header_set_len_w_chksum (
528 &hdr4_out->ip4, clib_host_to_net_u16 (b[0]->current_length));
532 hdr6_out->wg.header.type = MESSAGE_DATA;
533 hdr6_out->ip6.payload_length = hdr6_out->udp.length =
534 clib_host_to_net_u16 (encrypted_packet_len +
535 sizeof (udp_header_t));
536 b[0]->current_length =
537 (encrypted_packet_len + sizeof (ip6_udp_header_t));
541 if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
542 && (b[0]->flags & VLIB_BUFFER_IS_TRACED)))
544 wg_output_tun_trace_t *t =
545 vlib_add_trace (vm, node, b[0], sizeof (*t));
548 t->is_ip4 = is_ip4_out;
550 clib_memcpy (t->header, hdr4_out, sizeof (ip4_udp_header_t));
552 clib_memcpy (t->header, hdr6_out, sizeof (ip6_udp_header_t));
556 if (PREDICT_FALSE (err != WG_OUTPUT_NEXT_INTERFACE_OUTPUT))
558 noop_bi[n_noop] = from[b - bufs];
565 sync_bi[n_sync] = from[b - bufs];
566 sync_bufs[n_sync] = b[0];
581 /* wg-output-process-ops */
582 wg_output_process_ops (vm, node, ptd->crypto_ops, sync_bufs, nexts,
585 int n_left_from_sync_bufs = n_sync;
586 while (n_left_from_sync_bufs > 0)
588 n_left_from_sync_bufs--;
589 wg_calc_checksum (vm, sync_bufs[n_left_from_sync_bufs]);
592 vlib_buffer_enqueue_to_next (vm, node, sync_bi, nexts, n_sync);
596 /* submit all of the open frames */
597 vnet_crypto_async_frame_t **async_frame;
599 vec_foreach (async_frame, ptd->async_frames)
602 vnet_crypto_async_submit_open_frame (vm, *async_frame) < 0))
604 u32 n_drop = (*async_frame)->n_elts;
605 u32 *bi = (*async_frame)->buffer_indices;
609 noop_bi[index] = bi[0];
610 vlib_buffer_t *b = vlib_get_buffer (vm, bi[0]);
611 noop_nexts[index] = drop_next;
612 b->error = node->errors[WG_OUTPUT_ERROR_CRYPTO_ENGINE_ERROR];
616 n_noop += (*async_frame)->n_elts;
618 vnet_crypto_async_reset_frame (*async_frame);
619 vnet_crypto_async_free_frame (vm, *async_frame);
625 vlib_buffer_enqueue_to_next (vm, node, noop_bi, noop_nexts, n_noop);
628 return frame->n_vectors;
632 wg_output_tun_post (vlib_main_t *vm, vlib_node_runtime_t *node,
635 vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b = bufs;
636 u16 nexts[VLIB_FRAME_SIZE], *next = nexts;
637 u32 *from = vlib_frame_vector_args (frame);
638 u32 n_left = frame->n_vectors;
642 vlib_get_buffers (vm, from, b, n_left);
646 vlib_prefetch_buffer_header (b[0], LOAD);
647 vlib_prefetch_buffer_header (b[1], LOAD);
648 vlib_prefetch_buffer_header (b[2], LOAD);
649 vlib_prefetch_buffer_header (b[3], LOAD);
654 vlib_prefetch_buffer_header (b[4], LOAD);
655 vlib_prefetch_buffer_header (b[5], LOAD);
656 vlib_prefetch_buffer_header (b[6], LOAD);
657 vlib_prefetch_buffer_header (b[7], LOAD);
659 next[0] = (wg_post_data (b[0]))->next_index;
660 next[1] = (wg_post_data (b[1]))->next_index;
661 next[2] = (wg_post_data (b[2]))->next_index;
662 next[3] = (wg_post_data (b[3]))->next_index;
664 wg_calc_checksum (vm, b[0]);
665 wg_calc_checksum (vm, b[1]);
666 wg_calc_checksum (vm, b[2]);
667 wg_calc_checksum (vm, b[3]);
669 if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE))
671 if (b[0]->flags & VLIB_BUFFER_IS_TRACED)
673 wg_output_tun_post_trace_t *tr =
674 vlib_add_trace (vm, node, b[0], sizeof (*tr));
675 peeri = wg_peer_get_by_adj_index (
676 vnet_buffer (b[0])->ip.adj_index[VLIB_TX]);
678 tr->next_index = next[0];
680 if (b[1]->flags & VLIB_BUFFER_IS_TRACED)
682 wg_output_tun_post_trace_t *tr =
683 vlib_add_trace (vm, node, b[1], sizeof (*tr));
684 peeri = wg_peer_get_by_adj_index (
685 vnet_buffer (b[1])->ip.adj_index[VLIB_TX]);
686 tr->next_index = next[1];
688 if (b[2]->flags & VLIB_BUFFER_IS_TRACED)
690 wg_output_tun_post_trace_t *tr =
691 vlib_add_trace (vm, node, b[2], sizeof (*tr));
692 peeri = wg_peer_get_by_adj_index (
693 vnet_buffer (b[2])->ip.adj_index[VLIB_TX]);
694 tr->next_index = next[2];
696 if (b[3]->flags & VLIB_BUFFER_IS_TRACED)
698 wg_output_tun_post_trace_t *tr =
699 vlib_add_trace (vm, node, b[3], sizeof (*tr));
700 peeri = wg_peer_get_by_adj_index (
701 vnet_buffer (b[3])->ip.adj_index[VLIB_TX]);
702 tr->next_index = next[3];
713 wg_calc_checksum (vm, b[0]);
715 next[0] = (wg_post_data (b[0]))->next_index;
716 if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) &&
717 (b[0]->flags & VLIB_BUFFER_IS_TRACED)))
719 wg_output_tun_post_trace_t *tr =
720 vlib_add_trace (vm, node, b[0], sizeof (*tr));
721 peeri = wg_peer_get_by_adj_index (
722 vnet_buffer (b[0])->ip.adj_index[VLIB_TX]);
723 tr->next_index = next[0];
731 vlib_buffer_enqueue_to_next (vm, node, from, nexts, frame->n_vectors);
732 return frame->n_vectors;
735 VLIB_REGISTER_NODE (wg4_output_tun_post_node) = {
736 .name = "wg4-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 = "wg4-output-tun",
741 .n_errors = ARRAY_LEN (wg_output_error_strings),
742 .error_strings = wg_output_error_strings,
745 VLIB_REGISTER_NODE (wg6_output_tun_post_node) = {
746 .name = "wg6-output-tun-post-node",
747 .vector_size = sizeof (u32),
748 .format_trace = format_wg_output_tun_post_trace,
749 .type = VLIB_NODE_TYPE_INTERNAL,
750 .sibling_of = "wg6-output-tun",
751 .n_errors = ARRAY_LEN (wg_output_error_strings),
752 .error_strings = wg_output_error_strings,
755 VLIB_NODE_FN (wg4_output_tun_post_node)
756 (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
758 return wg_output_tun_post (vm, node, from_frame);
761 VLIB_NODE_FN (wg6_output_tun_post_node)
762 (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
764 return wg_output_tun_post (vm, node, from_frame);
767 VLIB_NODE_FN (wg4_output_tun_node)
768 (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
770 return wg_output_tun_inline (vm, node, frame, /* is_ip4 */ 1,
771 wg_encrypt_async_next.wg4_post_next);
774 VLIB_NODE_FN (wg6_output_tun_node)
775 (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
777 return wg_output_tun_inline (vm, node, frame, /* is_ip4 */ 0,
778 wg_encrypt_async_next.wg6_post_next);
782 VLIB_REGISTER_NODE (wg4_output_tun_node) =
784 .name = "wg4-output-tun",
785 .vector_size = sizeof (u32),
786 .format_trace = format_wg_output_tun_trace,
787 .type = VLIB_NODE_TYPE_INTERNAL,
788 .n_errors = ARRAY_LEN (wg_output_error_strings),
789 .error_strings = wg_output_error_strings,
790 .n_next_nodes = WG_OUTPUT_N_NEXT,
792 [WG_OUTPUT_NEXT_HANDOFF] = "wg4-output-tun-handoff",
793 [WG_OUTPUT_NEXT_INTERFACE_OUTPUT] = "adj-midchain-tx",
794 [WG_OUTPUT_NEXT_ERROR] = "error-drop",
798 VLIB_REGISTER_NODE (wg6_output_tun_node) =
800 .name = "wg6-output-tun",
801 .vector_size = sizeof (u32),
802 .format_trace = format_wg_output_tun_trace,
803 .type = VLIB_NODE_TYPE_INTERNAL,
804 .n_errors = ARRAY_LEN (wg_output_error_strings),
805 .error_strings = wg_output_error_strings,
806 .n_next_nodes = WG_OUTPUT_N_NEXT,
808 [WG_OUTPUT_NEXT_HANDOFF] = "wg6-output-tun-handoff",
809 [WG_OUTPUT_NEXT_INTERFACE_OUTPUT] = "adj-midchain-tx",
810 [WG_OUTPUT_NEXT_ERROR] = "error-drop",
816 * fd.io coding-style-patch-verification: ON
819 * eval: (c-set-style "gnu")