Re: [RFC] about net: Fix inconsistent teardown and release of private netdev state.

2017-08-25 Thread Eric Dumazet
On Mon, 2017-08-21 at 14:13 -0700, David Miller wrote: > From: Eric Dumazet > Date: Fri, 18 Aug 2017 20:40:01 -0700 > > > Let look at tun->pcpu_stats, for example. > > > > It is allocated at line 1831, before the register_netdevice() > > > > drivers/net/tun.c does not provide ndo_init() > > I

Re: [RFC] about net: Fix inconsistent teardown and release of private netdev state.

2017-08-21 Thread David Miller
From: Eric Dumazet Date: Fri, 18 Aug 2017 20:40:01 -0700 > Let look at tun->pcpu_stats, for example. > > It is allocated at line 1831, before the register_netdevice() > > drivers/net/tun.c does not provide ndo_init() I see the problem now. And it's done this way because several steps need to

Re: [RFC] about net: Fix inconsistent teardown and release of private netdev state.

2017-08-18 Thread Eric Dumazet
On Fri, 2017-08-18 at 15:58 -0700, David Miller wrote: > From: Eric Dumazet > Date: Fri, 18 Aug 2017 06:13:49 -0700 > > > On Thu, 2017-08-17 at 22:21 -0700, David Miller wrote: > >> From: Eric Dumazet > >> Date: Thu, 17 Aug 2017 15:30:40 -0700 > >> > >> > So we do not really know if we need to

Re: [RFC] about net: Fix inconsistent teardown and release of private netdev state.

2017-08-18 Thread David Miller
From: Eric Dumazet Date: Fri, 18 Aug 2017 06:13:49 -0700 > On Thu, 2017-08-17 at 22:21 -0700, David Miller wrote: >> From: Eric Dumazet >> Date: Thu, 17 Aug 2017 15:30:40 -0700 >> >> > So we do not really know if we need to clean up or not. >> >> We always know, the answer is that whenever reg

Re: [RFC] about net: Fix inconsistent teardown and release of private netdev state.

2017-08-18 Thread Eric Dumazet
On Thu, 2017-08-17 at 22:21 -0700, David Miller wrote: > From: Eric Dumazet > Date: Thu, 17 Aug 2017 15:30:40 -0700 > > > So we do not really know if we need to clean up or not. > > We always know, the answer is that whenever register_netdev() fails we > never need to perform any cleanup which i

Re: [RFC] about net: Fix inconsistent teardown and release of private netdev state.

2017-08-17 Thread David Miller
From: Eric Dumazet Date: Thu, 17 Aug 2017 15:30:40 -0700 > So we do not really know if we need to clean up or not. We always know, the answer is that whenever register_netdev() fails we never need to perform any cleanup which is done by priv_destructor. > Any idea how to fix the issue ? Your p

[RFC] about net: Fix inconsistent teardown and release of private netdev state.

2017-08-17 Thread Eric Dumazet
David If I read correctly this commit : cf124db566e6b036b8bcbe8decbed740bdfac8c6 ("net: Fix inconsistent teardown and release of private netdev state.") We have problems in drivers providing priv_destructor and handling a failure in register_netdevice() register_netdevice() might h

Re: net: Fix inconsistent teardown and release of private netdev state.

2017-07-10 Thread Cong Wang
On Sun, Jul 9, 2017 at 7:07 PM, Jason A. Donenfeld wrote: > On Sat, Jul 8, 2017 at 12:39 AM, Cong Wang wrote: >> On Thu, Jul 6, 2017 at 7:24 AM, Jason A. Donenfeld wrote: >>> list_add(&priv->list, &list_of_things); >>> >>> ret = register_netdevice(); // if ret is < 0, then destru

Re: net: Fix inconsistent teardown and release of private netdev state.

2017-07-09 Thread Jason A. Donenfeld
On Sat, Jul 8, 2017 at 12:39 AM, Cong Wang wrote: > On Thu, Jul 6, 2017 at 7:24 AM, Jason A. Donenfeld wrote: >> list_add(&priv->list, &list_of_things); >> >> ret = register_netdevice(); // if ret is < 0, then destruct above is >> automatically called >> >> // RACE WITH L

Re: net: Fix inconsistent teardown and release of private netdev state.

2017-07-07 Thread Cong Wang
On Thu, Jul 6, 2017 at 7:24 AM, Jason A. Donenfeld wrote: > list_add(&priv->list, &list_of_things); > > ret = register_netdevice(); // if ret is < 0, then destruct above is > automatically called > > // RACE WITH LIST_ADD/LIST_DEL!! It's impossible to call list_add > only

Re: net: Fix inconsistent teardown and release of private netdev state.

2017-07-06 Thread Jason A. Donenfeld
On Thu, Jul 6, 2017 at 4:24 PM, Jason A. Donenfeld wrote: > > if (!ret) > pr_info("Yay it worked!\n"); > > return 0; This is supposed to be `return ret;`. See, even in psuedocode it's hard to get right.

