23 #define foreach_wg_output_error \ 25 _(PEER, "Peer error") \ 26 _(KEYPAIR, "Keypair error") \ 27 _(TOO_BIG, "packet too big") \ 31 #define _(sym,str) WG_OUTPUT_ERROR_##sym, 38 #define _(sym,string) string, 93 n_left_from =
frame->n_vectors;
102 while (n_left_from > 0)
108 clib_net_to_host_u16 (((
ip4_header_t *) plain_data)->length);
118 b[0]->
error =
node->errors[WG_OUTPUT_ERROR_PEER];
140 b[0]->
error =
node->errors[WG_OUTPUT_ERROR_KEYPAIR];
150 PREDICT_FALSE ((b[0]->current_data + encrypted_packet_len) >=
153 b[0]->
error =
node->errors[WG_OUTPUT_ERROR_TOO_BIG];
165 &encrypted_packet->
counter, plain_data,
184 clib_memcpy (plain_data, (
u8 *) encrypted_packet, encrypted_packet_len);
186 hdr->
udp.
length = clib_host_to_net_u16 (encrypted_packet_len +
191 (&hdr->
ip4, clib_host_to_net_u16 (b[0]->current_length));
199 && (b[0]->
flags & VLIB_BUFFER_IS_TRACED)))
213 return frame->n_vectors;
219 .name =
"wg-output-tun",
220 .vector_size =
sizeof (
u32),
#define WG_DEFAULT_DATA_SIZE
wg_per_thread_data_t * per_thread_data
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
enum noise_state_crypt noise_remote_encrypt(vlib_main_t *vm, noise_remote_t *r, uint32_t *r_idx, uint64_t *nonce, uint8_t *src, size_t srclen, uint8_t *dst)
#define foreach_wg_output_error
u16 current_length
Nbytes between current data and the end of this buffer.
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
void wg_timers_any_authenticated_packet_traversal(wg_peer_t *peer)
static char * wg_output_error_strings[]
#define VLIB_NODE_FN(node)
#define clib_memcpy(d, s, n)
static index_t wg_peer_get_by_adj_index(index_t ai)
void wg_send_handshake_from_mt(u32 peer_idx, bool is_retry)
u8 * format_ip4_udp_header(u8 *s, va_list *args)
vl_api_fib_path_type_t type
vlib_error_t error
Error code for buffers to be enqueued to error handler.
void wg_timers_data_sent(wg_peer_t *peer)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static u8 * format_wg_output_tun_trace(u8 *s, va_list *args)
static_always_inline u32 vlib_buffer_get_default_data_size(vlib_main_t *vm)
#define VLIB_REGISTER_NODE(x,...)
#define message_data_len(plain_len)
static_always_inline void vlib_buffer_enqueue_to_next(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, u16 *nexts, uword count)
void wg_timers_any_authenticated_packet_sent(wg_peer_t *peer)
u8 data[WG_DEFAULT_DATA_SIZE]
vlib_main_t vlib_node_runtime_t * node
#define clib_atomic_cmp_and_swap(addr, old, new)
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
VLIB buffer representation.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
noise_keypair_t * r_current
static u32 wg_peer_assign_thread(u32 thread_id)
static void ip4_header_set_len_w_chksum(ip4_header_t *ip4, u16 len)
vl_api_dhcp_client_state_t state
struct ip4_udp_header_t_ ip4_udp_header_t
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static_always_inline void vlib_get_buffers(vlib_main_t *vm, u32 *bi, vlib_buffer_t **b, int count)
Translate array of buffer indices into buffer pointers.
#define VLIB_NODE_FLAG_TRACE
static wg_peer_t * wg_peer_get(index_t peeri)
vlib_node_registration_t wg_output_tun_node
(constructor) VLIB_REGISTER_NODE (wg_output_tun_node)