From nobody Mon Jun 17 04:28:02 2024 X-Original-To: dev-commits-src-all@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 4W2cLq1dszz5NGNd; Mon, 17 Jun 2024 04:28:03 +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 4W2cLp6r21z4twR; Mon, 17 Jun 2024 04:28:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718598483; 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=BfSswwa1rz2haaSlVTqQ+kpsHR/USrKt6SdrbLfn/ZM=; b=Syi7XEfs8dEqJ0VBYIh7T5FnGAoPuCU3iW2770rHMBrkcoRqyaB2w8g0Rv6FmsLO9Oetjm qv5VGMG7Q6Gyo93kpp31b1cqqmefK3v4377HbAmATlioAk1Q/fEsFsPZYf6S15tpQs3FWo M6ErILaPL3ZOduOY7cGcX8tIYCNqNon3al6OTu7APjKFx4Qy0ccdB/v3pZC8AvoXOzu/y8 rkIjdIHBSNgLsUlFo2yhENNCTXrifp1VDZOxRP/bH1zfYgtatv8D/qvGfiEvLorRtR/2JF JQA8Xfu4dFmdL/FiClsLkHh77W2SxotBcUZAlgvIZzh5T6KKLkXdNm8sp8VFYQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1718598483; a=rsa-sha256; cv=none; b=BJySJcuN/T//rN8KH9++77XFSQoR29LLGjZJ1oK3j5zh6+4axNdfVhzBslUfxnEVRZXaMw zWW1KeqaytvMNbxk6Mu64hGw/DWw2d75pyzLa5UbRSsDVfmb/PcREL/DnA7l0MFrMQW5SW EWvr4gyHB0h2ZCPoVsxU/i7gbErxMj2BbROKPi//oSrzNmrzz6d5YOwwL0aiUBuTcfC6o9 AJZDKv87euau0PE1uQts9rJegYK6gbXeHxVwjS4R1/OpzCpgymio5A4XMLrNUueb7X0q8A hBfam+N8mV0GH143K/RAx2HYGbCZIEOoBMwjQHmspfJl8AOQ9W4Uf9ahdeXx7g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718598483; 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=BfSswwa1rz2haaSlVTqQ+kpsHR/USrKt6SdrbLfn/ZM=; b=PiIA1TmqWcWeloJCt9k9VzQq2b/AFbEn9uWv+Q4XneHxZOXXjhu8Fngjx01ksFb/f3aaaX SLn1Q7BX2Zm7yy4Le/I3PnCXv+7pxOQEvOFwkRH4Iw/qZ1SuQKdqk5XNpA5BmcAUj/MZbq oL6PtXGtDaxsEVLUod7xnGVQ2ENn21OVQTFk6I33DNgm8kfIMCvJ1YbijHMbYtgkpFpAye ms+CmdK5KAXf9G18A0qnCtRGTdsMOGYWQcJOD2eaRO51I/t/NyUA9aFgDtOykgzokGMr2i NHuj+pQOtOR1YT/2v7wBiOLXMj4w4WDV5NekLM3uKc4SOZ+DLBUXbKxF59BWLA== 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 4W2cLp6M8kz1GM1; Mon, 17 Jun 2024 04:28:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 45H4S2Re074037; Mon, 17 Jun 2024 04:28:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45H4S2sx074034; Mon, 17 Jun 2024 04:28:02 GMT (envelope-from git) Date: Mon, 17 Jun 2024 04:28:02 GMT Message-Id: <202406170428.45H4S2sx074034@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Zhenlei Huang Subject: git: cbea6b60da00 - stable/13 - pflog: Correctly check if bpf peers are present List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: zlei X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: cbea6b60da007bff698e508a10dd632c80c22b22 Auto-Submitted: auto-generated The branch stable/13 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=cbea6b60da007bff698e508a10dd632c80c22b22 commit cbea6b60da007bff698e508a10dd632c80c22b22 Author: Zhenlei Huang AuthorDate: 2024-06-09 01:05:22 +0000 Commit: Zhenlei Huang CommitDate: 2024-06-17 04:10:35 +0000 pflog: Correctly check if bpf peers are present On creating the pflog(4) interface, pflog_clone_create() does an unconditional bpfattach(). Use bpf_peers_present() which was introduced in commit 16d878cc99ef [1] to check the presence of bpf peers. This will save a little CPU cycles when no bpf peers present. There should be no functional change. 1. 16d878cc99ef Fix the following bpf(4) race condition which can result in a panic Reviewed by: kp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D45532 (cherry picked from commit ebc2bab04823c24c524f913457d6b88dc7ea9fac) (cherry picked from commit 954e548b7e88b7490aa5b23d16df7972c407bef1) --- sys/netpfil/pf/if_pflog.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/netpfil/pf/if_pflog.c b/sys/netpfil/pf/if_pflog.c index 0f9c18654077..541625709494 100644 --- a/sys/netpfil/pf/if_pflog.c +++ b/sys/netpfil/pf/if_pflog.c @@ -207,9 +207,10 @@ pflog_packet(struct pfi_kkif *kif, struct mbuf *m, sa_family_t af, u_int8_t dir, struct pfloghdr hdr; if (kif == NULL || m == NULL || rm == NULL || pd == NULL) - return ( 1); + return (1); - if ((ifn = V_pflogifs[rm->logif]) == NULL || !ifn->if_bpf) + ifn = V_pflogifs[rm->logif]; + if (ifn == NULL || !bpf_peers_present(ifn->if_bpf)) return (0); bzero(&hdr, sizeof(hdr)); @@ -258,7 +259,7 @@ pflog_packet(struct pfi_kkif *kif, struct mbuf *m, sa_family_t af, u_int8_t dir, if_inc_counter(ifn, IFCOUNTER_OPACKETS, 1); if_inc_counter(ifn, IFCOUNTER_OBYTES, m->m_pkthdr.len); - BPF_MTAP2(ifn, &hdr, PFLOG_HDRLEN, m); + bpf_mtap2(ifn->if_bpf, &hdr, PFLOG_HDRLEN, m); return (0); }