Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net bpf_mtap() does not care about M_PKTHDR at the top. ...



details:   https://anonhg.NetBSD.org/src/rev/4289147c7d34
branches:  trunk
changeset: 546524:4289147c7d34
user:      itojun <itojun%NetBSD.org@localhost>
date:      Thu May 01 07:52:58 2003 +0000

description:
bpf_mtap() does not care about M_PKTHDR at the top.  M_COPY_PKTHDR has some
consequences, so avoid it.  if we need to attach dummy headers, we should
use M_PREPEND instead.

diffstat:

 sys/net/if_ieee1394subr.c |  10 ++++------
 sys/net/if_loop.c         |   7 +++----
 sys/net/if_sl.c           |   5 +++--
 sys/net/if_stf.c          |   6 ++++--
 sys/net/if_strip.c        |   5 +++--
 sys/net/if_tun.c          |   6 ++++--
 6 files changed, 21 insertions(+), 18 deletions(-)

diffs (201 lines):

diff -r 056a3e6fdef0 -r 4289147c7d34 sys/net/if_ieee1394subr.c
--- a/sys/net/if_ieee1394subr.c Thu May 01 07:41:59 2003 +0000
+++ b/sys/net/if_ieee1394subr.c Thu May 01 07:52:58 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ieee1394subr.c,v 1.20 2003/05/01 07:41:59 itojun Exp $      */
+/*     $NetBSD: if_ieee1394subr.c,v 1.21 2003/05/01 07:52:58 itojun Exp $      */
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ieee1394subr.c,v 1.20 2003/05/01 07:41:59 itojun Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ieee1394subr.c,v 1.21 2003/05/01 07:52:58 itojun Exp $");
 
 #include "opt_inet.h"
 #include "bpfilter.h"
@@ -189,14 +189,13 @@
        if (ifp->if_bpf) {
                struct mbuf mb;
 
-               M_COPY_PKTHDR(&mb, m0);
+               mb.m_flags = 0;
                mb.m_next = m0;
                mb.m_len = 14;
                ((u_int32_t *)mb.m_data)[0] = 0;
                ((u_int32_t *)mb.m_data)[1] = 0;
                ((u_int32_t *)mb.m_data)[2] = 0;
                ((u_int16_t *)mb.m_data)[6] = etype;
-               mb.m_pkthdr.len += mb.m_len;
                bpf_mtap(ifp->if_bpf, &mb);
        }
 #endif
@@ -370,14 +369,13 @@
        if (ifp->if_bpf) {
                struct mbuf mb;
 
-               M_COPY_PKTHDR(&mb, m);
+               mb.m_flags = 0;
                mb.m_next = m;
                mb.m_len = 14;
                ((u_int32_t *)mb.m_data)[0] = 0;
                ((u_int32_t *)mb.m_data)[1] = 0;
                ((u_int32_t *)mb.m_data)[2] = 0;
                ((u_int16_t *)mb.m_data)[6] = iuh->iuh_etype;
-               mb.m_pkthdr.len += mb.m_len;
                bpf_mtap(ifp->if_bpf, &mb);
        }
 #endif
diff -r 056a3e6fdef0 -r 4289147c7d34 sys/net/if_loop.c
--- a/sys/net/if_loop.c Thu May 01 07:41:59 2003 +0000
+++ b/sys/net/if_loop.c Thu May 01 07:52:58 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_loop.c,v 1.42 2003/02/26 06:31:13 matt Exp $        */
+/*     $NetBSD: if_loop.c,v 1.43 2003/05/01 07:52:58 itojun Exp $      */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -69,7 +69,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.42 2003/02/26 06:31:13 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.43 2003/05/01 07:52:58 itojun Exp $");
 
 #include "opt_inet.h"
 #include "opt_atalk.h"
@@ -210,11 +210,10 @@
                struct mbuf m0;
                u_int32_t af = dst->sa_family;
 
-               M_COPY_PKTHDR(&m0, m);
+               m0.m_flags = 0;
                m0.m_next = m;
                m0.m_len = 4;
                m0.m_data = (char *)&af;
-               m0.m_pkthdr.len += m0.m_len;
 
                bpf_mtap(ifp->if_bpf, &m0);
        }
