156 sw_if_index = adj->rewrite_header.sw_if_index;
209 const ip46_address_t *
dst,
211 u16 persistent_keepalive_interval,
226 return (VNET_API_ERROR_INVALID_INTERFACE);
285 if (tun_sw_if_index == ~0)
286 return (VNET_API_ERROR_INVALID_SW_IF_INDEX);
290 return (VNET_API_ERROR_INVALID_SW_IF_INDEX);
297 return (VNET_API_ERROR_ENTRY_ALREADY_EXISTS);
303 return (VNET_API_ERROR_LIMIT_EXCEEDED);
310 persistent_keepalive, allowed_ips, tun_sw_if_index);
342 return VNET_API_ERROR_NO_SUCH_ENTRY;
396 s =
format (s,
"[%d] endpoint:[%U->%U] %U keep-alive:%d adj:%d",
403 s =
format (s,
"\n key:%=s %U",
406 s =
format (s,
"\n allowed-ips:");
static u8 * wg_peer_build_rewrite(const wg_peer_t *peer)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
enum fib_source_t_ fib_source_t
The different sources that can create a route.
#define NOISE_KEY_LEN_BASE64
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.
wg_peer_allowed_ip_t * allowed_ips
#define vec_foreach_index(var, v)
Iterate over vector indices.
static void wg_peer_fib_flush(wg_peer_t *peer)
#define pool_foreach_index(i, v)
u16 persistent_keepalive_interval
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)
vnet_main_t * vnet_get_main(void)
void wg_if_peer_add(wg_if_t *wgi, index_t peeri)
static fib_source_t wg_fib_source
#define pool_foreach(VAR, POOL)
Iterate through pool.
static_always_inline wg_if_t * wg_if_get(index_t wgii)
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
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static f64 vlib_time_now(vlib_main_t *vm)
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.
tw_timer_wheel_16t_2w_512sl_t * timer_wheel
walk_rc_t(* wg_peer_walk_cb_t)(index_t peeri, void *arg)
index_t wg_peer_walk(wg_peer_walk_cb_t fn, void *data)
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
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).
uint8_t r_public[NOISE_PUBLIC_KEY_LEN]
bool key_to_base64(const u8 *src, size_t src_len, u8 *out)
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)
format_function_t format_vnet_sw_if_index_name
void wg_timers_stop(wg_peer_t *peer)
index_t wg_if_find_by_sw_if_index(u32 sw_if_index)
static void wg_peer_adj_stack(wg_peer_t *peer)
enum walk_rc_t_ walk_rc_t
Walk return code.
static void ip46_address_reset(ip46_address_t *ip46)
static ip_adjacency_t * adj_get(adj_index_t adj_index)
Get a pointer to an adjacency object from its index.
#define VLIB_INIT_FUNCTION(x)
vl_api_prefix_t allowed_ips[n_allowed_ips]
description fragment has unexpected format
u8 * format_fib_prefix(u8 *s, va_list *args)
Aggregate type for a prefix.
static void wg_peer_endpoint_init(wg_peer_endpoint_t *ep, const ip46_address_t *addr, u16 port)
void noise_remote_clear(vlib_main_t *vm, noise_remote_t *r)
void adj_unlock(adj_index_t adj_index)
Release a reference counting lock on the adjacency.
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
tw_timer_wheel_16t_2w_512sl_t timer_wheel
#define NOISE_PUBLIC_KEY_LEN
fib_source_t fib_source_allocate(const char *name, fib_source_priority_t prio, fib_source_behaviour_t bh)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static_always_inline void ip46_address_copy(ip46_address_t *dst, const ip46_address_t *src)
static void wg_peer_endpoint_reset(wg_peer_endpoint_t *ep)
void wg_if_peer_remove(wg_if_t *wgi, index_t peeri)
#define pool_put(P, E)
Free an object E in pool P.
#define vec_dup(V)
Return copy of vector (no header, no alignment)
add paths with [mpls] path extensions
fib_protocol_t ip_address_to_46(const ip_address_t *addr, ip46_address_t *a)
void cookie_maker_init(cookie_maker_t *cp, const uint8_t key[COOKIE_INPUT_SIZE])
format_function_t format_ip46_address
vl_api_address_t endpoint
static void wg_peer_fib_populate(wg_peer_t *peer, u32 fib_index)
void fib_table_entry_delete_index(fib_node_index_t fib_entry_index, fib_source_t source)
Delete a FIB entry.
sll srl srl sll sra u16x4 i
static u8 * format_wg_peer_endpoint(u8 *s, va_list *args)
#define vec_free(V)
Free vector's memory (no header).
u32 new_handshake_interval_tick
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
cookie_maker_t cookie_maker
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
static void wg_peer_init(vlib_main_t *vm, wg_peer_t *peer)
void adj_midchain_delegate_unstack(adj_index_t ai)
unstack a midchain delegate (this stacks it on a drop)
fib_node_index_t fib_entry_index
walk_rc_t wg_peer_if_table_change(wg_if_t *wgi, index_t peeri, void *data)
index_t * wg_peer_by_adj_index
bool timer_need_another_keepalive
dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto)
static vlib_main_t * vlib_get_main(void)
static uword vnet_sw_interface_is_admin_up(vnet_main_t *vnm, u32 sw_if_index)
u32 rehandshake_interval_tick
#define FIB_NODE_INDEX_INVALID
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
walk_rc_t wg_peer_if_admin_state_change(wg_if_t *wgi, index_t peeri, void *data)
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
u8 * format_wg_peer(u8 *s, va_list *va)
bool wg_send_keepalive(vlib_main_t *vm, wg_peer_t *peer)
int wg_peer_remove(index_t peeri)
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 vec_foreach(var, vec)
Vector iterator.
static void wg_peer_clear(vlib_main_t *vm, wg_peer_t *peer)
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header, unspecified alignment)
static wg_peer_t * wg_peer_get(index_t peeri)
u32 timer_handshake_attempts
static clib_error_t * wg_peer_module_init(vlib_main_t *vm)
static u16 ip4_header_checksum(ip4_header_t *i)
vl_api_interface_index_t sw_if_index
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
static uword pool_elts(void *v)
Number of active elements in a pool.