Subject: sys/dev/ic/smc91cxx.c fix for IFF_SIMPLEX behavior
To: None <thorpej@netbsd.org>
From: None <itojun@iijlab.net>
List: tech-net
Date: 09/08/1999 19:31:29
------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <3740.936786679.1@coconut.itojun.org>
Content-Transfer-Encoding: 7bit

	The following patch fixes behavior for sm* ethernet interface
	during promiscuous mode.  The driver loops back multicast packet
	sent from itself, during promiscuous mode (which is not IFF_SIMPLEX
	behavior).  This fixes IPv6 DAD behavior when you run tcpdump on
	sm* interface.

itojun



------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <3740.936786679.2@coconut.itojun.org>
Content-Transfer-Encoding: 7bit

Index: smc91cxx.c
===================================================================
RCS file: /cvsroot/kame/kame/netbsd/sys/dev/ic/smc91cxx.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 smc91cxx.c
*** smc91cxx.c	1999/07/29 12:24:01	1.1.1.1
--- smc91cxx.c	1999/09/08 10:17:55
***************
*** 928,944 ****
  	 * Hand the packet off to bpf listeners.  If there's a bpf listener,
  	 * we need to check if the packet is ours.
  	 */
! 	if (ifp->if_bpf) {
  		bpf_mtap(ifp->if_bpf, m);
  
! 		if ((ifp->if_flags & IFF_PROMISC) &&
! 		    (eh->ether_dhost[0] & 1) == 0 &&	/* !mcast and !bcast */
! 		    ether_cmp(eh->ether_dhost, LLADDR(ifp->if_sadl))) {
  			m_freem(m);
  			goto out;
  		}
  	}
- #endif
  
  	/*
  	 * Strip the ethernet header.
--- 928,958 ----
  	 * Hand the packet off to bpf listeners.  If there's a bpf listener,
  	 * we need to check if the packet is ours.
  	 */
! 	if (ifp->if_bpf)
  		bpf_mtap(ifp->if_bpf, m);
+ #endif
+ 
+ 	if ((ifp->if_flags & IFF_PROMISC) != 0) {
+ 		/*
+ 		 * If this is unicast and not for me, drop it.
+ 		 */
+ 		if ((eh->ether_dhost[0] & 1) == 0 &&	/* !mcast and !bcast */
+ 		    ether_cmp(eh->ether_dhost, LLADDR(ifp->if_sadl)) != 0) {
+ 			m_freem(m);
+ 			goto out;
+ 		}
  
! 		/*
! 		 * Make sure to behave as IFF_SIMPLEX in all cases.
! 		 * Drop multicast/broadcast packet looped back from myself
! 		 * (should be ensured by chipset configuration).
! 		 */
! 		if ((eh->ether_dhost[0] & 1) == 1 &&	/* mcast || bcast */
! 		    ether_cmp(eh->ether_shost, LLADDR(ifp->if_sadl)) == 0) {
  			m_freem(m);
  			goto out;
  		}
  	}
  
  	/*
  	 * Strip the ethernet header.

------- =_aaaaaaaaaa0--