From: Stanislav Kinsburskiy <skinsbur...@virtuozzo.com>

Once containerized, device won't be one and for all.
Thus make a helper template and use it instead of direct device object access.
Use ve0 for now.

Signed-off-by: Stanislav Kinsburskiy <skinsbur...@virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabi...@virtuozzo.com>

(cherry picked from vz8 commit db4e4f5f9db2e4a9a4fe78a479de5d3f7b244c7d)
Signed-off-by: Pavel Tikhomirov <ptikhomi...@virtuozzo.com>
---
 drivers/connector/connector.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index 48ec7ce6ecac..a4348d68698b 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -18,6 +18,7 @@
 #include <linux/mutex.h>
 #include <linux/proc_fs.h>
 #include <linux/spinlock.h>
+#include <linux/ve.h>
 
 #include <net/sock.h>
 
@@ -30,6 +31,11 @@ static struct cn_dev cdev;
 
 static int cn_already_initialized;
 
+static struct cn_dev *get_cdev(struct ve_struct *ve)
+{
+       return &cdev;
+}
+
 /*
  * Sends mult (multiple) cn_msg at a time.
  *
@@ -66,7 +72,7 @@ int cn_netlink_send_mult(struct cn_msg *msg, u16 len, u32 
portid, u32 __group,
        struct sk_buff *skb;
        struct nlmsghdr *nlh;
        struct cn_msg *data;
-       struct cn_dev *dev = &cdev;
+       struct cn_dev *dev = get_cdev(get_ve0());
        u32 group = 0;
        int found = 0;
 
@@ -132,7 +138,7 @@ static int cn_call_callback(struct sk_buff *skb)
 {
        struct nlmsghdr *nlh;
        struct cn_callback_entry *i, *cbq = NULL;
-       struct cn_dev *dev = &cdev;
+       struct cn_dev *dev = get_cdev(get_ve0());
        struct cn_msg *msg = nlmsg_data(nlmsg_hdr(skb));
        struct netlink_skb_parms *nsp = &NETLINK_CB(skb);
        int err = -ENODEV;
@@ -197,7 +203,7 @@ int cn_add_callback(const struct cb_id *id, const char 
*name,
                    void (*callback)(struct cn_msg *,
                                     struct netlink_skb_parms *))
 {
-       struct cn_dev *dev = &cdev;
+       struct cn_dev *dev = get_cdev(get_ve0());
 
        if (!cn_already_initialized)
                return -EAGAIN;
@@ -216,7 +222,7 @@ EXPORT_SYMBOL_GPL(cn_add_callback);
  */
 void cn_del_callback(const struct cb_id *id)
 {
-       struct cn_dev *dev = &cdev;
+       struct cn_dev *dev = get_cdev(get_ve0());
 
        cn_queue_del_callback(dev->cbdev, id);
 }
@@ -224,7 +230,7 @@ EXPORT_SYMBOL_GPL(cn_del_callback);
 
 static int __maybe_unused cn_proc_show(struct seq_file *m, void *v)
 {
-       struct cn_queue_dev *dev = cdev.cbdev;
+       struct cn_queue_dev *dev = get_cdev(get_ve0())->cbdev;
        struct cn_callback_entry *cbq;
 
        seq_printf(m, "Name            ID\n");
@@ -245,7 +251,7 @@ static int __maybe_unused cn_proc_show(struct seq_file *m, 
void *v)
 
 static int cn_init(void)
 {
-       struct cn_dev *dev = &cdev;
+       struct cn_dev *dev = get_cdev(get_ve0());
        struct netlink_kernel_cfg cfg = {
                .groups = CN_NETLINK_USERS + 0xf,
                .input  = cn_rx_skb,
@@ -270,7 +276,7 @@ static int cn_init(void)
 
 static void cn_fini(void)
 {
-       struct cn_dev *dev = &cdev;
+       struct cn_dev *dev = get_cdev(get_ve0());
 
        cn_already_initialized = 0;
 
-- 
2.31.1

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to