Subject: Re: sys/dev/ic/smc91cxx.c fix for IFF_SIMPLEX behavior
To: None <itojun@iijlab.net>
From: Jason Thorpe <thorpej@nas.nasa.gov>
List: tech-net
Date: 09/08/1999 10:56:33
On Wed, 08 Sep 1999 19:31:29 +0900
itojun@iijlab.net wrote:
> 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.
It only loops back to itself when in promiscuous mode? Wow, that's sick.
Change looks fine to me.
> 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--
-- Jason R. Thorpe <thorpej@nas.nasa.gov>