aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Dunwoodie <ncon@mail.noconroy.net>2019-10-01 20:34:01 +0100
committerMatt Dunwoodie <ncon@mail.noconroy.net>2019-10-01 20:34:01 +0100
commit98bcf27de0e2a1dffb2a9f3c4d2297036d8df053 (patch)
tree99c8fbd19ed55005e8fe7cccfee70b0adf06bfab
parentBig re-work of wireguard.c (diff)
downloadwireguard-openbsd-98bcf27de0e2a1dffb2a9f3c4d2297036d8df053.tar.xz
wireguard-openbsd-98bcf27de0e2a1dffb2a9f3c4d2297036d8df053.zip
Update DPRINTF calls to report the interface name.
-rw-r--r--src/if_wg.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/if_wg.c b/src/if_wg.c
index 53b4f15..a69d2ee 100644
--- a/src/if_wg.c
+++ b/src/if_wg.c
@@ -104,8 +104,12 @@ struct bloom_bucket wg_bb;
struct bloom_bucket wg_bb_verified;
+#define DPRINTF(sc, str, ...) do { if (ISSET((sc)->sc_if.if_flags, IFF_DEBUG)) \
+ printf("%s: " str, (sc)->sc_if.if_xname, __VA_ARGS__); } while (0)
+/*
#define DPRINTF(sc, ...) do { if (ISSET((sc)->sc_if.if_flags, IFF_DEBUG)) \
printf("wg: " __VA_ARGS__); } while (0)
+*/
#ifdef INET6
#define AF_VAL(af, v4, v6) ((af) == AF_INET ? v4 : (af) == AF_INET6 ? v6 : 0)
@@ -327,7 +331,8 @@ wg_mbuf_ratelimit(struct wg_softc *sc, struct mbuf *m)
sizeof(struct wg_msg_cookie));
struct wg_msg_cookie *cookie = mtod(m, struct wg_msg_cookie *);
- DPRINTF(sc, "transmit cookie\n");
+ /* TODO print ip */
+ DPRINTF(sc, "transmit cookie %d\n", 0);
wg_device_make_cookie(&sc->sc_dev, &c, sender, mac, cookie);
@@ -382,6 +387,7 @@ wg_route_send_initiation(struct wg_route *r)
void
wg_route_broken(struct wg_route *r)
{
+ DPRINTF(r->r_sc, "broken session %x\n", r->r_peer->p_id);
wg_peer_clean(r->r_peer);
wg_route_queue(r, WG_PKT_INITIATION);
}
@@ -395,6 +401,7 @@ wg_route_send_keepalive(struct wg_route *r)
void
wg_route_clean(struct wg_route *r)
{
+ DPRINTF(r->r_sc, "cleaning %x\n", r->r_peer->p_id);
wg_peer_clean(r->r_peer);
}
@@ -463,8 +470,8 @@ wg_encrypt_hs(struct mbuf *m)
panic("invalid packet type: %d\n", tag->t_type);
}
- DPRINTF(tag->t_sc, "%s tx for %x\n", wg_pkt_str[tag->t_type],
- session->s_local_id);
+ DPRINTF(tag->t_sc, "%s tx for %x, id %x\n", wg_pkt_str[tag->t_type],
+ session->s_peer->p_id, session->s_local_id);
m->m_pkthdr.ph_cookie = m;
tag->t_state = WG_PKT_STATE_DONE;
@@ -516,7 +523,7 @@ wg_encrypt(struct mbuf *m)
ifc_obytes, plain_len);
wg_timer_broken_flag(&session->s_peer->p_timers);
} else {
- DPRINTF(tag->t_sc, "send keepalive\n");
+ DPRINTF(tag->t_sc, "send keepalive %x\n", session->s_local_id);
}
wg_timer_keepalive_unflag(&session->s_peer->p_timers);
@@ -576,7 +583,8 @@ wg_decrypt_hs(struct mbuf *m)
panic("not a handshake packet: %d", tag->t_type);
}
- DPRINTF(tag->t_sc, "%s rx for %x\n", wg_pkt_str[tag->t_type], session->s_local_id);
+ DPRINTF(tag->t_sc, "%s rx for %x, id %x\n", wg_pkt_str[tag->t_type],
+ session->s_peer->p_id, session->s_local_id);
tag->t_state = WG_PKT_STATE_DONE;
peer_route(session->s_peer)->r_ip = tag->t_ip;
@@ -609,7 +617,7 @@ wg_decrypt(struct mbuf *m)
if (m->m_pkthdr.len == WG_ENCRYPTED_SIZE(0)) {
tag->t_state = WG_PKT_STATE_DEAD;
- DPRINTF(tag->t_sc, "recv keepalive\n");
+ DPRINTF(tag->t_sc, "recv keepalive %x\n", session->s_local_id);
goto keepalive;
}
@@ -1053,6 +1061,8 @@ wg_ioctl_set_peer(struct wg_softc *sc, u_long cmd, struct wg_set_peer *wsp)
(void (*)(void *)) wg_route_broken,
(void (*)(void *)) wg_route_send_initiation,
(void (*)(void *)) wg_route_clean);
+
+ DPRINTF(sc, "added peer: %x\n", peer->p_id);
} else {
route = peer->p_arg;
}
@@ -1072,6 +1082,7 @@ wg_ioctl_set_peer(struct wg_softc *sc, u_long cmd, struct wg_set_peer *wsp)
wg_timer_persistent_keepalive_set(&peer->p_timers, wsp->sp_pka);
break;
case SIOCDWGPEER:
+ DPRINTF(sc, "deleted peer: %x\n", peer->p_id);
SLIST_FOREACH_SAFE(raip, &route->r_aip, r_entry, traip)
wg_softc_route_delete(sc, &raip->r_cidr);
wg_peer_put(peer);