[Devel] [PATCH RHEL7 COMMIT] proc connector: call proc-related init and fini routines explicitly
Konstantin Khorenko
khorenko at virtuozzo.com
Thu Aug 31 17:40:39 MSK 2017
The commit is pushed to "branch-rh7-3.10.0-514.26.1.vz7.35.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.26.1.vz7.35.5
------>
commit 33a6978beb7622e8e97837904db45d7432776bb5
Author: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
Date: Thu Aug 31 17:40:39 2017 +0300
proc connector: call proc-related init and fini routines explicitly
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>
---
drivers/connector/cn_proc.c | 19 -------------------
drivers/connector/connector.c | 33 ++++++++++++++++++++++++++++-----
2 files changed, 28 insertions(+), 24 deletions(-)
diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c
index 8998335..7a1124a 100644
--- a/drivers/connector/cn_proc.c
+++ b/drivers/connector/cn_proc.c
@@ -345,22 +345,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;
-}
-
-module_init(cn_proc_init);
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index 110637b..59d81a3 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -281,6 +281,7 @@ static int cn_init_ve(struct ve_struct *ve)
.input = cn_rx_skb,
};
struct net *net = ve->ve_netns;
+ int err;
ve->cn = kzalloc(sizeof(*ve->cn), GFP_KERNEL);
if (!ve->cn)
@@ -289,20 +290,40 @@ static int cn_init_ve(struct ve_struct *ve)
dev = &ve->cn->cdev;
dev->nls = netlink_kernel_create(net, NETLINK_CONNECTOR, &cfg);
- if (!dev->nls)
- return -EIO;
+ if (!dev->nls) {
+ err = -EIO;
+ goto free_cn;
+ }
dev->cbdev = cn_queue_alloc_dev("cqueue", dev->nls);
if (!dev->cbdev) {
- netlink_kernel_release(dev->nls);
- return -EINVAL;
+ err = -EINVAL;
+ goto netlink_release;
}
ve->cn->cn_already_initialized = 1;
- proc_create("connector", S_IRUGO, net->proc_net, &cn_file_ops);
+ if (!proc_create("connector", S_IRUGO, net->proc_net, &cn_file_ops)) {
+ err = -ENOMEM;
+ goto free_cdev;
+ }
+
+ err = cn_proc_init_ve(ve);
+ if (err)
+ goto remove_proc;
return 0;
+
+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;
+ return err;
}
static void cn_fini_ve(struct ve_struct *ve)
@@ -312,6 +333,8 @@ static void cn_fini_ve(struct ve_struct *ve)
ve->cn->cn_already_initialized = 0;
+ cn_proc_fini_ve(ve);
+
remove_proc_entry("connector", net->proc_net);
cn_queue_free_dev(dev->cbdev);
More information about the Devel
mailing list