diff -r 056a3e6fdef0 -r 4289147c7d34 sys/net/if_sl.c
--- a/sys/net/if_sl.c   Thu May 01 07:41:59 2003 +0000
+++ b/sys/net/if_sl.c   Thu May 01 07:52:58 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_sl.c,v 1.82 2003/02/26 06:31:13 matt Exp $  */
+/*     $NetBSD: if_sl.c,v 1.83 2003/05/01 07:52:59 itojun Exp $        */
 
 /*
  * Copyright (c) 1987, 1989, 1992, 1993
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_sl.c,v 1.82 2003/02/26 06:31:13 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_sl.c,v 1.83 2003/05/01 07:52:59 itojun Exp $");
 
 #include "sl.h"
 #if NSL > 0
@@ -778,6 +778,7 @@
                        struct mbuf n;
                        u_char *hp;
 
+                       n.m_flags = 0;
                        n.m_next = bpf_m;
                        n.m_data = n.m_dat;
                        n.m_len = SLIP_HDRLEN;
diff -r 056a3e6fdef0 -r 4289147c7d34 sys/net/if_stf.c
--- a/sys/net/if_stf.c  Thu May 01 07:41:59 2003 +0000
+++ b/sys/net/if_stf.c  Thu May 01 07:52:58 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_stf.c,v 1.32 2002/11/17 19:29:31 itojun Exp $       */
+/*     $NetBSD: if_stf.c,v 1.33 2003/05/01 07:52:59 itojun Exp $       */
 /*     $KAME: if_stf.c,v 1.62 2001/06/07 22:32:16 itojun Exp $ */
 
 /*
@@ -75,7 +75,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_stf.c,v 1.32 2002/11/17 19:29:31 itojun Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_stf.c,v 1.33 2003/05/01 07:52:59 itojun Exp $");
 
 #include "opt_inet.h"
 
@@ -407,6 +407,7 @@
                struct mbuf m0;
                u_int32_t af = AF_INET6;
                
+               m0.m_flags = 0;
                m0.m_next = m;
                m0.m_len = 4;
                m0.m_data = (char *)&af;
@@ -686,6 +687,7 @@
                struct mbuf m0;
                u_int32_t af = AF_INET6;
                
+               m0.m_flags = 0;
                m0.m_next = m;
                m0.m_len = 4;
                m0.m_data = (char *)&af;
diff -r 056a3e6fdef0 -r 4289147c7d34 sys/net/if_strip.c
--- a/sys/net/if_strip.c        Thu May 01 07:41:59 2003 +0000
+++ b/sys/net/if_strip.c        Thu May 01 07:52:58 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_strip.c,v 1.47 2003/02/26 06:31:13 matt Exp $       */
+/*     $NetBSD: if_strip.c,v 1.48 2003/05/01 07:52:59 itojun Exp $     */
 /*     from: NetBSD: if_sl.c,v 1.38 1996/02/13 22:00:23 christos Exp $ */
 
 /*
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_strip.c,v 1.47 2003/02/26 06:31:13 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_strip.c,v 1.48 2003/05/01 07:52:59 itojun Exp $");
 
 #include "strip.h"
 
@@ -1171,6 +1171,7 @@
                        struct mbuf n;
                        u_char *hp;
 
+                       n.m_flags = 0;
                        n.m_next = bpf_m;
                        n.m_data = n.m_dat;
                        n.m_len = SLIP_HDRLEN;
diff -r 056a3e6fdef0 -r 4289147c7d34 sys/net/if_tun.c
--- a/sys/net/if_tun.c  Thu May 01 07:41:59 2003 +0000
+++ b/sys/net/if_tun.c  Thu May 01 07:52:58 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_tun.c,v 1.59 2003/03/13 10:24:38 dsl Exp $  */
+/*     $NetBSD: if_tun.c,v 1.60 2003/05/01 07:52:59 itojun Exp $       */
 
 /*
  * Copyright (c) 1988, Julian Onions <jpo%cs.nott.ac.uk@localhost>
@@ -15,7 +15,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.59 2003/03/13 10:24:38 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.60 2003/05/01 07:52:59 itojun Exp $");
 
 #include "tun.h"
 
@@ -472,6 +472,7 @@
                struct mbuf m;
                u_int32_t af = dst->sa_family;
 
+               m.m_flags = 0;
                m.m_next = m0;
                m.m_len = sizeof(af);
                m.m_data = (char *)&af;
@@ -834,6 +835,7 @@
                struct mbuf m;
                u_int32_t af = AF_INET;
 
+               m.m_flags = 0;
                m.m_next = top;
                m.m_len = sizeof(af);
                m.m_data = (char *)&af;



Home | Main Index | Thread Index | Old Index