diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2019-03-28 01:25:44 +0100 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2021-01-12 23:34:17 +0100 |
commit | f0d7e5f600985d37c18b9d2a00498c151174eeaf (patch) | |
tree | 7b3082d3ee06ac8ab8011380cc864b0a65d100c6 /proto | |
parent | fae2aebea7c9d41478c0ce2b919d02b1222d7511 (diff) |
Wireguard: Use recursive tunnel encaps
Diffstat (limited to 'proto')
-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); |