librelist archives

« back to archive

Problem with pcap_dispatch in userlevel fromdevice.cc

Problem with pcap_dispatch in userlevel fromdevice.cc

From:
Reed, Martin J
Date:
2015-06-23 @ 05:30
Hi,

We have been using click for a few years in an ICN project (EU PURSUIT and
now POINT). We have noticed a bug recently when using pcap_dispatch in 
fromdevice.cc<http://fromdevice.cc>. It seems that this worked a while 
back but is failing on recent kernels (not sure when it became a problem).
It seems that it returns immediately with zero when a packet is detected 
as entering. A quick look around and I see on other lists that this has 
been a problem elsewhere. Not quite sure but it might be that 
pcap_dispatch ignores the timeout and sets it to zero which is too short 
to get the packet. Whatever the reason it seems to fail. Noticed the 
problem on Ubuntu 14.04 kernel 3.16.0-30-generic with libpcap 1.5.3 (there
was a fix in libpcap related to this in a later version, but have not 
tried it yet).

Solution is to use another capture method e.g. “METHOD LINUX” works fine.

Not looking for fix necessarily, just posting in case others have the same
problem. I am pretty sure this is a libpcap bug not a click bug. Some 
interesting posts that might be relevant

https://github.com/the-tcpdump-group/libpcap/issues/350

which was fixed in libpcap-1.6.0 (not available on ubuntu yet):


https://github.com/the-tcpdump-group/libpcap/commit/9e35faaac7436d29b607e5664b73c4676ec326a4

Regards,

Martin


Dr. M.J. Reed                                         Room:       1NW.4.18
School of Computer Science and Electronic Engineering
Tel:+44 (0)1206 872479            FAX:+44 (0)1206 872900
University of Essex, Colchester CO4 3SQ, UK
Email mjreed@essex.ac.uk<mailto:mjreed@essex.ac.uk>
Web: http://csee.essex.ac.uk/staff/mjreed

Re: [click] Problem with pcap_dispatch in userlevel fromdevice.cc

From:
Beyers Cronje
Date:
2015-06-23 @ 13:53
Hi Martin,

This seems like the same issue we're experiencing. I've opened a github
issue at the Click repo for this a while back, please see
https://github.com/kohler/click/issues/164

The workaround works, but traditionally METHOD LINUX performance poorly
compared with PCAP.

Regarding the libpcap issue you posted, I actually tested compiling from
source libpcap 1.7.3 and still had the same Click issue. Unless I did
something wrong :)

Beyers

On Tue, Jun 23, 2015 at 7:30 AM, Reed, Martin J <mjreed@essex.ac.uk> wrote:

>  Hi,
>
>  We have been using click for a few years in an ICN project (EU PURSUIT
> and now POINT). We have noticed a bug recently when using pcap_dispatch in
> fromdevice.cc. It seems that this worked a while back but is failing on
> recent kernels (not sure when it became a problem). It seems that it
> returns immediately with zero when a packet is detected as entering. A
> quick look around and I see on other lists that this has been a problem
> elsewhere. Not quite sure but it might be that pcap_dispatch ignores the
> timeout and sets it to zero which is too short to get the packet. Whatever
> the reason it seems to fail. Noticed the problem on Ubuntu 14.04 kernel 
3.16.0-30-generic
> with libpcap 1.5.3 (there was a fix in libpcap related to this in a later
> version, but have not tried it yet).
>
>  Solution is to use another capture method e.g. “METHOD LINUX” works fine.
>
>  Not looking for fix necessarily, just posting in case others have the
> same problem. I am pretty sure this is a libpcap bug not a click bug. Some
> interesting posts that might be relevant
>
>  https://github.com/the-tcpdump-group/libpcap/issues/350
>
>  which was fixed in libpcap-1.6.0 (not available on ubuntu yet):
>
>
> 
https://github.com/the-tcpdump-group/libpcap/commit/9e35faaac7436d29b607e5664b73c4676ec326a4
>
>  Regards,
>
>  Martin
>
>
> Dr. M.J. Reed                                         Room:       1NW.4.18
> School of Computer Science and Electronic Engineering
> Tel:+44 (0)1206 872479            FAX:+44 (0)1206 872900
> University of Essex, Colchester CO4 3SQ, UK
> Email mjreed@essex.ac.uk
> Web: http://csee.essex.ac.uk/staff/mjreed
>
>
>

