[Devel] [PATCH RH9 18/26] proc connector: call proc-related init and fini routines explicitly

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Thu Oct 7 15:53:58 MSK 2021


From: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>

This allows to support per-container connector creation and destruction.

Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin at virtuozzo.com>

(cherry picked from vz8 commit 32c1390b702c4842360db8ae6690285786a06a95)
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 drivers/connector/cn_proc.c   | 18 ------------------
 drivers/connector/connector.c | 29 ++++++++++++++++++++++++-----
 2 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c
index c2f9d31305c1..a73d074ef488 100644
--- a/drivers/connector/cn_proc.c
+++ b/drivers/connector/cn_proc.c
@@ -369,21 +369,3 @@ void cn_proc_fini_ve(struct ve_struct *ve)
 {
 	cn_del_callback_ve(ve, &cn_proc_event_id);
 }
-
-/*
- * cn_proc_init - initialization entry point
- *
- * Adds the connector callback to the connector driver.
- */
-static int __init cn_proc_init(void)
-{
-	int err = cn_add_callback(&cn_proc_event_id,
-				  "cn_proc",
-				  &cn_proc_mcast_ctl);
-	if (err) {
-		pr_warn("cn_proc failed to register\n");
-		return err;
-	}
-	return 0;
-}
-device_initcall(cn_proc_init);
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index ff1d89b2ba5e..ddb690e901d7 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -297,22 +297,39 @@ static int cn_init_ve(struct ve_struct *ve)
 	err = -EIO;
 	dev->nls = netlink_kernel_create(net, NETLINK_CONNECTOR, &cfg);
 	if (!dev->nls)
-		goto net_unlock;
+		goto free_cn;
 
 	err = -EINVAL;
 	dev->cbdev = cn_queue_alloc_dev("cqueue", dev->nls);
 	if (!dev->cbdev) {
-		netlink_kernel_release(dev->nls);
-		goto net_unlock;
+		goto netlink_release;
 	}
 
 	ve->cn->cn_already_initialized = 1;
 
-	proc_create_single("connector", S_IRUGO, net->proc_net, cn_proc_show);
-	err = 0;
+	if (!proc_create_single("connector", S_IRUGO, net->proc_net,
+				cn_proc_show)) {
+		err = -ENOMEM;
+		goto free_cdev;
+	}
+
+	err = cn_proc_init_ve(ve);
+	if (err)
+		goto remove_proc;
 
 net_unlock:
 	return err;
+
+remove_proc:
+	remove_proc_entry("connector", net->proc_net);
+free_cdev:
+	cn_queue_free_dev(dev->cbdev);
+netlink_release:
+	netlink_kernel_release(dev->nls);
+free_cn:
+	kfree(ve->cn);
+	ve->cn = NULL;
+	goto net_unlock;
 }
 
 static void cn_fini_ve(struct ve_struct *ve)
@@ -322,6 +339,8 @@ static void cn_fini_ve(struct ve_struct *ve)
 
 	ve->cn->cn_already_initialized = 0;
 
+	cn_proc_fini_ve(ve);
+
 	/*
 	 * This is a hook called on ve stop, ve->ve_ns will be destroyed
 	 * later in the same thread, parallel ve stop is impossible,
-- 
2.31.1



More information about the Devel mailing list