Re: Peeking BPF
From: Lev Walkin (vlm_at_netli.com)
Date: 06/29/04
- Previous message: M. Warner Losh: "Re: PCI memory alloc..!"
- In reply to: Ivan Voras: "Peeking BPF"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 29 Jun 2004 10:08:08 -0700 To: Ivan Voras <ivoras@fer.hr>
Ivan Voras wrote:
>
> I need to convert this code:
>
> ret = recvfrom(thisint->sockInt, &resultframe, 1520, MSG_PEEK, 0, 0);
> if (ret > 0) return TRUE;
>
> to use BPF. Essentialy, how to find out if a packet is available over
> the BPF interface?
try to read() it and read() will hang there until there is data in it.
alternatively, use poll() or select() to check for readability event.
char resultBuffer[65536];
ret = read(thisint->bpfInt, resultBuffer, sizeof(resultBuffer));
if(ret > 0) return TRUE;
-- Lev Walkin vlm@netli.com _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
- Previous message: M. Warner Losh: "Re: PCI memory alloc..!"
- In reply to: Ivan Voras: "Peeking BPF"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
- Re: libpcap perf improvement? latest ideas?
... performance (with comparison of linux and freebsd) I searched freebsd resources for
pcap improvements. ... I agree that a reference model can be used to reduce the number of copies
done currently for BPF. ... In PF_PACKET you are forced to do a system call per-acquisition
and another system for receiving the time-stamp of the last packet read for example. ... I proposed
a model that allows for dynamic ring buffer size and signaling for soft and hard-limits to allow
application buffering to handle potential drops. ... (freebsd-hackers) - Re: crash when bpf is used heavily
... It looks like the BPF code is written to handle the case where allocation ...
but that it passes flags to the memory allocator that prevent the ... I've worked with
that need to do processing of many high speed packet ... (freebsd-current) - Re: Implementation of Sampling for BPF
... BPF was never intended to be reliable every-packet solution. ... every packet,
I am looking at attempting to define which packets it discards so that there is an equal chance of sampling
something that happens, rather then an unknown/unpredictable chance. ... Putting as many servers
as needed does scale well if you need only sampled data - just put an appropriate sampler/load
balancer before them. ... (freebsd-net) - Re: bpf writes on tun device
... >> would mean that we have to change it everywhere, including bpf ...
>> integer in front of everything else which is raw data', ... packet starts
and where the actual raw IP packet starts. ... If you want BPF/PCAP to return packets without
the 4-byte offset, ... (freebsd-net) - Re: Implementation of Sampling for BPF
... BPF was never intended to be reliable every-packet solution. ... I'm
not looking to transform BPF into a solution to reliably sample every packet, I am looking at
attempting to define which packets it discards so that there is an equal chance of sampling something
that happens, rather then an unknown/unpredictable chance. ... (freebsd-net)