Commit f607a158 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

garp: remove last synchronize_rcu() call

When removing last vlan from a device, garp_uninit_applicant() calls
synchronize_rcu() to make sure no user can still manipulate struct
garp_applicant before we free it.

Use call_rcu() instead, as a step to further net_device dismantle
optimizations.

Add the temporary garp_cleanup_module() function to make sure no pending
call_rcu() are left at module unload time [ this will be removed when
kfree_rcu() is available ]
Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e154b639
...@@ -104,6 +104,7 @@ struct garp_applicant { ...@@ -104,6 +104,7 @@ struct garp_applicant {
struct sk_buff_head queue; struct sk_buff_head queue;
struct sk_buff *pdu; struct sk_buff *pdu;
struct rb_root gid; struct rb_root gid;
struct rcu_head rcu;
}; };
struct garp_port { struct garp_port {
......
...@@ -603,6 +603,11 @@ int garp_init_applicant(struct net_device *dev, struct garp_application *appl) ...@@ -603,6 +603,11 @@ int garp_init_applicant(struct net_device *dev, struct garp_application *appl)
} }
EXPORT_SYMBOL_GPL(garp_init_applicant); EXPORT_SYMBOL_GPL(garp_init_applicant);
static void garp_app_kfree_rcu(struct rcu_head *head)
{
kfree(container_of(head, struct garp_applicant, rcu));
}
void garp_uninit_applicant(struct net_device *dev, struct garp_application *appl) void garp_uninit_applicant(struct net_device *dev, struct garp_application *appl)
{ {
struct garp_port *port = rtnl_dereference(dev->garp_port); struct garp_port *port = rtnl_dereference(dev->garp_port);
...@@ -611,7 +616,6 @@ void garp_uninit_applicant(struct net_device *dev, struct garp_application *appl ...@@ -611,7 +616,6 @@ void garp_uninit_applicant(struct net_device *dev, struct garp_application *appl
ASSERT_RTNL(); ASSERT_RTNL();
rcu_assign_pointer(port->applicants[appl->type], NULL); rcu_assign_pointer(port->applicants[appl->type], NULL);
synchronize_rcu();
/* Delete timer and generate a final TRANSMIT_PDU event to flush out /* Delete timer and generate a final TRANSMIT_PDU event to flush out
* all pending messages before the applicant is gone. */ * all pending messages before the applicant is gone. */
...@@ -621,7 +625,7 @@ void garp_uninit_applicant(struct net_device *dev, struct garp_application *appl ...@@ -621,7 +625,7 @@ void garp_uninit_applicant(struct net_device *dev, struct garp_application *appl
garp_queue_xmit(app); garp_queue_xmit(app);
dev_mc_del(dev, appl->proto.group_address); dev_mc_del(dev, appl->proto.group_address);
kfree(app); call_rcu(&app->rcu, garp_app_kfree_rcu);
garp_release_port(dev); garp_release_port(dev);
} }
EXPORT_SYMBOL_GPL(garp_uninit_applicant); EXPORT_SYMBOL_GPL(garp_uninit_applicant);
...@@ -639,3 +643,9 @@ void garp_unregister_application(struct garp_application *appl) ...@@ -639,3 +643,9 @@ void garp_unregister_application(struct garp_application *appl)
stp_proto_unregister(&appl->proto); stp_proto_unregister(&appl->proto);
} }
EXPORT_SYMBOL_GPL(garp_unregister_application); EXPORT_SYMBOL_GPL(garp_unregister_application);
static void __exit garp_cleanup_module(void)
{
rcu_barrier(); /* Wait for completion of call_rcu()'s */
}
module_exit(garp_cleanup_module);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment