From c714681773bb0b932d55b2028c46e3a7982bdd6a Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Fri, 27 Sep 2019 22:20:59 +0200 Subject: Wireguard: Generalize tunnel encapsulation --- proto/wireguard/wireguard.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'proto/wireguard/wireguard.c') diff --git a/proto/wireguard/wireguard.c b/proto/wireguard/wireguard.c index 6733010d..2c2e6796 100644 --- a/proto/wireguard/wireguard.c +++ b/proto/wireguard/wireguard.c @@ -16,8 +16,6 @@ #include "sysdep/unix/wg_user.h" #include "wireguard.h" -#define BA_TUNNEL_ENCAP 0x17 - static int get_device(struct wg_proto *p, wg_device **pdev, const char *device_name) { @@ -257,7 +255,8 @@ wg_rt_notify(struct proto *P, struct channel *CH, struct network *n, new->attrs->dest, n->n.addr); wg_key pubkey; - memset(pubkey, 0, sizeof(wg_key)); + size_t pubkey_size = sizeof(wg_key); + memset(pubkey, 0, pubkey_size); u32 tunnel_ep_as4 = 0; ip_addr tunnel_ep_addr = IPA_NONE; u16 udp_dest_port = 0; @@ -268,7 +267,7 @@ wg_rt_notify(struct proto *P, struct channel *CH, struct network *n, if (!t && he && he->src) { t = ea_find(he->src->eattrs, EA_CODE(PROTOCOL_BGP, BA_TUNNEL_ENCAP)); } - if (t && t->u.ptr && decode_tunnel_encap(t, c->tunnel_type, &pubkey, &tunnel_ep_as4, &tunnel_ep_addr, &color, &udp_dest_port, &flags) == 0) { + if (t && t->u.ptr && decode_tunnel_encap(t, c->tunnel_type, &pubkey, &pubkey_size, &tunnel_ep_as4, &tunnel_ep_addr, &color, &udp_dest_port, &flags) == 0 && pubkey_size == sizeof(wg_key)) { log(L_TRACE "WG: Attr %x %x %d %04x", t->flags, t->type, t->u.ptr->length, flags); struct wg_device *dev = p->dev; -- cgit v1.2.3