From: ebiederm@xmission.com (Eric W. Biederman)
To: Francesco Ruggeri <fruggeri@arista.com>
Cc: <netdev@vger.kernel.org>, "David S. Miller" <davem@davemloft.net>,
Mahesh Bandewar <maheshb@google.com>
Subject: Re: [PATCH net-next] macvlan: fix failure during registration
Date: Mon, 18 Apr 2016 13:48:12 -0500 [thread overview]
Message-ID: <87ega2sqhf.fsf@x220.int.ebiederm.org> (raw)
In-Reply-To: <1460992811-46992-1-git-send-email-fruggeri@arista.com> (Francesco Ruggeri's message of "Mon, 18 Apr 2016 08:20:11 -0700")
Francesco Ruggeri <fruggeri@arista.com> writes:
> Resending, did not include netdev the first time ...
>
> If a macvlan/macvtap creation fails in register_netdevice in
> call_netdevice_notifiers(NETDEV_REGISTER) then while cleaning things up in
> rollback_registered_many it invokes macvlan_uninit. This results in
> port->count being decremented twice (in macvlan_uninit and in
> macvlan_common_newlink).
> A similar problem may exist in the ipvlan driver.
> This patch adds priv_flags to struct macvlan_dev and a flag that
> macvlan_uninit can use to determine if it is invoked in the context of a
> failed newlink.
> In macvtap_device_event(NETDEV_UNREGISTER) it also avoids cleaning up
> /dev/tapNN in case creation of the char device had previously failed.
> Tested in 3.18.
These interactions all seem a little bit funny. At a quick skim it
would make more sense to increment the port count in macvlan_init,
and completely remove the need to mess with port counts anywhere except
macvlan_init and macvlan_uninit.
If for some reason that can't be done the code can easily look at
dev->reg_state. If dev->reg_state == NETREG_UNITIALIZED it should
be exactly the same as your new flag being set.
> diff --git a/include/linux/if_macvlan.h b/include/linux/if_macvlan.h
> index a4ccc31..7cf82d8 100644
> --- a/include/linux/if_macvlan.h
> +++ b/include/linux/if_macvlan.h
> @@ -48,6 +48,7 @@ struct macvlan_dev {
> netdev_features_t set_features;
> enum macvlan_mode mode;
> u16 flags;
> + u16 priv_flags;
> /* This array tracks active taps. */
> struct macvtap_queue __rcu *taps[MAX_MACVTAP_QUEUES];
> /* This list tracks all taps (both enabled and disabled) */
> @@ -63,6 +64,8 @@ struct macvlan_dev {
> unsigned int macaddr_count;
> };
>
> +#define MACVLAN_PRIV_FLAG_REGISTERING 1
> +
> static inline void macvlan_count_rx(const struct macvlan_dev *vlan,
> unsigned int len, bool success,
> bool multicast)
next prev parent reply other threads:[~2016-04-18 18:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-18 15:20 [PATCH net-next] macvlan: fix failure during registration Francesco Ruggeri
2016-04-18 18:48 ` Eric W. Biederman [this message]
2016-04-18 20:10 ` Francesco Ruggeri
2016-04-18 21:33 ` Eric W. Biederman
2016-04-20 1:13 ` Francesco Ruggeri
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=87ega2sqhf.fsf@x220.int.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=davem@davemloft.net \
--cc=fruggeri@arista.com \
--cc=maheshb@google.com \
--cc=netdev@vger.kernel.org \
/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