|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
25 #define foreach_wg_input_error \
26 _ (NONE, "No error") \
27 _ (HANDSHAKE_MAC, "Invalid MAC handshake") \
28 _ (PEER, "Peer error") \
29 _ (INTERFACE, "Interface error") \
30 _ (DECRYPTION, "Failed during decryption") \
31 _ (KEEPALIVE_SEND, "Failed while sending Keepalive") \
32 _ (HANDSHAKE_SEND, "Failed while sending Handshake") \
33 _ (HANDSHAKE_RECEIVE, "Failed while receiving Handshake") \
34 _ (TOO_BIG, "Packet too big") \
35 _ (UNDEFINED, "Undefined error")
39 #define _(sym,str) WG_INPUT_ERROR_##sym,
46 #define _(sym,string) string,
66 #define _(v,a) case MESSAGE_##v: return (format (s, "%s", a));
70 return (
format (s,
"unknown"));
82 s =
format (s,
"WG input: \n");
117 bool packet_needs_cookie;
137 return WG_INPUT_ERROR_INTERFACE;
148 return WG_INPUT_ERROR_PEER;
152 return WG_INPUT_ERROR_NONE;
155 u32 len = (header->
type == MESSAGE_HANDSHAKE_INITIATION ?
160 ((
u8 *) current_b_data +
len -
sizeof (*macs));
164 current_b_data,
len, under_load, ip4_src,
169 packet_needs_cookie =
false;
171 packet_needs_cookie =
true;
173 return WG_INPUT_ERROR_HANDSHAKE_MAC;
175 switch (header->
type)
177 case MESSAGE_HANDSHAKE_INITIATION:
181 if (packet_needs_cookie)
195 return WG_INPUT_ERROR_PEER;
202 WG_INPUT_ERROR_HANDSHAKE_SEND, 1);
206 case MESSAGE_HANDSHAKE_RESPONSE:
216 return WG_INPUT_ERROR_PEER;
219 return WG_INPUT_ERROR_PEER;
226 return WG_INPUT_ERROR_PEER;
228 if (packet_needs_cookie)
242 WG_INPUT_ERROR_KEEPALIVE_SEND,
249 return WG_INPUT_ERROR_HANDSHAKE_RECEIVE;
254 return WG_INPUT_ERROR_NONE;
298 bool is_keepalive =
false;
309 data->receiver_index);
318 b[0]->
error =
node->errors[WG_INPUT_ERROR_PEER];
341 b[0]->
error =
node->errors[WG_INPUT_ERROR_TOO_BIG];
349 data->receiver_index,
351 data->encrypted_data,
366 b[0]->
error =
node->errors[WG_INPUT_ERROR_DECRYPTION];
373 VNET_BUFFER_OFFLOAD_F_UDP_CKSUM);
390 bool allowed =
false;
424 if (ret != WG_INPUT_ERROR_NONE)
433 && (
b[0]->
flags & VLIB_BUFFER_IS_TRACED)))
436 t->
type = header_type;
448 return frame->n_vectors;
455 .vector_size =
sizeof (
u32),
u16 udp_src_port[default=4500]
void wg_timers_session_derived(wg_peer_t *peer)
vlib_buffer_t * bufs[VLIB_FRAME_SIZE]
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
void wg_send_handshake_from_mt(u32 peer_idx, bool is_retry)
u16 udp_dst_port[default=4500]
#define clib_memcpy(d, s, n)
ip4_main_t ip4_main
Global ip4 main structure.
#define NOISE_AUTHTAG_LEN
vlib_get_buffers(vm, from, b, n_left_from)
@ VLIB_NODE_TYPE_INTERNAL
static u32 wg_peer_assign_thread(u32 thread_id)
vlib_main_t vlib_node_runtime_t * node
wg_index_table_t index_table
enum message_type message_type_t
enum cookie_mac_state cookie_checker_validate_macs(vlib_main_t *vm, cookie_checker_t *cc, message_macs_t *cm, void *buf, size_t len, bool busy, ip4_address_t ip4, u16 udp_port)
u16 fp_len
The mask length.
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
bool noise_consume_initiation(vlib_main_t *vm, noise_local_t *l, noise_remote_t **rp, uint32_t s_idx, uint8_t ue[NOISE_PUBLIC_KEY_LEN], uint8_t es[NOISE_PUBLIC_KEY_LEN+NOISE_AUTHTAG_LEN], uint8_t ets[NOISE_TIMESTAMP_LEN+NOISE_AUTHTAG_LEN])
description malformed packet
vlib_buffer_enqueue_to_next(vm, node, from,(u16 *) nexts, frame->n_vectors)
u8 encrypted_nothing[noise_encrypted_len(0)]
struct message_data message_data_t
@ foreach_wg_message_type
u32 * wg_index_table_lookup(const wg_index_table_t *table, u32 key)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
#define VLIB_NODE_FN(node)
cookie_checker_t cookie_checker
#define VLIB_NODE_FLAG_TRACE
wg_per_thread_data_t * per_thread_data
void wg_timers_any_authenticated_packet_received(wg_peer_t *peer)
static_always_inline void vnet_buffer_offload_flags_clear(vlib_buffer_t *b, vnet_buffer_oflags_t oflags)
void wg_timers_data_received(wg_peer_t *peer)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
#define static_always_inline
u8 unencrypted_ephemeral[NOISE_PUBLIC_KEY_LEN]
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
bool wg_send_handshake_response(vlib_main_t *vm, wg_peer_t *peer)
@ VALID_MAC_BUT_NO_COOKIE
struct _vlib_node_registration vlib_node_registration_t
enum noise_state_crypt noise_remote_decrypt(vlib_main_t *vm, noise_remote_t *r, uint32_t r_idx, uint64_t nonce, uint8_t *src, size_t srclen, uint8_t *dst)
u16 current_length
Nbytes between current data and the end of this buffer.
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
static uword ip4_destination_matches_route(const ip4_main_t *im, const ip4_address_t *key, const ip4_address_t *dest, uword dest_length)
u8 encrypted_static[noise_encrypted_len(NOISE_PUBLIC_KEY_LEN)]
u8 unencrypted_ephemeral[NOISE_PUBLIC_KEY_LEN]
static_always_inline noise_local_t * noise_local_get(uint32_t locali)
bool wg_send_keepalive(vlib_main_t *vm, wg_peer_t *peer)
description fragment has unexpected format
#define clib_atomic_cmp_and_swap(addr, old, new)
struct message_handshake_initiation message_handshake_initiation_t
#define vec_foreach(var, vec)
Vector iterator.
bool noise_consume_response(vlib_main_t *vm, noise_remote_t *r, uint32_t s_idx, uint32_t r_idx, uint8_t ue[NOISE_PUBLIC_KEY_LEN], uint8_t en[0+NOISE_AUTHTAG_LEN])
fib_protocol_t fp_proto
protocol type
u8 data[WG_DEFAULT_DATA_SIZE]
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#define WG_DEFAULT_DATA_SIZE
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static wg_peer_t * wg_peer_get(index_t peeri)
u16 nexts[VLIB_FRAME_SIZE]
u8 encrypted_timestamp[noise_encrypted_len(NOISE_TIMESTAMP_LEN)]
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
void wg_timers_handshake_complete(wg_peer_t *peer)
bool noise_remote_begin_session(vlib_main_t *vm, noise_remote_t *r)
Aggregate type for a prefix.
vl_api_fib_path_type_t type
static_always_inline wg_if_t * wg_if_get_by_port(u16 port)
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
VLIB buffer representation.
#define VLIB_REGISTER_NODE(x,...)
void wg_timers_any_authenticated_packet_traversal(wg_peer_t *peer)