netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] net: inet: diag: expose sockets cgroup classid
@ 2017-08-17  0:35 Levin, Alexander (Sasha Levin)
  2017-08-18 23:11 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-08-17  0:35 UTC (permalink / raw)
  To: davem
  Cc: xiyou.wangcong, netdev, linux-kernel, Levin,
	Alexander (Sasha Levin), Levin, Alexander (Sasha Levin)

From: "Levin, Alexander (Sasha Levin)" <alexander.levin@one.verizon.com>

This is useful for directly looking up a task based on class id rather than
having to scan through all open file descriptors.

Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
 include/uapi/linux/inet_diag.h |  1 +
 net/ipv4/inet_diag.c           | 11 +++++++++++
 2 files changed, 12 insertions(+)

diff --git a/include/uapi/linux/inet_diag.h b/include/uapi/linux/inet_diag.h
index bbe201047df6..678496897a68 100644
--- a/include/uapi/linux/inet_diag.h
+++ b/include/uapi/linux/inet_diag.h
@@ -142,6 +142,7 @@ enum {
 	INET_DIAG_PAD,
 	INET_DIAG_MARK,
 	INET_DIAG_BBRINFO,
+	INET_DIAG_CLASS_ID,
 	__INET_DIAG_MAX,
 };
 
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index 3828b3a805cd..67325d5832d7 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -274,6 +274,17 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
 			goto errout;
 	}
 
+	if (ext & (1 << (INET_DIAG_CLASS_ID - 1))) {
+		u32 classid = 0;
+
+#ifdef CONFIG_SOCK_CGROUP_DATA
+		classid = sock_cgroup_classid(&sk->sk_cgrp_data);
+#endif
+
+		if (nla_put_u32(skb, INET_DIAG_CLASS_ID, classid))
+			goto errout;
+	}
+
 out:
 	nlmsg_end(skb, nlh);
 	return 0;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] net: inet: diag: expose sockets cgroup classid
  2017-08-17  0:35 [PATCH v3] net: inet: diag: expose sockets cgroup classid Levin, Alexander (Sasha Levin)
@ 2017-08-18 23:11 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-08-18 23:11 UTC (permalink / raw)
  To: alexander.levin; +Cc: xiyou.wangcong, netdev, linux-kernel

From: "Levin, Alexander (Sasha Levin)" <alexander.levin@verizon.com>
Date: Thu, 17 Aug 2017 00:35:11 +0000

> From: "Levin, Alexander (Sasha Levin)" <alexander.levin@one.verizon.com>
> 
> This is useful for directly looking up a task based on class id rather than
> having to scan through all open file descriptors.
> 
> Signed-off-by: Sasha Levin <alexander.levin@verizon.com>

Applied to net-next, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-08-18 23:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-17  0:35 [PATCH v3] net: inet: diag: expose sockets cgroup classid Levin, Alexander (Sasha Levin)
2017-08-18 23:11 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).