diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2007-09-18 13:20:41 -0700 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 16:51:35 -0700 |
commit | 768f3591e2b1cc309fd6f10d6579b216026d7817 (patch) | |
tree | 0328abd6a6a306e648120ac2ef20332954e852e0 /net/core | |
parent | 1a348ccc1047a00507e554826775a3d81f7f3437 (diff) | |
download | kernel_samsung_tuna-768f3591e2b1cc309fd6f10d6579b216026d7817.zip kernel_samsung_tuna-768f3591e2b1cc309fd6f10d6579b216026d7817.tar.gz kernel_samsung_tuna-768f3591e2b1cc309fd6f10d6579b216026d7817.tar.bz2 |
[NETNS]: Cleanup list walking in setup_net and cleanup_net
I proposed introducing a list_for_each_entry_continue_reverse macro
to be used in setup_net() when unrolling the failed ->init callback.
Here is the macro and some more cleanup in the setup_net() itself
to remove one variable from the stack :) The same thing is for the
cleanup_net() - the existing list_for_each_entry_reverse() is used.
Minor, but the code looks nicer.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/net_namespace.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index 1fc513c..0e6cb02 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c @@ -56,7 +56,6 @@ static void net_free(struct net *net) static void cleanup_net(struct work_struct *work) { struct pernet_operations *ops; - struct list_head *ptr; struct net *net; net = container_of(work, struct net, work); @@ -69,8 +68,7 @@ static void cleanup_net(struct work_struct *work) net_unlock(); /* Run all of the network namespace exit methods */ - list_for_each_prev(ptr, &pernet_list) { - ops = list_entry(ptr, struct pernet_operations, list); + list_for_each_entry_reverse(ops, &pernet_list, list) { if (ops->exit) ops->exit(net); } @@ -102,7 +100,6 @@ static int setup_net(struct net *net) { /* Must be called with net_mutex held */ struct pernet_operations *ops; - struct list_head *ptr; int error; memset(net, 0, sizeof(struct net)); @@ -110,8 +107,7 @@ static int setup_net(struct net *net) atomic_set(&net->use_count, 0); error = 0; - list_for_each(ptr, &pernet_list) { - ops = list_entry(ptr, struct pernet_operations, list); + list_for_each_entry(ops, &pernet_list, list) { if (ops->init) { error = ops->init(net); if (error < 0) @@ -120,12 +116,12 @@ static int setup_net(struct net *net) } out: return error; + out_undo: /* Walk through the list backwards calling the exit functions * for the pernet modules whose init functions did not fail. */ - for (ptr = ptr->prev; ptr != &pernet_list; ptr = ptr->prev) { - ops = list_entry(ptr, struct pernet_operations, list); + list_for_each_entry_continue_reverse(ops, &pernet_list, list) { if (ops->exit) ops->exit(net); } |