Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2989089pxj; Mon, 17 May 2021 15:02:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJ1zyrmEmWDoUVGHPb/qhbRtsqoxOFPvCkE31D8i22i98nIkrkihZAdhAd4wdJcM8ZsuGC X-Received: by 2002:a17:907:7355:: with SMTP id dq21mr2072943ejc.503.1621288940340; Mon, 17 May 2021 15:02:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621288940; cv=none; d=google.com; s=arc-20160816; b=TPL+f1cad/XAH8+yY8mWlMNUp0EWA8HFZTICn2Wl5Y1Eo/t1B/Zc/5WSUmNbYngxvA uf8xfG0Y+AOcB6i/H6RTRL9FtfhX+25OoI9zJ3rtJEuueKu/J/DdJaV00l9WGa9JJaLJ C4VHVKRm9TYZ4jKYNnSIqwRrj8qIDL323e8Vmq5Z1YD58v0KbQbTHnuR0ufR0yFUOpxj 6+n1ctDYv5zaYowF+9ngASxCjy3ykNdAc8UTX9MzS/XuAmqDBuYEw6NCjcrvpoiY3LEw k7MyEWphAB+moro0nMc02qyiLMdDmmVbWeF2jhCpPe7SdQBOqEJw18RWoPpNymDgvmke SVbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=d184nz86LS+xut+ysaItR/6lYgEVV+31eH/ZPHGlvM0=; b=09xTyXZhfG69NbXlDaIyEMsxGHPlfwA268ADmkb+gyBlg1u3oI3l/R+0mKMo2ZkdUV 3pA+/kbGZUkpq/oSPPn74ohFus3UcHQc04dJbSUPUXocPkyVFn1x0inznb5Jw2Ustwfm feqLGOQ/lsNlBvnz/yCoa6EV4x77sW4HpwhuScQ/8hexMrOCJl0R/09DYo7WKd9mAIrt aeX8Aq2S3obgqKnkjGMlpWxIQMxssRkKq5He5Ee4seoO185d2hkdKXXh4PPu7mXY5lHz bmsiseOKidHlgSVACjv2ZRGkrTZhb4EZjYGXVFzLKBDXIb5YK47m3ofM6DudqkANEElC rLmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yzSl3Yd6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hs9si14187278ejc.643.2021.05.17.15.01.44; Mon, 17 May 2021 15:02:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yzSl3Yd6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238732AbhEQOMP (ORCPT + 99 others); Mon, 17 May 2021 10:12:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:60382 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238117AbhEQOKF (ORCPT ); Mon, 17 May 2021 10:10:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 60AD5613AE; Mon, 17 May 2021 14:07:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260435; bh=pZWdYqIrjsU32570I3MPZ+fG8mfbkPd2wde5NkSNP28=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yzSl3Yd6WoDEqSNUEJ/+F5c4thW9zuGXJYug2z2Vv32fdx8PC3wUjkWndvLeoxX8N LpPJABzduzub0x1ufWinGWCgZTFdwH8B1pWewTJqOy401Na0z7hAoN7sc+LKLtVDSd AURj5Kr4rpQYi7acAOCBr7h5989THo7Ekq3RAuDY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Fainelli , Vladimir Oltean , "David S. Miller" , Sasha Levin Subject: [PATCH 5.12 081/363] net: bridge: propagate error code and extack from br_mc_disabled_update Date: Mon, 17 May 2021 15:59:07 +0200 Message-Id: <20210517140305.339768334@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Florian Fainelli [ Upstream commit ae1ea84b33dab45c7b6c1754231ebda5959b504c ] Some Ethernet switches might only be able to support disabling multicast snooping globally, which is an issue for example when several bridges span the same physical device and request contradictory settings. Propagate the return value of br_mc_disabled_update() such that this limitation is transmitted correctly to user-space. Signed-off-by: Florian Fainelli Signed-off-by: Vladimir Oltean Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/bridge/br_multicast.c | 28 +++++++++++++++++++++------- net/bridge/br_netlink.c | 4 +++- net/bridge/br_private.h | 3 ++- net/bridge/br_sysfs_br.c | 8 +------- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index 229309d7b4ff..72b3193b08ec 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -1593,7 +1593,8 @@ out: spin_unlock(&br->multicast_lock); } -static void br_mc_disabled_update(struct net_device *dev, bool value) +static int br_mc_disabled_update(struct net_device *dev, bool value, + struct netlink_ext_ack *extack) { struct switchdev_attr attr = { .orig_dev = dev, @@ -1602,11 +1603,13 @@ static void br_mc_disabled_update(struct net_device *dev, bool value) .u.mc_disabled = !value, }; - switchdev_port_attr_set(dev, &attr, NULL); + return switchdev_port_attr_set(dev, &attr, extack); } int br_multicast_add_port(struct net_bridge_port *port) { + int err; + port->multicast_router = MDB_RTR_TYPE_TEMP_QUERY; port->multicast_eht_hosts_limit = BR_MCAST_DEFAULT_EHT_HOSTS_LIMIT; @@ -1618,8 +1621,12 @@ int br_multicast_add_port(struct net_bridge_port *port) timer_setup(&port->ip6_own_query.timer, br_ip6_multicast_port_query_expired, 0); #endif - br_mc_disabled_update(port->dev, - br_opt_get(port->br, BROPT_MULTICAST_ENABLED)); + err = br_mc_disabled_update(port->dev, + br_opt_get(port->br, + BROPT_MULTICAST_ENABLED), + NULL); + if (err) + return err; port->mcast_stats = netdev_alloc_pcpu_stats(struct bridge_mcast_stats); if (!port->mcast_stats) @@ -3543,16 +3550,23 @@ static void br_multicast_start_querier(struct net_bridge *br, rcu_read_unlock(); } -int br_multicast_toggle(struct net_bridge *br, unsigned long val) +int br_multicast_toggle(struct net_bridge *br, unsigned long val, + struct netlink_ext_ack *extack) { struct net_bridge_port *port; bool change_snoopers = false; + int err = 0; spin_lock_bh(&br->multicast_lock); if (!!br_opt_get(br, BROPT_MULTICAST_ENABLED) == !!val) goto unlock; - br_mc_disabled_update(br->dev, val); + err = br_mc_disabled_update(br->dev, val, extack); + if (err == -EOPNOTSUPP) + err = 0; + if (err) + goto unlock; + br_opt_toggle(br, BROPT_MULTICAST_ENABLED, !!val); if (!br_opt_get(br, BROPT_MULTICAST_ENABLED)) { change_snoopers = true; @@ -3590,7 +3604,7 @@ unlock: br_multicast_leave_snoopers(br); } - return 0; + return err; } bool br_multicast_enabled(const struct net_device *dev) diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c index f2b1343f8332..0456593aceec 100644 --- a/net/bridge/br_netlink.c +++ b/net/bridge/br_netlink.c @@ -1293,7 +1293,9 @@ static int br_changelink(struct net_device *brdev, struct nlattr *tb[], if (data[IFLA_BR_MCAST_SNOOPING]) { u8 mcast_snooping = nla_get_u8(data[IFLA_BR_MCAST_SNOOPING]); - br_multicast_toggle(br, mcast_snooping); + err = br_multicast_toggle(br, mcast_snooping, extack); + if (err) + return err; } if (data[IFLA_BR_MCAST_QUERY_USE_IFADDR]) { diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index d7d167e10b70..af3430c2d6ea 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -810,7 +810,8 @@ void br_multicast_flood(struct net_bridge_mdb_entry *mdst, struct sk_buff *skb, bool local_rcv, bool local_orig); int br_multicast_set_router(struct net_bridge *br, unsigned long val); int br_multicast_set_port_router(struct net_bridge_port *p, unsigned long val); -int br_multicast_toggle(struct net_bridge *br, unsigned long val); +int br_multicast_toggle(struct net_bridge *br, unsigned long val, + struct netlink_ext_ack *extack); int br_multicast_set_querier(struct net_bridge *br, unsigned long val); int br_multicast_set_hash_max(struct net_bridge *br, unsigned long val); int br_multicast_set_igmp_version(struct net_bridge *br, unsigned long val); diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c index 072e29840082..381467b691d5 100644 --- a/net/bridge/br_sysfs_br.c +++ b/net/bridge/br_sysfs_br.c @@ -409,17 +409,11 @@ static ssize_t multicast_snooping_show(struct device *d, return sprintf(buf, "%d\n", br_opt_get(br, BROPT_MULTICAST_ENABLED)); } -static int toggle_multicast(struct net_bridge *br, unsigned long val, - struct netlink_ext_ack *extack) -{ - return br_multicast_toggle(br, val); -} - static ssize_t multicast_snooping_store(struct device *d, struct device_attribute *attr, const char *buf, size_t len) { - return store_bridge_parm(d, buf, len, toggle_multicast); + return store_bridge_parm(d, buf, len, br_multicast_toggle); } static DEVICE_ATTR_RW(multicast_snooping); -- 2.30.2