Download raw body.
wg(4) logging enhancement - revised patch
On Wed, 22 Jan 2025 22:36:23 +0100,
Lloyd <ng2d68@proton.me> wrote:
>
> @@ -1238,8 +1260,12 @@ wg_send_initiation(void *_peer)
> if (wg_timers_check_handshake_last_sent(&peer->p_timers) != ETIMEDOUT)
> return;
>
> - DPRINTF(peer->p_sc, "Sending handshake initiation to peer %llu\n",
> - peer->p_id);
> + char ipaddr[INET6_ADDRSTRLEN];
> +
> + WGPRINTF(LOG_INFO, peer->p_sc, &peer->p_endpoint_mtx, "Sending "
> + "handshake initiation to peer %llu (%s)\n", peer->p_id,
> + sockaddr_ntop(&peer->p_endpoint.e_remote.r_sa, ipaddr,
> + sizeof(ipaddr)));
I think you should move a declaration of ipaddr to the begining of the
functio, to match the style. Like you did it before.
> @@ -1557,9 +1622,14 @@ wg_encap(struct wg_softc *sc, struct mbuf *m)
> }
>
> /* A packet with length 0 is a keepalive packet */
> - if (__predict_false(m->m_pkthdr.len == 0))
> - DPRINTF(sc, "Sending keepalive packet to peer %llu\n",
> - peer->p_id);
> + if (__predict_false(m->m_pkthdr.len == 0)) {
> + char ipaddr[INET6_ADDRSTRLEN];
> +
> + WGPRINTF(LOG_DEBUG, sc, &peer->p_endpoint_mtx, "Sending "
> + "keepalive packet to peer %llu (%s)\n", peer->p_id,
> + sockaddr_ntop(&peer->p_endpoint.e_remote.r_sa, ipaddr,
> + sizeof(ipaddr)));
> + }
Same here.
> @@ -2058,8 +2135,14 @@ wg_input(void *_sc, struct mbuf *m, struct ip *ip, str
> (m->m_pkthdr.len == sizeof(struct wg_pkt_cookie) &&
> *mtod(m, uint32_t *) == WG_PKT_COOKIE)) {
>
> - if (mq_enqueue(&sc->sc_handshake_queue, m) != 0)
> - DPRINTF(sc, "Dropping handshake packet\n");
> + if (mq_enqueue(&sc->sc_handshake_queue, m) != 0) {
> + char ipaddr[INET6_ADDRSTRLEN];
> +
> + WGPRINTF(LOG_DEBUG, sc, NULL, "Dropping handshake"
> + "packet from %s\n",
> + sockaddr_ntop(&t->t_endpoint.e_remote.r_sa, ipaddr,
> + sizeof(ipaddr)));
> + }
and here.
--
wbr, Kirill
wg(4) logging enhancement - revised patch