Re: [click] Problem with pcap_dispatch in userlevel fromdevice.cc

From:
Reed, Martin J
Date:
2015-06-23 @ 19:58
Hi,

I have been looking into this. The clue seems to be in libpcap/pcap.c:

————————>8——————————————
#ifdef HAVE_TPACKET3
/*
* XXX - due to a set of (mis)features in the TPACKET_V3
* kernel code prior to the 3.19 kernel, blocking forever
* with a TPACKET_V3 socket can, if few packets are
* arriving and passing the socket filter, cause most
* packets to be dropped.  See libpcap issue #335 for the
* full painful story.
*
* The workaround is to have poll() time out very quickly,
* so we grab the frames handed to us, and return them to
* the kernel, ASAP.
*/
————————>8——————————————
It seems the poll time out is not working. Also I think (very much think 
as there is a lot of code to check) that when pcap is set to non-blocking 
mode it ignores the time out set externally and sets it to zero (in 
fromdevice.cc<http://fromdevice.cc> it is set to 500 ms). The above seems 
to apply to blocking mode, but it seems the bug is also present in 
non-blocking which is used in fromdevice.cc<http://fromdevice.cc> (if 
available, which it will be).

I am happy to report that upgrading to 3.19 seems to have fixed it for me,
although we have not extensively tested yet. When we are more certain we 
will let you know.

I will link this into the git issue comment when it comes live as a link 
in the list.

Regards,

Martin

Dr. M.J. Reed                                         Room:       1NW.4.18
School of Computer Science and Electronic Engineering
Tel:+44 (0)1206 872479            FAX:+44 (0)1206 872900
University of Essex, Colchester CO4 3SQ, UK
Email mjreed@essex.ac.uk<mailto:mjreed@essex.ac.uk>
Web: http://csee.essex.ac.uk/staff/mjreed


On 23 Jun 2015, at 14:53, Beyers Cronje 
<bcronje@gmail.com<mailto:bcronje@gmail.com>> wrote:

Hi Martin,

This seems like the same issue we're experiencing. I've opened a github 
issue at the Click repo for this a while back, please see 
https://github.com/kohler/click/issues/164

The workaround works, but traditionally METHOD LINUX performance poorly 
compared with PCAP.

Regarding the libpcap issue you posted, I actually tested compiling from 
source libpcap 1.7.3 and still had the same Click issue. Unless I did 
something wrong :)

Beyers

On Tue, Jun 23, 2015 at 7:30 AM, Reed, Martin J 
<mjreed@essex.ac.uk<mailto:mjreed@essex.ac.uk>> wrote:
Hi,

We have been using click for a few years in an ICN project (EU PURSUIT and
now POINT). We have noticed a bug recently when using pcap_dispatch in 
fromdevice.cc<http://fromdevice.cc/>. It seems that this worked a while 
back but is failing on recent kernels (not sure when it became a problem).
It seems that it returns immediately with zero when a packet is detected 
as entering. A quick look around and I see on other lists that this has 
been a problem elsewhere. Not quite sure but it might be that 
pcap_dispatch ignores the timeout and sets it to zero which is too short 
to get the packet. Whatever the reason it seems to fail. Noticed the 
problem on Ubuntu 14.04 kernel 3.16.0-30-generic with libpcap 1.5.3 (there
was a fix in libpcap related to this in a later version, but have not 
tried it yet).

Solution is to use another capture method e.g. “METHOD LINUX” works fine.

Not looking for fix necessarily, just posting in case others have the same
problem. I am pretty sure this is a libpcap bug not a click bug. Some 
interesting posts that might be relevant

https://github.com/the-tcpdump-group/libpcap/issues/350

which was fixed in libpcap-1.6.0 (not available on ubuntu yet):


https://github.com/the-tcpdump-group/libpcap/commit/9e35faaac7436d29b607e5664b73c4676ec326a4

Regards,

Martin


Dr. M.J. Reed                                         Room:       1NW.4.18
School of Computer Science and Electronic Engineering
Tel:+44 (0)1206 872479<tel:%2B44%20%280%291206%20872479>            
FAX:+44 (0)1206 872900<tel:%2B44%C2%A0%280%291206%20872900>
University of Essex, Colchester CO4 3SQ, UK
Email mjreed@essex.ac.uk<mailto:mjreed@essex.ac.uk>
Web: http://csee.essex.ac.uk/staff/mjreed