From nobody Fri Apr 26 20:32:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1575035053; cv=none; d=zohomail.com; s=zohoarc; b=WfiwXOdMvbNrh53PIfz4JmMBlce8lNbK6QpSQkfHNu5Z8cxBRHPxligCqQ15+Qnn/eDid5ztFId2RLAxATQ/OvBwELoJcdE5BNHMTyv4bNZkR/PHv3Qe/sryDZkNPxstSrfsYVutEeC6dla6/bNgru912N8+cEKg23XQtHFlaTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575035053; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=3vLHdln1DbX8BhwYGzhWQv2zwN23+8GT4g7zmpr3u9E=; b=VwYbFH08E05NrAjAFCA60fNyN6IaqJvbfGGruJqSU+0dcS8BKm9cCIHM3pHVNi3FmfQ1FkdEXkBD9DBHW8EojeMwEZNYY11Pu7KGgvgkNillbdntHdPCBwF65qEsBab9iu0DFiRiSb4D3/euH+1seP/KurRBKpOF6X0Y841ayVU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1575035053913327.88206485250464; Fri, 29 Nov 2019 05:44:13 -0800 (PST) Received: from localhost ([::1]:59236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iagZ8-0006sh-B4 for importer@patchew.org; Fri, 29 Nov 2019 08:44:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51489) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iadRs-0003um-Cd for qemu-devel@nongnu.org; Fri, 29 Nov 2019 05:24:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iadRp-0001yq-0w for qemu-devel@nongnu.org; Fri, 29 Nov 2019 05:24:26 -0500 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:42603) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iadRo-0001jB-O6; Fri, 29 Nov 2019 05:24:24 -0500 Received: by mail-wr1-x441.google.com with SMTP id a15so34481351wrf.9; Fri, 29 Nov 2019 02:24:21 -0800 (PST) Received: from PKL-BWASIM-LT.mgc.mentorg.com ([110.93.212.98]) by smtp.gmail.com with ESMTPSA id a26sm12698479wmm.14.2019.11.29.02.24.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Nov 2019 02:24:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3vLHdln1DbX8BhwYGzhWQv2zwN23+8GT4g7zmpr3u9E=; b=KLMMCDDvzQbjNZiuFf8HPcoa8P565LXBj5IVn/3rtTW94oK74YD6K7GsO5GN5ygyd/ TOvOtM7reXvFVTL1prqrX4dtuFZgX6QJkCnGBfGqNGxoS7nUt/VALUyNfobtiYOUtaWu d1WcOUhOTnl+s7mcrIwfqSmAzzTmuA6XOt6mZ3R123raDcMmL9nHqL6xH0zNdhd+eKq9 AC8vIN4LCr1xGnr/daGCzjqj4HCn8hN9+C/5/wLPGALwYUCYrkRghKcJ9vpSv2sEcDLL 1FTsguk01vWrEKRiiwDNkc7Ug4OcLx6pYQmVPc8X2V9jC/GT2QnlU3KXmchJY0O+m68e 97Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3vLHdln1DbX8BhwYGzhWQv2zwN23+8GT4g7zmpr3u9E=; b=IJGNvn+hqLNgMrv/0BMn66PPdw8KJbP7XfLZOOrUwrJVRZIkdikQhzopx13nHPScrc qalTAQBVG/yW+gx79uiRlz8hSy47L+nfrDpkH/ni6OBfBD3uf28V7O+HcYD/X2MENQnB tPTNA3hr/ouZOTGlHFlIELErvZ9YBUgi1AR4V7wm7BBrdAmwwr0B5qCBJhWYotLZ8256 wttn7hThPMP1M53dcZZqh8BkvB47D7fONSWPVfVlM598lvGBIEq9t/L9Gq8twquITuF4 UWthpBmwdp+OSqVLTksyDPYAvll8o0p8L8Q8NJlow67E6SAegb2STnJfRMEQcMeOaGtN wcVA== X-Gm-Message-State: APjAAAUmF3UXrhpupjtAiK7jYB2rzSlAbs0CzMt9o2HYlmx1zQfIV9Ik KrU4I0+ePGa+h3p5Xm7XPiM9hUnxpd8= X-Google-Smtp-Source: APXvYqxYuik7Uk3HEIinicPHFfngD9h79KY5ssbi9euvevLnoEg9vKEzqgb4wMcnGRG1ltJ2584pQg== X-Received: by 2002:a5d:68cf:: with SMTP id p15mr2093577wrw.31.1575023060081; Fri, 29 Nov 2019 02:24:20 -0800 (PST) From: bilalwasim676@gmail.com To: qemu-devel@nongnu.org Subject: [PATCH v3] net/cadence_gem: Updating the GEM MAC IP to properly filter out multicast addresses. Date: Fri, 29 Nov 2019 15:24:14 +0500 Message-Id: <20191129102414.14060-1-bilalwasim676@gmail.com> X-Mailer: git-send-email 2.19.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 X-Mailman-Approved-At: Fri, 29 Nov 2019 08:30:37 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: edgar.iglesias@gmail.com, qemu-arm@nongnu.org, bilal_wasim@mentor.com, alistair@alistair23.me, peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: bwasim The current code makes a bad assumption that the most-significant byte of the MAC address is used to determine if the address is multicast or unicast, but in reality only a single bit is used to determine this. This caused IPv6 to not work.. Fix is now in place and has been tested with ZCU102-A53 / IPv6 on a TAP interface. Works well.. Signed-off-by: Bilal Wasim Reviewed-by: Edgar E. Iglesias Tested-by: Edgar E. Iglesias --- hw/net/cadence_gem.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c index b8be73dc55..6400b3653b 100644 --- a/hw/net/cadence_gem.c +++ b/hw/net/cadence_gem.c @@ -34,6 +34,7 @@ #include "qemu/module.h" #include "sysemu/dma.h" #include "net/checksum.h" +#include "net/eth.h" =20 #ifdef CADENCE_GEM_ERR_DEBUG #define DB_PRINT(...) do { \ @@ -601,7 +602,7 @@ static void gem_receive_updatestats(CadenceGEMState *s,= const uint8_t *packet, } =20 /* Error-free Multicast Frames counter */ - if (packet[0] =3D=3D 0x01) { + if (is_multicast_ether_addr(packet)) { s->regs[GEM_RXMULTICNT]++; } =20 @@ -690,21 +691,25 @@ static int gem_mac_address_filter(CadenceGEMState *s,= const uint8_t *packet) } =20 /* Accept packets -w- hash match? */ - if ((packet[0] =3D=3D 0x01 && (s->regs[GEM_NWCFG] & GEM_NWCFG_MCAST_HA= SH)) || - (packet[0] !=3D 0x01 && (s->regs[GEM_NWCFG] & GEM_NWCFG_UCAST_HASH= ))) { + if ((is_multicast_ether_addr(packet) + && (s->regs[GEM_NWCFG] & GEM_NWCFG_MCAST_HASH)) || + (is_unicast_ether_addr(packet) + && (s->regs[GEM_NWCFG] & GEM_NWCFG_UCAST_HASH))) { unsigned hash_index; =20 hash_index =3D calc_mac_hash(packet); if (hash_index < 32) { if (s->regs[GEM_HASHLO] & (1<regs[GEM_HASHHI] & (1<regs[GEM_TXMCNT]++; } =20 --=20 2.19.1.windows.1