|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
72 &
peer->dst.addr,
peer->wg_sw_if_index, ~0, 1,
84 peer->timers_dispatched[
i] = 0;
101 peer->input_thread_index = ~0;
102 peer->output_thread_index = ~0;
104 peer->timer_wheel = 0;
105 peer->persistent_keepalive_interval = 0;
106 peer->timer_handshake_attempts = 0;
107 peer->last_sent_packet = 0;
108 peer->last_received_packet = 0;
109 peer->session_derived = 0;
110 peer->rehandshake_started = 0;
111 peer->new_handshake_interval_tick = 0;
112 peer->rehandshake_interval_tick = 0;
113 peer->timer_need_another_keepalive =
false;
114 peer->is_dead =
true;
174 .fp_addr =
peer->dst.addr,
210 const ip46_address_t *
dst,
212 u16 persistent_keepalive_interval,
218 peer->wg_sw_if_index = wg_sw_if_index;
220 peer->persistent_keepalive_interval = persistent_keepalive_interval;
222 peer->is_dead =
false;
227 return (VNET_API_ERROR_INVALID_INTERFACE);
286 if (tun_sw_if_index == ~0)
287 return (VNET_API_ERROR_INVALID_SW_IF_INDEX);
291 return (VNET_API_ERROR_INVALID_SW_IF_INDEX);
298 return (VNET_API_ERROR_ENTRY_ALREADY_EXISTS);
304 return (VNET_API_ERROR_LIMIT_EXCEEDED);
324 if (
peer->persistent_keepalive_interval != 0)
343 return VNET_API_ERROR_NO_SUCH_ENTRY;
394 s =
format (s,
"[%d] endpoint:[%U->%U] %U keep-alive:%d adj:%d",
399 peer->wg_sw_if_index,
400 peer->persistent_keepalive_interval,
peer->adj_index);
401 s =
format (s,
"\n key:%=s %U",
404 s =
format (s,
"\n allowed-ips:");
static void wg_peer_fib_populate(wg_peer_t *peer, u32 fib_index)
fib_node_index_t fib_table_entry_path_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, dpo_proto_t next_hop_proto, const ip46_address_t *next_hop, u32 next_hop_sw_if_index, u32 next_hop_fib_index, u32 next_hop_weight, fib_mpls_label_t *next_hop_labels, fib_route_path_flags_t path_flags)
Add one path to an entry (aka route) in the FIB.
walk_rc_t wg_peer_if_table_change(wg_if_t *wgi, index_t peeri, void *data)
static_always_inline wg_if_t * wg_if_get(index_t wgii)
#define NOISE_KEY_LEN_BASE64
fib_node_index_t fib_entry_index
static void wg_peer_endpoint_init(wg_peer_endpoint_t *ep, const ip46_address_t *addr, u16 port)
static void wg_peer_init(vlib_main_t *vm, wg_peer_t *peer)
adj_index_t adj_nbr_add_or_lock(fib_protocol_t nh_proto, vnet_link_t link_type, const ip46_address_t *nh_addr, u32 sw_if_index)
Neighbour Adjacency sub-type.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static void ip46_address_reset(ip46_address_t *ip46)
int wg_peer_remove(index_t peeri)
void adj_midchain_delegate_stack(adj_index_t ai, u32 fib_index, const fib_prefix_t *pfx)
create/attach a midchain delegate and stack it on the prefix passed
#define FIB_NODE_INDEX_INVALID
void adj_unlock(adj_index_t adj_index)
Release a reference counting lock on the adjacency.
static void wg_peer_fib_flush(wg_peer_t *peer)
static u8 * wg_peer_build_rewrite(const wg_peer_t *peer)
#define pool_put(P, E)
Free an object E in pool P.
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
walk_rc_t(* wg_peer_walk_cb_t)(index_t peeri, void *arg)
static u8 * format_wg_peer_endpoint(u8 *s, va_list *args)
walk_rc_t wg_peer_if_admin_state_change(wg_if_t *wgi, index_t peeri, void *data)
void wg_if_peer_remove(wg_if_t *wgi, index_t peeri)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
static void wg_peer_adj_stack(wg_peer_t *peer)
#define pool_foreach(VAR, POOL)
Iterate through pool.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void noise_remote_clear(vlib_main_t *vm, noise_remote_t *r)
#define vec_dup(V)
Return copy of vector (no header, no alignment)
vnet_main_t * vnet_get_main(void)
index_t wg_if_find_by_sw_if_index(u32 sw_if_index)
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
#define vec_foreach_index(var, v)
Iterate over vector indices.
int wg_peer_add(u32 tun_sw_if_index, const u8 public_key[NOISE_PUBLIC_KEY_LEN], u32 table_id, const ip46_address_t *endpoint, const fib_prefix_t *allowed_ips, u16 port, u16 persistent_keepalive, u32 *peer_index)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
fib_protocol_t ip_address_to_46(const ip_address_t *addr, ip46_address_t *a)
fib_source_t fib_source_allocate(const char *name, fib_source_priority_t prio, fib_source_behaviour_t bh)
dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto)
static_always_inline void ip46_address_copy(ip46_address_t *dst, const ip46_address_t *src)
static uword vnet_sw_interface_is_admin_up(vnet_main_t *vnm, u32 sw_if_index)
void noise_remote_init(noise_remote_t *r, uint32_t peer_pool_idx, const uint8_t public[NOISE_PUBLIC_KEY_LEN], u32 noise_local_idx)
void adj_midchain_delegate_unstack(adj_index_t ai)
unstack a midchain delegate (this stacks it on a drop)
@ FIB_SOURCE_BH_API
add paths with [mpls] path extensions
#define vec_free(V)
Free vector's memory (no header).
vl_api_prefix_t allowed_ips[n_allowed_ips]
bool key_to_base64(const u8 *src, size_t src_len, u8 *out)
void adj_nbr_midchain_update_rewrite(adj_index_t adj_index, adj_midchain_fixup_t fixup, const void *fixup_data, adj_flags_t flags, u8 *rewrite)
adj_nbr_midchain_update_rewrite
void cookie_maker_init(cookie_maker_t *cp, const uint8_t key[COOKIE_INPUT_SIZE])
#define pool_foreach_index(i, v)
format_function_t format_vnet_sw_if_index_name
bool wg_send_keepalive(vlib_main_t *vm, wg_peer_t *peer)
description fragment has unexpected format
static clib_error_t * wg_peer_module_init(vlib_main_t *vm)
vl_api_address_t endpoint
static void wg_peer_endpoint_reset(wg_peer_endpoint_t *ep)
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header,...
#define NOISE_PUBLIC_KEY_LEN
format_function_t format_ip46_address
u32 fib_table_get_index_for_sw_if_index(fib_protocol_t proto, u32 sw_if_index)
Get the index of the FIB bound to the interface.
@ FIB_ROUTE_PATH_FLAG_NONE
#define VLIB_INIT_FUNCTION(x)
u8 * format_fib_prefix(u8 *s, va_list *args)
#define vec_foreach(var, vec)
Vector iterator.
static uword pool_elts(void *v)
Number of active elements in a pool.
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static vlib_main_t * vlib_get_main(void)
static u16 ip4_header_checksum(ip4_header_t *i)
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
static wg_peer_t * wg_peer_get(index_t peeri)
enum fib_source_t_ fib_source_t
The different sources that can create a route.
void fib_table_entry_delete_index(fib_node_index_t fib_entry_index, fib_source_t source)
Delete a FIB entry.
u8 * format_wg_peer(u8 *s, va_list *va)
static f64 vlib_time_now(vlib_main_t *vm)
index_t * wg_peer_by_adj_index
static int wg_peer_fill(vlib_main_t *vm, wg_peer_t *peer, u32 table_id, const ip46_address_t *dst, u16 port, u16 persistent_keepalive_interval, const fib_prefix_t *allowed_ips, u32 wg_sw_if_index)
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
static void wg_peer_clear(vlib_main_t *vm, wg_peer_t *peer)
vl_api_interface_index_t sw_if_index
static fib_source_t wg_fib_source
void wg_if_peer_add(wg_if_t *wgi, index_t peeri)
enum walk_rc_t_ walk_rc_t
Walk return code.
@ ADJ_FLAG_MIDCHAIN_IP_STACK
static ip_adjacency_t * adj_get(adj_index_t adj_index)
Get a pointer to an adjacency object from its index.
void wg_timers_stop(wg_peer_t *peer)
Aggregate type for a prefix.
index_t wg_peer_walk(wg_peer_walk_cb_t fn, void *data)
tw_timer_wheel_16t_2w_512sl_t timer_wheel