From nobody Mon Jun 17 04:28:03 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 4W2cLr2RFVz5NGR0; Mon, 17 Jun 2024 04:28:04 +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 4W2cLr0gQ9z4thv; Mon, 17 Jun 2024 04:28:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718598484; 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=eMUNenBFHdd9+69/jQKYj7+67Xlz7AQZcF2be7+OMRU=; b=hBsFZJicOufgu1j6cdcRz02b0TT74tlTsC7YGOQ1yItwlqOPUEjD5StSdBFFQsUB4sZd21 Mv1IIRzljRir5+UgXpYQs0q+kcPwKHNLsIza//JAQofxifZqsuJHtvb9rg8JOc9+oa3vzR ZZv8V1zPdydn6fY/6SvKb4nOJ2NnmjXnQGDPhufbtAiDIHQ/+wXAtBqrPxpoyPQhY2mBTt VjSAwXA1qJNyZgcKqsx48OLjW3aO0xg7yxWyu9MOFqLiry3KvGmqyy90KNBvsoCUm2/4hJ Y6kRdqbE8sYSoK7wxH/z74/j47mvsidQVHc1/quAW5LMtgg/UKtz7qWOT/Dreg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1718598484; a=rsa-sha256; cv=none; b=ILKVhtyBQeU8ZtxeCIYRvY7sjlSa/6u2eLyPabBa4aopGfncmOuk8psxQ2ccsPHm9FqqLD 1TeU+CBeEL0iDEbMhtAfLAzef2YzWt3LAlUFg5A15RVIwvijjGIXK6/F9y6Tn0psVaYhbS RKsLywurJicn5Ve8mAytEqaaejrfKgQW2qUcvtM5h14YoOcyQ6kDvJm6ZRcRjLlnWYaldx wiZZuvgiB6t0hGyOL6SK6eM+Oq3xaTlt1rkvwODtCJzT0DDKA4lYME7azT129EuM7dU0a4 eVT1VdidNzDihzeu+w36pYRuLnYBJne2KakFUU7s5I0nJGI6Kst6ipVBbtgmdw== 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=1718598484; 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=eMUNenBFHdd9+69/jQKYj7+67Xlz7AQZcF2be7+OMRU=; b=XlS50APFrRIeWNX7qt1mwGopew0dIXkem4naiQNE0v/IGM1bSgY3QKgNw3VJ0lDnnE7tVr 8m/1yA92mUYk3VNqNwHQ0PjUyuwLw0nYk99EPp+XkitY1WiklLtaVgtKnNOFKVwJCT3zR3 w3xhIP/Lj5ElZzqK2ZhdEFDCJlDcv23dUEdFtgChzf1EYPJ9cGnvD59hXgqe1EorUrtJqy QdXcTNS1fpbxdWKImAZvSghOSkKl0opMjmieN1geJUe/FLfeFpBsW2mmOfPy38ibUQvqoW d4kW7/718aKFsdlUtPj2e/e94Y40kIcBItDzAKV2Bfjah/5uuUBPEH4Zmjxdug== 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 4W2cLr0F00z1GJd; Mon, 17 Jun 2024 04:28:04 +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 45H4S3Yn074088; Mon, 17 Jun 2024 04:28:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45H4S3lI074085; Mon, 17 Jun 2024 04:28:03 GMT (envelope-from git) Date: Mon, 17 Jun 2024 04:28:03 GMT Message-Id: <202406170428.45H4S3lI074085@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: 0dddcc657676 - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: 0dddcc6576768806aab1967289a349a65fe7cd3d Auto-Submitted: auto-generated The branch stable/13 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=0dddcc6576768806aab1967289a349a65fe7cd3d commit 0dddcc6576768806aab1967289a349a65fe7cd3d Author: Zhenlei Huang AuthorDate: 2024-06-09 01:05:22 +0000 Commit: Zhenlei Huang CommitDate: 2024-06-17 04:16:38 +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) (cherry picked from commit f14b540dc4c17f6b60e23274153985fb7a2f0cb7) --- 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 d4d3c521a568..1dde4e52e3f8 100644 --- a/sys/netpfil/pf/if_pfsync.c +++ b/sys/netpfil/pf/if_pfsync.c @@ -1587,7 +1587,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; } @@ -1689,10 +1689,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 += sizeof(*ip); m->m_len = m->m_pkthdr.len = b->b_len - sizeof(*ip); - BPF_MTAP(ifp, m); + bpf_mtap(ifp->if_bpf, m); m->m_data -= sizeof(*ip); m->m_len = m->m_pkthdr.len = b->b_len; }