If bpf(4) has not been compiled into the kernel, initialize the bpf interface
pointer to a zeroed, statically allocated bpf_if structure. This way the LIST_EMPTY() macro will always return true. This allows us to remove the additional unconditional memory reference for each packet in the fast path. Discussed with: sam
This commit is contained in:
parent
b0a06b380f
commit
c1cbf173b2
@ -1790,6 +1790,7 @@ SYSINIT(bpfdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE,bpf_drvinit,NULL)
|
||||
* A 'better' implementation would allow the core bpf functionality
|
||||
* to be loaded at runtime.
|
||||
*/
|
||||
static struct bpf_if bp_null;
|
||||
|
||||
void
|
||||
bpf_tap(bp, pkt, pktlen)
|
||||
@ -1820,6 +1821,8 @@ bpfattach(ifp, dlt, hdrlen)
|
||||
struct ifnet *ifp;
|
||||
u_int dlt, hdrlen;
|
||||
{
|
||||
|
||||
bpfattach2(ifp, dlt, hdrlen, &ifp->if_bpf);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1828,6 +1831,8 @@ bpfattach2(ifp, dlt, hdrlen, driverp)
|
||||
u_int dlt, hdrlen;
|
||||
struct bpf_if **driverp;
|
||||
{
|
||||
|
||||
*driverp = &bp_null;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -630,7 +630,7 @@ static __inline int
|
||||
bpf_peers_present(struct bpf_if *bpf)
|
||||
{
|
||||
|
||||
if (bpf && !LIST_EMPTY(&bpf->bif_dlist))
|
||||
if (!LIST_EMPTY(&bpf->bif_dlist))
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user