All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Vladimir Oltean <vladimir.oltean@nxp.com>,
	"David S . Miller" <davem@davemloft.net>,
	Sasha Levin <sashal@kernel.org>,
	netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 5.8 03/64] net: mscc: ocelot: fix encoding destination ports into multicast IPv4 address
Date: Mon, 10 Aug 2020 15:07:58 -0400	[thread overview]
Message-ID: <20200810190859.3793319-3-sashal@kernel.org> (raw)
In-Reply-To: <20200810190859.3793319-1-sashal@kernel.org>

From: Vladimir Oltean <vladimir.oltean@nxp.com>

[ Upstream commit 0897ecf7532577bda3dbcb043ce046a96948889d ]

The ocelot hardware designers have made some hacks to support multicast
IPv4 and IPv6 addresses. Normally, the MAC table matches on MAC
addresses and the destination ports are selected through the DEST_IDX
field of the respective MAC table entry. The DEST_IDX points to a Port
Group ID (PGID) which contains the bit mask of ports that frames should
be forwarded to. But there aren't a lot of PGIDs (only 80 or so) and
there are clearly many more IP multicast addresses than that, so it
doesn't scale to use this PGID mechanism, so something else was done.
Since the first portion of the MAC address is known, the hack they did
was to use a single PGID for _flooding_ unknown IPv4 multicast
(PGID_MCIPV4 == 62), but for known IP multicast, embed the destination
ports into the first 3 bytes of the MAC address recorded in the MAC
table.

The VSC7514 datasheet explains it like this:

    3.9.1.5 IPv4 Multicast Entries

    MAC table entries with the ENTRY_TYPE = 2 settings are interpreted
    as IPv4 multicast entries.
    IPv4 multicasts entries match IPv4 frames, which are classified to
    the specified VID, and which have DMAC = 0x01005Exxxxxx, where
    xxxxxx is the lower 24 bits of the MAC address in the entry.
    Instead of a lookup in the destination mask table (PGID), the
    destination set is programmed as part of the entry MAC address. This
    is shown in the following table.

    Table 78: IPv4 Multicast Destination Mask

        Destination Ports            Record Bit Field
        ---------------------------------------------
        Ports 10-0                   MAC[34-24]

    Example: All IPv4 multicast frames in VLAN 12 with MAC 01005E112233 are
    to be forwarded to ports 3, 8, and 9. This is done by inserting the
    following entry in the MAC table entry:
    VALID = 1
    VID = 12
    MAC = 0x000308112233
    ENTRY_TYPE = 2
    DEST_IDX = 0

But this procedure is not at all what's going on in the driver. In fact,
the code that embeds the ports into the MAC address looks like it hasn't
actually been tested. This patch applies the procedure described in the
datasheet.

Since there are many other fixes to be made around multicast forwarding
until it works properly, there is no real reason for this patch to be
backported to stable trees, or considered a real fix of something that
should have worked.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/mscc/ocelot.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c
index f17da67a4622e..d0b79cca51840 100644
--- a/drivers/net/ethernet/mscc/ocelot.c
+++ b/drivers/net/ethernet/mscc/ocelot.c
@@ -1605,14 +1605,14 @@ static int ocelot_port_obj_add_mdb(struct net_device *dev,
 	addr[0] = 0;
 
 	if (!new) {
-		addr[2] = mc->ports << 0;
-		addr[1] = mc->ports << 8;
+		addr[1] = mc->ports >> 8;
+		addr[2] = mc->ports & 0xff;
 		ocelot_mact_forget(ocelot, addr, vid);
 	}
 
 	mc->ports |= BIT(port);
-	addr[2] = mc->ports << 0;
-	addr[1] = mc->ports << 8;
+	addr[1] = mc->ports >> 8;
+	addr[2] = mc->ports & 0xff;
 
 	return ocelot_mact_learn(ocelot, 0, addr, vid, ENTRYTYPE_MACv4);
 }
@@ -1636,9 +1636,9 @@ static int ocelot_port_obj_del_mdb(struct net_device *dev,
 		return -ENOENT;
 
 	memcpy(addr, mc->addr, ETH_ALEN);
-	addr[2] = mc->ports << 0;
-	addr[1] = mc->ports << 8;
 	addr[0] = 0;
+	addr[1] = mc->ports >> 8;
+	addr[2] = mc->ports & 0xff;
 	ocelot_mact_forget(ocelot, addr, vid);
 
 	mc->ports &= ~BIT(port);
@@ -1648,8 +1648,8 @@ static int ocelot_port_obj_del_mdb(struct net_device *dev,
 		return 0;
 	}
 
-	addr[2] = mc->ports << 0;
-	addr[1] = mc->ports << 8;
+	addr[1] = mc->ports >> 8;
+	addr[2] = mc->ports & 0xff;
 
 	return ocelot_mact_learn(ocelot, 0, addr, vid, ENTRYTYPE_MACv4);
 }
-- 
2.25.1


  parent reply	other threads:[~2020-08-10 19:33 UTC|newest]

