summaryrefslogtreecommitdiff
path: root/proto
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2019-09-27 22:20:59 +0200
committerMikael Magnusson <mikma@users.sourceforge.net>2021-01-12 23:34:17 +0100
commit50e9bf08bd28629353d0c258347ac95ddf3394c7 (patch)
treec8f397407f91ddcfd7c39aa53044f4fa10c1a578 /proto
parentf773a3c93922cb4a122b97082f34053aeaae9f26 (diff)
TunnelEncaps: Generalize tunnel encapsulation
Diffstat (limited to 'proto')
-rw-r--r--proto/wireguard/wireguard.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/proto/wireguard/wireguard.c b/proto/wireguard/wireguard.c
index 212fc779..a355bf43 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;