[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <47FF75B9.2090508@openvz.org>
Date: Fri, 11 Apr 2008 18:29:13 +0400
From: Pavel Emelyanov <xemul@...nvz.org>
To: Daniel Lezcano <dlezcano@...ibm.com>
CC: Linux Netdev List <netdev@...r.kernel.org>,
Denis Lunev <den@...nvz.org>,
Linux Containers <containers@...ts.osdl.org>,
Benjamin Thery <benjamin.thery@...l.net>
Subject: Re: [PATCH 2/14][NETNS]: Generic per-net pointers.
[snip]
>> @@ -29,10 +32,21 @@ static __net_init int setup_net(struct net *net)
>> /* Must be called with net_mutex held */
>> struct pernet_operations *ops;
>> int error;
>> + struct net_generic *ng;
>>
>> atomic_set(&net->count, 1);
>> atomic_set(&net->use_count, 0);
>>
>> + error = -ENOMEM;
>> + ng = kzalloc(sizeof(struct net_generic) +
>> + INITIAL_NET_GEN_PTRS * sizeof(void *), GFP_KERNEL);
>
> Why do you need to allocate more than sizeof(struct net_generic) ?
That's just an optimization to avoid many reallocations in the
nearest future. I planned to make similar in net_assign_generic
(allocate a bit more that required), but decided to do it later
to keep net_assign_generic simpler.
Currently I have only 5 users of generic pointers (tun and vlan
you see and I have patches for ipip, ipgre and sit tunnels), so
that's enough for the first time.
[snip]
>> +int net_assign_generic(struct net *net, int id, void *data)
>> +{
>> + struct net_generic *ng, *old_ng;
>> +
>> + BUG_ON(!mutex_is_locked(&net_mutex));
>> + BUG_ON(id == 0);
>> +
>> + ng = old_ng = net->gen;
>
> shouldn't it be rcu_dereferenced ?
Nope - nobody can race with us and change this pointer, so it's
safe to get one without rcu_dereference.
Thanks,
Pavel
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists