summaryrefslogtreecommitdiff
path: root/proto/wireguard
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2019-03-28 01:25:44 +0100
committerMikael Magnusson <mikma@users.sourceforge.net>2020-09-13 18:05:34 +0200
commita18045ab367a31fdd616a00c376fb3610c8ceca0 (patch)
treebec041ad9f07d90ad26e305256bffefb26e88445 /proto/wireguard
parent036bb6a6da613033ac5bb2e742dd24c287fe3a89 (diff)
Wireguard: Use recursive tunnel encaps
Diffstat (limited to 'proto/wireguard')
-rw-r--r--proto/wireguard/wireguard.c17
1 files 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);