[{"id":1776208,"web_url":"http://patchwork.ozlabs.org/comment/1776208/","msgid":"<847022b2-4bf7-0fbd-abf8-3d74af215933@cogentembedded.com>","list_archive_url":null,"date":"2017-09-27T10:15:33","subject":"Re: [PATCH net-next 1/6] net: dsa: Fix\n\tSWITCHDEV_ATTR_ID_PORT_PARENT_ID","submitter":{"id":22564,"url":"http://patchwork.ozlabs.org/api/people/22564/","name":"Sergei Shtylyov","email":"sergei.shtylyov@cogentembedded.com"},"content":"Hello!\n\nOn 9/27/2017 1:25 AM, Andrew Lunn wrote:\n\n> SWITCHDEV_ATTR_ID_PORT_PARENT_ID is used by the software bridge when\n> determining which ports to flood a packet out. If the packet\n> originated from a switch, it assumes the switch has already flooded\n> the packet out the switches ports, so the bridge should not flood the\n> packet itself out switch ports. Ports on the same switch are expected\n> to return the same parent ID when SWITCHDEV_ATTR_ID_PORT_PARENT_ID is\n> called.\n> \n> DSA gets this wrong with clusters of switches. As far as the software\n> bridge is concerned, the cluster is all one switch. A packet from any\n> switch in the cluster can be assumed to of been flooded as needed out\n\n    s/of/have/?\n\n> all ports of the cluster, not just the switch it originated\n> from. Hence all ports of a cluster should return the same parent. The\n> old implementation did not, each switch in the cluster had its own ID.\n> \n> Also wrong was that the ID was not unique if multiple DSA instances\n> are in operation.\n> \n> Use the tree ID as the parent ID, which is the same for all switches\n> in a cluster and unique across switch clusters.\n> \n> Signed-off-by: Andrew Lunn <andrew@lunn.ch>\n> ---\n> v2: Swap from MAC address to dst->tree\n[...]\n\nMBR, Sergei","headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=cogentembedded-com.20150623.gappssmtp.com\n\theader.i=@cogentembedded-com.20150623.gappssmtp.com\n\theader.b=\"1dPh7epU\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3y2DH90RTpz9t66\n\tfor <patchwork-incoming@ozlabs.org>;\n\tWed, 27 Sep 2017 20:15:49 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1752667AbdI0KPq (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tWed, 27 Sep 2017 06:15:46 -0400","from mail-wr0-f173.google.com ([209.85.128.173]:53129 \"EHLO\n\tmail-wr0-f173.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1752659AbdI0KPk (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Wed, 27 Sep 2017 06:15:40 -0400","by mail-wr0-f173.google.com with SMTP id c23so15538854wrg.9\n\tfor <netdev@vger.kernel.org>; Wed, 27 Sep 2017 03:15:38 -0700 (PDT)","from [192.168.4.126] ([31.173.84.190])\n\tby smtp.gmail.com with ESMTPSA id\n\tx9sm2294328ljd.88.2017.09.27.03.15.33\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tWed, 27 Sep 2017 03:15:37 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=cogentembedded-com.20150623.gappssmtp.com; s=20150623;\n\th=subject:to:cc:references:from:message-id:date:user-agent\n\t:mime-version:in-reply-to:content-language:content-transfer-encoding; \n\tbh=JEiVCEtUoBwEoYVCgE05kt7Mn5FWTl551DbxhHpoRfA=;\n\tb=1dPh7epUkmlrpMksgPeDdNVUABh5IrHZoahcYlWePlY1ufuo6HZWPxk2dTA301sCBs\n\t/GOhNdUUQDYnIm8Hp9q5vT5qjXb/63UilZszZUUVyB8R3xcbRjhiErIE2mbNg47ZE/Zs\n\t/X7yPPU4h3WqQvqrJuDnSTRS2giZt+an9CiI0ldrT6JFeRnrtQQY8MoSOY9L/ctJ6hzg\n\tbxs2RxjgV4VPfbETyvat7eEc3BpKS4jz9ZKShkJaGFh9+A3Ex8ltieR327EbKv4IgQhJ\n\tCaEa1WGtY6EGsKr8f+irR4j1rI8aproTKRzob1DWWHBDYiyzn0f3qE8uHXtDkvaIym7H\n\t+LJA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:subject:to:cc:references:from:message-id:date\n\t:user-agent:mime-version:in-reply-to:content-language\n\t:content-transfer-encoding;\n\tbh=JEiVCEtUoBwEoYVCgE05kt7Mn5FWTl551DbxhHpoRfA=;\n\tb=GIGjAsdbqAOeVcsCWECAw/+U0Klxi4dz0zegrNATh/IxA/DfeZ5SS5f+LYca0rr5TE\n\tBMSYhkRQRvNCxP8WWDBx54ClIoE0DIAWCZsTL2Qil5WvLmHeDizOReSZOUjJh6OimxrR\n\t0eMjZ6JMiGYh/07rauCZKxO4d1XyrsnmEdSB/xbL8j5NSpXL14VpamYWrtyrQE8UkAr0\n\t13tYKp7VoVIi+TKSztKzGRMUNYJctQRXG17QBjuZIahvzabaH+DpKf4RCJn1wnH/G2Dt\n\t79GTFi2O4nfCvw+GraqJ7LoEMrRsw7R8wLE2zLjhJKAm9yAwLdbapj6fYt8wSFMi6q6n\n\tWX0A==","X-Gm-Message-State":"AMCzsaWmYCn3Wt92vsA6lAc6EaFEtTYlhC9/sA66W88DNY4ZLi+gHZsN\n\t4S0y4lMJzb57C+MJteKA2dHhf/j/NrM=","X-Google-Smtp-Source":"AOwi7QC3g7vYG3dq2vXTjjxQrzE7PhCyHAi604qN9o/8QosV7Jec6sa3bc5u+4oMoTqQn+S5fC9O1g==","X-Received":"by 10.25.145.90 with SMTP id y26mr366036lfj.247.1506507337826;\n\tWed, 27 Sep 2017 03:15:37 -0700 (PDT)","Subject":"Re: [PATCH net-next 1/6] net: dsa: Fix\n\tSWITCHDEV_ATTR_ID_PORT_PARENT_ID","To":"Andrew Lunn <andrew@lunn.ch>, David Miller <davem@davemloft.net>","Cc":"Vivien Didelot <vivien.didelot@savoirfairelinux.com>,\n\tnetdev <netdev@vger.kernel.org>","References":"<1506464764-12699-1-git-send-email-andrew@lunn.ch>\n\t<1506464764-12699-2-git-send-email-andrew@lunn.ch>","From":"Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>","Message-ID":"<847022b2-4bf7-0fbd-abf8-3d74af215933@cogentembedded.com>","Date":"Wed, 27 Sep 2017 13:15:33 +0300","User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<1506464764-12699-2-git-send-email-andrew@lunn.ch>","Content-Type":"text/plain; charset=utf-8; format=flowed","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"}},{"id":1776430,"web_url":"http://patchwork.ozlabs.org/comment/1776430/","msgid":"<87tvzow42d.fsf@weeman.i-did-not-set--mail-host-address--so-tickle-me>","list_archive_url":null,"date":"2017-09-27T15:31:54","subject":"Re: [PATCH net-next 1/6] net: dsa: Fix\n\tSWITCHDEV_ATTR_ID_PORT_PARENT_ID","submitter":{"id":15889,"url":"http://patchwork.ozlabs.org/api/people/15889/","name":"Vivien Didelot","email":"vivien.didelot@savoirfairelinux.com"},"content":"Hi Andrew,\n\nAndrew Lunn <andrew@lunn.ch> writes:\n\n> @@ -354,13 +354,16 @@ static int dsa_slave_port_attr_get(struct net_device *dev,\n>  \t\t\t\t   struct switchdev_attr *attr)\n>  {\n>  \tstruct dsa_slave_priv *p = netdev_priv(dev);\n> -\tstruct dsa_switch *ds = p->dp->ds;\n>  \n>  \tswitch (attr->id) {\n> -\tcase SWITCHDEV_ATTR_ID_PORT_PARENT_ID:\n> -\t\tattr->u.ppid.id_len = sizeof(ds->index);\n> -\t\tmemcpy(&attr->u.ppid.id, &ds->index, attr->u.ppid.id_len);\n> +\tcase SWITCHDEV_ATTR_ID_PORT_PARENT_ID: {\n> +\t\tstruct dsa_switch *ds = p->dp->ds;\n> +\t\tstruct dsa_switch_tree *dst = ds->dst;\n> +\n> +\t\tattr->u.ppid.id_len = sizeof(dst->tree);\n> +\t\tmemcpy(&attr->u.ppid.id, &dst->tree, sizeof(dst->tree));\n>  \t\tbreak;\n> +\t}\n>  \tcase SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT:\n>  \t\tattr->u.brport_flags_support = 0;\n>  \t\tbreak;\n\nI am pretty sure the kernel folks won't like blocks within case\nstatments. Simply declare dst = p->dp->ds->dst at the beginning.\n\nAlso keeping attr->u.ppid.id_len as memcpy's third argument like other\nswitchdev users do would be prefered.\n\nOtherwise using the tree index is indeed the way to go:\n\nReviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>\n\n\nThanks,\n\n        Vivien","headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3y2MN91H27z9tXC\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu, 28 Sep 2017 01:35:37 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1752484AbdI0Pff (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tWed, 27 Sep 2017 11:35:35 -0400","from mail.savoirfairelinux.com ([208.88.110.44]:56478 \"EHLO\n\tmail.savoirfairelinux.com\" rhost-flags-OK-OK-OK-OK) by\n\tvger.kernel.org with ESMTP id S1752279AbdI0Pfe (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Wed, 27 Sep 2017 11:35:34 -0400","from localhost (localhost [127.0.0.1])\n\tby mail.savoirfairelinux.com (Postfix) with ESMTP id A37989C1AE5;\n\tWed, 27 Sep 2017 11:35:33 -0400 (EDT)","from mail.savoirfairelinux.com ([127.0.0.1])\n\tby localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new,\n\tport 10032)\n\twith ESMTP id yljW6cmble9z; Wed, 27 Sep 2017 11:35:32 -0400 (EDT)","from localhost (localhost [127.0.0.1])\n\tby mail.savoirfairelinux.com (Postfix) with ESMTP id 52E6D9C277D;\n\tWed, 27 Sep 2017 11:35:32 -0400 (EDT)","from mail.savoirfairelinux.com ([127.0.0.1])\n\tby localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new,\n\tport 10026)\n\twith ESMTP id JJ5MDOC-Ka34; Wed, 27 Sep 2017 11:35:32 -0400 (EDT)","from localhost (modemcable249.105-163-184.mc.videotron.ca\n\t[184.163.105.249])\n\tby mail.savoirfairelinux.com (Postfix) with ESMTPSA id 24BA79C1AE5;\n\tWed, 27 Sep 2017 11:35:32 -0400 (EDT)"],"X-Virus-Scanned":"amavisd-new at mail.savoirfairelinux.com","From":"Vivien Didelot <vivien.didelot@savoirfairelinux.com>","To":"Andrew Lunn <andrew@lunn.ch>, David Miller <davem@davemloft.net>","Cc":"netdev <netdev@vger.kernel.org>, Andrew Lunn <andrew@lunn.ch>","Subject":"Re: [PATCH net-next 1/6] net: dsa: Fix\n\tSWITCHDEV_ATTR_ID_PORT_PARENT_ID","In-Reply-To":"<1506464764-12699-2-git-send-email-andrew@lunn.ch>","References":"<1506464764-12699-1-git-send-email-andrew@lunn.ch>\n\t<1506464764-12699-2-git-send-email-andrew@lunn.ch>","Date":"Wed, 27 Sep 2017 11:31:54 -0400","Message-ID":"<87tvzow42d.fsf@weeman.i-did-not-set--mail-host-address--so-tickle-me>","MIME-Version":"1.0","Content-Type":"text/plain","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"}}]