lkml.org 
[lkml]   [2017]   [Nov]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Subject[PATCH v2 01/31] net: Assign net to net_namespace_list in setup_net()
    From
    Date
    This patch merges two repeating pieces of code in one,
    and they will live in setup_net() now.

    It acts as cleanup even despite init_net_initialized
    assignment is reordered with the linking of net now.
    This variable is need for proc_net_init() called from:

    start_kernel()->proc_root_init()->proc_net_init(),

    which can't race with net_ns_init(), called from
    initcall.

    Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
    ---
    net/core/net_namespace.c | 13 +++----------
    1 file changed, 3 insertions(+), 10 deletions(-)

    diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
    index b797832565d3..7ecf71050ffa 100644
    --- a/net/core/net_namespace.c
    +++ b/net/core/net_namespace.c
    @@ -296,6 +296,9 @@ static __net_init int setup_net(struct net *net, struct user_namespace *user_ns)
    if (error < 0)
    goto out_undo;
    }
    + rtnl_lock();
    + list_add_tail_rcu(&net->list, &net_namespace_list);
    + rtnl_unlock();
    out:
    return error;

    @@ -417,11 +420,6 @@ struct net *copy_net_ns(unsigned long flags,

    net->ucounts = ucounts;
    rv = setup_net(net, user_ns);
    - if (rv == 0) {
    - rtnl_lock();
    - list_add_tail_rcu(&net->list, &net_namespace_list);
    - rtnl_unlock();
    - }
    mutex_unlock(&net_mutex);
    if (rv < 0) {
    dec_net_namespaces(ucounts);
    @@ -847,11 +845,6 @@ static int __init net_ns_init(void)
    panic("Could not setup the initial network namespace");

    init_net_initialized = true;
    -
    - rtnl_lock();
    - list_add_tail_rcu(&init_net.list, &net_namespace_list);
    - rtnl_unlock();
    -
    mutex_unlock(&net_mutex);

    register_pernet_subsys(&net_ns_ops);
    \
     
     \ /
      Last update: 2017-11-20 19:45    [W:3.602 / U:0.064 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site