Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp2421701pxf; Sat, 20 Mar 2021 15:42:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyc5+TEPe6m2tuTWXYgyy0CENhFVDfwme/BRVYomS2oqEbmqptdJBE/kSTakGk6jji/8Ni8 X-Received: by 2002:a17:907:d15:: with SMTP id gn21mr11369670ejc.337.1616280159015; Sat, 20 Mar 2021 15:42:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616280159; cv=none; d=google.com; s=arc-20160816; b=CA6GNoV9EjeTkdrcqn/ppkgBahMpdEjBZh5nD+DWIYxjqAmTOg5l7wDQidL6yZ9qcD s8+jtFX4CDYQ9P3Kud2weKY9IUkLreAi9hIVVpKuAji4Qfh0jcZ0GTlv7GN+Yy8j8ZvO KiVA2x9eN4ijQ4qu7tLgCcAJvnfuxUEXDLDEN3ECS9V5vIRZJXlKuYR+Th7OiWJh4mYV LnHIYSh7bzGIv174nogrIgidpPLVwygqqD7vEgKqTBsz2hPxgGWsWyO2Amzj9D/yg48X BVT2njKW1dBl0c6KABVzrqrg1/9Qeu/895WZNqNzCVfWyXADGGhXzKm6VWLXC2uvYR1R LOSQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rw+kglmFcQnryQjzxMm2RqClK1crzr9d9kBr/GNKjX4=; b=bEAx1cmiwdHR3WnTXF1TvaYQyA1E7Kzb+YJgZ+Q7NjkN0JSoNc7wDofQsEkrhrGYTP TKmYq+h3+/VExwQHV3AjBCQxzFb2AnxYJDq/35q3iIHxzt9c/4dMGGHVZKwRZIK14hZ9 B+FvtAQtK6kD9ybZbRFj4tCh0pZBnwEFLKIuL8YLO3T+0tRy9VeFmSehUvdDU8wXxj9g gc62kV4mKs0SkmIUXIGky62uTFW+Xo5W7Hshu03cFrXJXvYXq84jblmyf2R0OUKOQkFH 1wzrYRlScJWUydDOO5yt/c0pxDr0oZD8PonJkDlf7yyXnQA3LTo7xZRpnCBV8tqMiyLJ gHMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=neLfK1xD; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y3si7339251eds.265.2021.03.20.15.42.16; Sat, 20 Mar 2021 15:42:39 -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=@gmail.com header.s=20161025 header.b=neLfK1xD; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229985AbhCTWfb (ORCPT + 99 others); Sat, 20 Mar 2021 18:35:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229805AbhCTWfW (ORCPT ); Sat, 20 Mar 2021 18:35:22 -0400 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08173C061574; Sat, 20 Mar 2021 15:35:22 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id h13so14959554eds.5; Sat, 20 Mar 2021 15:35:21 -0700 (PDT) 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=rw+kglmFcQnryQjzxMm2RqClK1crzr9d9kBr/GNKjX4=; b=neLfK1xDeWrLSdFFdduHV9nQShTeuPxiwxACh93SZIIqdSYfnc6JSNXXhLQGd8Tron R5m4p4OYU+yKoiv+Qd6jWaLHoSVwJUzYjUfS2gYRvCLA8c/LHkD1s23eGbpU3UYrpPYb HmLMdc3e7ZBkui38R8OY2eCoK4FXbtzOlrYlMwx7a5PvXeUd39kc5fPvX6/wE3+qldHd lNBusAVAZAVjX4wApkjEqQZ7oVJDyW7LdcWKIRA3przQ0VIHuB/GTK3tUyHA8YkevKUn pa+px6wr95gSEmpUsiWMxvk6/FUihzRY5aKWSx9c7k6GhP08ULQHqnhKFxRfpvBXScgK TjEA== 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=rw+kglmFcQnryQjzxMm2RqClK1crzr9d9kBr/GNKjX4=; b=RfIS5RJA1i4MglIEpjxbCpr9SvCAPADowng89mwxFlKG9KGmk618jBz9ecxid8tXEZ NCPY7x17yrvsxS+ELPsdi5j4erbNmIchheG9W/n9d751J74S5k/1ldUs11P1GRTd+hmP QbQlbXDBaCa//MISMmhB675G/tSJSylCeIHYcJSHT+OUYiWR+7vhJqv6KDRYEjeve4zP tY5fdEbC7gbwJs0cReDBMwRjnGd5GLbMRXxo//QqT35t6QEXe96KqEYvTMesiDYlHtXA h6X/VYXG0EFKx9w2yGgAFYyDXc5jHodYJMHJ9NE9E6YOcREFtADwYv7p+1ao5yk+iGag /Y0A== X-Gm-Message-State: AOAM5313ioZhkMZxnj8T6N3zpvzhustcXfd8oLlCD5lQMAlnZX6LHQE7 xfxj3KgybujPoS3SphZ9vKo= X-Received: by 2002:a05:6402:27d3:: with SMTP id c19mr17773003ede.129.1616279720799; Sat, 20 Mar 2021 15:35:20 -0700 (PDT) Received: from localhost.localdomain (5-12-16-165.residential.rdsnet.ro. [5.12.16.165]) by smtp.gmail.com with ESMTPSA id n2sm6090850ejl.1.2021.03.20.15.35.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 15:35:20 -0700 (PDT) From: Vladimir Oltean To: Jakub Kicinski , "David S. Miller" Cc: Andrew Lunn , Vivien Didelot , Florian Fainelli , Tobias Waldekranz , Claudiu Manoil , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Roopa Prabhu , Nikolay Aleksandrov , Jiri Pirko , Ido Schimmel , Alexandre Belloni , UNGLinuxDriver@microchip.com, Ivan Vecera , linux-omap@vger.kernel.org, Vladimir Oltean Subject: [PATCH v3 net-next 01/12] net: dsa: call dsa_port_bridge_join when joining a LAG that is already in a bridge Date: Sun, 21 Mar 2021 00:34:37 +0200 Message-Id: <20210320223448.2452869-2-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210320223448.2452869-1-olteanv@gmail.com> References: <20210320223448.2452869-1-olteanv@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vladimir Oltean DSA can properly detect and offload this sequence of operations: ip link add br0 type bridge ip link add bond0 type bond ip link set swp0 master bond0 ip link set bond0 master br0 But not this one: ip link add br0 type bridge ip link add bond0 type bond ip link set bond0 master br0 ip link set swp0 master bond0 Actually the second one is more complicated, due to the elapsed time between the enslavement of bond0 and the offloading of it via swp0, a lot of things could have happened to the bond0 bridge port in terms of switchdev objects (host MDBs, VLANs, altered STP state etc). So this is a bit of a can of worms, and making sure that the DSA port's state is in sync with this already existing bridge port is handled in the next patches. Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- Changes in v3: None. net/dsa/port.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/net/dsa/port.c b/net/dsa/port.c index c9c6d7ab3f47..d39262a9fe0e 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -249,17 +249,31 @@ int dsa_port_lag_join(struct dsa_port *dp, struct net_device *lag, .lag = lag, .info = uinfo, }; + struct net_device *bridge_dev; int err; dsa_lag_map(dp->ds->dst, lag); dp->lag_dev = lag; err = dsa_port_notify(dp, DSA_NOTIFIER_LAG_JOIN, &info); - if (err) { - dp->lag_dev = NULL; - dsa_lag_unmap(dp->ds->dst, lag); - } + if (err) + goto err_lag_join; + bridge_dev = netdev_master_upper_dev_get(lag); + if (!bridge_dev || !netif_is_bridge_master(bridge_dev)) + return 0; + + err = dsa_port_bridge_join(dp, bridge_dev); + if (err) + goto err_bridge_join; + + return 0; + +err_bridge_join: + dsa_port_notify(dp, DSA_NOTIFIER_LAG_LEAVE, &info); +err_lag_join: + dp->lag_dev = NULL; + dsa_lag_unmap(dp->ds->dst, lag); return err; } -- 2.25.1