[Devel] [PATCH RH9 05/26] connector: per-ve helpers intoruduced

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


From: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>

This is precursor patch.

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

(cherry picked from vz8 commit 0c549e1074be22cab602238ddbc9b4ccd161040d)
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 drivers/connector/connector.c | 49 +++++++++++++++++++++++++++--------
 include/linux/connector.h     |  9 +++++++
 2 files changed, 47 insertions(+), 11 deletions(-)

diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index e2af22d7a4ee..cc649ec99c8b 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -62,15 +62,15 @@ static struct cn_dev *get_cdev(struct ve_struct *ve)
  * The message is sent to, the portid if given, the group if given, both if
  * both, or if both are zero then the group is looked up and sent there.
  */
-int cn_netlink_send_mult(struct cn_msg *msg, u16 len, u32 portid, u32 __group,
-	gfp_t gfp_mask)
+int cn_netlink_send_mult_ve(struct ve_struct *ve, struct cn_msg *msg, u16 len,
+			    u32 portid, 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,8 +119,22 @@ int cn_netlink_send_mult(struct cn_msg *msg, u16 len, u32 portid, u32 __group,
 	return netlink_unicast(dev->nls, skb, portid,
 			!gfpflags_allow_blocking(gfp_mask));
 }
+
+int cn_netlink_send_mult(struct cn_msg *msg, u16 len, u32 portid, u32 __group,
+	gfp_t gfp_mask)
+{
+	return cn_netlink_send_mult_ve(get_ve0(), msg, len, portid,
+				       __group, gfp_mask);
+}
 EXPORT_SYMBOL_GPL(cn_netlink_send_mult);
 
+int cn_netlink_send_ve(struct ve_struct *ve, struct cn_msg *msg, u32 portid,
+		       u32 __group, gfp_t gfp_mask)
+{
+	return cn_netlink_send_mult_ve(ve, msg, msg->len, portid,
+				       __group, gfp_mask);
+}
+
 /* same as cn_netlink_send_mult except msg->len is used for len */
 int cn_netlink_send(struct cn_msg *msg, u32 portid, u32 __group,
 	gfp_t gfp_mask)
@@ -191,6 +205,19 @@ static void cn_rx_skb(struct sk_buff *skb)
 	}
 }
 
+int cn_add_callback_ve(struct ve_struct *ve,
+		       const struct cb_id *id, const char *name,
+		       void (*callback)(struct cn_msg *,
+					struct netlink_skb_parms *))
+{
+	struct cn_dev *dev = get_cdev(ve);
+
+	if (!cn_already_initialized)
+		return -EAGAIN;
+
+	return cn_queue_add_callback(dev->cbdev, name, id, callback);
+}
+
 /*
  * Callback add routing - adds callback with given ID and name.
  * If there is registered callback with the same ID it will not be added.
@@ -201,14 +228,16 @@ 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 = get_cdev(get_ve0());
+	return cn_add_callback_ve(get_ve0(), id, name, callback);
+}
+EXPORT_SYMBOL_GPL(cn_add_callback);
 
-	if (!cn_already_initialized)
-		return -EAGAIN;
+void cn_del_callback_ve(struct ve_struct *ve, const struct cb_id *id)
+{
+	struct cn_dev *dev = get_cdev(ve);
 
-	return cn_queue_add_callback(dev->cbdev, name, id, callback);
+	cn_queue_del_callback(dev->cbdev, id);
 }
-EXPORT_SYMBOL_GPL(cn_add_callback);
 
 /*
  * Callback remove routing - removes callback
@@ -220,9 +249,7 @@ EXPORT_SYMBOL_GPL(cn_add_callback);
  */
 void cn_del_callback(const 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 c3bc18eee9f6..acee2c3bfc60 100644
--- a/include/linux/connector.h
+++ b/include/linux/connector.h
@@ -63,6 +63,15 @@ struct cn_private {
 
 };
 
+struct ve_struct;
+int cn_add_callback_ve(struct ve_struct *ve,
+		       const 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, const struct cb_id *id);
+int cn_netlink_send_ve(struct ve_struct *ve, struct cn_msg *msg, u32 portid,
+		       u32 group, gfp_t gfp_mask);
+
 /**
  * cn_add_callback() - Registers new callback with connector core.
  *
-- 
2.31.1



More information about the Devel mailing list