Fri Dec 16 03:05:23 2011 UTC ()
make comment reflect reality


(christos)
diff -r1.167 -r1.168 src/sys/net/bpf.c

cvs diff -r1.167 -r1.168 src/sys/net/bpf.c (expand / switch to unified diff)

--- src/sys/net/bpf.c 2011/12/15 22:20:26 1.167
+++ src/sys/net/bpf.c 2011/12/16 03:05:23 1.168
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: bpf.c,v 1.167 2011/12/15 22:20:26 christos Exp $ */ 1/* $NetBSD: bpf.c,v 1.168 2011/12/16 03:05:23 christos Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1990, 1991, 1993 4 * Copyright (c) 1990, 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from the Stanford/CMU enet packet filter, 7 * This code is derived from the Stanford/CMU enet packet filter,
8 * (net/enet.c) distributed as part of 4.3BSD, and code contributed 8 * (net/enet.c) distributed as part of 4.3BSD, and code contributed
9 * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence 9 * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
10 * Berkeley Laboratory. 10 * Berkeley Laboratory.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -29,27 +29,27 @@ @@ -29,27 +29,27 @@
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE. 34 * SUCH DAMAGE.
35 * 35 *
36 * @(#)bpf.c 8.4 (Berkeley) 1/9/95 36 * @(#)bpf.c 8.4 (Berkeley) 1/9/95
37 * static char rcsid[] = 37 * static char rcsid[] =
38 * "Header: bpf.c,v 1.67 96/09/26 22:00:52 leres Exp "; 38 * "Header: bpf.c,v 1.67 96/09/26 22:00:52 leres Exp ";
39 */ 39 */
40 40
41#include <sys/cdefs.h> 41#include <sys/cdefs.h>
42__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.167 2011/12/15 22:20:26 christos Exp $"); 42__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.168 2011/12/16 03:05:23 christos Exp $");
43 43
44#if defined(_KERNEL_OPT) 44#if defined(_KERNEL_OPT)
45#include "opt_bpf.h" 45#include "opt_bpf.h"
46#include "sl.h" 46#include "sl.h"
47#include "strip.h" 47#include "strip.h"
48#endif 48#endif
49 49
50#include <sys/param.h> 50#include <sys/param.h>
51#include <sys/systm.h> 51#include <sys/systm.h>
52#include <sys/mbuf.h> 52#include <sys/mbuf.h>
53#include <sys/buf.h> 53#include <sys/buf.h>
54#include <sys/time.h> 54#include <sys/time.h>
55#include <sys/proc.h> 55#include <sys/proc.h>
@@ -1537,32 +1537,33 @@ bpf_hdrlen(struct bpf_d *d) @@ -1537,32 +1537,33 @@ bpf_hdrlen(struct bpf_d *d)
1537 /* 1537 /*
1538 * Compute the length of the bpf header. This is not necessarily 1538 * Compute the length of the bpf header. This is not necessarily
1539 * equal to SIZEOF_BPF_HDR because we want to insert spacing such 1539 * equal to SIZEOF_BPF_HDR because we want to insert spacing such
1540 * that the network layer header begins on a longword boundary (for 1540 * that the network layer header begins on a longword boundary (for
1541 * performance reasons and to alleviate alignment restrictions). 1541 * performance reasons and to alleviate alignment restrictions).
1542 */ 1542 */
1543#ifdef _LP64 1543#ifdef _LP64
1544 if (d->bd_compat32) 1544 if (d->bd_compat32)
1545 return (BPF_WORDALIGN32(hdrlen + SIZEOF_BPF_HDR32) - hdrlen); 1545 return (BPF_WORDALIGN32(hdrlen + SIZEOF_BPF_HDR32) - hdrlen);
1546 else 1546 else
1547#endif 1547#endif
1548 return (BPF_WORDALIGN(hdrlen + SIZEOF_BPF_HDR) - hdrlen); 1548 return (BPF_WORDALIGN(hdrlen + SIZEOF_BPF_HDR) - hdrlen);
1549} 1549}
 1550
1550/* 1551/*
1551 * Move the packet data from interface memory (pkt) into the 1552 * Move the packet data from interface memory (pkt) into the
1552 * store buffer. Return 1 if it's time to wakeup a listener (buffer full), 1553 * store buffer. Call the wakeup functions if it's time to wakeup
1553 * otherwise 0. "copy" is the routine called to do the actual data 1554 * a listener (buffer full), "cpfn" is the routine called to do the
1554 * transfer. memcpy is passed in to copy contiguous chunks, while 1555 * actual data transfer. memcpy is passed in to copy contiguous chunks,
1555 * bpf_mcpy is passed in to copy mbuf chains. In the latter case, 1556 * while bpf_mcpy is passed in to copy mbuf chains. In the latter case,
1556 * pkt is really an mbuf. 1557 * pkt is really an mbuf.
1557 */ 1558 */
1558static void 1559static void
1559catchpacket(struct bpf_d *d, u_char *pkt, u_int pktlen, u_int snaplen, 1560catchpacket(struct bpf_d *d, u_char *pkt, u_int pktlen, u_int snaplen,
1560 void *(*cpfn)(void *, const void *, size_t), struct timespec *ts) 1561 void *(*cpfn)(void *, const void *, size_t), struct timespec *ts)
1561{ 1562{
1562 struct bpf_hdr *hp; 1563 struct bpf_hdr *hp;
1563#ifdef _LP64 1564#ifdef _LP64
1564 struct bpf_hdr32 *hp32; 1565 struct bpf_hdr32 *hp32;
1565#endif 1566#endif
1566 int totlen, curlen; 1567 int totlen, curlen;
1567 int hdrlen = bpf_hdrlen(d); 1568 int hdrlen = bpf_hdrlen(d);
1568 int do_wakeup = 0; 1569 int do_wakeup = 0;