From 46686164f71d1ea7a906eb551334c4c58d7fcf6e Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Thu, 28 Mar 2019 01:25:44 +0100 Subject: Wireguard: Use recursive tunnel encaps --- proto/wireguard/wireguard.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/proto/wireguard/wireguard.c b/proto/wireguard/wireguard.c index ade81f1a..970a383f 100644 --- a/proto/wireguard/wireguard.c +++ b/proto/wireguard/wireguard.c @@ -385,13 +385,23 @@ wg_rt_notify(struct proto *P, struct channel *CH, struct network *n, // debug("WG: notify\n"); if (new) { - iface = new->attrs->nh.iface; + struct nexthop *nh = &new->attrs->nh; + iface = nh->iface; ifname = iface ? iface->name : NULL; if (iface && iface == p->iface) { struct eattr *t; - debug("WG: found iface\n"); + debug("WG: found %p iface %I %p\n", new->attrs, nh->gw, nh->next); + + struct hostentry *he = new->attrs->hostentry; + + debug("WG: he %p src %p\n", he, he?he->src:NULL); + if (he && he->src) { + struct eattr *t = ea_find(he->src->eattrs, EA_CODE(PROTOCOL_BGP, BA_TUNNEL_ENCAP)); + debug("WG: he %p %I %I %p %p %I\n", t, he->addr, he->link, he->next, he->src->hostentry, he->src->nh.gw); + } + en = fib_get(&ch->rtable, n->n.addr); debug("WG: notify new %d %N\n", @@ -406,6 +416,9 @@ wg_rt_notify(struct proto *P, struct channel *CH, struct network *n, u16 flags = 0; t = ea_find(new->attrs->eattrs, EA_CODE(PROTOCOL_BGP, BA_TUNNEL_ENCAP)); + 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, &pubkey, &remote_ep_as4, &remote_ep_addr, &color, &udp_dest_port, &flags) == 0) { log(L_TRACE "WG: Attr %x %x %d %04x", t->flags, t->type, t->u.ptr->length, flags); -- cgit v1.2.3