From patchwork Sun Jul 8 09:15:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10513045 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 2E20C60329 for ; Sun, 8 Jul 2018 09:16:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 186942893C for ; Sun, 8 Jul 2018 09:16:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0CF9928965; Sun, 8 Jul 2018 09:16:19 +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 165FE2893C for ; Sun, 8 Jul 2018 09:16:18 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41NjWN2w2tzDrDl for ; Sun, 8 Jul 2018 19:16:16 +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="ci9mhVuw"; 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.0.43; helo=eur02-am5-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="ci9mhVuw"; dkim-atps=neutral Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00043.outbound.protection.outlook.com [40.107.0.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41NjWD3WFTzDqBW for ; Sun, 8 Jul 2018 19:16:08 +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=OcUW+OZC/ZKm38hUrsiyUCETaJbxIxmWc2mfK8aNvEI=; b=ci9mhVuwaeb82Cx59c7J1DYs/b4iZrO8juy6FnXOsQlZMv4X0lW6P7uYDrCwHorQoXuIf44avK6HLZgKmiix9hxlPW4DE1YsSgUA/mUvSWtoz5bdC6aDTRUe29HJXM/qPml0dPAf3G7lwNbbAIk0B3oh/YQcnccqegrtB3JgOac= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=idosch@mellanox.com; Received: from splinter.mtl.com (193.47.165.251) by VI1PR0501MB2333.eurprd05.prod.outlook.com (2603:10a6:800:2c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.930.19; Sun, 8 Jul 2018 09:15:58 +0000 From: Ido Schimmel To: linux-internal@mellanox.com Subject: [PATCH net-next mlxsw v2 1/4] mlxsw: spectrum: Enable macvlan upper devices Date: Sun, 8 Jul 2018 12:15:35 +0300 Message-Id: <20180708091538.22068-2-idosch@mellanox.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180708091538.22068-1-idosch@mellanox.com> References: <20180708091538.22068-1-idosch@mellanox.com> MIME-Version: 1.0 X-Originating-IP: [193.47.165.251] X-ClientProxiedBy: DB6PR07CA0018.eurprd07.prod.outlook.com (2603:10a6:6:2d::28) To VI1PR0501MB2333.eurprd05.prod.outlook.com (2603:10a6:800:2c::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5a442a4c-5d7a-4399-35c9-08d5e4b36b12 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(48565401081)(2017052603328)(7153060)(7193020); SRVR:VI1PR0501MB2333; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0501MB2333; 3:1hZa+09Q94PpCYmZrC+z6OUhJRSQB5aqtbAKUtgkFuIR8lExZ5GBcmuOmpj+B5OcmP985lGhOQvb8V83jDnrhJ0Fb/YKWfeXNUUikldPkr+WdF6ECp5pRjAIcSEXeBVUnORc+gITQE07Xn4QvLFKFncuH0vGz7D8MQltwcP0mQBH0J3EfaSrDaINx2GMpjFiwX+DxMYtP++0OhOn55G27pfS0w5fJ/T/15rYVrzDxLTogCKWyExaRYS54kgqzXFj; 25:6fa9JB/ouCqnZBFMpQcu7aeDZ1DQQP906LlkfFOyIZ2Zqs+KZICDPObEUFu9iQg4zQRfB3PNVb8qy5NyJ63Gm/FmMIWdgufW4sSB4Y14fABaKsZ22eEMIcYld78qJMl7R2eglp4Jg+NUSgqqufPM8LuLhJFSK62cMeWkUgX99VgLrzDHrH7sDQLDAtRsgbz4iaWz2Q7Qt8kiEyI2Dfc2qgFthDClPoyVbqyR1it1lCJwZfPXtmEeiLERugFQnR11cSD4V1Tti6proDkfGVNGZpaNyUe4HaKkYRPr+Wwd+uJ32rF0MHw5up9zmkDxY03ad5ggRH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QkhSYB0UuHS5YQcoGzrDs6A5OuhizJ1g== 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)(3002001)(10201501046)(3231311)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:VI1PR0501MB2333; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0501MB2333; X-Forefront-PRVS: 0727122FC6 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(346002)(136003)(396003)(376002)(39860400002)(189003)(199004)(3846002)(81166006)(5660300001)(47776003)(81156014)(8676002)(6116002)(107886003)(316002)(16586007)(1076002)(34206002)(37006003)(6666003)(66066001)(36756003)(48376002)(26005)(6512007)(4326008)(50466002)(6636002)(25786009)(16526019)(86362001)(575784001)(52116002)(76176011)(51416003)(8936002)(6506007)(6486002)(53416004)(478600001)(2351001)(106356001)(305945005)(486006)(7736002)(446003)(476003)(105586002)(68736007)(2616005)(956004)(11346002)(2361001)(14444005)(386003)(2906002)(50226002)(53936002)(97736004); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0501MB2333; 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; VI1PR0501MB2333; 23:/RjtRnI/99o46pyvsXavY+wrLlxQ8MdzcCko1f9?= =?us-ascii?Q?7QchUpmyo495c5+zHr7FQTSm1M0IabhTHfANNcviOhzZiElZCEEGmNWH/b1b?= =?us-ascii?Q?4Kul63MxXoLBSbOWy+vS0doKVRszBzCAMmjvm06av2nWTy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lDFRq/XSUseuN26ciLmuTDsWgBCfwiVsdFtDpSNlIXYfSSb/rn+Czi54McDlNybSkzOhjYNazZN+XI1qFPFC/iYXBafJpDXJ5edemJbdwRgRrgLOaSFVt1jvJwREtvcu0iS9fDDbskHCGGFbElvg1Of9qAOMNxDJTStIi98LtbU4txm2dV0NmLhy3v41Jhz3gZINsvWKX5zfPsBs9BO2b3ilnDCmD0o2LvQ==; 5:Lxo1vj7GyzRLhqyrSsDz1TrvH3en46QX1oTRznal48U5UIPs/GN1tI0sxfRwPSc8qKFjsNWJDPNt08O3du1UAGDZGZ9VZOBy2hW8MHTHRL7M4a+WUT7JigmtUl8dcJz6cyLZJWBPMMm9quNvjJkFjE82Z2gOorE9CYARk4r8BDk=; 24:/HJ7zlSqcPdhyOvpN9Udsuo6KlQ5hBDgcCMdRptSlOl7BtZTAEjzqEuhRg63ZvXA6N2KnRxWRr/PP4C1l1Zq9oa9pAhL48wLuPYuXs0CJ60= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR0501MB2333; 7:n/gEVGQYldKJgIRz+bFIenrMNZML+YVREe0A8fmm11fgJkodrWamZVimOCRYhNLaFB0l/hs0/8cROVU0Oe1zYetbhmCQ9+kfKVWtHxeEicq96RON6z7fGQ2HF7cuGEvbdhk4qfcX025j+bhcRW+1/aiolEtZSgF5xbyL8qfC4HxSABR04Hdn3reze+1t9CXPGV/zM52f3uRFnum7n+nOmgjAC++KlWyDeOz8w09Ee8SxOacnkz1a4xn1CugIT4gD X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2018 09:15:58.2852 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5a442a4c-5d7a-4399-35c9-08d5e4b36b12 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0501MB2333 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 Reviewed-by: Petr Machata --- Notes: v2: * Resolve 'extack' only when we know it's an upper change event 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 cba0e9ba7dea..bb1a3ee2120d 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -4401,7 +4401,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; } @@ -4427,6 +4428,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; @@ -4549,8 +4555,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) @@ -4562,6 +4569,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; @@ -4624,6 +4636,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; + + if (!mlxsw_sp || event != NETDEV_PRECHANGEUPPER) + return 0; + + extack = netdev_notifier_info_to_extack(&info->info); + + /* 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; @@ -4665,6 +4730,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 79dcadb40857..948d8d00e676 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) {