From b33308db391d74271bc3c44c31c6e4ff8f1594d0 Mon Sep 17 00:00:00 2001 From: Kristof Provost Date: Thu, 12 May 2022 21:48:23 +0200 Subject: [PATCH] if_ovpn: static probe points Sprinkle a few SDTs around if_ovpn to ease debugging. Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/net/if_ovpn.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/sys/net/if_ovpn.c b/sys/net/if_ovpn.c index 57e85a41459..33ccea02e09 100644 --- a/sys/net/if_ovpn.c +++ b/sys/net/if_ovpn.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -216,6 +217,11 @@ VNET_DEFINE_STATIC(struct if_clone *, ovpn_cloner); #define TO_IN(x) ((struct sockaddr_in *)(x)) #define TO_IN6(x) ((struct sockaddr_in6 *)(x)) +SDT_PROVIDER_DEFINE(if_ovpn); +SDT_PROBE_DEFINE1(if_ovpn, tx, transmit, start, "struct mbuf *"); +SDT_PROBE_DEFINE2(if_ovpn, tx, route, ip4, "struct in_addr *", "struct ovpn_kpeer *"); +SDT_PROBE_DEFINE2(if_ovpn, tx, route, ip6, "struct in6_addr *", "struct ovpn_kpeer *"); + static const char ovpnname[] = "ovpn"; static const char ovpngroupname[] = "openvpn"; @@ -1636,12 +1642,16 @@ ovpn_route_peer(struct ovpn_softc *sc, struct mbuf **m0, } peer = ovpn_find_peer_by_ip(sc, *ip_dst); + SDT_PROBE2(if_ovpn, tx, route, ip4, ip_dst, peer); if (peer == NULL) { nh = fib4_lookup(M_GETFIB(*m0), *ip_dst, 0, NHR_NONE, 0); - if (nh && (nh->nh_flags & NHF_GATEWAY)) + if (nh && (nh->nh_flags & NHF_GATEWAY)) { peer = ovpn_find_peer_by_ip(sc, nh->gw4_sa.sin_addr); + SDT_PROBE2(if_ovpn, tx, route, ip4, + &nh->gw4_sa.sin_addr, peer); + } } break; } @@ -1666,12 +1676,16 @@ ovpn_route_peer(struct ovpn_softc *sc, struct mbuf **m0, } peer = ovpn_find_peer_by_ip6(sc, ip6_dst); + SDT_PROBE2(if_ovpn, tx, route, ip6, ip6_dst, peer); if (peer == NULL) { nh = fib6_lookup(M_GETFIB(*m0), ip6_dst, 0, NHR_NONE, 0); - if (nh && (nh->nh_flags & NHF_GATEWAY)) + if (nh && (nh->nh_flags & NHF_GATEWAY)) { peer = ovpn_find_peer_by_ip6(sc, &nh->gw6_sa.sin6_addr); + SDT_PROBE2(if_ovpn, tx, route, ip6, + &nh->gw6_sa.sin6_addr, peer); + } } break; } @@ -1958,6 +1972,8 @@ ovpn_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, OVPN_RLOCK(sc); + SDT_PROBE1(if_ovpn, tx, transmit, start, m); + if (__predict_false(ifp->if_link_state != LINK_STATE_UP)) { OVPN_COUNTER_ADD(sc, lost_data_pkts_out, 1); OVPN_RUNLOCK(sc);