From nobody Sun Jun 09 01:06:48 2024 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 4VxcGJ3wwrz5N7xM; Sun, 09 Jun 2024 01:06:48 +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 4VxcGJ26PBz4Dm5; Sun, 9 Jun 2024 01:06:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717895208; 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=Qd/1tkdh/Gbyx+TDoplL0YFffPtsIP22I/3M2jgxIyE=; b=dXoFaGbLxoYt26TM8C+zYR3FRF8bPD5ofutQy6mVCOKxHhXruG52ba7APmAKvqGLsObPxi oPrTK4xFSHHaDDr9p0/5pFd/aZ2s1xVvmAS5+Elv5quf/3ELxdRGwj3ra4y4AjdqO0fCeA Vkms1F7WW0//018fWmUhghrTxmf7QtXf2fn6A9Vr+HR0iVvTHFYc0N/67KakrYFmEnXKu/ 5E7hFD9d2xzQrmEGa2TgaiTqC8jpGgdc82gX4Wk/vhe08JWkG7VNmwAMiJMXslVXdbkfV9 Ga+H7zSzSKkiF7Y6E5uLaET774YfNg33dQv7BE+D9H9kBiTwkpdiBH0sbNJ6Sw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1717895208; a=rsa-sha256; cv=none; b=FLdefHM72G1F2CqmnYIv6o0iI5RAGgXKGdeYjL1j9gyzmQ/BkccW4TTBf1qEfrLbIo2aWz 2F8FfE5dBJyuEXKISkhPDAnbjLaBamTbXHImphhuzZhwFGj0K9ZwTgyutNaU+v/JLwVQa8 +bSHd6gkQX7KAHoX9g/e0hABVboV9/iIk48O9GhaXm43Y64vSLL6SuD+BRvaetBk4w+BH/ 32hvKIJ778isY+29r9jRjo01s8TLc9olikRr37t3OOsTgxc1uk+ufOovQ0qfCfHaVM5oyY Dgq2+h4Ak/P6gpEmkSm1Z/Un1EMZE6Z1mnDBJ2VnXoWtDj6wsmNuQFOZFHmTFw== 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=1717895208; 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=Qd/1tkdh/Gbyx+TDoplL0YFffPtsIP22I/3M2jgxIyE=; b=EyNQ034gBAIZQW49E/P+ZCEoOx6s6N18duW/+Sy+heQwZVk4QOV68TTXE7Pv5jxiJZlwMj xSvL9xiqyiPb+Zj2lbYKutcD9FeSWAI4GsLeSgWRdmNW37WfQLzZbJQdzldGVRJA+s9eIA uNfVIkZ80EKIb5jjDnoe74OL5EdUZJX6eOsGk0oETjcYZii4UhPnfhcysLhG9ImdUW3uDJ /DRGzgqYp5AYy6JVPHx3pqoCPlXAni27sBlgRuSOiUuhQbAguIXwcu/IVN3oW/JODqhMDX ZEhFWb3ZcG5PMgd4L0L2y7PLQUgZRHpbZSHR0HdqtwUTPDP8L/4Cejl8sCWO2Q== 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 4VxcGJ1jtHzLfM; Sun, 9 Jun 2024 01:06:48 +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 45916m78052656; Sun, 9 Jun 2024 01:06:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45916mrm052653; Sun, 9 Jun 2024 01:06:48 GMT (envelope-from git) Date: Sun, 9 Jun 2024 01:06:48 GMT Message-Id: <202406090106.45916mrm052653@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Zhenlei Huang Subject: git: 2671bde99295 - main - pfsync: Correctly check if bpf peers are present 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 2671bde99295d9e01d10316d0f3fb8b6d21f0f4d Auto-Submitted: auto-generated The branch main has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=2671bde99295d9e01d10316d0f3fb8b6d21f0f4d commit 2671bde99295d9e01d10316d0f3fb8b6d21f0f4d Author: Zhenlei Huang AuthorDate: 2024-06-09 01:05:22 +0000 Commit: Zhenlei Huang CommitDate: 2024-06-09 01:05:22 +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 --- 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 c22a6a5982a9..80d6fddc709c 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; }