Subject: kern/12720: BIOCSSEESENT ioctl command for bpf is not implemented (but mentioned in the manual)
To: None <gnats-bugs@gnats.netbsd.org>
From: None <ryoji.kato@nrj.ericsson.se>
List: netbsd-bugs
Date: 04/22/2001 22:24:27
>Number:         12720
>Category:       kern
>Synopsis:       BIOCSSEESENT ioctl command for bpf is not implemented (but mentioned in the manual)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Apr 22 22:25:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Ryoji Kato
>Release:        1.5
>Organization:
Nippon Ericsson K.K.
>Environment:
NetBSD air 1.5 NetBSD 1.5 (CONF_AIR_EQUIUM) #0: Wed Apr 18 17:19:01 GMT 2001 nrjryka@net:/work/i386/sys/arch/i386/compile/CONF_AIR_EQUIUM i386
>Description:
"man bpf" says BPF see only incoming packets on the interface if
BIOCSSEESENT set to zero. But this command seem not to be implemented
in the kernel and not appeared in the bpf header file.
>How-To-Repeat:
You will get the compile error when using BIOCSSEESENT command in your
bpf application.
>Fix:
This patch could fix the problem. The patched header files should be copied to /usr/include/net.


--- sys/net/bpf.h.orig  Wed Apr 18 14:39:46 2001
+++ sys/net/bpf.h       Wed Apr 18 14:40:24 2001
@@ -139,6 +139,8 @@
 #define BIOCSUDPF      _IOW('B',115, struct bpf_program)
 #define        BIOCGHDRCMPLT   _IOR('B',116, u_int)
 #define        BIOCSHDRCMPLT   _IOW('B',117, u_int)
+#define BIOCGSEESENT   _IOR('B',118, u_int)
+#define BIOCSSEESENT   _IOW('B',119, u_int)
 #endif

 /*
--- sys/net/bpfdesc.h.orig      Wed Apr 18 14:40:36 2001
+++ sys/net/bpfdesc.h   Wed Apr 18 14:42:32 2001
@@ -79,6 +79,7 @@
        u_char          bd_state;       /* idle, waiting, or timed out */
        u_char          bd_immediate;   /* true to return on packet arrival */
        int             bd_hdrcmplt;    /* false to fill in src lladdr */
+       int             bd_seesent;     /* true if bpf sees sent packets */
        int             bd_async;       /* non-zero if packet reception should g
enerate signal */
        pid_t           bd_pgid;        /* process or group id for signal */
 #if BSD < 199103
--- sys/net/bpf.c.orig  Wed Apr 18 14:43:23 2001
+++ sys/net/bpf.c       Wed Apr 18 14:47:00 2001
@@ -352,6 +352,7 @@
        /* Mark "free" and do most initialization. */
        memset((char *)d, 0, sizeof(*d));
        d->bd_bufsize = bpf_bufsize;
+       d->bd_seesent = 1;

        return (0);
 }
@@ -806,6 +807,14 @@
                d->bd_hdrcmplt = *(u_int *)addr ? 1 : 0;
                break;

+       case BIOCGSEESENT:      /* get "see sent packets" flag */
+               *(u_int *)addr = d->bd_seesent;
+               break;
+
+       case BIOCSSEESENT:      /* set "see sent packets" flag */
+               d->bd_seesent = *(u_int *)addr;
+               break;
+
        case FIONBIO:           /* Non-blocking I/O */
                if (*(int *)addr)
                        d->bd_rtout = -1;
@@ -1078,6 +1087,8 @@
                pktlen += m0->m_len;

        for (d = bp->bif_dlist; d != 0; d = d->bd_next) {
+               if (!d->bd_seesent && (m->m_pkthdr.rcvif == NULL))
+                       continue;
                ++d->bd_rcount;
                slen = bpf_filter(d->bd_filter, (u_char *)m, pktlen, 0);
                if (slen != 0)



>Release-Note:
>Audit-Trail:
>Unformatted: