[Devel] [PATCH RHEL7 COMMIT] venet: add newlink and dellink callbacks to rtnetlink operations

Konstantin Khorenko khorenko at virtuozzo.com
Tue Oct 20 07:57:07 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-229.7.2.vz7.9.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-229.7.2.vz7.8.9
------>
commit ea0e2f962febe5be45e32131a826dfe60da553ed
Author: Stanislav Kinsburskiy <skinsbursky at odin.com>
Date:   Tue Sep 22 17:49:18 2015 +0400

    venet: add newlink and dellink callbacks to rtnetlink operations
    
    Patchset description:
    This series add venet device creation and destruction support via netlink.
    It also removes device creation via per-net init hook.
    
    https://jira.sw.ru/browse/PSBM-23441
    
    v3: -ENOTSUP replaced with -ENOSYS. -ENOTSUP doesn't exist.
    
    v2: return -ENOTSUP in case of attempt to create a venet device in nested
    namespace.
    
    Stanislav Kinsburskiy (3):
          venet: fix false positive return code in case of error in venet_init()
          venet: add newlink and dellink callbacks to rtnetlink operations
          venet: remove per-net hooks and related code
    
    =====================================
    This patch description:
    
    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>
    Acked-by: Andrew Vagin <avagin at odin.com>
---
 drivers/net/venetdev.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/drivers/net/venetdev.c b/drivers/net/venetdev.c
index 50b3c91..fb3ef1e 100644
--- a/drivers/net/venetdev.c
+++ b/drivers/net/venetdev.c
@@ -749,6 +749,52 @@ 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 -ENOSYS;
+
+	if (env->veip)
+		return -EEXIST;
+
+	env->ve_netns = src_net;
+
+	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 +1253,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,



More information about the Devel mailing list