Hello community, here is the log from the commit of package libpcap for openSUSE:Factory checked in at 2014-02-17 09:56:27 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libpcap (Old) and /work/SRC/openSUSE:Factory/.libpcap.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libpcap" Changes: -------- --- /work/SRC/openSUSE:Factory/libpcap/libpcap.changes 2013-12-17 10:02:08.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.libpcap.new/libpcap.changes 2014-02-17 09:56:28.000000000 +0100 @@ -1,0 +2,20 @@ +Thu Feb 13 16:18:19 UTC 2014 - [email protected] + +- added support for netlink (bnc#863823) + * libpcap-netlink.patch + +------------------------------------------------------------------- +Thu Feb 13 15:14:48 UTC 2014 - [email protected] + +- update to 1.5.3 + * Don't let packets that don't match the current filter get to the + application when TPACKET_V3 is used. (GitHub issue #331) + * Fix handling of pcap_loop()/pcap_dispatch() with a packet count + of 0 on some platforms (including Linux with TPACKET_V3). + (GitHub issue #333) + * Work around TPACKET_V3 deficiency that causes packets to be lost + when a timeout of 0 is specified. (GitHub issue #335) + * Man page formatting fixes. +- refreshed libpcap-1.5.2-filter-fix.patch + +------------------------------------------------------------------- Old: ---- libpcap-1.5.2.tar.gz libpcap-1.5.2.tar.gz.sig New: ---- libpcap-1.5.3.tar.gz libpcap-1.5.3.tar.gz.sig libpcap-netlink.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libpcap.spec ++++++ --- /var/tmp/diff_new_pack.VPOLUT/_old 2014-02-17 09:56:28.000000000 +0100 +++ /var/tmp/diff_new_pack.VPOLUT/_new 2014-02-17 09:56:28.000000000 +0100 @@ -1,7 +1,7 @@ # # spec file for package libpcap # -# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: libpcap -Version: 1.5.2 +Version: 1.5.3 Release: 0 Summary: A Library for Network Sniffers License: BSD-3-Clause @@ -32,6 +32,7 @@ Patch2: libpcap-1.0.0-ppp.patch Patch3: libpcap-1.0.0-s390.patch Patch4: libpcap-ocloexec.patch +Patch5: libpcap-netlink.patch BuildRequires: automake BuildRequires: bison BuildRequires: bluez-devel @@ -96,6 +97,7 @@ %patch2 %patch3 %patch4 -p1 +%patch5 -p1 %build %ifarch %sparc pic="PIC" ++++++ libpcap-1.5.2-filter-fix.patch ++++++ --- /var/tmp/diff_new_pack.VPOLUT/_old 2014-02-17 09:56:28.000000000 +0100 +++ /var/tmp/diff_new_pack.VPOLUT/_new 2014-02-17 09:56:28.000000000 +0100 @@ -3,10 +3,10 @@ pcap-linux.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) -Index: libpcap-1.5.2/pcap-bpf.c +Index: libpcap-1.5.3/pcap-bpf.c =================================================================== ---- libpcap-1.5.2.orig/pcap-bpf.c 2013-11-07 23:23:22.000000000 +0000 -+++ libpcap-1.5.2/pcap-bpf.c 2013-12-14 11:28:40.000000000 +0000 +--- libpcap-1.5.3.orig/pcap-bpf.c 2014-02-13 17:22:30.794295046 +0100 ++++ libpcap-1.5.3/pcap-bpf.c 2014-02-13 17:22:31.667305231 +0100 @@ -494,7 +494,7 @@ bpf_open(pcap_t *p) fd = open(device, O_RDWR); if (fd == -1 && errno == EACCES) @@ -16,11 +16,11 @@ /* * XXX better message for all minors used -Index: libpcap-1.5.2/pcap-linux.c +Index: libpcap-1.5.3/pcap-linux.c =================================================================== ---- libpcap-1.5.2.orig/pcap-linux.c 2013-12-03 15:11:24.000000000 +0000 -+++ libpcap-1.5.2/pcap-linux.c 2013-12-14 11:30:29.000000000 +0000 -@@ -2475,8 +2475,30 @@ pcap_setfilter_linux_common(pcap_t *hand +--- libpcap-1.5.3.orig/pcap-linux.c 2014-02-13 17:22:31.668305243 +0100 ++++ libpcap-1.5.3/pcap-linux.c 2014-02-13 17:24:01.924357989 +0100 +@@ -2476,11 +2476,33 @@ pcap_setfilter_linux_common(pcap_t *hand if (can_filter_in_kernel) { if ((err = set_kernel_filter(handle, &fcode)) == 0) { @@ -29,8 +29,11 @@ + int ret; + unsigned int received = 0, rec_len = 0; + socklen_t optlen = sizeof(rec_len); - /* Installation succeded - using kernel filter. */ - handlep->filtering_in_kernel = 1; + /* + * Installation succeded - using kernel filter, + * so userland filtering not needed. + */ + handlep->filter_in_userland = 0; + + oldflags = fcntl(handle->fd, F_GETFL, 0); + oldflags |= O_NONBLOCK; @@ -38,7 +41,7 @@ + getsockopt(handle->fd, SOL_SOCKET, SO_RCVBUF, + (char *)&rec_len, &optlen); + -+ /* now read all packets received until now */ ++ /* now read all packets received until now */ + while((ret = read(handle->fd, buf, 1024)) > 0 + && received < rec_len) { + received += ret; ++++++ libpcap-1.5.2.tar.gz -> libpcap-1.5.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libpcap-1.5.2/CHANGES new/libpcap-1.5.3/CHANGES --- old/libpcap-1.5.2/CHANGES 2013-11-08 00:23:22.000000000 +0100 +++ new/libpcap-1.5.3/CHANGES 2014-01-14 21:41:24.000000000 +0100 @@ -1,3 +1,25 @@ +Wednesday December 18, 2013 [email protected] +Summary for 1.5.3 libpcap release + Don't let packets that don't match the current filter get to the + application when TPACKET_V3 is used. (GitHub issue #331) + Fix handling of pcap_loop()/pcap_dispatch() with a packet count + of 0 on some platforms (including Linux with TPACKET_V3). + (GitHub issue #333) + Work around TPACKET_V3 deficiency that causes packets to be lost + when a timeout of 0 is specified. (GitHub issue #335) + Man page formatting fixes. + +Wednesday December 4, 2013 [email protected] +Summary for 1.5.2 libpcap release + Fix libpcap to work when compiled with TPACKET_V3 support and + running on a kernel without TPACKET_V3 support. (GitHub + issue #329) + +Wednesday November 20, 2013 [email protected] +Summary for 1.5.1 libpcap release + Report an error, rather than crashing, if an IPv6 address is + used for link-layer filtering. (Wireshark bug 9376) + Wednesday October 30, 2013 [email protected] Summary for 1.5.0 libpcap release TPACKET_V3 support added for Linux @@ -7,7 +29,8 @@ Fixed build on Solaris 11 Support filtering filtering E1 SS7 traffic on MTP2 layer Annex A Use "ln -s" to link man pages by default - Added pcap_open_dead_with_tstamp_precision API interface. + Add support for getting nanosecond-resolution time stamps when + capturing and reading capture files Many changes to autoconf to deal better with non-GCC compilers added many new DLT types diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libpcap-1.5.2/VERSION new/libpcap-1.5.3/VERSION --- old/libpcap-1.5.2/VERSION 2013-12-03 16:11:28.000000000 +0100 +++ new/libpcap-1.5.3/VERSION 2014-01-14 21:41:09.000000000 +0100 @@ -1 +1 @@ -1.5.2 +1.5.3 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libpcap-1.5.2/dlpisubs.c new/libpcap-1.5.3/dlpisubs.c --- old/libpcap-1.5.2/dlpisubs.c 2013-11-08 00:23:22.000000000 +0100 +++ new/libpcap-1.5.3/dlpisubs.c 2014-01-14 21:40:35.000000000 +0100 @@ -193,7 +193,7 @@ if (pkthdr.caplen > p->snapshot) pkthdr.caplen = p->snapshot; (*callback)(user, &pkthdr, pk); - if (++n >= count && count >= 0) { + if (++n >= count && !PACKET_COUNT_IS_UNLIMITED(count)) { p->cc = ep - bufp; p->bp = bufp; return (n); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libpcap-1.5.2/pcap-bpf.c new/libpcap-1.5.3/pcap-bpf.c --- old/libpcap-1.5.2/pcap-bpf.c 2013-11-08 00:23:22.000000000 +0100 +++ new/libpcap-1.5.3/pcap-bpf.c 2014-01-14 21:40:35.000000000 +0100 @@ -1037,7 +1037,7 @@ #endif (*callback)(user, &pkthdr, datap); bp += BPF_WORDALIGN(caplen + hdrlen); - if (++n >= cnt && cnt > 0) { + if (++n >= cnt && !PACKET_COUNT_IS_UNLIMITED(cnt)) { p->bp = bp; p->cc = ep - bp; /* diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libpcap-1.5.2/pcap-dag.c new/libpcap-1.5.3/pcap-dag.c --- old/libpcap-1.5.2/pcap-dag.c 2013-11-08 00:23:22.000000000 +0100 +++ new/libpcap-1.5.3/pcap-dag.c 2014-01-14 21:40:35.000000000 +0100 @@ -579,7 +579,7 @@ /* Only count packets that pass the filter, for consistency with standard Linux behaviour. */ processed++; - if (processed == cnt && cnt > 0) + if (processed == cnt && !PACKET_COUNT_IS_UNLIMITED(cnt)) { /* Reached the user-specified limit. */ return cnt; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libpcap-1.5.2/pcap-dos.c new/libpcap-1.5.3/pcap-dos.c --- old/libpcap-1.5.2/pcap-dos.c 2013-11-08 00:23:22.000000000 +0100 +++ new/libpcap-1.5.3/pcap-dos.c 2014-01-14 21:40:35.000000000 +0100 @@ -335,7 +335,7 @@ struct pcap_dos *pd = p->priv; int rc, num = 0; - while (num <= cnt || (cnt < 0)) + while (num <= cnt || PACKET_COUNT_IS_UNLIMITED(cnt)) { if (p->fd <= 0) return (-1); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libpcap-1.5.2/pcap-int.h new/libpcap-1.5.3/pcap-int.h --- old/libpcap-1.5.2/pcap-int.h 2013-11-08 00:23:22.000000000 +0100 +++ new/libpcap-1.5.3/pcap-int.h 2014-01-14 21:40:35.000000000 +0100 @@ -337,6 +337,12 @@ #endif /* + * Does the packet count argument to a module's read routine say + * "supply packets until you run out of packets"? + */ +#define PACKET_COUNT_IS_UNLIMITED(count) ((count) <= 0) + +/* * Routines that most pcap implementations can use for non-blocking mode. */ #if !defined(WIN32) && !defined(MSDOS) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libpcap-1.5.2/pcap-linux.c new/libpcap-1.5.3/pcap-linux.c --- old/libpcap-1.5.2/pcap-linux.c 2013-12-03 16:11:24.000000000 +0100 +++ new/libpcap-1.5.3/pcap-linux.c 2014-01-14 21:40:35.000000000 +0100 @@ -289,7 +289,8 @@ struct pcap_stat stat; char *device; /* device name */ - int filtering_in_kernel; /* using kernel filter */ + int filter_in_userland; /* must filter in userland */ + int blocks_to_filter_in_userland; int must_do_on_close; /* stuff we must do when we close */ int timeout; /* timeout for buffering */ int sock_packet; /* using Linux 2.0 compatible interface */ @@ -1703,7 +1704,7 @@ caplen = handle->snapshot; /* Run the packet filter if not using kernel filter */ - if (!handlep->filtering_in_kernel && handle->fcode.bf_insns) { + if (handlep->filter_in_userland && handle->fcode.bf_insns) { if (bpf_filter(handle->fcode.bf_insns, bp, packet_len, caplen) == 0) { @@ -2387,7 +2388,7 @@ * Run user level packet filter by default. Will be overriden if * installing a kernel filter succeeds. */ - handlep->filtering_in_kernel = 0; + handlep->filter_in_userland = 1; /* Install kernel level filter if possible */ @@ -2475,8 +2476,11 @@ if (can_filter_in_kernel) { if ((err = set_kernel_filter(handle, &fcode)) == 0) { - /* Installation succeded - using kernel filter. */ - handlep->filtering_in_kernel = 1; + /* + * Installation succeded - using kernel filter, + * so userland filtering not needed. + */ + handlep->filter_in_userland = 0; } else if (err == -1) /* Non-fatal error */ { @@ -2501,7 +2505,7 @@ * calling "pcap_setfilter()". Otherwise, the kernel filter may * filter out packets that would pass the new userland filter. */ - if (!handlep->filtering_in_kernel) + if (handlep->filter_in_userland) reset_kernel_filter(handle); /* @@ -3511,7 +3515,19 @@ handlep->tp_hdrlen = sizeof(struct tpacket_hdr); #ifdef HAVE_TPACKET3 - ret = init_tpacket(handle, TPACKET_V3, "TPACKET_V3"); + /* + * The only mode in which buffering is done on PF_PACKET + * sockets, so that packets might not be delivered + * immediately, is TPACKET_V3 mode. + * + * The buffering cannot be disabled in that mode, so + * if the user has requested immediate mode, we don't + * use TPACKET_V3. + */ + if (handle->opt.immediate) + ret = 1; /* pretend TPACKET_V3 couldn't be set */ + else + ret = init_tpacket(handle, TPACKET_V3, "TPACKET_V3"); if (-1 == ret) { /* Error during setting up TPACKET_V3. */ return -1; @@ -4054,9 +4070,31 @@ pollinfo.fd = handle->fd; pollinfo.events = POLLIN; - if (handlep->timeout == 0) - timeout = -1; /* block forever */ - else if (handlep->timeout > 0) + if (handlep->timeout == 0) { +#ifdef HAVE_TPACKET3 + /* + * XXX - due to a set of (mis)features in the + * TPACKET_V3 kernel code, 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. + * + * If those issues are ever fixed, we might + * want to check the kernel version and block + * forever with TPACKET_V3 if we're running + * with a kernel that has the fix. + */ + if (handlep->tp_version == TPACKET_V3) + timeout = 1; /* don't block for very long */ + else +#endif + timeout = -1; /* block forever */ + } else if (handlep->timeout > 0) timeout = handlep->timeout; /* block for that amount of time */ else timeout = 0; /* non-blocking mode - poll to pick up errors */ @@ -4145,7 +4183,6 @@ { struct pcap_linux *handlep = handle->priv; unsigned char *bp; - int run_bpf; struct sockaddr_ll *sll; struct pcap_pkthdr pcaphdr; @@ -4162,15 +4199,13 @@ * If the kernel filtering is enabled we need to run the * filter until all the frames present into the ring * at filter creation time are processed. - * In such case filtering_in_kernel is used as a counter for the - * packet we need to filter. + * In this case, blocks_to_filter_in_userland is used + * as a counter for the packet we need to filter. * Note: alternatively it could be possible to stop applying * the filter when the ring became empty, but it can possibly * happen a lot later... */ bp = frame + tp_mac; - run_bpf = (!handlep->filtering_in_kernel) || - ((handlep->filtering_in_kernel>1) && handlep->filtering_in_kernel--); - if (run_bpf && handle->fcode.bf_insns && + if (handlep->filter_in_userland && handle->fcode.bf_insns && (bpf_filter(handle->fcode.bf_insns, bp, tp_len, tp_snaplen) == 0)) return 0; @@ -4282,7 +4317,7 @@ /* non-positive values of max_packets are used to require all * packets currently available in the ring */ - while ((pkts < max_packets) || (max_packets <= 0)) { + while ((pkts < max_packets) || PACKET_COUNT_IS_UNLIMITED(max_packets)) { union thdr h; h.raw = pcap_get_ring_frame(handle, TP_STATUS_USER); @@ -4308,9 +4343,25 @@ return ret; } - /* next packet */ + /* + * Hand this block back to the kernel, and, if we're + * counting blocks that need to be filtered in userland + * after having been filtered by the kernel, count + * the one we've just processed. + */ h.h1->tp_status = TP_STATUS_KERNEL; + if (handlep->blocks_to_filter_in_userland > 0) { + handlep->blocks_to_filter_in_userland--; + if (handlep->blocks_to_filter_in_userland == 0) { + /* + * No more blocks need to be filtered + * in userland. + */ + handlep->filter_in_userland = 0; + } + } + /* next block */ if (++handle->offset >= handle->cc) handle->offset = 0; @@ -4340,7 +4391,7 @@ /* non-positive values of max_packets are used to require all * packets currently available in the ring */ - while ((pkts < max_packets) || (max_packets <= 0)) { + while ((pkts < max_packets) || PACKET_COUNT_IS_UNLIMITED(max_packets)) { union thdr h; h.raw = pcap_get_ring_frame(handle, TP_STATUS_USER); @@ -4370,9 +4421,25 @@ return ret; } - /* next packet */ + /* + * Hand this block back to the kernel, and, if we're + * counting blocks that need to be filtered in userland + * after having been filtered by the kernel, count + * the one we've just processed. + */ h.h2->tp_status = TP_STATUS_KERNEL; + if (handlep->blocks_to_filter_in_userland > 0) { + handlep->blocks_to_filter_in_userland--; + if (handlep->blocks_to_filter_in_userland == 0) { + /* + * No more blocks need to be filtered + * in userland. + */ + handlep->filter_in_userland = 0; + } + } + /* next block */ if (++handle->offset >= handle->cc) handle->offset = 0; @@ -4409,7 +4476,7 @@ /* non-positive values of max_packets are used to require all * packets currently available in the ring */ - while ((pkts < max_packets) || (max_packets <= 0)) { + while ((pkts < max_packets) || PACKET_COUNT_IS_UNLIMITED(max_packets)) { if (handlep->current_packet == NULL) { h.raw = pcap_get_ring_frame(handle, TP_STATUS_USER); if (!h.raw) @@ -4420,7 +4487,7 @@ } int packets_to_read = handlep->packets_left; - if (max_packets >= 0 && packets_to_read > max_packets) { + if (!PACKET_COUNT_IS_UNLIMITED(max_packets) && packets_to_read > max_packets) { packets_to_read = max_packets; } @@ -4454,9 +4521,26 @@ } if (handlep->packets_left <= 0) { - /* next block */ + /* + * Hand this block back to the kernel, and, if + * we're counting blocks that need to be + * filtered in userland after having been + * filtered by the kernel, count the one we've + * just processed. + */ h.h3->hdr.bh1.block_status = TP_STATUS_KERNEL; + if (handlep->blocks_to_filter_in_userland > 0) { + handlep->blocks_to_filter_in_userland--; + if (handlep->blocks_to_filter_in_userland == 0) { + /* + * No more blocks need to be filtered + * in userland. + */ + handlep->filter_in_userland = 0; + } + } + /* next block */ if (++handle->offset >= handle->cc) handle->offset = 0; @@ -4490,13 +4574,22 @@ if (ret < 0) return ret; - /* if the kernel filter is enabled, we need to apply the filter on - * all packets present into the ring. Get an upper bound of their number + /* + * If we're filtering in userland, there's nothing to do; + * the new filter will be used for the next packet. */ - if (!handlep->filtering_in_kernel) + if (handlep->filter_in_userland) return ret; - /* walk the ring backward and count the free slot */ + /* + * We're filtering in the kernel; the packets present in + * all blocks currently in the ring were already filtered + * by the old filter, and so will need to be filtered in + * userland by the new filter. + * + * Get an upper bound for the number of such blocks; first, + * walk the ring backward and count the free blocks. + */ offset = handle->offset; if (--handle->offset < 0) handle->offset = handle->cc - 1; @@ -4507,11 +4600,39 @@ break; } + /* + * If we found free blocks, decrement the count of free + * blocks by 1, just in case we lost a race with another + * thread of control that was adding a packet while + * we were counting and that had run the filter before + * we changed it. + * + * XXX - could there be more than one block added in + * this fashion? + * + * XXX - is there a way to avoid that race, e.g. somehow + * wait for all packets that passed the old filter to + * be added to the ring? + */ + if (n != 0) + n--; + /* be careful to not change current ring position */ handle->offset = offset; - /* store the number of packets currently present in the ring */ - handlep->filtering_in_kernel = 1 + (handle->cc - n); + /* + * Set the count of blocks worth of packets to filter + * in userland to the total number of blocks in the + * ring minus the number of free blocks we found, and + * turn on userland filtering. (The count of blocks + * worth of packets to filter in userland is guaranteed + * not to be zero - n, above, couldn't be set to a + * value > handle->cc, and if it were equal to + * handle->cc, it wouldn't be zero, and thus would + * be decremented to handle->cc - 1.) + */ + handlep->blocks_to_filter_in_userland = handle->cc - n; + handlep->filter_in_userland = 1; return ret; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libpcap-1.5.2/pcap-nit.c new/libpcap-1.5.3/pcap-nit.c --- old/libpcap-1.5.2/pcap-nit.c 2013-11-08 00:23:22.000000000 +0100 +++ new/libpcap-1.5.3/pcap-nit.c 2014-01-14 21:40:35.000000000 +0100 @@ -189,7 +189,7 @@ h.len = nh->nh_wirelen; h.caplen = caplen; (*callback)(user, &h, cp); - if (++n >= cnt && cnt > 0) { + if (++n >= cnt && !PACKET_COUNT_IS_UNLIMITED(cnt)) { p->cc = ep - bp; p->bp = bp; return (n); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libpcap-1.5.2/pcap-pf.c new/libpcap-1.5.3/pcap-pf.c --- old/libpcap-1.5.2/pcap-pf.c 2013-11-08 00:23:22.000000000 +0100 +++ new/libpcap-1.5.3/pcap-pf.c 2014-01-14 21:40:35.000000000 +0100 @@ -219,7 +219,7 @@ buflen -= pad; h.caplen = buflen; (*callback)(user, &h, p); - if (++n >= cnt && cnt > 0) { + if (++n >= cnt && !PACKET_COUNT_IS_UNLIMITED(cnt)) { pc->cc = cc; pc->bp = bp; return (n); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libpcap-1.5.2/pcap-snf.c new/libpcap-1.5.3/pcap-snf.c --- old/libpcap-1.5.2/pcap-snf.c 2013-11-08 00:23:22.000000000 +0100 +++ new/libpcap-1.5.3/pcap-snf.c 2014-01-14 21:40:35.000000000 +0100 @@ -118,7 +118,7 @@ return -1; n = 0; - while (n < cnt || cnt < 0) { + while (n < cnt || PACKET_COUNT_IS_UNLIMITED(cnt)) { /* * Has "pcap_breakloop()" been called? */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libpcap-1.5.2/pcap-snit.c new/libpcap-1.5.3/pcap-snit.c --- old/libpcap-1.5.2/pcap-snit.c 2013-11-08 00:23:22.000000000 +0100 +++ new/libpcap-1.5.3/pcap-snit.c 2014-01-14 21:40:35.000000000 +0100 @@ -201,7 +201,7 @@ h.len = nlp->nh_pktlen; h.caplen = caplen; (*callback)(user, &h, cp); - if (++n >= cnt && cnt > 0) { + if (++n >= cnt && !PACKET_COUNT_IS_UNLIMITED(cnt)) { p->cc = ep - bp; p->bp = bp; return (n); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libpcap-1.5.2/pcap-usb-linux.c new/libpcap-1.5.3/pcap-usb-linux.c --- old/libpcap-1.5.2/pcap-usb-linux.c 2013-11-08 00:23:22.000000000 +0100 +++ new/libpcap-1.5.3/pcap-usb-linux.c 2014-01-14 21:40:35.000000000 +0100 @@ -908,8 +908,8 @@ } } - /* with max_packets <= 0 we stop afer the first chunk*/ - if ((max_packets <= 0) || (packets == max_packets)) + /* with max_packets specifying "unlimited" we stop afer the first chunk*/ + if (PACKET_COUNT_IS_UNLIMITED(max_packets) || (packets == max_packets)) break; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libpcap-1.5.2/pcap-win32.c new/libpcap-1.5.3/pcap-win32.c --- old/libpcap-1.5.2/pcap-win32.c 2013-11-08 00:23:22.000000000 +0100 +++ new/libpcap-1.5.3/pcap-win32.c 2014-01-14 21:40:35.000000000 +0100 @@ -256,7 +256,7 @@ */ (*callback)(user, (struct pcap_pkthdr*)bp, bp + hdrlen); bp += Packet_WORDALIGN(caplen + hdrlen); - if (++n >= cnt && cnt > 0) { + if (++n >= cnt && !PACKET_COUNT_IS_UNLIMITED(cnt)) { p->bp = bp; p->cc = ep - bp; return (n); @@ -416,7 +416,7 @@ header = (dag_record_t*)((char*)header + erf_record_len); /* Stop if the number of packets requested by user has been reached*/ - if (++n >= cnt && cnt > 0) + if (++n >= cnt && !PACKET_COUNT_IS_UNLIMITED(cnt)) { p->bp = (char*)header; p->cc = endofbuf - (char*)header; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libpcap-1.5.2/pcap.3pcap.in new/libpcap-1.5.3/pcap.3pcap.in --- old/libpcap-1.5.2/pcap.3pcap.in 2013-11-08 00:23:22.000000000 +0100 +++ new/libpcap-1.5.3/pcap.3pcap.in 2014-01-14 21:40:35.000000000 +0100 @@ -174,9 +174,11 @@ .IP Not all platforms support a read timeout; on platforms that don't, the read timeout is ignored. A zero value for the timeout, -on platforms that support a read timeout, -will cause a read to wait forever to allow enough packets to -arrive, with no timeout. +on platforms that support a read timeout, has platform-dependent +behavior that could cause a read to wait for an unlimited amount +of time until the capture buffer fills up or could cause a read timeout +of 1 millisecond to be used. We recommend that a value of zero not be +used. .IP .BR NOTE : the read timeout cannot be used to cause calls that read diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libpcap-1.5.2/pcap.c new/libpcap-1.5.3/pcap.c --- old/libpcap-1.5.2/pcap.c 2013-11-08 00:23:22.000000000 +0100 +++ new/libpcap-1.5.3/pcap.c 2014-01-14 21:40:35.000000000 +0100 @@ -858,7 +858,7 @@ } if (n <= 0) return (n); - if (cnt > 0) { + if (!PACKET_COUNT_IS_UNLIMITED(cnt)) { cnt -= n; if (cnt <= 0) return (0); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libpcap-1.5.2/pcap_datalink_val_to_name.3pcap new/libpcap-1.5.3/pcap_datalink_val_to_name.3pcap --- old/libpcap-1.5.2/pcap_datalink_val_to_name.3pcap 2013-11-08 00:23:22.000000000 +0100 +++ new/libpcap-1.5.3/pcap_datalink_val_to_name.3pcap 2014-01-14 21:40:35.000000000 +0100 @@ -37,8 +37,12 @@ .SH DESCRIPTION .B pcap_datalink_val_to_name() translates a link-layer header type value to the corresponding -link-layer header type name. NULL is returned on failure. +link-layer header type name. +.B NULL +is returned on failure. .PP .B pcap_datalink_val_to_description() translates a link-layer header type value to a short description of that -link-layer header type. NULL is returned on failure. +link-layer header type. +.B NULL +is returned on failure. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libpcap-1.5.2/pcap_get_tstamp_precision.3pcap.in new/libpcap-1.5.3/pcap_get_tstamp_precision.3pcap.in --- old/libpcap-1.5.2/pcap_get_tstamp_precision.3pcap.in 2013-11-08 00:23:22.000000000 +0100 +++ new/libpcap-1.5.3/pcap_get_tstamp_precision.3pcap.in 2014-01-14 21:40:35.000000000 +0100 @@ -39,8 +39,13 @@ descriptor. .SH RETURN VALUE .B pcap_get_tstamp_precision() -returns PCAP_TSTAMP_PRECISION_MICRO or PCAP_TSTAMP_PRECISION_NANO, which indicates -that pcap captures contains time stamps in microseconds or nanoseconds respectively. +returns +.B PCAP_TSTAMP_PRECISION_MICRO +or +.BR PCAP_TSTAMP_PRECISION_NANO , +which indicates +that pcap captures contains time stamps in microseconds or nanoseconds +respectively. .SH SEE ALSO pcap(3PCAP), pcap_set_tstamp_precision(3PCAP), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libpcap-1.5.2/pcap_set_immediate_mode.3pcap new/libpcap-1.5.3/pcap_set_immediate_mode.3pcap --- old/libpcap-1.5.2/pcap_set_immediate_mode.3pcap 2013-11-08 00:23:22.000000000 +0100 +++ new/libpcap-1.5.3/pcap_set_immediate_mode.3pcap 2014-01-14 21:40:35.000000000 +0100 @@ -18,7 +18,7 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" -.TH PCAP_SET_IMMEDIATE_MODE 3PCAP "8 May 20013" +.TH PCAP_SET_IMMEDIATE_MODE 3PCAP "8 May 2013" .SH NAME pcap_set_immediate_mode \- set immediate mode for a not-yet-activated capture handle diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libpcap-1.5.2/pcap_set_timeout.3pcap new/libpcap-1.5.3/pcap_set_timeout.3pcap --- old/libpcap-1.5.2/pcap_set_timeout.3pcap 2013-11-08 00:23:22.000000000 +0100 +++ new/libpcap-1.5.3/pcap_set_timeout.3pcap 2014-01-14 21:40:35.000000000 +0100 @@ -38,6 +38,9 @@ the handle is activated to .IR to_ms , which is in units of milliseconds. +.LP +The behavior, if the timeout isn't specified, is undefined. We +recommend always setting the timeout to a non-zero value. .SH RETURN VALUE .B pcap_set_timeout() returns 0 on success or diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libpcap-1.5.2/pcap_tstamp_type_val_to_name.3pcap new/libpcap-1.5.3/pcap_tstamp_type_val_to_name.3pcap --- old/libpcap-1.5.2/pcap_tstamp_type_val_to_name.3pcap 2013-11-08 00:23:22.000000000 +0100 +++ new/libpcap-1.5.3/pcap_tstamp_type_val_to_name.3pcap 2014-01-14 21:40:35.000000000 +0100 @@ -36,10 +36,14 @@ .SH DESCRIPTION .B pcap_tstamp_type_val_to_name() translates a time stamp type value to the corresponding time stamp type -name. NULL is returned on failure. +name. +.B NULL +is returned on failure. .PP .B pcap_tstamp_type_val_to_description() translates a time stamp type value to a short description of that time -stamp type. NULL is returned on failure. +stamp type. +.B NULL +is returned on failure. .SH SEE ALSO pcap(3PCAP), pcap_tstamp_type_name_to_val(3PCAP) ++++++ libpcap-netlink.patch ++++++ diff --git a/pcap-common.c b/pcap-common.c index 6175a5a..f26d22e 100644 --- a/pcap-common.c +++ b/pcap-common.c @@ -932,7 +932,12 @@ */ #define LINKTYPE_WIRESHARK_UPPER_PDU 252 -#define LINKTYPE_MATCHING_MAX 252 /* highest value in the "matching" range */ +/* + * Link-layer header type for the netlink protocol (nlmon devices). + */ +#define LINKTYPE_NETLINK 253 + +#define LINKTYPE_MATCHING_MAX 253 /* highest value in the "matching" range */ static struct linktype_map { int dlt; diff --git a/pcap-linux.c b/pcap-linux.c index c6fd076..1d2c130 100644 --- a/pcap-linux.c +++ b/pcap-linux.c @@ -2604,6 +2604,8 @@ map_packet_type_to_sll_type(short int sll_pkttype) */ static void map_arphrd_to_dlt(pcap_t *handle, int arptype, int cooked_ok) { + struct pcap_linux *handlep = handle->priv; + switch (arptype) { case ARPHRD_ETHER: @@ -2976,6 +2976,19 @@ static void map_arphrd_to_dlt(pcap_t *handle, int arptype, int cooked_ok) handle->linktype = DLT_IEEE802_15_4_NOFCS; break; +#ifndef ARPHRD_NETLINK +#define ARPHRD_NETLINK 824 +#endif + case ARPHRD_NETLINK: + handle->linktype = DLT_NETLINK; + /* + * We need to use cooked mode, so that in sll_protocol we + * pick up the netlink protocol type such as NETLINK_ROUTE, + * NETLINK_GENERIC, NETLINK_FIB_LOOKUP, etc. + */ + handlep->cooked = 1; + break; + default: handle->linktype = -1; break; @@ -3181,7 +3194,8 @@ activate_new(pcap_t *handle) * same applies to LAPD capture. */ if (handle->linktype != DLT_LINUX_IRDA && - handle->linktype != DLT_LINUX_LAPD) + handle->linktype != DLT_LINUX_LAPD && + handle->linktype != DLT_NETLINK) handle->linktype = DLT_LINUX_SLL; } diff --git a/pcap.c b/pcap.c index 6b16cea..83d4bb1 100644 --- a/pcap.c +++ b/pcap.c @@ -1203,6 +1203,7 @@ static struct dlt_choice dlt_choices[] = { DLT_CHOICE(DLT_NETANALYZER_TRANSPARENT, "Ethernet with Hilscher netANALYZER pseudo-header and with preamble and SFD"), DLT_CHOICE(DLT_IPOIB, "RFC 4391 IP-over-Infiniband"), DLT_CHOICE(DLT_DBUS, "D-Bus"), + DLT_CHOICE(DLT_NETLINK, "Linux netlink"), DLT_CHOICE_SENTINEL }; diff --git a/pcap/bpf.h b/pcap/bpf.h index 608ef39..d30bf95 100644 --- a/pcap/bpf.h +++ b/pcap/bpf.h @@ -1243,7 +1243,12 @@ struct bpf_program { */ #define DLT_WIRESHARK_UPPER_PDU 252 -#define DLT_MATCHING_MAX 252 /* highest value in the "matching" range */ +/* + * DLT type for the netlink protocol (nlmon devices). + */ +#define DLT_NETLINK 253 + +#define DLT_MATCHING_MAX 253 /* highest value in the "matching" range */ /* * DLT and savefile link type values are split into a class and -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
