diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2019-03-28 01:25:44 +0100 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2020-05-08 18:52:55 +0200 |
commit | 46686164f71d1ea7a906eb551334c4c58d7fcf6e (patch) | |
tree | 194ae2816955434a293ffd7107b415060715f536 | |
parent | 9c3bdd56436665dd93e47f3c62ebe11d4b4c5d2a (diff) |
Wireguard: Use recursive tunnel encaps
-rw-r--r-- | proto/wireguard/wireguard.c | 17 |
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); |