Re: net: Fix inconsistent teardown and release of private netdev state.

2017-07-06 Thread Jason A. Donenfeld
Hey guys, I see why this priv_destructor patch is an acceptable bandaid for certain drivers, but I'm not exactly sure on the cleanest way of using it in new drivers. Check out the following psuedocode. Here's how error handling in newlink used to work before this patch: static void destruct(stru

Re: [PATCH] net: Fix inconsistent teardown and release of private netdev state.

2017-06-12 Thread Stephen Hemminger
On Fri, 09 Jun 2017 14:54:34 -0400 (EDT) David Miller wrote: > From: Stephen Hemminger > Date: Fri, 9 Jun 2017 10:21:04 -0700 > > > Is there anything in Documentation/networking/netdevices.txt about this to > > avoid any future issues? > > You asked me about this last time, and I did not for

Re: [PATCH] net: Fix inconsistent teardown and release of private netdev state.

2017-06-09 Thread David Miller
From: Stephen Hemminger Date: Fri, 9 Jun 2017 10:21:04 -0700 > Is there anything in Documentation/networking/netdevices.txt about this to > avoid any future issues? You asked me about this last time, and I did not forget about it. I sincerely lack the time to do a writeup about it, and I felt t

Re: [PATCH] net: Fix inconsistent teardown and release of private netdev state.

2017-06-09 Thread Stephen Hemminger
On Wed, 07 Jun 2017 15:54:11 -0400 (EDT) David Miller wrote: > Network devices can allocate reasources and private memory using > netdev_ops->ndo_init(). However, the release of these resources > can occur in one of two different places. > > Either netdev_ops->ndo_uninit() or netdev->destructor

Re: [PATCH] net: Fix inconsistent teardown and release of private netdev state.

2017-06-09 Thread David Miller
From: Johannes Berg Date: Fri, 09 Jun 2017 16:33:47 +0200 > Right. Do you want me to put that into my tree? I could do it tonight, > or perhaps only Monday though. Please submit it formally to netdev for me to apply. I want to queue it up with the original patch for -stable to make sure all the

Re: [PATCH] net: Fix inconsistent teardown and release of private netdev state.

2017-06-09 Thread Johannes Berg
On Fri, 2017-06-09 at 10:17 -0400, David Miller wrote: > > > I guess this must mean that that all others are dealing with the > > problem "manually", right? Perhaps needs_free_netdev isn't all that > > necessary then? > > Yeah, the major two modes of operation are manual freeing of the > netdev (

Re: [PATCH] net: Fix inconsistent teardown and release of private netdev state.

2017-06-09 Thread David Miller
From: Johannes Berg Date: Fri, 09 Jun 2017 14:45:25 +0200 > Under drivers/ in general, I count more than 400 calls to > register_netdev[ice](), but only 39 that set the new needs_free_netdev. > Some will overlap and have the same ops, but still, that's a rather > small portion of them. The logic

Re: [PATCH] net: Fix inconsistent teardown and release of private netdev state.

2017-06-09 Thread Johannes Berg
Hi Dave, I hope you don't mind a question or two for my understanding here. Actually, this got pretty long... but I think there's a bug in here. (For background, I'm looking into this because I'm interested in what to do about backporting this to older kernels, or better, how to deal with it in

[PATCH] net: Fix inconsistent teardown and release of private netdev state.

2017-06-07 Thread David Miller
Network devices can allocate reasources and private memory using netdev_ops->ndo_init(). However, the release of these resources can occur in one of two different places. Either netdev_ops->ndo_uninit() or netdev->destructor(). The decision of which operation frees the resources depends upon wh

Re: [PATCH RFC] net: Fix inconsistent teardown and release of private netdev state.

2017-05-08 Thread David Miller
From: Stephen Hemminger Date: Mon, 8 May 2017 12:13:59 -0700 > Thanks for addressing a confusing and messy semantic. If you merge > this then it would be good to update the documentation in > Doucmentation/networking to describe how drivers are supposed to > behave. Will do. > An alternative an

Re: [PATCH RFC] net: Fix inconsistent teardown and release of private netdev state.

2017-05-08 Thread Stephen Hemminger
On Mon, 08 May 2017 12:52:43 -0400 (EDT) David Miller wrote: > Network devices can allocate reasources and private memory using > netdev_ops->ndo_init(). However, the release of these resources > can occur in one of two different places. > > Either netdev_ops->ndo_uninit() or netdev->destructor

[PATCH RFC] net: Fix inconsistent teardown and release of private netdev state.

2017-05-08 Thread David Miller
Network devices can allocate reasources and private memory using netdev_ops->ndo_init(). However, the release of these resources can occur in one of two different places. Either netdev_ops->ndo_uninit() or netdev->destructor(). The decision of which operation frees the resources depends upon wh