git: ff4b8d51ac72 - stable/13 - mlx4, mlx5: Eliminate redundent NULL check for packet filter

From: Zhenlei Huang <zlei_at_FreeBSD.org>
Date: Wed, 05 Jun 2024 04:45:41 UTC
The branch stable/13 has been updated by zlei:

URL: https://cgit.FreeBSD.org/src/commit/?id=ff4b8d51ac72b426618c7c7ea438c5e2c7586fb6

commit ff4b8d51ac72b426618c7c7ea438c5e2c7586fb6
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2024-05-28 04:46:04 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2024-06-05 04:44:22 +0000

    mlx4, mlx5: Eliminate redundent NULL check for packet filter
    
    mlx4 and mlx5 are Ethernet devices and ether_ifattach() does an
    unconditional bpfattach(). From commit 16d878cc99ef [1] and on, we
    should not check ifp->if_bpf to tell us whether or not we have any bpf
    peers that might be interested in receiving packets. And since commit
    2b9600b4497b [2], ifp->if_bpf can not be NULL even after the network
    interface has been detached.
    
    No functional change intended.
    
    1. 16d878cc99ef Fix the following bpf(4) race condition which can result in a panic
    2. 2b9600b4497b Add dead_bpf_if structure, that should be used as fake bpf_if during ifnet detach
    
    Reviewed by:    kp, kib
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D45196
    
    (cherry picked from commit 2439ae948352766f6b993c5103a4c516376bec28)
    (cherry picked from commit d98ced6588b522e8833888bc99b7b9468312b221)
---
 sys/dev/mlx4/mlx4_en/mlx4_en_tx.c | 2 +-
 sys/dev/mlx5/mlx5_en/mlx5_en_tx.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/dev/mlx4/mlx4_en/mlx4_en_tx.c b/sys/dev/mlx4/mlx4_en/mlx4_en_tx.c
index 7cff1a224e9a..0bbc54790a40 100644
--- a/sys/dev/mlx4/mlx4_en/mlx4_en_tx.c
+++ b/sys/dev/mlx4/mlx4_en/mlx4_en_tx.c
@@ -688,7 +688,7 @@ int mlx4_en_xmit(struct mlx4_en_priv *priv, int tx_ind, struct mbuf **mbp)
 	dseg = &tx_desc->data;
 
 	/* send a copy of the frame to the BPF listener, if any */
-	if (ifp != NULL && ifp->if_bpf != NULL)
+	if (ifp != NULL)
 		ETHER_BPF_MTAP(ifp, mb);
 
 	/* get default flags */
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c b/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
index 7a023c2499e2..44f38db911cb 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
@@ -745,7 +745,7 @@ top:
 	mb = *mbp;
 
 	/* Send a copy of the frame to the BPF listener, if any */
-	if (ifp != NULL && ifp->if_bpf != NULL)
+	if (ifp != NULL)
 		ETHER_BPF_MTAP(ifp, mb);
 
 	if (mb->m_pkthdr.csum_flags & (CSUM_IP | CSUM_TSO)) {