[Devel,5/6] proc connector: cn_initialized() helper added

Submitted by Stanislav Kinsburskiy on Aug. 15, 2017, 12:42 p.m.

Details

Message ID 20170815124214.22445.44779.stgit@localhost.localdomain
State New
Series "proc connector: containerize on per-net basis"
Headers show

Commit Message

Stanislav Kinsburskiy Aug. 15, 2017, 12:42 p.m.
This is a precursor helper, which will hide all the containerization magic.

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
---
 drivers/connector/connector.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index 833aea4..e098d6f 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -187,6 +187,11 @@  static void cn_rx_skb(struct sk_buff *__skb)
 	}
 }
 
+static int cn_initialized(struct net *net)
+{
+	return cn_already_initialized;
+}
+
 /*
  * Callback add routing - adds callback with given ID and name.
  * If there is registered callback with the same ID it will not be added.
@@ -197,10 +202,11 @@  int cn_add_callback(struct cb_id *id, const char *name,
 		    void (*callback)(struct cn_msg *,
 				     struct netlink_skb_parms *))
 {
+	struct net *net = get_exec_env()->ve_netns;
 	int err;
 	struct cn_dev *dev = get_cdev();
 
-	if (!cn_already_initialized)
+	if (!cn_initialized(net))
 		return -EAGAIN;
 
 	err = cn_queue_add_callback(dev->cbdev, name, id, callback);