git: b33308db391d - main - if_ovpn: static probe points

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Tue, 28 Jun 2022 11:59:34 UTC
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=b33308db391d74271bc3c44c31c6e4ff8f1594d0

commit b33308db391d74271bc3c44c31c6e4ff8f1594d0
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2022-05-12 19:48:23 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2022-06-28 11:50:54 +0000

    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 57e85a414592..33ccea02e099 100644
--- a/sys/net/if_ovpn.c
+++ b/sys/net/if_ovpn.c
@@ -42,6 +42,7 @@
 #include <sys/priv.h>
 #include <sys/protosw.h>
 #include <sys/rmlock.h>
+#include <sys/sdt.h>
 #include <sys/smp.h>
 #include <sys/socket.h>
 #include <sys/socketvar.h>
@@ -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);