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

Jesse Gross jesse at nicira.com
Wed Jul 10 22:52:53 UTC 2013


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.

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.
X-CudaMail-Whitelist-To: dev at openvswitch.org



More information about the dev mailing list