From: Jay Vosburgh <jay.vosburgh@canonical.com>
To: Jonathan Toppins <jtoppins@redhat.com>
Cc: netdev@vger.kernel.org, Veaceslav Falico <vfalico@gmail.com>,
Andy Gospodarek <andy@greyhouse.net>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: [net-next v2 2/2] bonding: cleanup bond_create
Date: Wed, 08 Jun 2022 11:51:22 -0700 [thread overview]
Message-ID: <12962.1654714282@famine> (raw)
In-Reply-To: <03db585475d164343991f90b268d2d08fa42afb6.1654711315.git.jtoppins@redhat.com>
Jonathan Toppins <jtoppins@redhat.com> wrote:
>Setting RLB_NULL_INDEX is not needed as this is done in bond_alb_initialize
>which is called by bond_open.
>
>Also reduce the number of rtnl_unlock calls by just using the standard
>goto cleanup path.
>
>Signed-off-by: Jonathan Toppins <jtoppins@redhat.com>
Acked-by: Jay Vosburgh <jay.vosburgh@canonical.com>
>---
> drivers/net/bonding/bond_main.c | 24 ++++++------------------
> 1 file changed, 6 insertions(+), 18 deletions(-)
>
>diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
>index f85372adf042..3d427183ec8e 100644
>--- a/drivers/net/bonding/bond_main.c
>+++ b/drivers/net/bonding/bond_main.c
>@@ -6218,45 +6218,33 @@ int bond_create(struct net *net, const char *name)
> {
> struct net_device *bond_dev;
> struct bonding *bond;
>- struct alb_bond_info *bond_info;
>- int res;
>+ int res = -ENOMEM;
>
> rtnl_lock();
>
> bond_dev = alloc_netdev_mq(sizeof(struct bonding),
> name ? name : "bond%d", NET_NAME_UNKNOWN,
> bond_setup, tx_queues);
>- if (!bond_dev) {
>- pr_err("%s: eek! can't alloc netdev!\n", name);
>- rtnl_unlock();
>- return -ENOMEM;
>- }
>+ if (!bond_dev)
>+ goto out;
>
>- /*
>- * Initialize rx_hashtbl_used_head to RLB_NULL_INDEX.
>- * It is set to 0 by default which is wrong.
>- */
> bond = netdev_priv(bond_dev);
>- bond_info = &(BOND_ALB_INFO(bond));
>- bond_info->rx_hashtbl_used_head = RLB_NULL_INDEX;
>-
> dev_net_set(bond_dev, net);
> bond_dev->rtnl_link_ops = &bond_link_ops;
>
> res = register_netdevice(bond_dev);
> if (res < 0) {
> free_netdev(bond_dev);
>- rtnl_unlock();
>-
>- return res;
>+ goto out;
> }
>
> netif_carrier_off(bond_dev);
>
> bond_work_init_all(bond);
>
>+out:
> rtnl_unlock();
>- return 0;
>+ return res;
> }
>
> static int __net_init bond_net_init(struct net *net)
>--
>2.27.0
>
next prev parent reply other threads:[~2022-06-08 18:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-08 18:14 [net-next v2 0/2] bonding: netlink errors and cleanup Jonathan Toppins
2022-06-08 18:14 ` [net-next v2 1/2] bonding: netlink error message support for options Jonathan Toppins
2022-06-08 18:52 ` Jay Vosburgh
2022-06-08 18:14 ` [net-next v2 2/2] bonding: cleanup bond_create Jonathan Toppins
2022-06-08 18:51 ` Jay Vosburgh [this message]
2022-06-10 6:20 ` [net-next v2 0/2] bonding: netlink errors and cleanup patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=12962.1654714282@famine \
--to=jay.vosburgh@canonical.com \
--cc=andy@greyhouse.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jtoppins@redhat.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vfalico@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).