From nobody Sun Jun 09 01:06:46 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 4VxcGH1TNJz5N7lV; Sun, 09 Jun 2024 01:06:47 +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 4VxcGH0pmcz4Dgj; Sun, 9 Jun 2024 01:06:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717895207; 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=6ZYIn8yOMRrj432MAAd3BpjVlYKyPZHYWoh/A0cnXN4=; b=E8RgN1PXxF8gJUj/ksDhug/ya5TiDhhr1GF1le7GvUHhXTVIPzdFmSynU8olH8Vj+gCSZo ew4hVwc+65i5VAeW922AXuMAKy/NJXOvpcep5sJKI5tWVC6xSYDJ9wjWDpzZuiEPgVDZbq T3MJKHWyoAfsVldHTBtzQTTknkypCS3BE7og4MvGNI3Hvtqwutia1NJU2Ts+Bw9e0/nTmH MM61p/FxZaq+7XFJQ4J8sa7H2ZoJfxbhuPZYN8x5IcnhpgWG/0Y7XDAJQog51jxZqqA+zJ 61BggtGBIoXw+M84RWHZA7vc7OlUq1wfqzpT420r2C2oCx3SrabUH/XpGhe0ng== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1717895207; a=rsa-sha256; cv=none; b=EMR51oRHEWFrtZ7AHZSO10Mj+M0G2dkgqtUDwGn00vGSOPQDr8RRD3tCmeraz2PMuqhLlB E361a0dJYtS3NnUtO7jqcjzXKGqQdAx8Joc2tiDKOtSsA17u+qRp4xARsZxcVfXz/CsIGi eSnzh7Mm0CULI1l4YiAeuILhkcv1UVpB2r5y/QQuQQH+YAKto2eZyruxaCmjQJUBtCjM+Z bBTKd0K8bCJ1vwXMqWiaTpYCpzXE5jkERzuMYUtXsfsFvnVihFW3Htq3kSjn08K0EF3sgY Sh8WjXTm547ZDMuASp+zFgp2ySMjF3hAErgnukKpy+ikNujjHLV/HR4bLLXMMQ== 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=1717895207; 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=6ZYIn8yOMRrj432MAAd3BpjVlYKyPZHYWoh/A0cnXN4=; b=OpIBKv5xQzlsQ3wiXlSHNoWJOKJ6cpY7Vk8EEbDI+NDaiDuxm57uMDH6ZEpb6ETlvNWeZq 3Nrg/sc9TNyzM65xBpUpt4UfrJx9yvKXmdkNHxLqRWH/J6JR1Np7jKi0PXTdA97sq6rbI0 ezQ+Xi29XLWKpb9cZpQi3YsUsaGzE2yWTS57u6VqmRljPgTfIkJO/cVoth9fjA89Hz9YV0 lANhdOxlgLDdGXdIdgolIgxqSC/J5zxne3w3/ClUIlet54c3Zr+WBm3+5+bWWt88hPPZVU f/Nu2YoL49KTb3WwTWzpc8wT/jJzvEOO3jo6KpgOUF4jcagPg9DrVM3sVypRXg== 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 4VxcGH0QqpzLsV; Sun, 9 Jun 2024 01:06:47 +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 45916ljF052599; Sun, 9 Jun 2024 01:06:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45916kjJ052596; Sun, 9 Jun 2024 01:06:46 GMT (envelope-from git) Date: Sun, 9 Jun 2024 01:06:46 GMT Message-Id: <202406090106.45916kjJ052596@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: ebc2bab04823 - main - 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/main X-Git-Reftype: branch X-Git-Commit: ebc2bab04823c24c524f913457d6b88dc7ea9fac Auto-Submitted: auto-generated The branch main has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=ebc2bab04823c24c524f913457d6b88dc7ea9fac commit ebc2bab04823c24c524f913457d6b88dc7ea9fac Author: Zhenlei Huang AuthorDate: 2024-06-09 01:05:22 +0000 Commit: Zhenlei Huang CommitDate: 2024-06-09 01:05:22 +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 --- 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 7ac337a84c5d..1e73d5f51851 100644 --- a/sys/netpfil/pf/if_pflog.c +++ b/sys/netpfil/pf/if_pflog.c @@ -223,9 +223,10 @@ pflog_packet(struct pfi_kkif *kif, struct mbuf *m, sa_family_t af, 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)); @@ -274,7 +275,7 @@ pflog_packet(struct pfi_kkif *kif, struct mbuf *m, sa_family_t af, 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); }