diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2019-10-01 19:06:27 +0200 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2020-05-08 18:52:55 +0200 |
commit | a3ac30fd374a665c67ca0718ce9999f8f0c03be2 (patch) | |
tree | 2143e5a6ed769fb8d53125ed06a78bb1dde3f363 | |
parent | e58547642077da985fcc721e0625b02b4e9ddd45 (diff) |
WIP
-rw-r--r-- | filter/filter.c | 2 | ||||
-rw-r--r-- | lib/tunnel_encaps.c | 20 | ||||
-rw-r--r-- | lib/tunnel_encaps.h | 6 | ||||
-rw-r--r-- | nest/rt-show.c | 2 | ||||
-rw-r--r-- | proto/wireguard/wireguard.c | 5 |
5 files changed, 34 insertions, 1 deletions
diff --git a/filter/filter.c b/filter/filter.c index ff8a2a9b..5549c56c 100644 --- a/filter/filter.c +++ b/filter/filter.c @@ -44,6 +44,8 @@ #include "filter/f-inst.h" #include "filter/data.h" +#undef DEBUGGING + /* Exception bits */ enum f_exception { diff --git a/lib/tunnel_encaps.c b/lib/tunnel_encaps.c index 590cf958..b77bc710 100644 --- a/lib/tunnel_encaps.c +++ b/lib/tunnel_encaps.c @@ -58,7 +58,19 @@ int decode_tunnel_ep(const void *p, size_t sub_tlv_len, struct tunnel_encap *enc encap->ep.asn = get_u32(p); u16 af = get_u16(p + 4); + encap->ep.af = af; switch (af) { + case 0: + if (sub_tlv_len != 6) { + log(L_TRACE "WG: Fam 0 len error %d", sub_tlv_len); + return -1; + } + if (encap->ep.asn != 0) { + log(L_TRACE "WG: Fam 0 asn error %d", sub_tlv_len); + return -1; + } + encap->ep.ip = IP6_NONE; + return 0; case NET_IP4: if (sub_tlv_len != 10) { log(L_TRACE "WG: IPv4 len error %d", sub_tlv_len); @@ -289,3 +301,11 @@ int format_tunnel_encap(const eattr *a, byte *buf, uint size) return pos - buf; } + +void register_format_tunnel_encap(int type, format_tunnel_encap_fn cb) +{ +} + +void unregister_format_tunnel_encap(int type, format_tunnel_encap_fn cb) +{ +} diff --git a/lib/tunnel_encaps.h b/lib/tunnel_encaps.h index 7358947e..12a905db 100644 --- a/lib/tunnel_encaps.h +++ b/lib/tunnel_encaps.h @@ -19,6 +19,7 @@ /* Tunnel Encapsulation */ struct tunnel_endpoint { u32 asn; + u16 af; ip_addr ip; }; @@ -32,8 +33,13 @@ struct tunnel_encap { u16 flags; }; +typedef int (*format_tunnel_encap_fn)(const struct tunnel_encap *, byte *buf, uint size); + int decode_tunnel_encap(const eattr *e, struct tunnel_encap *encap, struct pool *pool); int format_tunnel_encap(const eattr *a, byte *buf, uint size); +void register_format_tunnel_encap(int type, format_tunnel_encap_fn cb); +void unregister_format_tunnel_encap(int type, format_tunnel_encap_fn cb); + #endif /* _BIRD_TUNNEL_ENCAPS_ */ diff --git a/nest/rt-show.c b/nest/rt-show.c index a730881b..62a47010 100644 --- a/nest/rt-show.c +++ b/nest/rt-show.c @@ -54,7 +54,7 @@ rt_show_rte(struct cli *c, byte *ia, rte *e, struct rt_show_data *d, int primary /* Need to normalize the extended attributes */ if (d->verbose && !rta_is_cached(a) && a->eattrs) - if (a->eattrs) +// if (a->eattrs) ea_normalize(a->eattrs); get_route_info = a->src->proto->proto->get_route_info; diff --git a/proto/wireguard/wireguard.c b/proto/wireguard/wireguard.c index 90740490..9e7442b0 100644 --- a/proto/wireguard/wireguard.c +++ b/proto/wireguard/wireguard.c @@ -431,6 +431,8 @@ wg_rt_notify(struct proto *P, struct channel *CH, struct network *n, if (!found) { peer = add_peer(dev, pubkey); } + + dump_peer(peer); if (is_tunnel_ep) set_peer_tunnel_ep(peer, encap.ep.ip, encap.udp_dest_port); if (add_ip) @@ -550,10 +552,13 @@ wg_rt_notify(struct proto *P, struct channel *CH, struct network *n, if (found) { struct wg_allowedip *allowedip = alloca(sizeof(struct wg_allowedip)); init_allowed_ip(allowedip, ch->c.net_type, n); + dump_peer(peer); if (remove_allowed_ip(peer, allowedip)) { ip_addr ip = allowedip_to_ipa(allowedip); log(L_TRACE "WG: removed %I/%d", ip, allowedip->cidr); peer->flags |= WGPEER_REPLACE_ALLOWEDIPS; + + dump_peer(peer); } } } |