From nobody Mon Jun 17 04:03:31 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 4W2bpW6NTCz5NCl5; Mon, 17 Jun 2024 04:03:31 +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 4W2bpW2TDGz4qp7; Mon, 17 Jun 2024 04:03:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718597011; 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=jCcLY/u3Lb5GhLTVchThsi8RcR+eeElEdCzEiPshTkU=; b=i8NdbQylSc/RRMD4cxJBh5XaT3fIrSc6j+4qhrTVdpuJxWL3iHkbw4MWEfTprADJCuTFoD kG6GlKwKUrnIEpKx4AGU6gu83yIKf2fEGXLkwSHhmB33zlDWCpbP1dVTOzWUK86OQsoFfX LGg+bY1pOX1bMYEf4WXKm+dYH8tZWoX7g5g54NfMAbGnFBNQ+1m4/rAn4HqvDYW0yuGvO2 tIatboSdX/6c/UJUtmhdbPe7YzVGFc4vYDOHLdCVFA/WkYxhmqBswzJlOCVexQFd+hjYp/ 17a1pqLm/sGAtytrkg8aGvEwqoAs6xZPqEHfMyPa86IjRsr45wQkqe1EqIRBNA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1718597011; a=rsa-sha256; cv=none; b=S7+Wh1paUOFP0PqRvXEZyex8vCcsH+BWJ74TigUEdFGi4Vy6CKoKwTUd6X/oarCL4xcOP+ PdGDElddrViWvWGsYVMxK7Q7Ok9/zJdXsT0YYh+x1uZFM4Y529/h41vKXsK7g7RdaRzY6q wEuOnRy1d2fiQE1JSfe1IULGj9nw3jdJ5O12yg+0o4i5C8hTeQFW2xhdXJEw26PgjvqYNU lgWpmhMuPu1VyWf368EwdmBnAeDQeqVLXxKbQT1Jvko6tSEQWuM5gfc4/dqLTgLoNlAOOo y7rWCd69vmFGzrTZXmywKgcFI+8zO3tqmzShuxbnfPErvjKduc5WXwVo0s5Bcw== 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=1718597011; 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=jCcLY/u3Lb5GhLTVchThsi8RcR+eeElEdCzEiPshTkU=; b=a2h2ojjQsyjTHNPVmB9G8CuQ6SX0q86VUBDCzuZy3b8Z4/sxD721RTgCHwdXewC3BKLJ4Z 2ehDvl9mqsOCGD3n3is/gUgxg9aet8IQ28pJV4XxKvCKLezCzAaKcRIuWbbSD1ik+wzQei 83JsP2rMEey/dd186HakRSKJFVbXpgyRiPBwUqh00EgUO2vXqhYGA+zSNJiuPNt3d0D8um 3PXZqcj+YPLauW3kxmFuNMMePWrM1NW4LcpIebgsocReMnFea5BGkzxukxz4MHBeaffmY+ 5brsay/XbyJI8cRBgnqvwhHNqmH3p5zBAp1HO/q+IKget9mo92wYNOMzIEe7oQ== 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 4W2bpW25WVz1Ft4; Mon, 17 Jun 2024 04:03:31 +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 45H43VDk039760; Mon, 17 Jun 2024 04:03:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45H43VHp039757; Mon, 17 Jun 2024 04:03:31 GMT (envelope-from git) Date: Mon, 17 Jun 2024 04:03:31 GMT Message-Id: <202406170403.45H43VHp039757@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: f14b540dc4c1 - stable/14 - pfsync: 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/14 X-Git-Reftype: branch X-Git-Commit: f14b540dc4c17f6b60e23274153985fb7a2f0cb7 Auto-Submitted: auto-generated The branch stable/14 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=f14b540dc4c17f6b60e23274153985fb7a2f0cb7 commit f14b540dc4c17f6b60e23274153985fb7a2f0cb7 Author: Zhenlei Huang AuthorDate: 2024-06-09 01:05:22 +0000 Commit: Zhenlei Huang CommitDate: 2024-06-17 04:00:02 +0000 pfsync: Correctly check if bpf peers are present On creating the pfsync(4) interface, pfsync_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 and memory usage when the synchronisation interface is not configured and there is 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/D45533 (cherry picked from commit 2671bde99295d9e01d10316d0f3fb8b6d21f0f4d) --- sys/netpfil/pf/if_pfsync.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c index def06cd0c113..b188813cb8d1 100644 --- a/sys/netpfil/pf/if_pfsync.c +++ b/sys/netpfil/pf/if_pfsync.c @@ -1796,7 +1796,7 @@ pfsync_sendout(int schedswi, int c) ("%s: sc_len %zu", __func__, b->b_len)); PFSYNC_BUCKET_LOCK_ASSERT(b); - if (ifp->if_bpf == NULL && sc->sc_sync_if == NULL) { + if (!bpf_peers_present(ifp->if_bpf) && sc->sc_sync_if == NULL) { pfsync_drop(sc); return; } @@ -1925,10 +1925,10 @@ pfsync_sendout(int schedswi, int c) V_pfsyncstats.pfsyncs_oacts[PFSYNC_ACT_EOF]++; /* we're done, let's put it on the wire */ - if (ifp->if_bpf) { + if (bpf_peers_present(ifp->if_bpf)) { m->m_data += aflen; m->m_len = m->m_pkthdr.len = len - aflen; - BPF_MTAP(ifp, m); + bpf_mtap(ifp->if_bpf, m); m->m_data -= aflen; m->m_len = m->m_pkthdr.len = len; }