From patchwork Mon Apr 11 13:38:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joachim Wiberg X-Patchwork-Id: 12809119 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9ADD2C433F5 for ; Mon, 11 Apr 2022 13:39:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346597AbiDKNlT (ORCPT ); Mon, 11 Apr 2022 09:41:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343598AbiDKNlK (ORCPT ); Mon, 11 Apr 2022 09:41:10 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D43EB21E15 for ; Mon, 11 Apr 2022 06:38:56 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id z17so2182729lfj.11 for ; Mon, 11 Apr 2022 06:38:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=15O42YcTjpmDhDPvSQqOizS3ABZbH38ENN7jhBTnn4Q=; b=IaBb4jkSWIxICG3VJbssykTGz95G7zDiifz0RBjL7GZ0tpIylTl8B5PNRmMO5lYyW9 u4I8tQzRMFBFmViPiEgTzX9uNrJ0bvNsnj9b6BxHtlJnbk6D/3daKgMX+7/zPJ9688lV UXkLUnEF2gFdok5cQjofcP4nnSwFnnoI+P+WEUmEjDG2/byd8dBjrlFJjcKhvr32ZbY5 KB3pT6TLB8YBzk/xlcdHO/I0xOZtmpYImmemgxjl48DHu5Sk7WeWYbpTz/1IQiKiimzG mSROXfhet++r3kzANHZrmtF51DKjmziKgj1dg8TOPZeE8u7wm/G65hAMbS7VVbMX3uGv E3bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=15O42YcTjpmDhDPvSQqOizS3ABZbH38ENN7jhBTnn4Q=; b=4711b+JTvhC5nkqv+sFSOGIjdtA2XCSUJfNJyxEhP6EI50nSApSy9xdJO57anCQPRW 1FLb26Kmo2+BBCUmC6s1CuRFu4I5Hp9gZ0UIN+3BgVIVmhLFXGlgiMU4HSIpqz7xZW3c 25XWPxXXhVfRI5jwN/f52mD/4y74FjqhUkHi8uoG8clYesBW27HOnJGniyVVs8DXecO7 BwI/Ex/PTJWYN8LkRJDm8ArK6Qw8zYPAweRYVdqm2PfNdrHHFXWUhis2afLrNWvdidxb ZrRSQWDVnao1RlHChD7fkdvE3pz1Rn7B5JdbS6fuff7y6XVva67dZEgFUwaXRGb3pMcO aM3g== X-Gm-Message-State: AOAM530CCaYz9vUyusIg2mUQk+z4bdIiGKVEgUC/+yT9MPoU3p60alT7 bZtIjZjRj725bpujA7pwtis= X-Google-Smtp-Source: ABdhPJwVX0p4K8mGxFlbxBh0ugRbtpmk0aqkD7A7QNIJgZPtnwRRD6Kal5WfasVud0lNUC7kiIzQ2g== X-Received: by 2002:a05:6512:3402:b0:448:c29:ce8a with SMTP id i2-20020a056512340200b004480c29ce8amr22242644lfr.633.1649684335092; Mon, 11 Apr 2022 06:38:55 -0700 (PDT) Received: from wbg.labs.westermo.se (h-158-174-22-128.NA.cust.bahnhof.se. [158.174.22.128]) by smtp.gmail.com with ESMTPSA id p12-20020a056512138c00b0044833f1cd85sm3336847lfa.62.2022.04.11.06.38.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Apr 2022 06:38:54 -0700 (PDT) From: Joachim Wiberg To: Roopa Prabhu , Nikolay Aleksandrov Cc: netdev@vger.kernel.org, bridge@lists.linux-foundation.org, "David S . Miller" , Jakub Kicinski , Joachim Wiberg , Tobias Waldekranz , Vladimir Oltean Subject: [PATCH RFC net-next 03/13] net: bridge: minor refactor of br_setlink() for readability Date: Mon, 11 Apr 2022 15:38:27 +0200 Message-Id: <20220411133837.318876-4-troglobit@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220411133837.318876-1-troglobit@gmail.com> References: <20220411133837.318876-1-troglobit@gmail.com> MIME-Version: 1.0 Organization: Westermo Network Technologies AB Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The br_setlink() function extracts the struct net_bridge pointer a bit sloppy. It's easy to interpret the code wrong. This patch attempts to clear things up a bit. Signed-off-by: Joachim Wiberg --- net/bridge/br_netlink.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c index 7fca8ff13ec7..8f4297287b32 100644 --- a/net/bridge/br_netlink.c +++ b/net/bridge/br_netlink.c @@ -1040,6 +1040,8 @@ int br_setlink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags, return 0; p = br_port_get_rtnl(dev); + if (p) + br = p->br; /* We want to accept dev as bridge itself if the AF_SPEC * is set to see if someone is setting vlan info on the bridge */ @@ -1055,17 +1057,17 @@ int br_setlink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags, if (err) return err; - spin_lock_bh(&p->br->lock); + spin_lock_bh(&br->lock); err = br_setport(p, tb, extack); - spin_unlock_bh(&p->br->lock); + spin_unlock_bh(&br->lock); } else { /* Binary compatibility with old RSTP */ if (nla_len(protinfo) < sizeof(u8)) return -EINVAL; - spin_lock_bh(&p->br->lock); + spin_lock_bh(&br->lock); err = br_set_port_state(p, nla_get_u8(protinfo)); - spin_unlock_bh(&p->br->lock); + spin_unlock_bh(&br->lock); } if (err) goto out;