From patchwork Wed Feb 24 11:43:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 387103 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D009C433E0 for ; Wed, 24 Feb 2021 11:46:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 41B5064E90 for ; Wed, 24 Feb 2021 11:46:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235044AbhBXLqS (ORCPT ); Wed, 24 Feb 2021 06:46:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234189AbhBXLpI (ORCPT ); Wed, 24 Feb 2021 06:45:08 -0500 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D120BC06178C for ; Wed, 24 Feb 2021 03:44:06 -0800 (PST) Received: by mail-ed1-x52f.google.com with SMTP id h25so2090815eds.4 for ; Wed, 24 Feb 2021 03:44:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yoeAVXVVgmxIroT+hw2AkHBtvfntX19xz1hn/RwiUHo=; b=QqBVRTlRH4UmpnUe3vf/XKZfg283KiLXd9GaHYMDaFTz3pbjLSb2/RJBvk5D12xvY3 GM3WsUh/F+2HS7c81WJYiIkqMpdyqlPBQro5KfjqAfohM1l5ZfZCA2DQv2HBjcHzReYV ZPgA7zNzFbSjZQCpi4Yla4WqN2ry5BuTg2WK7boUK0JnHm/oDBHzcOAD89F6atg+flip aju7FaYb1DpEuvTcUBc3VlREH005D6UkzM7Hr1gcamkQFi9SykR51/943rLpFc/G7+e7 KxcCknOQDb5R01WOR7uNmvB6VAMLkMt+ROaeMSlGCe+4YF2Q5wjJ5TuXBVh3BZS3qNh7 5ybQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yoeAVXVVgmxIroT+hw2AkHBtvfntX19xz1hn/RwiUHo=; b=loHkCBcsOCfZfgSURABvo2BthhPIiQOxBkHX13vRZNxH3PxrVvIKD8kQk36DuNDcRa B75BiWA27a62g0GLc/OlJL58nBioaQRvOei4J9b7c2wSx6NFNrsNEyUXwMndL8754xed q5CcH9eZeKBuK9rKcnvE3CtaH+EjZ/rJ0kKRthEZG6Ov4yWGmIJHcZSRS0WxVWVH7Kao L4ft0s5Y1qe8IL1Ry5MMqOFpAbxSsvD8VkAPEFlTKgMXfzoUSD/44Agz0hI9k4bHfySC 0iKsUGcBhO7z9/ICgSyY7qkT6/LKmtuA8r/9CHmqzrhJsdzv981uZm+jcfLim1iO3IkN 4u2A== X-Gm-Message-State: AOAM531Z0cc0IO77IhskpVQwdWwVaWlCBbMiO8V7BgblMnbnZyqIyedR yW3J39aruRCP6zvTdqatjOfDwXLQPdE= X-Google-Smtp-Source: ABdhPJwHE/yG7le0+dXFw79KdfZeaq/qV/N2rEKvBzipX7VSzGlbidosUeHpY7fjzbZQPNbUUj6jug== X-Received: by 2002:aa7:d2c4:: with SMTP id k4mr15362246edr.237.1614167045449; Wed, 24 Feb 2021 03:44:05 -0800 (PST) Received: from localhost.localdomain ([188.25.217.13]) by smtp.gmail.com with ESMTPSA id r5sm1203921ejx.96.2021.02.24.03.44.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 03:44:05 -0800 (PST) From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Andrew Lunn , Florian Fainelli , Vivien Didelot , Jiri Pirko , Ido Schimmel , DENG Qingfang , Tobias Waldekranz , George McCollister , Vlad Yasevich , Roopa Prabhu , Nikolay Aleksandrov Subject: [RFC PATCH v2 net-next 04/17] net: dsa: install the port MAC addresses as host fdb entries Date: Wed, 24 Feb 2021 13:43:37 +0200 Message-Id: <20210224114350.2791260-5-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210224114350.2791260-1-olteanv@gmail.com> References: <20210224114350.2791260-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean In preparation of support for IFF_UNICAST_FLT for DSA standalone ports, the unicast address of the DSA interfaces should always be known to the switch and installed as an FDB entry towards the CPU port associated with that user port. Signed-off-by: Vladimir Oltean --- net/dsa/slave.c | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index b6ea7e21b3b6..6544a4ec69f4 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -223,11 +223,9 @@ static int dsa_slave_open(struct net_device *dev) goto out; } - if (!ether_addr_equal(dev->dev_addr, master->dev_addr)) { - err = dev_uc_add(master, dev->dev_addr); - if (err < 0) - goto out; - } + err = dsa_host_fdb_add(dp, dev->dev_addr, 0); + if (err && err != -EOPNOTSUPP) + goto out; if (dev->flags & IFF_ALLMULTI) { err = dev_set_allmulti(master, 1); @@ -253,8 +251,7 @@ static int dsa_slave_open(struct net_device *dev) if (dev->flags & IFF_ALLMULTI) dev_set_allmulti(master, -1); del_unicast: - if (!ether_addr_equal(dev->dev_addr, master->dev_addr)) - dev_uc_del(master, dev->dev_addr); + dsa_host_fdb_del(dp, dev->dev_addr, 0); out: return err; } @@ -273,8 +270,7 @@ static int dsa_slave_close(struct net_device *dev) if (dev->flags & IFF_PROMISC) dev_set_promiscuity(master, -1); - if (!ether_addr_equal(dev->dev_addr, master->dev_addr)) - dev_uc_del(master, dev->dev_addr); + dsa_host_fdb_del(dp, dev->dev_addr, 0); return 0; } @@ -302,26 +298,18 @@ static void dsa_slave_set_rx_mode(struct net_device *dev) static int dsa_slave_set_mac_address(struct net_device *dev, void *a) { - struct net_device *master = dsa_slave_to_master(dev); + struct dsa_port *dp = dsa_slave_to_port(dev); struct sockaddr *addr = a; int err; if (!is_valid_ether_addr(addr->sa_data)) return -EADDRNOTAVAIL; - if (!(dev->flags & IFF_UP)) - goto out; - - if (!ether_addr_equal(addr->sa_data, master->dev_addr)) { - err = dev_uc_add(master, addr->sa_data); - if (err < 0) - return err; - } - - if (!ether_addr_equal(dev->dev_addr, master->dev_addr)) - dev_uc_del(master, dev->dev_addr); + err = dsa_host_fdb_add(dp, addr->sa_data, 0); + if (err && err != -EOPNOTSUPP) + return err; -out: + dsa_host_fdb_del(dp, dev->dev_addr, 0); ether_addr_copy(dev->dev_addr, addr->sa_data); return 0;