Thread overview: 108+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-10 19:07 [PATCH AUTOSEL 5.8 01/64] drm/tilcdc: fix leak & null ref in panel_connector_get_modes Sasha Levin
2020-08-10 19:07 ` Sasha Levin
2020-08-10 19:07 ` [PATCH AUTOSEL 5.8 02/64] soc: qcom: rpmh-rsc: Set suppress_bind_attrs flag Sasha Levin
2020-08-10 19:07 ` Sasha Levin [this message]
2020-08-10 19:07 ` [PATCH AUTOSEL 5.8 04/64] ARM: exynos: clear L310_AUX_CTRL_FULL_LINE_ZERO in default l2c_aux_val Sasha Levin
2020-08-10 19:07   ` Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 05/64] Bluetooth: add a mutex lock to avoid UAF in do_enale_set Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 06/64] loop: be paranoid on exit and prevent new additions / removals Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 07/64] io_uring: fix req->work corruption Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 08/64] fs/btrfs: Add cond_resched() for try_release_extent_mapping() stalls Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 09/64] drm/amdgpu: avoid dereferencing a NULL pointer Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 10/64] drm/radeon: Fix reference count leaks caused by pm_runtime_get_sync Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 11/64] crypto: aesni - Fix build with LLVM_IAS=1 Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 12/64] video: fbdev: savage: fix memory leak on error handling path in probe Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 13/64] video: fbdev: neofb: fix memory leak in neo_scan_monitor() Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 14/64] bus: ti-sysc: Add missing quirk flags for usb_host_hs Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 15/64] md-cluster: fix wild pointer of unlock_all_bitmaps() Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 16/64] rtw88: 8822ce: add support for device ID 0xc82f Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 17/64] drm/nouveau/kms/nv50-: Fix disabling dithering Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 18/64] arm64: dts: hisilicon: hikey: fixes to comply with adi, adv7533 DT binding Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 19/64] drm/etnaviv: fix ref count leak via pm_runtime_get_sync Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 20/64] ionic: rearrange reset and bus-master control Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 21/64] memory: samsung: exynos5422-dmc: Do not ignore return code of regmap_read() Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 22/64] drm/nouveau: fix reference count leak in nouveau_debugfs_strap_peek Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 23/64] drm/nouveau: fix multiple instances of reference count leaks Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 24/64] mmc: sdhci-cadence: do not use hardware tuning for SD mode Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 25/64] btrfs: fix lockdep splat from btrfs_dump_space_info Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 26/64] usb: mtu3: clear dual mode of u3port when disable device Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 27/64] drm: msm: a6xx: fix gpu failure after system resume Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 28/64] drm/msm: Fix a null pointer access in msm_gem_shrinker_count() Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 29/64] drm/debugfs: fix plain echo to connector "force" attribute Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 30/64] drm/radeon: disable AGP by default Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 31/64] net: phy: mscc: restore the base page in vsc8514/8584_config_init Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 32/64] irqchip/irq-mtk-sysirq: Replace spinlock with raw_spinlock Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 33/64] mm/mmap.c: Add cond_resched() for exit_mmap() CPU stalls Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 34/64] drm/amd/display: Improve DisplayPort monitor interop Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 35/64] drm/amdgpu/debugfs: fix ref count leak when pm_runtime_get_sync fails Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 36/64] drm/amdgpu/display bail early in dm_pp_get_static_clocks Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 37/64] drm/amdgpu/display: properly guard the calls to swSMU functions Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 38/64] drm/amd/display: allow query ddc data over aux to be read only operation Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 39/64] drm/amd/powerplay: fix compile error with ARCH=arc Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 40/64] bpf: Fix fds_example SIGSEGV error Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 41/64] Bluetooth: hci_qca: Bug fixes for SSR Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 42/64] brcmfmac: keep SDIO watchdog running when console_interval is non-zero Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 43/64] brcmfmac: To fix Bss Info flag definition Bug Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 44/64] brcmfmac: set state of hanger slot to FREE when flushing PSQ Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 45/64] platform/x86: asus-nb-wmi: add support for ASUS ROG Zephyrus G14 and G15 Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 46/64] iwlegacy: Check the return value of pcie_capability_read_*() Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 47/64] gpu: host1x: debug: Fix multiple channels emitting messages simultaneously Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 48/64] drm/amd/powerplay: suppress compile error around BUG_ON Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08   ` Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 49/64] ionic: update eid test for overflow Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 50/64] x86/uaccess: Make __get_user_size() Clang compliant on 32-bit Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 51/64] mmc: sdhci-pci-o2micro: Bug fix for O2 host controller Seabird1 Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 52/64] usb: gadget: net2280: fix memory leak on probe error handling paths Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 53/64] bdc: Fix bug causing crash after multiple disconnects Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 54/64] usb: bdc: Halt controller on suspend Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 55/64] dyndbg: fix a BUG_ON in ddebug_describe_flags Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 56/64] dyndbg: prefer declarative init in caller, to memset in callee Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 57/64] bcache: fix super block seq numbers comparision in register_cache_set() Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 58/64] btrfs: allow btrfs_truncate_block() to fallback to nocow for data space reservation Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 59/64] btrfs: qgroup: free per-trans reserved space when a subvolume gets dropped Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 60/64] ACPICA: Do not increment operation_region reference counts for field units Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 61/64] io_uring: fix racy overflow count reporting Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 62/64] io_uring: fix stalled deferred requests Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 63/64] crypto: caam - silence .setkey in case of bad key length Sasha Levin
2020-08-10 19:08 ` [PATCH AUTOSEL 5.8 64/64] drm/msm: ratelimit crtc event overflow error Sasha Levin
2020-08-10 19:08   ` Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200810190859.3793319-3-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=vladimir.oltean@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.