[Devel] [PATCH RHEL7 COMMIT] connector: per-ve init and fini helpers introduced
Konstantin Khorenko
khorenko at virtuozzo.com
Thu Aug 31 17:40:29 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 37c6a11416ce88290d381482e0b8bf568dc59e97
Author: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
Date: Thu Aug 31 17:40:29 2017 +0300
connector: per-ve init and fini helpers introduced
This helpers will be used later to initialize per-container connector.
Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
drivers/connector/connector.c | 31 +++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index 407fe52..f5484b2 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -259,15 +259,20 @@ static const struct file_operations cn_file_ops = {
.release = single_release
};
-static int cn_init(void)
+static int cn_init_ve(struct ve_struct *ve)
{
struct cn_dev *dev = get_cdev(get_ve0());
struct netlink_kernel_cfg cfg = {
.groups = CN_NETLINK_USERS + 0xf,
.input = cn_rx_skb,
};
+ struct net *net = ve->ve_netns;
+
+ ve->cn = kzalloc(sizeof(*ve->cn), GFP_KERNEL);
+ if (!ve->cn)
+ return -ENOMEM;
- dev->nls = netlink_kernel_create(&init_net, NETLINK_CONNECTOR, &cfg);
+ dev->nls = netlink_kernel_create(net, NETLINK_CONNECTOR, &cfg);
if (!dev->nls)
return -EIO;
@@ -279,21 +284,35 @@ static int cn_init(void)
cn_already_initialized = 1;
- proc_create("connector", S_IRUGO, init_net.proc_net, &cn_file_ops);
+ proc_create("connector", S_IRUGO, net->proc_net, &cn_file_ops);
return 0;
}
-static void cn_fini(void)
+static void cn_fini_ve(struct ve_struct *ve)
{
- struct cn_dev *dev = get_cdev(get_ve0());
+ struct cn_dev *dev = get_cdev(ve);
+ struct net *net = ve->ve_netns;
cn_already_initialized = 0;
- remove_proc_entry("connector", init_net.proc_net);
+ remove_proc_entry("connector", net->proc_net);
cn_queue_free_dev(dev->cbdev);
netlink_kernel_release(dev->nls);
+
+ kfree(ve->cn);
+ ve->cn = NULL;
+}
+
+static int cn_init(void)
+{
+ return cn_init_ve(get_ve0());
+}
+
+static void cn_fini(void)
+{
+ return cn_fini_ve(get_ve0());
}
subsys_initcall(cn_init);
More information about the Devel
mailing list