[ovs-dev] [PATCH 1/2] datapath: Improve net-namespace compat code.

Jesse Gross jesse at nicira.com
Thu Jul 11 20:03:08 UTC 2013


On Thu, Jul 11, 2013 at 12:25 PM, Pravin Shelar <pshelar at nicira.com> wrote:
> On Wed, Jul 10, 2013 at 3:52 PM, Jesse Gross <jesse at nicira.com> wrote:
>> On Mon, Jul 1, 2013 at 3:28 PM, Pravin B Shelar <pshelar at nicira.com> wrote:
>>> diff --git a/datapath/linux/compat/net_namespace.c b/datapath/linux/compat/net_namespace.c
>>> index 4e8a891..39b4a28 100644
>>> --- a/datapath/linux/compat/net_namespace.c
>>> +++ b/datapath/linux/compat/net_namespace.c
>>>  int rpl_register_pernet_##PNET_TYPE(struct rpl_pernet_operations *rpl_pnet)    \
>>>  {                                                                              \
>>>         pnet_##PNET_TYPE = rpl_pnet;                                            \
>>> -       return register_pernet_##PNET_TYPE(pnet_##PNET_TYPE->id, &pnet_compat_##PNET_TYPE); \
>>> +       rpl_pnet->ops = pnet_compat_##PNET_TYPE;                                \
>>> +       return register_pernet_##PNET_TYPE(pnet_##PNET_TYPE->id, &rpl_pnet->ops); \
>>>  }
>>
>> I think this works for initializing the device for existing namespaces
>> but if a new namespace is brought up then it will have problems. In
>> that case, it will call the registration function for the last device
>> repeatedly.
>>
> right.
>
>> We could avoid this issue if we just used contain_of instead of a set
>> of global variables to recover the original ops. That might also allow
>> us to significantly reduce the amount of token pasting, which would
>> also make this easier to read.
> I am not sure what are you suggesting.
> problem is compat-per-net-init function has net as parameter and it
> need id to get private net obj. but there is no way to get
> net_id/net-obj for this compat function without global pointer, but
> that does not work as you explained.

You're right, it doesn't work.

> I can think of some more macro tricks to hide this compat code, that
> will involve moving this code to header and using file-name (and may
> be line no) to build specific compat functions rather than sharing
> same functions for multiple net-ops.

I guess that works. It will be hard to read but I don't have a better idea.
X-CudaMail-Whitelist-To: dev at openvswitch.org



More information about the dev mailing list