* Re: [PATCH 15/20] net: Simplify phonet pernet operations.
@ 2009-11-30 8:33 Rémi Denis-Courmont
0 siblings, 0 replies; 2+ messages in thread
From: Rémi Denis-Courmont @ 2009-11-30 8:33 UTC (permalink / raw)
To: Eric W. Biederman
Cc: David Miller, netdev, jamal, Daniel Lezcano, Alexey Dobriyan,
Patrick McHardy
On Sun, 29 Nov 2009 17:46:12 -0800, "Eric W. Biederman"
<ebiederm@xmission.com> wrote:
> From: Eric W. Biederman <ebiederm@xmission.com>
>
> Take advantage of the new pernet automatic storage management,
> and stop using compatibility network namespace functions.
>
> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Acked-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
Thanks.
--
Rémi Denis-Courmont
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 01/20] net: NETDEV_UNREGISTER_PERNET -> NETDEV_UNREGISTER_BATCH
@ 2009-11-30 1:45 Eric W. Biederman
2009-11-30 1:46 ` [PATCH 15/20] net: Simplify phonet pernet operations Eric W. Biederman
0 siblings, 1 reply; 2+ messages in thread
From: Eric W. Biederman @ 2009-11-30 1:45 UTC (permalink / raw)
To: David Miller
Cc: netdev, jamal, Daniel Lezcano, Alexey Dobriyan, Patrick McHardy,
Eric W. Biederman, Octavian Purdila
From: Eric W. Biederman <ebiederm@xmission.com>
The motivation for an additional notifier in batched netdevice
notification (rt_do_flush) only needs to be called once per
batch not once per namespace. For further batching improvements
I need a guarantee that the netdevices are unregistered in order
allowing me to unregister an all of the network devices in a network
namespace at the same time with the guarantee that the loopback
device is really and truly unregistered last.
Additionally it appears that we moved the route cache flush after
the final synchronize_net, which seems wrong and there was no
explanation. So I have restored the original location of the final
synchronize_net.
Cc: Octavian Purdila <opurdila@ixiacom.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---
include/linux/notifier.h | 2 +-
include/net/route.h | 1 +
net/core/dev.c | 36 +++++++++---------------------------
net/ipv4/fib_frontend.c | 4 +++-
net/ipv4/route.c | 6 ++++++
5 files changed, 20 insertions(+), 29 deletions(-)
diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index b0c3671..fee6c2f 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -202,7 +202,7 @@ static inline int notifier_to_errno(int ret)
#define NETDEV_BONDING_OLDTYPE 0x000E
#define NETDEV_BONDING_NEWTYPE 0x000F
#define NETDEV_POST_INIT 0x0010
-#define NETDEV_UNREGISTER_PERNET 0x0011
+#define NETDEV_UNREGISTER_BATCH 0x0011
#define SYS_DOWN 0x0001 /* Notify of system down */
#define SYS_RESTART SYS_DOWN
diff --git a/include/net/route.h b/include/net/route.h
index cfb4c07..bce6dd6 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -108,6 +108,7 @@ extern int ip_rt_init(void);
extern void ip_rt_redirect(__be32 old_gw, __be32 dst, __be32 new_gw,
__be32 src, struct net_device *dev);
extern void rt_cache_flush(struct net *net, int how);
+extern void rt_cache_flush_batch(void);
extern int __ip_route_output_key(struct net *, struct rtable **, const struct flowi *flp);
extern int ip_route_output_key(struct net *, struct rtable **, struct flowi *flp);
extern int ip_route_output_flow(struct net *, struct rtable **rp, struct flowi *flp, struct sock *sk, int flags);
diff --git a/net/core/dev.c b/net/core/dev.c
index 7775e8b..124029e 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1353,7 +1353,7 @@ rollback:
nb->notifier_call(nb, NETDEV_DOWN, dev);
}
nb->notifier_call(nb, NETDEV_UNREGISTER, dev);
- nb->notifier_call(nb, NETDEV_UNREGISTER_PERNET, dev);
+ nb->notifier_call(nb, NETDEV_UNREGISTER_BATCH, dev);
}
}
@@ -4770,8 +4770,7 @@ static void net_set_todo(struct net_device *dev)
static void rollback_registered_many(struct list_head *head)
{
- struct net_device *dev, *aux, *fdev;
- LIST_HEAD(pernet_list);
+ struct net_device *dev;
BUG_ON(dev_boot_phase);
ASSERT_RTNL();
@@ -4827,26 +4826,14 @@ static void rollback_registered_many(struct list_head *head)
netdev_unregister_kobject(dev);
}
- synchronize_net();
+ /* Process any work delayed until the end of the batch */
+ dev = list_entry(head->next, struct net_device, unreg_list);
+ call_netdevice_notifiers(NETDEV_UNREGISTER_BATCH, dev);
- list_for_each_entry_safe(dev, aux, head, unreg_list) {
- int new_net = 1;
- list_for_each_entry(fdev, &pernet_list, unreg_list) {
- if (net_eq(dev_net(dev), dev_net(fdev))) {
- new_net = 0;
- dev_put(dev);
- break;
- }
- }
- if (new_net)
- list_move(&dev->unreg_list, &pernet_list);
- }
+ synchronize_net();
- list_for_each_entry_safe(dev, aux, &pernet_list, unreg_list) {
- call_netdevice_notifiers(NETDEV_UNREGISTER_PERNET, dev);
- list_move(&dev->unreg_list, head);
+ list_for_each_entry(dev, head, unreg_list)
dev_put(dev);
- }
}
static void rollback_registered(struct net_device *dev)
@@ -5128,7 +5115,7 @@ static void netdev_wait_allrefs(struct net_device *dev)
/* Rebroadcast unregister notification */
call_netdevice_notifiers(NETDEV_UNREGISTER, dev);
- /* don't resend NETDEV_UNREGISTER_PERNET, _PERNET users
+ /* don't resend NETDEV_UNREGISTER_BATCH, _BATCH users
* should have already handle it the first time */
if (test_bit(__LINK_STATE_LINKWATCH_PENDING,
@@ -5441,11 +5428,6 @@ EXPORT_SYMBOL(unregister_netdevice_queue);
/**
* unregister_netdevice_many - unregister many devices
* @head: list of devices
- *
- * WARNING: Calling this modifies the given list
- * (in rollback_registered_many). It may change the order of the elements
- * in the list. However, you can assume it does not add or delete elements
- * to/from the list.
*/
void unregister_netdevice_many(struct list_head *head)
{
@@ -5554,7 +5536,7 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
this device. They should clean all the things.
*/
call_netdevice_notifiers(NETDEV_UNREGISTER, dev);
- call_netdevice_notifiers(NETDEV_UNREGISTER_PERNET, dev);
+ call_netdevice_notifiers(NETDEV_UNREGISTER_BATCH, dev);
/*
* Flush the unicast and multicast chains
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 6c1e56a..3b373a8 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -959,9 +959,11 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
break;
case NETDEV_CHANGEMTU:
case NETDEV_CHANGE:
- case NETDEV_UNREGISTER_PERNET:
rt_cache_flush(dev_net(dev), 0);
break;
+ case NETDEV_UNREGISTER_BATCH:
+ rt_cache_flush_batch();
+ break;
}
return NOTIFY_DONE;
}
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 9889fbd..90cdcfc 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -900,6 +900,12 @@ void rt_cache_flush(struct net *net, int delay)
rt_do_flush(!in_softirq());
}
+/* Flush previous cache invalidated entries from the cache */
+void rt_cache_flush_batch(void)
+{
+ rt_do_flush(!in_softirq());
+}
+
/*
* We change rt_genid and let gc do the cleanup
*/
--
1.6.5.2.143.g8cc62
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH 15/20] net: Simplify phonet pernet operations.
2009-11-30 1:45 [PATCH 01/20] net: NETDEV_UNREGISTER_PERNET -> NETDEV_UNREGISTER_BATCH Eric W. Biederman
@ 2009-11-30 1:46 ` Eric W. Biederman
0 siblings, 0 replies; 2+ messages in thread
From: Eric W. Biederman @ 2009-11-30 1:46 UTC (permalink / raw)
To: David Miller
Cc: netdev, jamal, Daniel Lezcano, Alexey Dobriyan, Patrick McHardy,
Eric W. Biederman
From: Eric W. Biederman <ebiederm@xmission.com>
Take advantage of the new pernet automatic storage management,
and stop using compatibility network namespace functions.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---
net/phonet/pn_dev.c | 16 ++++++----------
1 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c
index d87388c..bc4a33b 100644
--- a/net/phonet/pn_dev.c
+++ b/net/phonet/pn_dev.c
@@ -313,19 +313,14 @@ static struct notifier_block phonet_device_notifier = {
/* Per-namespace Phonet devices handling */
static int phonet_init_net(struct net *net)
{
- struct phonet_net *pnn = kzalloc(sizeof(*pnn), GFP_KERNEL);
- if (!pnn)
- return -ENOMEM;
+ struct phonet_net *pnn = net_generic(net, phonet_net_id);
- if (!proc_net_fops_create(net, "phonet", 0, &pn_sock_seq_fops)) {
- kfree(pnn);
+ if (!proc_net_fops_create(net, "phonet", 0, &pn_sock_seq_fops))
return -ENOMEM;
- }
INIT_LIST_HEAD(&pnn->pndevs.list);
mutex_init(&pnn->pndevs.lock);
mutex_init(&pnn->routes.lock);
- net_assign_generic(net, phonet_net_id, pnn);
return 0;
}
@@ -349,18 +344,19 @@ static void phonet_exit_net(struct net *net)
rtnl_unlock();
proc_net_remove(net, "phonet");
- kfree(pnn);
}
static struct pernet_operations phonet_net_ops = {
.init = phonet_init_net,
.exit = phonet_exit_net,
+ .id = &phonet_net_id,
+ .size = sizeof(struct phonet_net),
};
/* Initialize Phonet devices list */
int __init phonet_device_init(void)
{
- int err = register_pernet_gen_device(&phonet_net_id, &phonet_net_ops);
+ int err = register_pernet_device(&phonet_net_ops);
if (err)
return err;
@@ -375,7 +371,7 @@ void phonet_device_exit(void)
{
rtnl_unregister_all(PF_PHONET);
unregister_netdevice_notifier(&phonet_device_notifier);
- unregister_pernet_gen_device(phonet_net_id, &phonet_net_ops);
+ unregister_pernet_device(&phonet_net_ops);
}
int phonet_route_add(struct net_device *dev, u8 daddr)
--
1.6.5.2.143.g8cc62
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-11-30 8:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-30 8:33 [PATCH 15/20] net: Simplify phonet pernet operations Rémi Denis-Courmont
-- strict thread matches above, loose matches on Subject: below --
2009-11-30 1:45 [PATCH 01/20] net: NETDEV_UNREGISTER_PERNET -> NETDEV_UNREGISTER_BATCH Eric W. Biederman
2009-11-30 1:46 ` [PATCH 15/20] net: Simplify phonet pernet operations Eric W. Biederman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox