Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux: Kernel

[ 12/53] net: In unregister_netdevice_notifier unregister the netdevices.

 

 

Linux kernel RSS feed   Index | Next | Previous | View Threaded


ben at decadent

May 17, 2012, 7:33 PM

Post #1 of 5 (107 views)
Permalink
[ 12/53] net: In unregister_netdevice_notifier unregister the netdevices.

3.2.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: "Eric W. Biederman" <ebiederm [at] xmission>

[ Upstream commit 7d3d43dab4e978d8d9ad1acf8af15c9b1c4b0f0f ]

We already synthesize events in register_netdevice_notifier and synthesizing
events in unregister_netdevice_notifier allows to us remove the need for
special case cleanup code.

This change should be safe as it adds no new cases for existing callers
of unregiser_netdevice_notifier to handle.

Signed-off-by: Eric W. Biederman <ebiederm [at] xmission>
Signed-off-by: David S. Miller <davem [at] davemloft>
Signed-off-by: Ben Hutchings <ben [at] decadent>
---
net/core/dev.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)

diff --git a/net/core/dev.c b/net/core/dev.c
index 55cd370..d1d2a56 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1421,14 +1421,34 @@ EXPORT_SYMBOL(register_netdevice_notifier);
* register_netdevice_notifier(). The notifier is unlinked into the
* kernel structures and may then be reused. A negative errno code
* is returned on a failure.
+ *
+ * After unregistering unregister and down device events are synthesized
+ * for all devices on the device list to the removed notifier to remove
+ * the need for special case cleanup code.
*/

int unregister_netdevice_notifier(struct notifier_block *nb)
{
+ struct net_device *dev;
+ struct net *net;
int err;

rtnl_lock();
err = raw_notifier_chain_unregister(&netdev_chain, nb);
+ if (err)
+ goto unlock;
+
+ for_each_net(net) {
+ for_each_netdev(net, dev) {
+ if (dev->flags & IFF_UP) {
+ nb->notifier_call(nb, NETDEV_GOING_DOWN, dev);
+ nb->notifier_call(nb, NETDEV_DOWN, dev);
+ }
+ nb->notifier_call(nb, NETDEV_UNREGISTER, dev);
+ nb->notifier_call(nb, NETDEV_UNREGISTER_BATCH, dev);
+ }
+ }
+unlock:
rtnl_unlock();
return err;
}
--
1.7.10.1




--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


herton.krzesinski at canonical

May 17, 2012, 10:09 PM

Post #2 of 5 (103 views)
Permalink
Re: [ 12/53] net: In unregister_netdevice_notifier unregister the netdevices. [In reply to]

On Fri, May 18, 2012 at 03:33:06AM +0100, Ben Hutchings wrote:
> 3.2.18-stable review patch. If anyone has any objections, please let me know.
>
> ------------------
>
> From: "Eric W. Biederman" <ebiederm [at] xmission>
>
> [ Upstream commit 7d3d43dab4e978d8d9ad1acf8af15c9b1c4b0f0f ]
>
> We already synthesize events in register_netdevice_notifier and synthesizing
> events in unregister_netdevice_notifier allows to us remove the need for
> special case cleanup code.
>
> This change should be safe as it adds no new cases for existing callers
> of unregiser_netdevice_notifier to handle.

It seems this introduces a regression later fixed by commit
c57b54684060c8aced64a5b78ff69ff289af97b9

>
> Signed-off-by: Eric W. Biederman <ebiederm [at] xmission>
> Signed-off-by: David S. Miller <davem [at] davemloft>
> Signed-off-by: Ben Hutchings <ben [at] decadent>
> ---
> net/core/dev.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 55cd370..d1d2a56 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -1421,14 +1421,34 @@ EXPORT_SYMBOL(register_netdevice_notifier);
> * register_netdevice_notifier(). The notifier is unlinked into the
> * kernel structures and may then be reused. A negative errno code
> * is returned on a failure.
> + *
> + * After unregistering unregister and down device events are synthesized
> + * for all devices on the device list to the removed notifier to remove
> + * the need for special case cleanup code.
> */
>
> int unregister_netdevice_notifier(struct notifier_block *nb)
> {
> + struct net_device *dev;
> + struct net *net;
> int err;
>
> rtnl_lock();
> err = raw_notifier_chain_unregister(&netdev_chain, nb);
> + if (err)
> + goto unlock;
> +
> + for_each_net(net) {
> + for_each_netdev(net, dev) {
> + if (dev->flags & IFF_UP) {
> + nb->notifier_call(nb, NETDEV_GOING_DOWN, dev);
> + nb->notifier_call(nb, NETDEV_DOWN, dev);
> + }
> + nb->notifier_call(nb, NETDEV_UNREGISTER, dev);
> + nb->notifier_call(nb, NETDEV_UNREGISTER_BATCH, dev);
> + }
> + }
> +unlock:
> rtnl_unlock();
> return err;
> }
> --
> 1.7.10.1
>
>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe stable" in
> the body of a message to majordomo [at] vger
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>

--
[]'s
Herton
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


davem at davemloft

May 17, 2012, 10:41 PM

Post #3 of 5 (105 views)
Permalink
Re: [ 12/53] net: In unregister_netdevice_notifier unregister the netdevices. [In reply to]

From: Herton Ronaldo Krzesinski <herton.krzesinski [at] canonical>
Date: Fri, 18 May 2012 02:09:05 -0300

> On Fri, May 18, 2012 at 03:33:06AM +0100, Ben Hutchings wrote:
>> 3.2.18-stable review patch. If anyone has any objections, please let me know.
>>
>> ------------------
>>
>> From: "Eric W. Biederman" <ebiederm [at] xmission>
>>
>> [ Upstream commit 7d3d43dab4e978d8d9ad1acf8af15c9b1c4b0f0f ]
>>
>> We already synthesize events in register_netdevice_notifier and synthesizing
>> events in unregister_netdevice_notifier allows to us remove the need for
>> special case cleanup code.
>>
>> This change should be safe as it adds no new cases for existing callers
>> of unregiser_netdevice_notifier to handle.
>
> It seems this introduces a regression later fixed by commit
> c57b54684060c8aced64a5b78ff69ff289af97b9

Indeed, but thankfully that only hits people who try to unload the
pktgen module which is a pretty small group of people :)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


ben at decadent

May 18, 2012, 5:31 PM

Post #4 of 5 (98 views)
Permalink
Re: [ 12/53] net: In unregister_netdevice_notifier unregister the netdevices. [In reply to]

On Fri, 2012-05-18 at 01:41 -0400, David Miller wrote:
> From: Herton Ronaldo Krzesinski <herton.krzesinski [at] canonical>
> Date: Fri, 18 May 2012 02:09:05 -0300
>
> > On Fri, May 18, 2012 at 03:33:06AM +0100, Ben Hutchings wrote:
> >> 3.2.18-stable review patch. If anyone has any objections, please let me know.
> >>
> >> ------------------
> >>
> >> From: "Eric W. Biederman" <ebiederm [at] xmission>
> >>
> >> [ Upstream commit 7d3d43dab4e978d8d9ad1acf8af15c9b1c4b0f0f ]
> >>
> >> We already synthesize events in register_netdevice_notifier and synthesizing
> >> events in unregister_netdevice_notifier allows to us remove the need for
> >> special case cleanup code.
> >>
> >> This change should be safe as it adds no new cases for existing callers
> >> of unregiser_netdevice_notifier to handle.
> >
> > It seems this introduces a regression later fixed by commit
> > c57b54684060c8aced64a5b78ff69ff289af97b9
>
> Indeed, but thankfully that only hits people who try to unload the
> pktgen module which is a pretty small group of people :)

Surely we ought to avoid introducing a known regression. Though I also
see that that the above fix for pktgen was incorrect and the
fix-of-the-fix (d4b1133558e0d417342d5d2c49e4c35b428ff20d) is not in
mainline yet. But if the latter reaches mainline by Sunday, perhaps I
could add them both?

Ben.

--
Ben Hutchings
Experience is directly proportional to the value of equipment destroyed.
- Carolyn Scheppner
Attachments: signature.asc (0.81 KB)


davem at davemloft

May 18, 2012, 8:43 PM

Post #5 of 5 (102 views)
Permalink
Re: [ 12/53] net: In unregister_netdevice_notifier unregister the netdevices. [In reply to]

From: Ben Hutchings <ben [at] decadent>
Date: Sat, 19 May 2012 01:31:36 +0100

> On Fri, 2012-05-18 at 01:41 -0400, David Miller wrote:
>> From: Herton Ronaldo Krzesinski <herton.krzesinski [at] canonical>
>> Date: Fri, 18 May 2012 02:09:05 -0300
>>
>> > On Fri, May 18, 2012 at 03:33:06AM +0100, Ben Hutchings wrote:
>> >> 3.2.18-stable review patch. If anyone has any objections, please let me know.
>> >>
>> >> ------------------
>> >>
>> >> From: "Eric W. Biederman" <ebiederm [at] xmission>
>> >>
>> >> [ Upstream commit 7d3d43dab4e978d8d9ad1acf8af15c9b1c4b0f0f ]
>> >>
>> >> We already synthesize events in register_netdevice_notifier and synthesizing
>> >> events in unregister_netdevice_notifier allows to us remove the need for
>> >> special case cleanup code.
>> >>
>> >> This change should be safe as it adds no new cases for existing callers
>> >> of unregiser_netdevice_notifier to handle.
>> >
>> > It seems this introduces a regression later fixed by commit
>> > c57b54684060c8aced64a5b78ff69ff289af97b9
>>
>> Indeed, but thankfully that only hits people who try to unload the
>> pktgen module which is a pretty small group of people :)
>
> Surely we ought to avoid introducing a known regression. Though I also
> see that that the above fix for pktgen was incorrect and the
> fix-of-the-fix (d4b1133558e0d417342d5d2c49e4c35b428ff20d) is not in
> mainline yet. But if the latter reaches mainline by Sunday, perhaps I
> could add them both?

I just asked Linus to pull it in.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Linux kernel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.