Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=1dba323b3f92cf4a475236763b0373cb7d49395d
Commit:     1dba323b3f92cf4a475236763b0373cb7d49395d
Parent:     6257ff2177ff02d7f260a7a501876aa41cb9a9f6
Author:     Pavel Emelyanov <[EMAIL PROTECTED]>
AuthorDate: Thu Nov 1 00:42:43 2007 -0700
Committer:  David S. Miller <[EMAIL PROTECTED]>
CommitDate: Thu Nov 1 00:42:43 2007 -0700

    [NETNS]: Make the init/exit hooks checks outside the loop
    
    When the new pernet something (subsys, device or operations) is
    being registered, the init callback is to be called for each
    namespace, that currently exitst in the system. During the
    unregister, the same is to be done with the exit callback.
    
    However, not every pernet something has both calls, but the
    check for the appropriate pointer to be not NULL is performed
    inside the for_each_net() loop.
    
    This is (at least) strange, so tune this.
    
    Signed-off-by: Pavel Emelyanov <[EMAIL PROTECTED]>
    Signed-off-by: David S. Miller <[EMAIL PROTECTED]>
---
 net/core/net_namespace.c |   23 +++++++++++------------
 1 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 662e6ea..4e52921 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -187,29 +187,28 @@ static int register_pernet_operations(struct list_head 
*list,
        struct net *net, *undo_net;
        int error;
 
-       error = 0;
        list_add_tail(&ops->list, list);
-       for_each_net(net) {
-               if (ops->init) {
+       if (ops->init) {
+               for_each_net(net) {
                        error = ops->init(net);
                        if (error)
                                goto out_undo;
                }
        }
-out:
-       return error;
+       return 0;
 
 out_undo:
        /* If I have an error cleanup all namespaces I initialized */
        list_del(&ops->list);
-       for_each_net(undo_net) {
-               if (undo_net == net)
-                       goto undone;
-               if (ops->exit)
+       if (ops->exit) {
+               for_each_net(undo_net) {
+                       if (undo_net == net)
+                               goto undone;
                        ops->exit(undo_net);
+               }
        }
 undone:
-       goto out;
+       return error;
 }
 
 static void unregister_pernet_operations(struct pernet_operations *ops)
@@ -217,8 +216,8 @@ static void unregister_pernet_operations(struct 
pernet_operations *ops)
        struct net *net;
 
        list_del(&ops->list);
-       for_each_net(net)
-               if (ops->exit)
+       if (ops->exit)
+               for_each_net(net)
                        ops->exit(net);
 }
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to