git: 49e0e1481778 - stable/14 - pf: add sctp multihome probe points

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Thu, 13 Jun 2024 12:44:47 UTC
The branch stable/14 has been updated by kp:

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

commit 49e0e148177897d0d7a6e9ac6d0413a8b38681f9
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2024-06-06 15:35:09 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2024-06-13 12:17:34 +0000

    pf: add sctp multihome probe points
    
    Add probe points to allow us to probe when we add or remove multihome addresses.
    
    Example use:
            pf:sctp:multihome:add
            {
                    printf("Add tag %x address %x", arg0,
                        ((struct pf_sctp_source *)arg1)->addr.v4.s_addr);
            }
    
            pf:sctp:multihome:remove
            {
                    printf("Remove tag %x address %x", arg0,
                        ((struct pf_sctp_source *)arg2)->addr.v4.s_addr);
            }
    
    MFC after:      1 week
    Sponsored by:   Orange Business Services
    
    (cherry picked from commit f042e1515433456dca4a2be8ec8ac60c75860304)
---
 sys/netpfil/pf/pf.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c
index 6874dd59c1f7..ae0c5dcf8128 100644
--- a/sys/netpfil/pf/pf.c
+++ b/sys/netpfil/pf/pf.c
@@ -128,6 +128,10 @@ SDT_PROBE_DEFINE5(pf, ip, state, lookup, "struct pfi_kkif *",
     "struct pf_kstate *");
 SDT_PROBE_DEFINE4(pf, sctp, multihome, test, "struct pfi_kkif *",
     "struct pf_krule *", "struct mbuf *", "int");
+SDT_PROBE_DEFINE2(pf, sctp, multihome, add, "uint32_t",
+    "struct pf_sctp_source *");
+SDT_PROBE_DEFINE3(pf, sctp, multihome, remove, "uint32_t",
+    "struct pf_kstate *", "struct pf_sctp_source *");
 
 SDT_PROBE_DEFINE3(pf, eth, test_rule, entry, "int", "struct ifnet *",
     "struct mbuf *");
@@ -6001,11 +6005,12 @@ pf_sctp_multihome_detach_addr(const struct pf_kstate *s)
 	key.v_tag = s->dst.scrub->pfss_v_tag;
 	ep  = RB_FIND(pf_sctp_endpoints, &V_pf_sctp_endpoints, &key);
 	if (ep != NULL) {
-		/* XXX Actually remove! */
 		TAILQ_FOREACH_SAFE(i, &ep->sources, entry, tmp) {
 			if (pf_addr_cmp(&i->addr,
 			    &s->key[PF_SK_WIRE]->addr[s->direction == PF_OUT],
 			    s->key[PF_SK_WIRE]->af) == 0) {
+				SDT_PROBE3(pf, sctp, multihome, remove,
+				    key.v_tag, s, i);
 				TAILQ_REMOVE(&ep->sources, i, entry);
 				free(i, M_PFTEMP);
 				break;
@@ -6026,6 +6031,8 @@ pf_sctp_multihome_detach_addr(const struct pf_kstate *s)
 			if (pf_addr_cmp(&i->addr,
 			    &s->key[PF_SK_WIRE]->addr[s->direction == PF_IN],
 			    s->key[PF_SK_WIRE]->af) == 0) {
+				SDT_PROBE3(pf, sctp, multihome, remove,
+				    key.v_tag, s, i);
 				TAILQ_REMOVE(&ep->sources, i, entry);
 				free(i, M_PFTEMP);
 				break;
@@ -6083,6 +6090,7 @@ pf_sctp_multihome_add_addr(struct pf_pdesc *pd, struct pf_addr *a, uint32_t v_ta
 	i->af = pd->af;
 	memcpy(&i->addr, a, sizeof(*a));
 	TAILQ_INSERT_TAIL(&ep->sources, i, entry);
+	SDT_PROBE2(pf, sctp, multihome, add, v_tag, i);
 
 	PF_SCTP_ENDPOINTS_UNLOCK();
 }