From patchwork Thu Aug 9 15:15:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10561531 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C949914C0 for ; Thu, 9 Aug 2018 15:16:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B151A29FA2 for ; Thu, 9 Aug 2018 15:16:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A42F72A628; Thu, 9 Aug 2018 15:16:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,MAILING_LIST_MULTI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C81D82A144 for ; Thu, 9 Aug 2018 15:16:39 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41mX0P6fZyzDqCD for ; Fri, 10 Aug 2018 01:16:37 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="TomObYNN"; dkim-atps=neutral X-Original-To: linux-mlxsw@lists.ozlabs.org Delivered-To: linux-mlxsw@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=mellanox.com (client-ip=2a01:111:f400:fe1e::619; helo=eur01-he1-obe.outbound.protection.outlook.com; envelope-from=idosch@mellanox.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="TomObYNN"; dkim-atps=neutral Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0619.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe1e::619]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41mX0H0PC4zDqBy for ; Fri, 10 Aug 2018 01:16:29 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2hKkEElB9QqyU6Uo/9fPxyo4pJd0vt+45/hUghb6GXY=; b=TomObYNN6nA9xaKI4y5zyCg81Yj1VwetC2SX/2TrSUQNMFJHLXqu/eWZvIUNQP1ZkqWvI5HjDlDAyRX1KtjrMNq4PtUwKM/WrKEBye9AiAMOzLvT83iVIEbW4JD9Chq1mpKhAwc/moYnnjm/Vq2oxoySCZ0mb/Y7YldmKJhT4kk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=idosch@mellanox.com; Received: from splinter.mtl.com (193.47.165.251) by VI1PR05MB4990.eurprd05.prod.outlook.com (2603:10a6:803:60::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.15; Thu, 9 Aug 2018 15:16:20 +0000 From: Ido Schimmel To: linux-internal@mellanox.com Subject: [PATCH net mlxsw] mlxsw: spectrum_switchdev: Do not leak RIFs when removing bridge Date: Thu, 9 Aug 2018 18:15:41 +0300 Message-Id: <20180809151541.32232-1-idosch@mellanox.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [193.47.165.251] X-ClientProxiedBy: HE1PR0701CA0066.eurprd07.prod.outlook.com (2603:10a6:3:9e::34) To VI1PR05MB4990.eurprd05.prod.outlook.com (2603:10a6:803:60::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9f195f5e-7f38-4231-b708-08d5fe0b1017 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR05MB4990; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4990; 3:h0SLBH+zlUZ1uzxzRL3dOmxk2jwTcX10Y4RCvVy1TUiQ4N/S32vre4sakiDux8ZxCSwuDfbUs0Tdc5+bQWwNB05kc/ZGH1UJ8ke5bR/EvqVvNWi7EcrkkCGa3mtyrcikzdgpd9f8ml6966dPX5jz98fPanVdv2b5LOO+3HXzvb4TkdgDkabF5r3QvGvQYfd5KtAmzO70WuYmNyEWdQTVLdXTGLMmrJ92Y87278HMUJAPHfbKZm8ah/QVTD7D2mnl; 25:VCe0w7e++kv7YswKIq87GHR9+rERyVSOffpG11sv1disX1su9xWi0fGY2uYq7hzO3ojmBnQ79Q97M9Sbutjut1DiRLvQwS/QKSUzwaToJq7yBN/kNLmZWs3JZgz8WXNh+rlVtSrhkuuOkMyBHInOlW8R2ACgpWCxvXfaujDuSvb6DmepQ95eNstZU563f+LonuFegytpdsJRELenkNjFkjmdpZsaf4618v/s+XC2L0D3voBZI39FXH8zd0b3x34fhsE2kLysfOTm+ILx4P3pvewzZwCH0X3YQLgW0zoNT6LgnXxyJ1LA9EC754Uvs3fwcGwjmQoRZlV9B7NIdvj8dg==; 31:fow3dDF4hTekr4l+Fm2t0nzu/gHYH2U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antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231311)(944501410)(52105095)(10201501046)(3002001)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123558120)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:VI1PR05MB4990; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB4990; X-Forefront-PRVS: 0759F7A50A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(366004)(136003)(346002)(39860400002)(376002)(199004)(189003)(43544003)(3846002)(5660300001)(6116002)(8936002)(25786009)(107886003)(97736004)(4326008)(8676002)(81166006)(81156014)(6666003)(6636002)(36756003)(478600001)(50466002)(34206002)(52116002)(51416003)(48376002)(86362001)(316002)(66066001)(68736007)(2351001)(6486002)(1076002)(956004)(16526019)(26005)(2906002)(6506007)(386003)(2361001)(47776003)(6512007)(50226002)(16586007)(37006003)(305945005)(476003)(2616005)(486006)(53416004)(106356001)(7736002)(53936002)(105586002)(309714004); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB4990; H:splinter.mtl.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR05MB4990; 23:nHHXWvx4QdL0IylJmt6i/PP8l+NRQedEcV7biqk7J?= ihGveGRMxXr3oY/XMPLlvxFC72KNH0CsDo0ljmemUFVBBTD0m9NRSAjl5i99lQguAteu59K9f/Qnb1Wno+WRqn1Cj8P1rK5/P7XA9kTHPssDHk/Ypc/7G8zz3cLU8SkJ74xhs82bo9V5snfdSCEnjd5qCPahoirlK1EKcoAhSfnkrs6SxiUBxWHJ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:4eOS+R01+Bw/NgsNq1yNxKUS3nceYxnL6WHzFZ6kB8YX1m+5t2K3hHuwEP+Tpk18q/o36HLjiINGcUqmObHnFlR1VcpIBzfcyWv5fdf4jQZn99RNdeaoiRAghpz4+Aqhr6HSGyJUrcYDfB05NZWSgaR+YENELCF9FkhPrrxw01+7EiDmDuhh/HTo5t2h8qEKgjCAPYXk1/TEwUbpv9/Id6nX4u5pQAgwYlpi35428VZV7LI87fojf5z9f538c8Y7 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2018 15:16:20.2302 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9f195f5e-7f38-4231-b708-08d5fe0b1017 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4990 X-BeenThere: linux-mlxsw@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: mlxsw driver development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-mlxsw-bounces+patchwork-linux-mlxsw=patchwork.kernel.org@lists.ozlabs.org X-Virus-Scanned: ClamAV using ClamSMTP When a bridge device is removed, the VLANs are flushed from each configured port. This causes the ports to decrement the reference count on the associated FIDs (filtering identifier). If the reference count of a FID is 1 and it has a RIF (router interface), then this RIF is destroyed. However, if no port is member in the VLAN for which a RIF exists, then the RIF will continue to exist after the removal of the bridge. To reproduce: # ip link add name br0 type bridge vlan_filtering 1 # ip link set dev swp1 master br0 # ip link add link br0 name br0.10 type vlan id 10 # ip address add 192.0.2.0/24 dev br0.10 # ip link del dev br0 The RIF associated with br0.10 continues to exist. Fix this by iterating over all the bridge device uppers when it is destroyed and take care of destroying their RIFs. Fixes: 99f44bb3527b ("mlxsw: spectrum: Enable L3 interfaces on top of bridge devices") Signed-off-by: Ido Schimmel --- .../net/ethernet/mellanox/mlxsw/spectrum.h | 2 ++ .../ethernet/mellanox/mlxsw/spectrum_router.c | 11 ++++++++++ .../mellanox/mlxsw/spectrum_switchdev.c | 20 +++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h index 4a519d8edec8..3500c79e29cd 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h @@ -433,6 +433,8 @@ mlxsw_sp_netdevice_ipip_ul_event(struct mlxsw_sp *mlxsw_sp, void mlxsw_sp_port_vlan_router_leave(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan); void mlxsw_sp_rif_destroy(struct mlxsw_sp_rif *rif); +void mlxsw_sp_rif_destroy_by_dev(struct mlxsw_sp *mlxsw_sp, + struct net_device *dev); /* spectrum_kvdl.c */ int mlxsw_sp_kvdl_init(struct mlxsw_sp *mlxsw_sp); diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 77b2adb29341..cb43d17097fa 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -6228,6 +6228,17 @@ void mlxsw_sp_rif_destroy(struct mlxsw_sp_rif *rif) mlxsw_sp_vr_put(mlxsw_sp, vr); } +void mlxsw_sp_rif_destroy_by_dev(struct mlxsw_sp *mlxsw_sp, + struct net_device *dev) +{ + struct mlxsw_sp_rif *rif; + + rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, dev); + if (!rif) + return; + mlxsw_sp_rif_destroy(rif); +} + static void mlxsw_sp_rif_subport_params_init(struct mlxsw_sp_rif_params *params, struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c index eea5666a86b2..6cb43dda8232 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c @@ -160,6 +160,24 @@ bool mlxsw_sp_bridge_device_is_offloaded(const struct mlxsw_sp *mlxsw_sp, return !!mlxsw_sp_bridge_device_find(mlxsw_sp->bridge, br_dev); } +static int mlxsw_sp_bridge_device_upper_rif_destroy(struct net_device *dev, + void *data) +{ + struct mlxsw_sp *mlxsw_sp = data; + + mlxsw_sp_rif_destroy_by_dev(mlxsw_sp, dev); + return 0; +} + +static void mlxsw_sp_bridge_device_rifs_destroy(struct mlxsw_sp *mlxsw_sp, + struct net_device *dev) +{ + mlxsw_sp_rif_destroy_by_dev(mlxsw_sp, dev); + netdev_walk_all_upper_dev_rcu(dev, + mlxsw_sp_bridge_device_upper_rif_destroy, + mlxsw_sp); +} + static struct mlxsw_sp_bridge_device * mlxsw_sp_bridge_device_create(struct mlxsw_sp_bridge *bridge, struct net_device *br_dev) @@ -198,6 +216,8 @@ static void mlxsw_sp_bridge_device_destroy(struct mlxsw_sp_bridge *bridge, struct mlxsw_sp_bridge_device *bridge_device) { + mlxsw_sp_bridge_device_rifs_destroy(bridge->mlxsw_sp, + bridge_device->dev); list_del(&bridge_device->list); if (bridge_device->vlan_enabled) bridge->vlan_enabled_exists = false;