mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-04 15:40:44 +00:00
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 commit16d878cc99
[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.16d878cc99
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
This commit is contained in:
parent
13a51233e4
commit
ebc2bab048
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue