From patchwork Tue Apr 24 23:09:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10361193 X-Patchwork-Delegate: idosch@idosch.org 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 A8393601BE for ; Tue, 24 Apr 2018 23:09:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9785128D53 for ; Tue, 24 Apr 2018 23:09:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B9B128E86; Tue, 24 Apr 2018 23:09:34 +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 AFE6C28D53 for ; Tue, 24 Apr 2018 23:09:33 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40VzYS19TzzF24d for ; Wed, 25 Apr 2018 09:09:32 +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="gmOO8Pob"; 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=104.47.1.84; helo=eur01-ve1-obe.outbound.protection.outlook.com; envelope-from=petrm@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="gmOO8Pob"; dkim-atps=neutral Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0084.outbound.protection.outlook.com [104.47.1.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40VzYK3d6ZzF24j for ; Wed, 25 Apr 2018 09:09:25 +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; bh=XflZhTBdz+96MglfQVxRi7cpy4qQoPtsPoHiqSAFBTk=; b=gmOO8PobOBlE+oQ8ogUslmsGbic8ExIJ4yex3ZrRNATpyiDYFBaYEccdOi5hbg0h6RcB8z62vnZb5L23rKpJGNE08MY6HkBSDPKzCP5siq3rHdkFOdmlmD2srIgPTeGOAB2+rN+1h4h4peIOT+FEaBZB7+XLTOFtLdczIdJ6c2s= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (89.177.127.115) by DB7PR05MB4185.eurprd05.prod.outlook.com (2603:10a6:5:18::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.12; Tue, 24 Apr 2018 23:09:17 +0000 From: Petr Machata To: Subject: [PATCH net-next mlxsw v2 7/7] mlxsw: spectrum_span: Allow bridge for gretap mirror In-Reply-To: References: Message-Id: Date: Wed, 25 Apr 2018 01:09:13 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-Originating-IP: [89.177.127.115] X-ClientProxiedBy: CWLP265CA0209.GBRP265.PROD.OUTLOOK.COM (2603:10a6:401:4e::29) To DB7PR05MB4185.eurprd05.prod.outlook.com (2603:10a6:5:18::26) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(48565401081)(2017052603328)(7153060)(7193020); SRVR:DB7PR05MB4185; X-Microsoft-Exchange-Diagnostics: 1; DB7PR05MB4185; 3:RdKLN82QcoSspryhyXYGKtH6A9JZK33ZWYB9hqF0yBPUYDx075zAOCpcRj9MNbDupbYKV2hOaQNXpCN9RkUVq8STZeNQksi3i2I9ioa1pEMOKWyyrpDB4MLZdFBqp/5erlcV4s8lZp1xZGRCBiEOmke+imORymIr5PDDgTmCs5+FqSri+m98FBLg4eS3UqvHWn/Vk1AOZLJKDB/XAowKwOuYqOBnZTludGzHCyYMuBwRxR3klZxFteQ6AHapA/av; 25:O0RmqfZiO7emD+DPhNMA8tAFSC+KgCCJlxo19XdnrRZ7YKfl5jH7LbV2IeOqK4Uu7ytX8AikqslGOTeuv98otDFRE8iipSD5m3zh8R/dQrugI+uiqOdqLEiI4Dy0jbLvzd7okJZMTKwy3Svfe/OFhCslCZNSBv3bU8BRw6m9hfdaBjYgx/Gs0gOjB7GBNInpE2fqWYb4t2GCWzKxb9oL/vPJdZVbAqQ8COB7Hyl7cpW23cuzVYSvnhaQE8fYvRZEWNPXClHEOSwHkvLPMpcN38UvYkzz1cQ+SWkXxTbO4yd+Aodw3wYdOb+6rjQdutp/NeWJ/lWv5dSn1zbTtR26JQ==; 31:STerw+/rQfWp4thqOFqsxznjtxk5zXxAApo3RkMspJ4QJiftu+2DGavUoQcVbQIXxCjK6ilyMhJ0S4TiJMIzea591q2jimmvhzRsTt0NuHMvRa+uNVujDx9GhD5/HEgZiAj0JdBNsn73lgZ+QLvg5UyA9rxNuQeGu19mHTOL0QqGFR++LjyfJLobhAp1Ed8H2FBGEohbIIKJHVgTDXQuXyttwcMjgh6Znf0uvlZD6Ws= X-MS-TrafficTypeDiagnostic: DB7PR05MB4185: X-Microsoft-Exchange-Diagnostics: 1; DB7PR05MB4185; 20:YbAib4qzyMXY8ReT5w1bIRaviWb5QtiAKOeV3xV9bd+z9FzVJTqBwr9bvI3PhphGCzLThem3wqFT++WTT1dd3iNTNtjvjmd6yMVj5oryS8/rqKBMk/w0+QQdappn72uMaQens12ASQ6xjXObMY5o/+HvxTBVPIgSNuQ4oTeRLu+CgRe3VfeGJRieN4aPahqqVm3mW7b1M6+noVwp4M0jBdSQVgPcV4bRJOpscdqpIuXPah0npUrwkSBFskU6VVhbhhktrURFnKM+P9X2Larwc7aJVPQbh86aDKR0thrP0IAwGNU1ffvBOzzk1ej9PjS4WSVlws6v+DRCmVkHzGSAUKDToo/rP6Goq2TTd/0bEvO64+zENRpGsoRbjLhvYSCtY0d2F0BiALwNadC54RRP2MKuW0U/xHqYuqKiGwzyT/gMe9I0irytk2dCvIpt4jvuxf0/Oxr2keeFCnIXqHceJ5YhE11Hi6wQ3VGLA5/7h4eRJ4iV6xsRk1DgY/9lUBjo; 4:4tGp00XY0Yp82RvlQCELhR4zrTQIom9TuaM7Bjl9znyb5HC8gI7dWqWcUoTyxZZyOwlIK2Q9Gf13euMXLy4OmkkRdeM64b9tEsfOvUqYeTamNEGC76WpGXDvHFP8ViqI6VpST6CxFfmHrttGWb+u6qUtUlqFCTk17zw1yxcoCHoVOztDgyZswQOOA5i0ALgw3IA1e7sxq0DumRnqKeVBfXNrvF8uN5ImFHx+o6pK1FpPY8UvjxbZmqt0S7vmFVphwaXy9oPn6jHBLj43LVVI0A== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231232)(944501410)(52105095)(10201501046)(3002001)(6055026)(6041310)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011); SRVR:DB7PR05MB4185; BCL:0; PCL:0; RULEID:; SRVR:DB7PR05MB4185; X-Forefront-PRVS: 0652EA5565 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(346002)(39860400002)(396003)(39380400002)(366004)(189003)(199004)(8936002)(48376002)(6916009)(36756003)(50466002)(4326008)(105586002)(53936002)(11346002)(956004)(16526019)(446003)(486006)(476003)(2616005)(2351001)(51416003)(6496006)(52116002)(6486002)(107886003)(106356001)(26005)(118296001)(316002)(97736004)(76176011)(66066001)(6666003)(16586007)(386003)(575784001)(86362001)(3846002)(6116002)(58126008)(305945005)(25786009)(81156014)(7736002)(2906002)(478600001)(8676002)(47776003)(5660300001)(68736007)(81166006)(309714004); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR05MB4185; H:t540p; 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; DB7PR05MB4185; 23:OzfN+kdDOixrDFdOLiXOkNFHs77pHmzgzT4js34MI?= =?us-ascii?Q?QC/DKOsPfqppkYZKF4Pa6u+IZSN6zk5QuJqotoW1pXvf0lEpL1q8gzdyRgJX?= =?us-ascii?Q?0jKYnJZwSQMT6BtkXAF/G7VxReY673ivxSJdaMM4Eqbxg0VUnEDdWbzqiZ+M?= =?us-ascii?Q?/6zFfj4gX7noR2/NcugTk7GYCLQ7HRhomgGLjP6M+vnLXBsRpL5zBQHva6ax?= =?us-ascii?Q?z25jzTP6kCHH6XJm5q5zyJLoVFsCseh8vHe5Y3NvuNEfx8dBnxmvJNScSO4D?= =?us-ascii?Q?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p5OT11Z17O0e7W2wJaBHSYzTisFxVkvC4zK9p3XkkDFgsq3+vufzz69Utk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB7PR05MB4185; 7:h6zr9Yex8V+o3aQa/5uZEkH3CinjXZz2VfzsMbLQSmXL291H6XN4nuKL+ku+mOHa2ILWqb28wfcrP7FNHnaJVLTVcuhtnl6fOdY3/EZNjeIHAiRFyYbD0ajtSBKY4omLZ68aRVBOln7EmMpNDQnI3X/qxZYbMOTGxnQe4C//S9weHmgN+6YoRea8/0ntQbWgKOpzeFwRCufIDa8WWoho0hE5QAKsfOHAeDRt6xdKcQLohkudzoGAqOGkjkkyxs81 X-MS-Office365-Filtering-Correlation-Id: 0cd5d8f4-d45a-4b1e-5764-08d5aa3867a0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2018 23:09:17.3588 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0cd5d8f4-d45a-4b1e-5764-08d5aa3867a0 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR05MB4185 X-BeenThere: linux-mlxsw@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: mlxsw driver development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-internal@mellanox.com Errors-To: linux-mlxsw-bounces+patchwork-linux-mlxsw=patchwork.kernel.org@lists.ozlabs.org Sender: "Linux-mlxsw" X-Virus-Scanned: ClamAV using ClamSMTP When handling mirroring to a gretap or ip6gretap netdevice in mlxsw, the underlay address (i.e. the remote address of the tunnel) may be routed to a bridge. In that case, look up the resolved neighbor Ethernet address in that bridge's FDB. Then configure the offload to direct the mirrored traffic to that port, possibly with tagging. Signed-off-by: Petr Machata --- Notes: Changes from v1 to v2: - Don't offload if there's no PVID set for the bridge. - Constify br_dev parameter of mlxsw_sp_span_entry_bridge{,_8021d,_8021q,_lookup_dev}(), - s/vidp/p_vid/g .../net/ethernet/mellanox/mlxsw/spectrum_span.c | 104 +++++++++++++++++++-- .../net/ethernet/mellanox/mlxsw/spectrum_span.h | 1 + 2 files changed, 99 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c index ac22776..f5518f3 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c @@ -32,6 +32,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include @@ -39,8 +40,9 @@ #include #include "spectrum.h" -#include "spectrum_span.h" #include "spectrum_ipip.h" +#include "spectrum_span.h" +#include "spectrum_switchdev.h" int mlxsw_sp_span_init(struct mlxsw_sp *mlxsw_sp) { @@ -168,6 +170,81 @@ mlxsw_sp_span_entry_unoffloadable(struct mlxsw_sp_span_parms *sparmsp) return 0; } +static struct net_device * +mlxsw_sp_span_entry_bridge_8021q(const struct net_device *br_dev, + unsigned char *dmac, + const struct switchdev_obj_port_vlan *vlan, + u16 *p_vid) +{ + struct net_bridge_vlan_group *vg = br_vlan_group_rtnl(br_dev); + u16 pvid = br_vlan_group_pvid(vg); + struct net_device *edev = NULL; + struct net_bridge_vlan *v; + u16 flags; + + if (pvid) + edev = br_fdb_find_port(br_dev, dmac, pvid); + if (!edev) + return NULL; + + if (vlan && vlan->obj.orig_dev == edev && + pvid >= vlan->vid_begin && pvid <= vlan->vid_end) { + flags = vlan->flags; + } else { + vg = br_port_vlan_group_rtnl(edev); + v = br_vlan_find(vg, pvid); + if (!v) + return NULL; + flags = br_vlan_flags(v); + } + if (!(flags & BRIDGE_VLAN_INFO_UNTAGGED)) + *p_vid = pvid; + return edev; +} + +static struct net_device * +mlxsw_sp_span_entry_bridge_8021d(const struct net_device *br_dev, + unsigned char *dmac) +{ + return br_fdb_find_port(br_dev, dmac, 0); +} + +static struct net_device * +mlxsw_sp_span_entry_bridge(const struct net_device *br_dev, + unsigned char dmac[ETH_ALEN], + const struct switchdev_obj_port_vlan *vlan, + u16 *p_vid) +{ + struct mlxsw_sp_bridge_port *bridge_port; + enum mlxsw_reg_spms_state spms_state; + struct mlxsw_sp_port *port; + struct net_device *dev; + u8 stp_state; + + if (br_vlan_enabled(br_dev)) + dev = mlxsw_sp_span_entry_bridge_8021q(br_dev, dmac, + vlan, p_vid); + else + dev = mlxsw_sp_span_entry_bridge_8021d(br_dev, dmac); + if (!dev) + return NULL; + + port = mlxsw_sp_port_dev_lower_find(dev); + if (!port) + return NULL; + + bridge_port = mlxsw_sp_bridge_port_find(port->mlxsw_sp->bridge, dev); + if (!bridge_port) + return NULL; + + stp_state = mlxsw_sp_bridge_port_stp_state(bridge_port); + spms_state = mlxsw_sp_stp_spms_state(stp_state); + if (spms_state != MLXSW_REG_SPMS_STATE_FORWARDING) + return NULL; + + return dev; +} + static __maybe_unused int mlxsw_sp_span_entry_tunnel_parms_common(struct net_device *l3edev, union mlxsw_sp_l3addr saddr, @@ -179,13 +256,22 @@ mlxsw_sp_span_entry_tunnel_parms_common(struct net_device *l3edev, struct mlxsw_sp_span_parms *sparmsp) { unsigned char dmac[ETH_ALEN]; + u16 vid = 0; if (mlxsw_sp_l3addr_is_zero(gw)) gw = daddr; - if (!l3edev || !mlxsw_sp_port_dev_check(l3edev) || - mlxsw_sp_span_dmac(tbl, &gw, l3edev, dmac)) - return mlxsw_sp_span_entry_unoffloadable(sparmsp); + if (!l3edev || mlxsw_sp_span_dmac(tbl, &gw, l3edev, dmac)) + goto unoffloadable; + + if (netif_is_bridge_master(l3edev)) { + l3edev = mlxsw_sp_span_entry_bridge(l3edev, dmac, vlan, &vid); + if (!l3edev) + goto unoffloadable; + } + + if (!mlxsw_sp_port_dev_check(l3edev)) + goto unoffloadable; sparmsp->dest_port = netdev_priv(l3edev); sparmsp->ttl = ttl; @@ -193,7 +279,11 @@ mlxsw_sp_span_entry_tunnel_parms_common(struct net_device *l3edev, memcpy(sparmsp->smac, l3edev->dev_addr, ETH_ALEN); sparmsp->saddr = saddr; sparmsp->daddr = daddr; + sparmsp->vid = vid; return 0; + +unoffloadable: + return mlxsw_sp_span_entry_unoffloadable(sparmsp); } #if IS_ENABLED(CONFIG_NET_IPGRE) @@ -271,9 +361,10 @@ mlxsw_sp_span_entry_gretap4_configure(struct mlxsw_sp_span_entry *span_entry, /* Create a new port analayzer entry for local_port. */ mlxsw_reg_mpat_pack(mpat_pl, pa_id, local_port, true, MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH_L3); + mlxsw_reg_mpat_eth_rspan_pack(mpat_pl, sparms.vid); mlxsw_reg_mpat_eth_rspan_l2_pack(mpat_pl, MLXSW_REG_MPAT_ETH_RSPAN_VERSION_NO_HEADER, - sparms.dmac, false); + sparms.dmac, !!sparms.vid); mlxsw_reg_mpat_eth_rspan_l3_ipv4_pack(mpat_pl, sparms.ttl, sparms.smac, be32_to_cpu(sparms.saddr.addr4), @@ -372,9 +463,10 @@ mlxsw_sp_span_entry_gretap6_configure(struct mlxsw_sp_span_entry *span_entry, /* Create a new port analayzer entry for local_port. */ mlxsw_reg_mpat_pack(mpat_pl, pa_id, local_port, true, MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH_L3); + mlxsw_reg_mpat_eth_rspan_pack(mpat_pl, sparms.vid); mlxsw_reg_mpat_eth_rspan_l2_pack(mpat_pl, MLXSW_REG_MPAT_ETH_RSPAN_VERSION_NO_HEADER, - sparms.dmac, false); + sparms.dmac, !!sparms.vid); mlxsw_reg_mpat_eth_rspan_l3_ipv6_pack(mpat_pl, sparms.ttl, sparms.smac, sparms.saddr.addr6, sparms.daddr.addr6); diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.h index 9a7806e..b8fe0e7 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.h @@ -64,6 +64,7 @@ struct mlxsw_sp_span_parms { unsigned char smac[ETH_ALEN]; union mlxsw_sp_l3addr daddr; union mlxsw_sp_l3addr saddr; + u16 vid; }; struct mlxsw_sp_span_entry_ops;