[Devel] [PATCH vz7 2/3] venet: add newlink and dellink callbacks to rtnetlink operations

Stanislav Kinsburskiy skinsbursky at odin.com
Tue Sep 22 05:38:45 PDT 2015



22.09.2015 13:28, Andrew Vagin пишет:
> On Tue, Sep 22, 2015 at 01:20:11PM +0200, Stanislav Kinsburskiy wrote:
>>
>> 22.09.2015 13:15, Andrew Vagin пишет:
>>> On Tue, Sep 22, 2015 at 11:40:03AM +0200, Stanislav Kinsburskiy wrote:
>>>> 22.09.2015 11:36, Andrew Vagin пишет:
>>>>> On Mon, Sep 21, 2015 at 07:44:31PM +0400, Stanislav Kinsburskiy wrote:
>>>>>> From: Stanislav Kinsburskiy <skinsbursky at parallels.com>
>>>>>>
>>>>>> This functions are mostly duplicating existent code in per-net hooks, except
>>>>>> some initialization and locking, which are performed in rtnetlink layer.
>>>>>>
>>>>>> https://jira.sw.ru/browse/PSBM-23441
>>>>>>
>>>>>> Signed-off-by: Stanislav Kinsburskiy <skinsbursky at parallels.com>
>>>>>> ---
>>>>>>   drivers/net/venetdev.c |   49 ++++++++++++++++++++++++++++++++++++++++++++++++
>>>>>>   1 file changed, 49 insertions(+)
>>>>>>
>>>>>> diff --git a/drivers/net/venetdev.c b/drivers/net/venetdev.c
>>>>>> index 50b3c91..261be76 100644
>>>>>> --- a/drivers/net/venetdev.c
>>>>>> +++ b/drivers/net/venetdev.c
>>>>>> @@ -749,6 +749,53 @@ static void venet_setup(struct net_device *dev)
>>>>>>   	SET_ETHTOOL_OPS(dev, &venet_ethtool_ops);
>>>>>>   }
>>>>>> +static void venet_dellink(struct net_device *dev, struct list_head *head)
>>>>>> +{
>>>>>> +	struct ve_struct *env = dev->nd_net->owner_ve;
>>>>>> +
>>>>>> +	venet_ext_clean(env);
>>>>>> +	veip_stop(env);
>>>>>> +
>>>>>> +	env->_venet_dev = NULL;
>>>>>> +	unregister_netdevice_queue(dev, head);
>>>>>> +}
>>>>>> +
>>>>>> +static int venet_newlink(struct net *src_net, struct net_device *dev,
>>>>>> +		  struct nlattr *tb[], struct nlattr *data[])
>>>>>> +{
>>>>>> +	struct ve_struct *env = src_net->owner_ve;
>>>>>> +	int err;
>>>>>> +
>>>>>> +	if (env->ve_netns && src_net != env->ve_netns) {
>>>>>> +		/* Don't create venet-s in sub net namespaces */
>>>>>> +		return 0;
>>> Are you sure that we can return 0 here? Looks like EEXIST.
>>
>> It's a former logic, so I preserved it.
>> Introduced by Andrew Vagin here:
>> 4504338aaf4c7deb2285fc192ddfebf711f10129
> I don't return 0 from venet_newlink...

Makes sense. Should I return -ENOTSUPP?

>
>>>>>> +	}
>>>>>> +
>>>>>> +	if (env->veip)
>>>>> Where is env->veip set to NULL, when venet is removed?
>>>>>
>>>> This is missing, thanks. I'll add.
>>>>
>>>>>> +		return -EEXIST;
>>>>>> +
>>>>>> +	env->ve_netns = src_net;
>>>>> Why do we set ve_netns here?
>>>> To prevent venet creation in nested network namespaces within containers.
>>>>
>>>>>> +
>>>>>> +	err = veip_start(env);
>>>>>> +	if (err)
>>>>>> +		goto err;
>>>>>> +
>>>>>> +	dev->features |= NETIF_F_NETNS_LOCAL;
>>>>>> +
>>>>>> +	err = register_netdevice(dev);
>>>>>> +	if (err)
>>>>>> +		goto err_stop;
>>>>>> +
>>>>>> +	env->_venet_dev = dev;
>>>>>> +	return 0;
>>>>>> +
>>>>>> +err_stop:
>>>>>> +	veip_stop(env);
>>>>>> +err:
>>>>>> +	env->ve_netns = NULL;
>>>>>> +	return err;
>>>>>> +}
>>>>>> +
>>>>>>   #ifdef CONFIG_PROC_FS
>>>>>>   static void veaddr_seq_print(struct seq_file *m, struct ve_struct *ve)
>>>>>>   {
>>>>>> @@ -1207,6 +1254,8 @@ static const struct nla_policy venet_policy[VENET_INFO_MAX + 1] = {
>>>>>>   static struct rtnl_link_ops venet_link_ops = {
>>>>>>   	.kind		= "venet",
>>>>>>   	.priv_size	= sizeof(struct veip_struct),
>>>>>> +	.newlink	= venet_newlink,
>>>>>> +	.dellink	= venet_dellink,
>>>>>>   	.setup		= venet_setup,
>>>>>>   	.changelink	= venet_changelink,
>>>>>>   	.policy		= venet_policy,
>>>>>>
>>>>>> _______________________________________________
>>>>>> Devel mailing list
>>>>>> Devel at openvz.org
>>>>>> https://lists.openvz.org/mailman/listinfo/devel




More information about the Devel mailing list