summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2019-03-01 21:53:19 +0100
committerMikael Magnusson <mikma@users.sourceforge.net>2019-04-02 00:27:38 +0200
commit4cac57b0dc71d761e46f28f3b5633dec0f2c2707 (patch)
tree19a00ffcb5695c6db8da6fdd4a35e273cf6bb031
parent42f647f4f699093ef436828da502a24088b9253c (diff)
Wireguard: Debug
-rw-r--r--proto/wireguard/wireguard.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/proto/wireguard/wireguard.c b/proto/wireguard/wireguard.c
index cdc50317..d959de6f 100644
--- a/proto/wireguard/wireguard.c
+++ b/proto/wireguard/wireguard.c
@@ -35,6 +35,17 @@ wg_if_notify(struct proto *P, unsigned flags, struct iface *i)
}
static void
+dump(void *ptr, size_t len)
+{
+ unsigned char *data = ptr;
+
+ for (size_t i=0; i<len; i++) {
+ fprintf(stderr, "%02x ", data[i]);
+ }
+ fprintf(stderr, "\n");
+}
+
+static void
wg_rt_notify(struct proto *P, struct channel *ch UNUSED, struct network *n,
struct rte *new, struct rte *old UNUSED)
{
@@ -168,8 +179,10 @@ wg_rt_notify(struct proto *P, struct channel *ch UNUSED, struct network *n,
/* Withdraw */
en = fib_find(&p->rtable, n->n.addr);
- if (!en) // || en->valid != RIP_ENTRY_VALID)
+ if (!en) { // || en->valid != RIP_ENTRY_VALID)
+ debug("WG: fib not found\n");
return;
+ }
struct wg_device *dev = NULL;
@@ -201,16 +214,21 @@ wg_rt_notify(struct proto *P, struct channel *ch UNUSED, struct network *n,
wg_for_each_allowedip(peer, ip) {
if (allowedip->family != ip->family) {
+ debug("WG: family no match\n");
previp = ip;
continue;
}
if (allowedip->cidr != ip->cidr) {
+ debug("WG: cidr no match\n");
previp = ip;
continue;
}
if (memcmp(&allowedip->ip6, &ip->ip6, sizeof(struct in6_addr))) {
+ debug("WG: ip no match\n");
+ dump(&allowedip->ip6, sizeof(struct in6_addr));
+ dump(&ip->ip6, sizeof(struct in6_addr));
previp = ip;
continue;
}