From nobody Wed Mar 02 16:00:44 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 0342B19E090D; Wed, 2 Mar 2022 16:00:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4K7zNs1Gdgz3N67; Wed, 2 Mar 2022 16:00:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646236845; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4ezyJ0LUBlONXwUCX5kj4PaSfA2jgCdMN5FzXmwzCpo=; b=A1KOgDjB4wo9V3wQRst/w8Gy9v0jwO8SmaoR7+EZBAosUzEJs5vC/P8Tefg5dMSIsJosLY okB2RmGQAioPBuVvleQnHDGdQlEs6g8dTf8SvqPKr1xrjuyWYV3WSfbKFEd8CRuaYKbugq 5aQcbItNZdPhPXYTdmeKIuTIsYuc3YI66TqJWzuHfcq0dXpsBPirSdYkpWI1BfHV5Z/n7r 85tC4XQ4fXTKQqZ3N8h5sIz7ebCAfgG4DWdEzrSyoqUNSqk2GEWU7i/6JwIb3F9GqaVmoh /k6khLOKkKXgl0Pki6rhJzmsu2epG4Jc4ZO4UcvF/yhjUn/Of8rlE4kFBw8mPw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B8D0626227; Wed, 2 Mar 2022 16:00:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 222G0irX091031; Wed, 2 Mar 2022 16:00:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 222G0iST091029; Wed, 2 Mar 2022 16:00:44 GMT (envelope-from git) Date: Wed, 2 Mar 2022 16:00:44 GMT Message-Id: <202203021600.222G0iST091029@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 5c75dfdf6056 - main - pf: SDTs for ether rule matching List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5c75dfdf6056f68d8d750b52b385018b5be31e13 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646236845; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4ezyJ0LUBlONXwUCX5kj4PaSfA2jgCdMN5FzXmwzCpo=; b=NpKmoLpDIj58WZhyL1UmpV7i/Y6p8GhhyeQKXbjGGWWcPbiEqI6Z+IiYcP8SEVWOFhdjQg SZuHj2qIA5pJQu2SYsdkZ2pvXiEa3aUU3KNOX06ETOmqAdxnZA77uNeVxPsmwckc1Cz+Tc hxtnPt02b5LJtyv4BtyPTTmOZFYhLw6vYFL6Lu0NQyLkzQispnXbOpY8MwFiAmzH1y60mK fC6yM3YcdNjgl6RTaJR9JVcYc+vxCtjvCFi+wEUeMd+Dk16RMZ9xuwaHFanyJYYdGdDKs1 t90hx3PRyVjL7jXOaJkRr6xj0spdWvpMMNqiMDLk6g5B9VYz5kuze59SOxGdvw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646236845; a=rsa-sha256; cv=none; b=f+sMBVE1uSFCqvVZZkFAmXXDZUhfm1Zj9VtmHKiEBPpL2uar8lC3XTyfTWeU8MyAeGub6N NYABXcIuML5+OoX1cHBuU8pElMuOinBPvUjCgyWs8JkzWOvddMfEuKp74SB8YF8yeAI/1O V+a/idHXdenmjkNLTBo74OCXubiprQRd7WdAe0keyJ3UulwlUMxW3aFPEz5ydYYG0ns6qd V/wnqO3K6AG0yI6cNZmpnO9M2biczERwUIJPzNS0Xtq4q12Cv8C22Qu1S1pOOgiL3paf2I 3DvgR7Q50eEBDBge4BdL7fQQCMkLhgzi81zS8su8772dytvAk7BPouqIrTjEHg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=5c75dfdf6056f68d8d750b52b385018b5be31e13 commit 5c75dfdf6056f68d8d750b52b385018b5be31e13 Author: Kristof Provost AuthorDate: 2021-02-16 09:08:26 +0000 Commit: Kristof Provost CommitDate: 2022-03-02 16:00:04 +0000 pf: SDTs for ether rule matching Add static DTrace probe points to allow debugging of ether rule matching. Reviewed by: mjg Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31741 --- sys/netpfil/pf/pf.c | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index c45880a6974b..8bf309caf7d4 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -129,6 +129,15 @@ SDT_PROBE_DEFINE5(pf, ip, state, lookup, "struct pfi_kkif *", "struct pf_state_key_cmp *", "int", "struct pf_pdesc *", "struct pf_kstate *"); +SDT_PROBE_DEFINE3(pf, eth, test_rule, entry, "int", "struct ifnet *", + "struct mbuf *"); +SDT_PROBE_DEFINE2(pf, eth, test_rule, test, "int", "struct pf_keth_rule *"); +SDT_PROBE_DEFINE3(pf, eth, test_rule, mismatch, + "int", "struct pf_keth_rule *", "char *"); +SDT_PROBE_DEFINE2(pf, eth, test_rule, match, "int", "struct pf_keth_rule *"); +SDT_PROBE_DEFINE2(pf, eth, test_rule, final_match, + "int", "struct pf_keth_rule *"); + /* * Global variables */ @@ -3720,6 +3729,8 @@ pf_test_eth_rule(int dir, struct pfi_kkif *kif, struct mbuf *m) MPASS(kif->pfik_ifp->if_vnet == curvnet); NET_EPOCH_ASSERT(); + SDT_PROBE3(pf, eth, test_rule, entry, dir, kif->pfik_ifp, m); + e = mtod(m, struct ether_header *); settings = ck_pr_load_ptr(&V_pf_keth); @@ -3728,21 +3739,39 @@ pf_test_eth_rule(int dir, struct pfi_kkif *kif, struct mbuf *m) while (r != NULL) { counter_u64_add(r->evaluations, 1); - if (pfi_kkif_match(r->kif, kif) == r->ifnot) + SDT_PROBE2(pf, eth, test_rule, test, r->nr, r); + + if (pfi_kkif_match(r->kif, kif) == r->ifnot) { + SDT_PROBE3(pf, eth, test_rule, mismatch, r->nr, r, + "kif"); r = r->skip[PFE_SKIP_IFP].ptr; - else if (r->direction && r->direction != dir) + } + else if (r->direction && r->direction != dir) { + SDT_PROBE3(pf, eth, test_rule, mismatch, r->nr, r, + "dir"); r = r->skip[PFE_SKIP_DIR].ptr; - else if (r->proto && r->proto != ntohs(e->ether_type)) + } + else if (r->proto && r->proto != ntohs(e->ether_type)) { + SDT_PROBE3(pf, eth, test_rule, mismatch, r->nr, r, + "proto"); r = r->skip[PFE_SKIP_PROTO].ptr; - else if (! pf_match_eth_addr(e->ether_shost, &r->src)) + } + else if (! pf_match_eth_addr(e->ether_shost, &r->src)) { + SDT_PROBE3(pf, eth, test_rule, mismatch, r->nr, r, + "src"); r = r->skip[PFE_SKIP_SRC_ADDR].ptr; + } else if (! pf_match_eth_addr(e->ether_dhost, &r->dst)) { + SDT_PROBE3(pf, eth, test_rule, mismatch, r->nr, r, + "dst"); r = TAILQ_NEXT(r, entries); } else { /* Rule matches */ rm = r; + SDT_PROBE2(pf, eth, test_rule, match, r->nr, r); + if (r->quick) break; @@ -3752,6 +3781,8 @@ pf_test_eth_rule(int dir, struct pfi_kkif *kif, struct mbuf *m) r = rm; + SDT_PROBE2(pf, eth, test_rule, final_match, (r != NULL ? r->nr : -1), r); + /* Default to pass. */ if (r == NULL) return (PF_PASS);