40 u32 dev_instance = va_arg (*args,
u32);
41 return format (s,
"wg%d", dev_instance);
53 s =
format (s,
"[%d] %U src:%U port:%d",
60 s =
format (s,
" private-key:%s", key);
67 s =
format (s,
" public-key:%s", key);
94 uint8_t *
public =
data;
160 .name =
"Wireguard Tunnel",
175 #define WG_ITF_MAX_INSTANCE (16 * 1024) 251 *sw_if_indexp = (
u32) ~ 0;
258 return VNET_API_ERROR_UDP_PORT_TAKEN;
266 return VNET_API_ERROR_INVALID_REGISTRATION;
269 struct noise_upcall upcall = {
283 return VNET_API_ERROR_INVALID_REGISTRATION;
305 wg_if_device_class.index,
307 wg_hw_interface_class.index, t_idx);
327 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
331 return VNET_API_ERROR_INVALID_VALUE;
336 return VNET_API_ERROR_INVALID_SW_IF_INDEX_2;
339 return VNET_API_ERROR_INVALID_VALUE_2;
392 if (WALK_STOP == fn(wgi, peeri, data))
414 .old_fib_index = old_fib_index,
415 .new_fib_index = new_fib_index,
434 .old_fib_index = old_fib_index,
435 .new_fib_index = new_fib_index,
void udp_unregister_dst_port(vlib_main_t *vm, udp_dst_port_t dst_port, u8 is_ip4)
#define NOISE_KEY_LEN_BASE64
#define hash_set(h, key, value)
ip4_table_bind_function_t * function
#define pool_foreach_index(i, v)
#define hash_unset(h, key)
vl_api_wireguard_peer_flags_t flags
void noise_local_init(noise_local_t *l, struct noise_upcall *upcall)
vnet_main_t * vnet_get_main(void)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
void wg_if_peer_add(wg_if_t *wgi, index_t peeri)
vnet_interface_main_t interface_main
static_always_inline wg_if_t * wg_if_get(index_t wgii)
static f64 vlib_time_now(vlib_main_t *vm)
static uword * wg_if_instances
a non-broadcast multiple access interface
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
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...
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
wg_if_t * wg_if_pool
Data-plane exposed functions.
void udp_register_dst_port(vlib_main_t *vm, udp_dst_port_t dst_port, u32 node_index, u8 is_ip4)
static int wg_if_instance_free(u32 instance)
static uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap. ...
static udp_dst_port_info_t * udp_get_dst_port_info(udp_main_t *um, udp_dst_port_t dst_port, u8 is_ip4)
walk_rc_t(* wg_if_walk_cb_t)(index_t wgi, void *data)
u32 vnet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u32 hw_class_index, u32 hw_instance)
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, vnet_hw_interface_flags_t flags)
#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)
format_function_t format_vnet_sw_if_index_name
index_t wg_if_find_by_sw_if_index(u32 sw_if_index)
enum walk_rc_t_ walk_rc_t
Walk return code.
static u32 wg_if_instance_alloc(u32 want)
#define VLIB_INIT_FUNCTION(x)
description fragment has unexpected format
#define hash_foreach(key_var, value_var, h, body)
index_t wg_if_peer_walk(wg_if_t *wgi, wg_if_peer_walk_cb_t fn, void *data)
int wg_if_delete(u32 sw_if_index)
index_t * wg_if_index_by_port
static u8 * format_wg_if_name(u8 *s, va_list *args)
static void wg_if_table_bind_v6(ip6_main_t *im, uword opaque, u32 sw_if_index, u32 new_fib_index, u32 old_fib_index)
#define NOISE_PUBLIC_KEY_LEN
vlib_node_registration_t wg_input_node
(constructor) VLIB_REGISTER_NODE (wg_input_node)
u8 * format_wg_if(u8 *s, va_list *args)
void wg_if_peer_remove(wg_if_t *wgi, index_t peeri)
static noise_remote_t * wg_remote_get(const uint8_t public[NOISE_PUBLIC_KEY_LEN])
void wg_index_table_del(wg_index_table_t *table, u32 key)
#define pool_put(P, E)
Free an object E in pool P.
ip6_table_bind_callback_t * table_bind_callbacks
Functions to call when interface to table biding changes.
bool noise_local_set_private(noise_local_t *l, const uint8_t private[NOISE_PUBLIC_KEY_LEN])
uint8_t l_public[NOISE_PUBLIC_KEY_LEN]
static uint32_t wg_index_set(noise_remote_t *remote)
static clib_error_t * wg_if_module_init(vlib_main_t *vm)
walk_rc_t(* wg_if_peer_walk_cb_t)(wg_if_t *wgi, index_t peeri, void *data)
u8 * format_ip_address(u8 *s, va_list *args)
static clib_error_t * wg_if_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
u32 adj_index_t
An index for adjacencies.
static uword clib_bitmap_get(uword *ai, uword i)
Gets the ith bit value from a bitmap.
wg_index_table_t index_table
static index_t * wg_if_index_by_sw_if_index
#define pool_put_index(p, i)
Free pool element with given index.
static uword hash_elts(void *v)
walk_rc_t wg_peer_if_table_change(wg_if_t *wgi, index_t peeri, void *data)
void vnet_delete_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
u32 wg_index_table_add(wg_index_table_t *table, u32 peer_pool_idx, u32 rnd_seed)
VNET_HW_INTERFACE_CLASS(wg_hw_interface_class)
VNET_DEVICE_CLASS(wg_if_device_class)
void wg_if_walk(wg_if_walk_cb_t fn, void *data)
void wg_if_update_adj(vnet_main_t *vnm, u32 sw_if_index, adj_index_t ai)
static vlib_main_t * vlib_get_main(void)
ip4_table_bind_callback_t * table_bind_callbacks
Functions to call when interface to table biding changes.
uint8_t l_private[NOISE_PUBLIC_KEY_LEN]
static void wg_index_drop(uint32_t key)
static void wg_if_table_bind_v4(ip4_main_t *im, uword opaque, u32 sw_if_index, u32 new_fib_index, u32 old_fib_index)
#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)
static walk_rc_t wg_if_find_peer_by_public_key(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...
vnet_sw_interface_t * sw_interfaces
ip6_table_bind_function_t * function
void cookie_checker_update(cookie_checker_t *cc, uint8_t key[COOKIE_INPUT_SIZE])
#define WG_ITF_MAX_INSTANCE
void ip_address_copy(ip_address_t *dst, const ip_address_t *src)
ip4_main_t ip4_main
Global ip4 main structure.
static_always_inline noise_local_t * noise_local_get(uint32_t locali)
int wg_if_create(u32 user_instance, const u8 private_key[NOISE_PUBLIC_KEY_LEN], u16 port, const ip_address_t *src_ip, u32 *sw_if_indexp)
uint8_t cc_mac1_key[COOKIE_KEY_SIZE]
cookie_checker_t cookie_checker
static uword clib_bitmap_first_clear(uword *ai)
Return the lowest numbered clear bit in a bitmap.
#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)
noise_local_t * noise_local_pool
static wg_peer_t * wg_peer_get(index_t peeri)
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)