Source-Changes-HG archive

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

[src/netbsd-1-6]: src/sys/net Pull up revision 1.106 (requested by bouyer in ...



details:   https://anonhg.NetBSD.org/src/rev/f61849e2e3aa
branches:  netbsd-1-6
changeset: 530492:f61849e2e3aa
user:      grant <grant%NetBSD.org@localhost>
date:      Mon Jun 30 03:17:56 2003 +0000

description:
Pull up revision 1.106 (requested by bouyer in ticket #1356):

Make promiscous mode work on vlans: introduce a new link-layer m_flag
M_PROMISC. In ether_input(), flag packets comming from an interface in
promiscous mode which are not for us M_PROMISC instead of droping them.
Drop M_PROMISC packets which are not passed to vlan_input(). M_PROMISC
packets passed to vlan_input() will be looped back to ether_input()
the M_PROMISC flag will be handled appropriately.
Clear M_PROMISC before giving the packet to bridge, as bridge has its
own checks for local MAC addresses.
This also makes bridges on vlan working.

diffstat:

 sys/net/if_ethersubr.c |  49 ++++++++++++++++++++++++++++---------------------
 1 files changed, 28 insertions(+), 21 deletions(-)

diffs (96 lines):

diff -r 070bf9767bc8 -r f61849e2e3aa sys/net/if_ethersubr.c
--- a/sys/net/if_ethersubr.c    Mon Jun 30 03:17:18 2003 +0000
+++ b/sys/net/if_ethersubr.c    Mon Jun 30 03:17:56 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ethersubr.c,v 1.95.2.4 2003/06/24 08:17:22 grant Exp $      */
+/*     $NetBSD: if_ethersubr.c,v 1.95.2.5 2003/06/30 03:17:56 grant Exp $      */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.95.2.4 2003/06/24 08:17:22 grant Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.95.2.5 2003/06/30 03:17:56 grant Exp $");
 
 #include "opt_inet.h"
 #include "opt_atalk.h"
@@ -722,6 +722,8 @@
         * process it locally.
         */
        if (ifp->if_bridge) {
+               /* clear M_PROMISC, in case the packets comes from a vlan */
+               m->m_flags &= ~M_PROMISC;
                m = bridge_input(ifp, m);
                if (m == NULL)
                        return;
@@ -732,29 +734,27 @@
                 * to "bridge" the packet locally.
                 */
                ifp = m->m_pkthdr.rcvif;
-       }
+       } else 
 #endif /* NBRIDGE > 0 */
-
-       /*
-        * XXX This comparison is redundant if we are a bridge
-        * XXX and processing the packet locally.
-        */
-       if ((m->m_flags & (M_BCAST|M_MCAST)) == 0 &&
-           (ifp->if_flags & IFF_PROMISC) != 0 &&
-           memcmp(LLADDR(ifp->if_sadl), eh->ether_dhost,
-                  ETHER_ADDR_LEN) != 0) {
-               m_freem(m);
-               return;
+       {
+               if ((m->m_flags & (M_BCAST|M_MCAST)) == 0 &&
+                   (ifp->if_flags & IFF_PROMISC) != 0 &&
+                   memcmp(LLADDR(ifp->if_sadl), eh->ether_dhost,
+                          ETHER_ADDR_LEN) != 0) {
+                       m->m_flags |= M_PROMISC;
+               }
        }
 
 #ifdef PFIL_HOOKS
-       if (pfil_run_hooks(&ifp->if_pfil, &m, ifp, PFIL_IN) != 0)
-               return;
-       if (m == NULL)
-               return;
+       if ((m->m_flags & M_PROMISC) == 0) {
+               if (pfil_run_hooks(&ifp->if_pfil, &m, ifp, PFIL_IN) != 0)
+                       return;
+               if (m == NULL)
+                       return;
 
-       eh = mtod(m, struct ether_header *);
-       etype = ntohs(eh->ether_type);
+               eh = mtod(m, struct ether_header *);
+               etype = ntohs(eh->ether_type);
+       }
 #endif
 
        /*
@@ -796,6 +796,10 @@
 #if NPPPOE > 0
        case ETHERTYPE_PPPOEDISC:
        case ETHERTYPE_PPPOE:
+               if (m->m_flags & M_PROMISC) {
+                       m_freem(m);
+                       return;
+               }
 #ifndef PPPOE_SERVER
                if (m->m_flags & (M_MCAST | M_BCAST)) {
                        m_freem(m);
@@ -823,7 +827,10 @@
                return;
 #endif /* NPPPOE > 0 */
        default:
-               ; /* Nothing. */
+               if (m->m_flags & M_PROMISC) {
+                       m_freem(m);
+                       return;
+               }
        }
 
        /* Strip off the Ethernet header. */



Home | Main Index | Thread Index | Old Index