Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp993807iog; Thu, 30 Jun 2022 14:39:23 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v0P5XlcfDFl/nwlvYAI4nOx/EWlaCXsPK6lximBr1IlVrklv/JvfJ9i2/m9RxYYDTVtATd X-Received: by 2002:a17:90a:9f03:b0:1ed:53c7:aa11 with SMTP id n3-20020a17090a9f0300b001ed53c7aa11mr14596178pjp.39.1656625163569; Thu, 30 Jun 2022 14:39:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656625163; cv=none; d=google.com; s=arc-20160816; b=I+uczsoBx6ZLFbKVBrimSj1XdNOEwetITnoaFJvtufqAzcFzpI4aQI40xlOPWsgp92 D+5zhz2ZoajUlTWLFi8Fo11TWraEkAr/iXY7W/7a+hQok6W/a/jvDbhxWNTzFwzcKXp0 Iu8Hi1pp2+Y7tLi7Hi1T8xznQ60FHN4B1dnCfn1eMRcQVMehwedYR1V7gqBVY+FIjxUh ObE2GKCaRHifPfuszj9xGM2dBRUZ8JtXyO/RmBvv9TfsSjnnzzltN3B2RjmPD8aMN0x/ 37ftYIAt4nDxcDn1vtRWyksZo8RRgs3NNjWlV1AHl4AoEZVXVVvitfKztrDhHP8qqaCs Z+cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=xwFag/8dD9IbF/CnQDYyQibGAMvtrP+argkacsTtWyA=; b=RH/hPzvtBM1E2G6s3qvs0EyUlalE9ycKi8cTxzY4yKuNW6y2u0TlA80W9RKxVJsHPb GuJWl0R0jne0QgsKMSLMsX7g5kv/T7x+DDbVYzAktCw9hMLzMcNPLfvNuFmh60Wm8KZe mnzhpyTuLZztGHTtlNvMTP45j3lwWnf/0+c/TI2u6U3YUzItCPZ1Hb/0KFx7iAS5ANKP AviUz+UOuxVUq54Dgp2296mJW93hSdFvi7rPrEBbUsDpumVQPeScGt2elp5R9qkxLOLr t7CrSOAdxnI7I13REVUxetR/b2lHFhGcsfFsNortagl+4mBjcg3wYDOnv/OsW8Dj92+5 GXyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@googlemail.com header.s=20210112 header.b=c6F7SPIB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j63-20020a625542000000b005280e22a904si4356276pfb.376.2022.06.30.14.39.09; Thu, 30 Jun 2022 14:39:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@googlemail.com header.s=20210112 header.b=c6F7SPIB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237518AbiF3V1g (ORCPT + 99 others); Thu, 30 Jun 2022 17:27:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237383AbiF3V13 (ORCPT ); Thu, 30 Jun 2022 17:27:29 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9548D2C644; Thu, 30 Jun 2022 14:27:28 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id cf14so526748edb.8; Thu, 30 Jun 2022 14:27:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xwFag/8dD9IbF/CnQDYyQibGAMvtrP+argkacsTtWyA=; b=c6F7SPIBvZxuDf5DQh6bLbiCsnJEu9ZJgBpILntm10WfLxUfKHfF8e3yUt3C4xV+EG xve3lphmmuAiuYM5tkI766IJJ4RJKCOb141J8QGJh8tahssi5qZcQSY1kpE80ADTiQRl p9MS83pu8r7QuqBBTIzXwZdxUiy2KkHsIYKc8/CRgQTUZiTWFJdpdqj+Ol/8d4O2ZToz W1BS1mVrOdXJTqxfO06sFsb3EoD43U4Z/Eogl/HF07GFs41SyW/9jLQ505jMB185QNS3 fp2M0yHlZgNORm/hFfMNYf42fbDYI4Y4ApmbmIsOdygm/QwtkJXuaZP9fE8aA8nFtgtw 0KOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xwFag/8dD9IbF/CnQDYyQibGAMvtrP+argkacsTtWyA=; b=pqtmzculiZutJj8X6yEo5pidSqxLyI2eyrZBK4cN7X8haVzMYl1IN2bwoxOUKPLqbx 8yRI/tTD1u9/6DrFkXNUQDtG10dPuhWlkMlDfcD3WIKAz9qfhkl0quWTYQ5q0332gEod Cgfi0TBlUjdVoriHNF1UlJkhWxsCXQ+M21gYUsrbJmqWBzLr3JWAA7LaCtSuCUV2lj9p P6CqLVVJPHWZjCkn41DrkVHT+5o6aEg39sNLv/RPV5rMLUzenhLIXcSdrRTGdiKGb1l1 nEpdiCpbqHQINyidRBy202jtvGqcg1C6ynY0NW+9jVXcDPUjyRHPTXU1z34gCG/rZr9Q imGQ== X-Gm-Message-State: AJIora/4JohFrSZER+5p5uJz8xaRXo7odrtq0gk+xwfUB31LbBIEfw6c uaPiyBptEWcquT2qSb+/FYQ= X-Received: by 2002:a05:6402:3785:b0:435:5d0e:2a2e with SMTP id et5-20020a056402378500b004355d0e2a2emr14829034edb.307.1656624447134; Thu, 30 Jun 2022 14:27:27 -0700 (PDT) Received: from localhost.localdomain (dynamic-2a01-0c23-c4e7-0400-0000-0000-0000-0e63.c23.pool.telefonica.de. [2a01:c23:c4e7:400::e63]) by smtp.googlemail.com with ESMTPSA id m9-20020a509989000000b004355d27799fsm14159078edb.96.2022.06.30.14.27.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 14:27:26 -0700 (PDT) From: Martin Blumenstingl To: hauke@hauke-m.de, netdev@vger.kernel.org Cc: andrew@lunn.ch, vivien.didelot@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.org, Martin Blumenstingl , stable@vger.kernel.org Subject: [PATCH net v1] net: dsa: lantiq_gswip: Fix FDB add/remove on the CPU port Date: Thu, 30 Jun 2022 23:27:03 +0200 Message-Id: <20220630212703.3280485-1-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.37.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There's no bridge available when adding or removing a static FDB entry for (towards) the CPU port. This is intentional because the CPU port is always considered standalone, even if technically for the GSWIP driver it's part of every bridge. Handling FDB add/remove on the CPU port fixes the following message during boot in OpenWrt: port 4 failed to add vid 1 to fdb: -22 as well as the following message during system shutdown: port 4 failed to delete vid 1 from fdb: -22 Use FID 0 (which is also the "default" FID) when adding/removing an FDB entry for the CPU port. Testing with a BT Home Hub 5A shows that this "default" FID works as expected: - traffic from/to LAN (ports in a bridge) is not seen on the WAN port (standalone port) - traffic from/to the WAN port (standalone port) is not seen on the LAN (ports in a bridge) ports - traffic from/to LAN is not seen on another LAN port with a different VLAN - traffic from/to one LAN port to another is still seen Fixes: 58c59ef9e930c4 ("net: dsa: lantiq: Add Forwarding Database access") Cc: stable@vger.kernel.org Signed-off-by: Martin Blumenstingl --- This patch is "minimalistic" on purpose: the goal is to have it backported to Linux 5.15. Linux 5.15 doesn't have dsa_fdb_present_in_other_db() or struct dsa_db yet. Once this patch has been accepted I will work on implementing FDB isolation for the Lantiq GSWIP driver. Hauke, I hope I considered all test-cases which you find relevant. If not then please let me know. drivers/net/dsa/lantiq_gswip.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c index e531b93f3cb2..9dab28903af0 100644 --- a/drivers/net/dsa/lantiq_gswip.c +++ b/drivers/net/dsa/lantiq_gswip.c @@ -1365,19 +1365,26 @@ static int gswip_port_fdb(struct dsa_switch *ds, int port, int i; int err; - if (!bridge) - return -EINVAL; - - for (i = max_ports; i < ARRAY_SIZE(priv->vlans); i++) { - if (priv->vlans[i].bridge == bridge) { - fid = priv->vlans[i].fid; - break; + if (bridge) { + for (i = max_ports; i < ARRAY_SIZE(priv->vlans); i++) { + if (priv->vlans[i].bridge == bridge) { + fid = priv->vlans[i].fid; + break; + } } - } - if (fid == -1) { - dev_err(priv->dev, "Port not part of a bridge\n"); - return -EINVAL; + if (fid == -1) { + dev_err(priv->dev, "Port not part of a bridge\n"); + return -EINVAL; + } + } else if (dsa_is_cpu_port(ds, port)) { + /* Use FID 0 which is the "default" and used as fallback. This + * is not used by any standalone port or a bridge, so we can + * safely use it for the CPU port. + */ + fid = 0; + } else { + return -EOPNOTSUPP; } mac_bridge.table = GSWIP_TABLE_MAC_BRIDGE; -- 2.37.0