[Devel] [PATCH RHEL7 COMMIT] connector: per-ve helpers intoruduced

Konstantin Khorenko khorenko at virtuozzo.com
Thu Aug 31 17:40:30 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 596e20e4cfc9660a390027c3d5b5d2d9fc61b203
Author: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
Date:   Thu Aug 31 17:40:30 2017 +0300

    connector: per-ve helpers intoruduced
    
    This is precursor patch.
    
    Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
    Reviewed-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
 drivers/connector/connector.c | 48 +++++++++++++++++++++++++++++--------------
 include/linux/connector.h     |  7 +++++++
 2 files changed, 40 insertions(+), 15 deletions(-)

diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index bc2308a..bba667d 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -67,14 +67,14 @@ static struct cn_dev *get_cdev(struct ve_struct *ve)
 	return &ve->cn->cdev;
 }
 
-int cn_netlink_send(struct cn_msg *msg, u32 __group, gfp_t gfp_mask)
+int cn_netlink_send_ve(struct ve_struct *ve, struct cn_msg *msg, u32 __group, gfp_t gfp_mask)
 {
 	struct cn_callback_entry *__cbq;
 	unsigned int size;
 	struct sk_buff *skb;
 	struct nlmsghdr *nlh;
 	struct cn_msg *data;
-	struct cn_dev *dev = get_cdev(get_ve0());
+	struct cn_dev *dev = get_cdev(ve);
 	u32 group = 0;
 	int found = 0;
 
@@ -119,6 +119,11 @@ int cn_netlink_send(struct cn_msg *msg, u32 __group, gfp_t gfp_mask)
 
 	return netlink_broadcast(dev->nls, skb, 0, group, gfp_mask);
 }
+
+int cn_netlink_send(struct cn_msg *msg, u32 __group, gfp_t gfp_mask)
+{
+	return cn_netlink_send_ve(get_ve0(), msg, __group, gfp_mask);
+}
 EXPORT_SYMBOL_GPL(cn_netlink_send);
 
 /*
@@ -183,18 +188,13 @@ static void cn_rx_skb(struct sk_buff *__skb)
 	}
 }
 
-/*
- * Callback add routing - adds callback with given ID and name.
- * If there is registered callback with the same ID it will not be added.
- *
- * May sleep.
- */
-int cn_add_callback(struct cb_id *id, const char *name,
-		    void (*callback)(struct cn_msg *,
-				     struct netlink_skb_parms *))
+int cn_add_callback_ve(struct ve_struct *ve,
+		       struct cb_id *id, const char *name,
+		       void (*callback)(struct cn_msg *,
+					struct netlink_skb_parms *))
 {
 	int err;
-	struct cn_dev *dev = get_cdev(get_ve0());
+	struct cn_dev *dev = get_cdev(ve);
 
 	if (!cn_already_initialized)
 		return -EAGAIN;
@@ -205,8 +205,28 @@ int cn_add_callback(struct cb_id *id, const char *name,
 
 	return 0;
 }
+
+/*
+ * Callback add routing - adds callback with given ID and name.
+ * If there is registered callback with the same ID it will not be added.
+ *
+ * May sleep.
+ */
+int cn_add_callback(struct cb_id *id, const char *name,
+		    void (*callback)(struct cn_msg *,
+				     struct netlink_skb_parms *))
+{
+	return cn_add_callback_ve(get_ve0(), id, name, callback);
+}
 EXPORT_SYMBOL_GPL(cn_add_callback);
 
+void cn_del_callback_ve(struct ve_struct *ve, struct cb_id *id)
+{
+	struct cn_dev *dev = get_cdev(ve);
+
+	cn_queue_del_callback(dev->cbdev, id);
+}
+
 /*
  * Callback remove routing - removes callback
  * with given ID.
@@ -217,9 +237,7 @@ EXPORT_SYMBOL_GPL(cn_add_callback);
  */
 void cn_del_callback(struct cb_id *id)
 {
-	struct cn_dev *dev = get_cdev(get_ve0());
-
-	cn_queue_del_callback(dev->cbdev, id);
+	cn_del_callback_ve(get_ve0(), id);
 }
 EXPORT_SYMBOL_GPL(cn_del_callback);
 
diff --git a/include/linux/connector.h b/include/linux/connector.h
index 9e05e28..8b44bf0 100644
--- a/include/linux/connector.h
+++ b/include/linux/connector.h
@@ -76,6 +76,13 @@ struct cn_private {
 
 };
 
+int cn_add_callback_ve(struct ve_struct *ve,
+		       struct cb_id *id, const char *name,
+		       void (*callback)(struct cn_msg *,
+					struct netlink_skb_parms *));
+void cn_del_callback_ve(struct ve_struct *ve, struct cb_id *id);
+int cn_netlink_send_ve(struct ve_struct *ve, struct cn_msg *, u32, gfp_t);
+
 int cn_add_callback(struct cb_id *id, const char *name,
 		    void (*callback)(struct cn_msg *, struct netlink_skb_parms *));
 void cn_del_callback(struct cb_id *);


More information about the Devel mailing list