[Devel] [PATCH vz7 2/3] venet: add newlink and dellink callbacks to rtnetlink operations
Stanislav Kinsburskiy
skinsbursky at odin.com
Tue Sep 22 02:42:33 PDT 2015
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;
>> + }
>> +
>> + if (env->veip)
> Where is env->veip set to NULL, when venet is removed?
Sorry. This is done in veip_release callback, called from veip_stop.
>> + return -EEXIST;
>> +
>> + env->ve_netns = src_net;
> Why do we set ve_netns here?
>
>> +
>> + 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