From patchwork Thu Jul 5 13:58:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10509389 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BA1CC603D7 for ; Thu, 5 Jul 2018 14:03:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3DB929007 for ; Thu, 5 Jul 2018 14:03:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98596290AC; Thu, 5 Jul 2018 14:03:37 +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 A3C5429094 for ; Thu, 5 Jul 2018 14:03:36 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41M02G58m4zF1lm for ; Fri, 6 Jul 2018 00:03:34 +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="bxoAqPb+"; 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=40.107.4.72; helo=eur03-db5-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="bxoAqPb+"; dkim-atps=neutral Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40072.outbound.protection.outlook.com [40.107.4.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41LzxB3ZhBzF1kK for ; Thu, 5 Jul 2018 23:59:10 +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=Yt12IN3tewzQYN5byk8/VSHGr7nR6IJYW3gwH8KKR4I=; b=bxoAqPb+b6RFcIlg+Ra8iqS3RcU/k4ifR/fCHhCNqOA5NXS0yWmr9Uao3iRvvfm9lVT6/ivvmju89go9RQ35USdy5+T8Z/4pm+5YdIspGENMrEXBFDkfVC02YjxYv2u7im/+ddxbv7vY6GnA+V0R+lRuYNQDecetX6cIAYEBmg0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=idosch@mellanox.com; Received: from splinter.mtl.com (193.47.165.251) by VI1PR0501MB2334.eurprd05.prod.outlook.com (2603:10a6:800:2c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.906.25; Thu, 5 Jul 2018 13:59:01 +0000 From: Ido Schimmel To: idosch@idosch.org Subject: [PATCH net-next mlxsw 1/4] mlxsw: spectrum: Enable macvlan upper devices Date: Thu, 5 Jul 2018 16:58:24 +0300 Message-Id: <20180705135827.14770-2-idosch@mellanox.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180705135827.14770-1-idosch@mellanox.com> References: <20180705135827.14770-1-idosch@mellanox.com> MIME-Version: 1.0 X-Originating-IP: [193.47.165.251] X-ClientProxiedBy: DB6P193CA0012.EURP193.PROD.OUTLOOK.COM (2603:10a6:6:29::22) To VI1PR0501MB2334.eurprd05.prod.outlook.com (2603:10a6:800:2c::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 84080a96-70a4-42b7-2933-08d5e27f766e X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:VI1PR0501MB2334; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0501MB2334; 3:J5tV3G58H9O4LZCgnO+f5/tE0PHsniUvUts8gTYBXYwPRxFhbYL7YVGCodIc5pzjEqRfRmsmPgov4A/HfdvUJ84pxzBZMFsHpGNpVqEmGUa7WvJ+z1CSS+O+WvTrBrfG+5Q3/DnQp86mcLfSiSE/KOr+nslw3nOG4laTqlGVQ1sEHItlFcMIfTzAp/Y4J9nrvuoDE2/vRrdset073sqhq7Wt0V2uIVcIELXGtWZjMZAvjRIlyF1R/EGu5ywrqOuB; 25:QyQHiL5iPdGHApukUvrIBEK5GTilY522TqlYrZEbwF4PZX0HSbBdFkiMv1Ck3BtxEWbzEU6pLwyZTVBub3AirHkREI3sYPRs9gBlv7WIcJtiPOGeQh1oaoXKHLba25YahXL1o52p+SbMEuA0ry//cML6MI8Ypt6RGOTmmQEpjTwL2SuqLHDGE1LIjg7pQRST8DcYOF5vTfGDOmf5KmqonYKzBMpfUe5WWr7rcmeUqp+Z1m8khUkCX9Lmnb7FT+WRy9UDzQRPwgsDPcOq8iVMsRwxp4ILEXmnFM7idWANu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B75GCwpuuPMHB3mKrgujY2YzhljHePFPViaJO9Rv2MLjXVFjRSr28CHbk5lk6CvBl1bFW1l7EQ== X-Microsoft-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)(93006095)(93001095)(10201501046)(3002001)(3231254)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:VI1PR0501MB2334; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0501MB2334; X-Forefront-PRVS: 0724FCD4CD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(136003)(39860400002)(346002)(366004)(376002)(189003)(199004)(107886003)(478600001)(1076002)(14444005)(97736004)(6116002)(3846002)(2361001)(6916009)(53936002)(4326008)(8936002)(81156014)(81166006)(8676002)(2906002)(305945005)(7736002)(86362001)(25786009)(316002)(2351001)(6512007)(186003)(26005)(76176011)(386003)(6506007)(51416003)(5660300001)(16586007)(52116002)(16526019)(6486002)(50226002)(50466002)(36756003)(47776003)(68736007)(106356001)(105586002)(6666003)(66066001)(53416004)(2616005)(48376002)(486006)(476003)(956004)(11346002)(446003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0501MB2334; H:splinter.mtl.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0501MB2334; 23:6L5mYavslRwiue9TYyDQmcLdepgOmhR+3s9oHxC?= =?us-ascii?Q?1DPmLZTHc1KQwgnRF2kKa5F8ZjWN4u6aE0zgghQhVLm3rgaI2oJ08sc9xcnh?= =?us-ascii?Q?uBuMXVX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KJZMK1iUJq993G7UWapqa5bLF+uDtlYm0gepDYjVYxoE7Frbxkt+F+YlS2VT+WrUNsfNthprk6HhCL6Ed7xT5wsiGjJ4w0zq2BZmFhZf7bPZsA+bU9k+evOeBXK+o1urdfaQKGtOJm5HiimOe7b99+PJyfdkHlwni0LpaeUhTBtcMZsA+Y83PrQgI1K/BnQRW1A1mqdIAk6Mh+4ehwDmpYU9w==; 5:3tfx4F22CHii0mil/f5N5K3cAR06Q/coI3XbmutgOs/DHBQ1pnzyGbuGTXLEpA0yVaBwUKnYVu7IIFkK31C8WyEAERmFAMb0J3ahnOHCVu5EyP4I9CoGHFSQSDqAc959RYgkCAfzWeEKYA8Rr7P5/wdAXcHuaimXXXfpbULv+Fc=; 24:a7xGKfe5czpSUcQzUvak7kyCLF23QMkzJ9BdeZibHiDILjYu1xmRCpUNeKEWkyUGJskWL2Dj1lNc0m0ho1KznX3t7ib9QgalO75nux0Oiuo= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR0501MB2334; 7:vUPtf7HHQKqGeU12lP3yLeqQbqz2Xn4Ugtg5RNkb6gQHKxzTfMFZ+kSKxZueeEuOcNdHlXSlO2c1623wJk7X4sXiXLdDuDwK7aUjoGJz9xE8VbnOc3vHcfuZe/l9Iz1w13+jhQN+wRKP6Irs4Ougby3CzfW3bYQTQgFVbOO2Ypba5+qvTjJS4UpRf1ArAO/YLXVHQbqP24iI3qyrP220hz/+F3s4Sq2KEKiuCD77/L6F4o4D4hzh/0GPHvb84lMx X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2018 13:59:01.3173 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 84080a96-70a4-42b7-2933-08d5e27f766e X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0501MB2334 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 In order to allow more unicast MAC addresses (e.g., VRRP virtual MAC) to be directed to the router we need to enable macvlan uppers on top of mlxsw netdevs. Allow macvlan upper devices on top of mlxsw netdevs and sanitize configurations that can't work. For example, a macvlan can't be enslaved to a bridge as without ACLs the device doesn't take the destination MAC into account when classifying a packet to a bridge instance (i.e., a FID). Signed-off-by: Ido Schimmel --- Notes: v1: * Remove redundant check about port with a macvlan being enslaved to LAG. This is already forbidden by the stack, as both register an Rx handler * Refactor mlxsw_sp_netdevice_bridge_event() - no functional changes drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 75 +++++++++++++++++++++- .../net/ethernet/mellanox/mlxsw/spectrum_router.c | 5 +- 2 files changed, 76 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index 52437363766a..cb02fdf1c8b2 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -4399,7 +4399,8 @@ static int mlxsw_sp_netdevice_port_upper_event(struct net_device *lower_dev, if (!is_vlan_dev(upper_dev) && !netif_is_lag_master(upper_dev) && !netif_is_bridge_master(upper_dev) && - !netif_is_ovs_master(upper_dev)) { + !netif_is_ovs_master(upper_dev) && + !netif_is_macvlan(upper_dev)) { NL_SET_ERR_MSG_MOD(extack, "Unknown upper device type"); return -EINVAL; } @@ -4425,6 +4426,11 @@ static int mlxsw_sp_netdevice_port_upper_event(struct net_device *lower_dev, NL_SET_ERR_MSG_MOD(extack, "Can not put a VLAN on a LAG port"); return -EINVAL; } + if (netif_is_macvlan(upper_dev) && + !mlxsw_sp_rif_find_by_dev(mlxsw_sp, lower_dev)) { + NL_SET_ERR_MSG_MOD(extack, "macvlan is only supported on top of router interfaces"); + return -EOPNOTSUPP; + } if (netif_is_ovs_master(upper_dev) && vlan_uses_dev(dev)) { NL_SET_ERR_MSG_MOD(extack, "Master device is an OVS master and this device has a VLAN"); return -EINVAL; @@ -4547,8 +4553,9 @@ static int mlxsw_sp_netdevice_port_vlan_event(struct net_device *vlan_dev, switch (event) { case NETDEV_PRECHANGEUPPER: upper_dev = info->upper_dev; - if (!netif_is_bridge_master(upper_dev)) { - NL_SET_ERR_MSG_MOD(extack, "VLAN devices only support bridge and VRF uppers"); + if (!netif_is_bridge_master(upper_dev) && + !netif_is_macvlan(upper_dev)) { + NL_SET_ERR_MSG_MOD(extack, "Unknown upper device type"); return -EINVAL; } if (!info->linking) @@ -4560,6 +4567,11 @@ static int mlxsw_sp_netdevice_port_vlan_event(struct net_device *vlan_dev, NL_SET_ERR_MSG_MOD(extack, "Enslaving a port to a device that already has an upper device is not supported"); return -EINVAL; } + if (netif_is_macvlan(upper_dev) && + !mlxsw_sp_rif_find_by_dev(mlxsw_sp, vlan_dev)) { + NL_SET_ERR_MSG_MOD(extack, "macvlan is only supported on top of router interfaces"); + return -EOPNOTSUPP; + } break; case NETDEV_CHANGEUPPER: upper_dev = info->upper_dev; @@ -4622,6 +4634,59 @@ static int mlxsw_sp_netdevice_vlan_event(struct net_device *vlan_dev, return 0; } +static int mlxsw_sp_netdevice_bridge_event(struct net_device *br_dev, + unsigned long event, void *ptr) +{ + struct mlxsw_sp *mlxsw_sp = mlxsw_sp_lower_get(br_dev); + struct netdev_notifier_changeupper_info *info = ptr; + struct netlink_ext_ack *extack; + struct net_device *upper_dev; + + if (!mlxsw_sp) + return 0; + + extack = netdev_notifier_info_to_extack(&info->info); + + switch (event) { + case NETDEV_PRECHANGEUPPER: + upper_dev = info->upper_dev; + if (!is_vlan_dev(upper_dev) && !netif_is_macvlan(upper_dev)) { + NL_SET_ERR_MSG_MOD(extack, "Unknown upper device type"); + return -EOPNOTSUPP; + } + if (!info->linking) + break; + if (netif_is_macvlan(upper_dev) && + !mlxsw_sp_rif_find_by_dev(mlxsw_sp, br_dev)) { + NL_SET_ERR_MSG_MOD(extack, "macvlan is only supported on top of router interfaces"); + return -EOPNOTSUPP; + } + break; + case NETDEV_CHANGEUPPER: + break; + } + + return 0; +} + +static int mlxsw_sp_netdevice_macvlan_event(struct net_device *macvlan_dev, + unsigned long event, void *ptr) +{ + struct mlxsw_sp *mlxsw_sp = mlxsw_sp_lower_get(macvlan_dev); + struct netdev_notifier_changeupper_info *info = ptr; + struct netlink_ext_ack *extack; + + extack = netdev_notifier_info_to_extack(&info->info); + + if (!mlxsw_sp || event != NETDEV_PRECHANGEUPPER) + return 0; + + /* VRF enslavement is handled in mlxsw_sp_netdevice_vrf_event() */ + NL_SET_ERR_MSG_MOD(extack, "Unknown upper device type"); + + return -EOPNOTSUPP; +} + static bool mlxsw_sp_is_vrf_event(unsigned long event, void *ptr) { struct netdev_notifier_changeupper_info *info = ptr; @@ -4663,6 +4728,10 @@ static int mlxsw_sp_netdevice_event(struct notifier_block *nb, err = mlxsw_sp_netdevice_lag_event(dev, event, ptr); else if (is_vlan_dev(dev)) err = mlxsw_sp_netdevice_vlan_event(dev, event, ptr); + else if (netif_is_bridge_master(dev)) + err = mlxsw_sp_netdevice_bridge_event(dev, event, ptr); + else if (netif_is_macvlan(dev)) + err = mlxsw_sp_netdevice_macvlan_event(dev, event, ptr); return notifier_from_errno(err); } diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 88bd27ace8d9..2d29c6ec84d0 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -6686,7 +6686,10 @@ int mlxsw_sp_netdevice_vrf_event(struct net_device *l3_dev, unsigned long event, struct mlxsw_sp *mlxsw_sp = mlxsw_sp_lower_get(l3_dev); int err = 0; - if (!mlxsw_sp) + /* We do not create a RIF for a macvlan, but only use it to + * direct more MAC addresses to the router. + */ + if (!mlxsw_sp || netif_is_macvlan(l3_dev)) return 0; switch (event) {