Subject: hme ALLMULTI mishandling
To: None <port-sparc64@netbsd.org>
From: FUKAUMI Naoki <naoki@fukaumi.org>
List: port-sparc64
Date: 11/16/2001 11:01:00
sys/dev/ic/hme.c has ether_cmp().
when call hme::ether_cmp(A, B),

if A is same as B then return 1
if A is NOT same as B then return 0

I think this ether_cmp() behavior is a reverse.

sys/dev/ic/smc91cxx.c also has ether_cmp().
It returns

if A is same as B then return 0
if A is NOT same as B then return 1

memcmp() returns

if A is same as B then return 0
if A is NOT same as B then return other than 0 (number of difference)

hme on My U10 is always ALLMULTI flag on.

# ifconfig hme0
hme0: flags=8a63<UP,BROADCAST,NOTRAILERS,RUNNING,ALLMULTI,SIMPLEX,MULTICAST> mtu 1500
(snip)

I made patch and attach this mail.



**other topic**

sys/dev/ic/an.c use memcmp() as "if (!memcmp..."

If memcmp returns 0 (same) then "if (!memcmp" is true.
But if memcmp returns other than all bit 1 (different) then "if (!memcmp"
is ALSO true.
Only memcmp returns all bit 1 (different) then "if (!memcmp" is false.

If it want
  if A == B then do it
It should be "if (memcmp(A, B, n) == 0) then do it" ???

I'm wrong ?

-- 
FUKAUMI Naoki

--- sys/dev/ic/hme.c.orig	Mon Nov 12 14:07:29 2001
+++ sys/dev/ic/hme.c	Mon Nov 12 14:39:23 2001
@@ -119,8 +119,6 @@
 int		hme_rint __P((struct hme_softc *));
 int		hme_tint __P((struct hme_softc *));
 
-static int	ether_cmp __P((u_char *, u_char *));
-
 /* Default buffer copy routines */
 void	hme_copytobuf_contig __P((struct hme_softc *, void *, int, int));
 void	hme_copyfrombuf_contig __P((struct hme_softc *, void *, int, int));
@@ -641,21 +639,6 @@
 	hme_start(ifp);
 }
 
-/*
- * Compare two Ether/802 addresses for equality, inlined and unrolled for
- * speed.
- */
-static __inline__ int
-ether_cmp(a, b)
-	u_char *a, *b;
-{       
-        
-	if (a[5] != b[5] || a[4] != b[4] || a[3] != b[3] ||
-	    a[2] != b[2] || a[1] != b[1] || a[0] != b[0])
-		return (0);
-	return (1);
-}
-
 
 /*
  * Routine to copy from mbuf chain to transmit buffer in
@@ -1340,7 +1331,7 @@
 
 	ETHER_FIRST_MULTI(step, ec, enm);
 	while (enm != NULL) {
-		if (ether_cmp(enm->enm_addrlo, enm->enm_addrhi)) {
+		if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
 			/*
 			 * We must listen to a range of multicast addresses.
 			 * For now, just accept all multicasts, rather than