From b3d4891af03d1d4fe497b537519ed4995630aa08 Mon Sep 17 00:00:00 2001 From: Kornel Duleba Date: Tue, 30 Nov 2021 09:23:29 +0100 Subject: [PATCH] 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; }