Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Dec 2021 08:34:48 GMT
From:      Wojciech Macek <wma@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: b3d4891af03d - main - enetc: Fix VID/mcast address hash calculation
Message-ID:  <202112080834.1B88YmLt097225@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by wma:

URL: https://cgit.FreeBSD.org/src/commit/?id=b3d4891af03d1d4fe497b537519ed4995630aa08

commit b3d4891af03d1d4fe497b537519ed4995630aa08
Author:     Kornel Duleba <mindal@semihalf.com>
AuthorDate: 2021-11-30 08:23:29 +0000
Commit:     Wojciech Macek <wma@FreeBSD.org>
CommitDate: 2021-12-08 08:32:51 +0000

    enetc: Fix VID/mcast address hash calculation
    
    The hash is calculated by XOR-ing together bits of the VID.
    Prepend a statement with "!!" to make sure that we're get bit 0
    on both sides of the equation.
    
    Obtained from: Semihalf
    Sponsored by: Alstom Group
---
 sys/dev/enetc/if_enetc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/dev/enetc/if_enetc.c b/sys/dev/enetc/if_enetc.c
index abdb527760f6..e05e551ff48f 100644
--- a/sys/dev/enetc/if_enetc.c
+++ b/sys/dev/enetc/if_enetc.c
@@ -811,7 +811,7 @@ enetc_hash_mac(void *arg, struct sockaddr_dl *sdl, u_int cnt)
 	for (i = 0; i < 6; i++) {
 		bit = 0;
 		for (j = 0; j < 8; j++)
-			bit ^= address & BIT(i + j*6);
+			bit ^= !!(address & BIT(i + j*6));
 
 		hash |= bit << i;
 	}
@@ -852,7 +852,7 @@ enetc_hash_vid(uint16_t vid)
 
 	for (i = 0;i < 6;i++) {
 		bit = vid & BIT(i);
-		bit ^= vid & BIT(i + 6);
+		bit ^= !!(vid & BIT(i + 6));
 		hash |= bit << i;
 	}
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202112080834.1B88YmLt097225>