From fee9853a4f5d9a180ef6309cc37bd4060d27a51e Mon Sep 17 00:00:00 2001 From: Alexander Chernavin Date: Thu, 4 Aug 2022 08:11:57 +0000 Subject: wireguard: add peers roaming support Type: feature With this change, peers are able to roam between different external endpoints. Successfully authenticated handshake or data packet that is received from a new endpoint will cause the peer's endpoint to be updated accordingly. Signed-off-by: Alexander Chernavin Change-Id: Ib4eb7dfa3403f3fb9e8bbe19ba6237c4960c764c --- src/plugins/wireguard/wireguard_peer.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/plugins/wireguard/wireguard_peer.h') diff --git a/src/plugins/wireguard/wireguard_peer.h b/src/plugins/wireguard/wireguard_peer.h index a14f2692b1c..c07ea894b36 100644 --- a/src/plugins/wireguard/wireguard_peer.h +++ b/src/plugins/wireguard/wireguard_peer.h @@ -68,6 +68,13 @@ typedef enum WG_PEER_ESTABLISHED = 0x2, } wg_peer_flags; +typedef struct wg_peer_adj_t_ +{ + adj_index_t adj_index; + fib_node_index_t fib_entry_index; + u32 sibling_index; +} wg_peer_adj_t; + typedef struct wg_peer { noise_remote_t remote; @@ -80,7 +87,7 @@ typedef struct wg_peer wg_peer_endpoint_t dst; wg_peer_endpoint_t src; u32 table_id; - adj_index_t *adj_indices; + wg_peer_adj_t *adjs; /* rewrite built from address information */ u8 *rewrite; @@ -144,6 +151,10 @@ adj_walk_rc_t wg_peer_adj_walk (adj_index_t ai, void *data); void wg_api_peer_event (index_t peeri, wg_peer_flags flags); void wg_peer_update_flags (index_t peeri, wg_peer_flags flag, bool add_del); +void wg_peer_update_endpoint (index_t peeri, const ip46_address_t *addr, + u16 port); +void wg_peer_update_endpoint_from_mt (index_t peeri, + const ip46_address_t *addr, u16 port); static inline bool wg_peer_is_dead (wg_peer_t *peer) @@ -200,6 +211,12 @@ fib_prefix_is_cover_addr_46 (const fib_prefix_t *p1, const ip46_address_t *ip) return (false); } +static inline bool +wg_peer_can_send (wg_peer_t *peer) +{ + return peer && peer->rewrite; +} + #endif // __included_wg_peer_h__ /* -- cgit 1.2.3-korg