* [PATCH net] inet_diag: add cgroup id attribute
@ 2020-03-30 8:11 Dmitry Yakunin
2020-03-30 10:40 ` kbuild test robot
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Dmitry Yakunin @ 2020-03-30 8:11 UTC (permalink / raw)
To: davem, netdev; +Cc: khlebnikov
This patch adds cgroup v2 id to common inet diag message attributes.
This allows investigate sockets on per cgroup basis when
net_cls/net_prio cgroup not used.
Signed-off-by: Dmitry Yakunin <zeil@yandex-team.ru>
Reviewed-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
---
include/linux/inet_diag.h | 6 +++++-
include/uapi/linux/inet_diag.h | 1 +
net/ipv4/inet_diag.c | 7 +++++++
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/include/linux/inet_diag.h b/include/linux/inet_diag.h
index c91cf2d..8bc5e7d 100644
--- a/include/linux/inet_diag.h
+++ b/include/linux/inet_diag.h
@@ -66,7 +66,11 @@ static inline size_t inet_diag_msg_attrs_size(void)
+ nla_total_size(1) /* INET_DIAG_SKV6ONLY */
#endif
+ nla_total_size(4) /* INET_DIAG_MARK */
- + nla_total_size(4); /* INET_DIAG_CLASS_ID */
+ + nla_total_size(4) /* INET_DIAG_CLASS_ID */
+#ifdef CONFIG_CGROUPS
+ + nla_total_size(8) /* INET_DIAG_CGROUP_ID */
+#endif
+ ;
}
int inet_diag_msg_attrs_fill(struct sock *sk, struct sk_buff *skb,
struct inet_diag_msg *r, int ext,
diff --git a/include/uapi/linux/inet_diag.h b/include/uapi/linux/inet_diag.h
index a1ff345..dc87ad6 100644
--- a/include/uapi/linux/inet_diag.h
+++ b/include/uapi/linux/inet_diag.h
@@ -154,6 +154,7 @@ enum {
INET_DIAG_CLASS_ID, /* request as INET_DIAG_TCLASS */
INET_DIAG_MD5SIG,
INET_DIAG_ULP_INFO,
+ INET_DIAG_CGROUP_ID,
__INET_DIAG_MAX,
};
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index 8c83775..ba0bb14 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -161,6 +161,13 @@ int inet_diag_msg_attrs_fill(struct sock *sk, struct sk_buff *skb,
goto errout;
}
+#ifdef CONFIG_CGROUPS
+ if (nla_put_u64_64bit(skb, INET_DIAG_CGROUP_ID,
+ cgroup_id(sock_cgroup_ptr(&sk->sk_cgrp_data)),
+ INET_DIAG_PAD))
+ goto errout;
+#endif
+
r->idiag_uid = from_kuid_munged(user_ns, sock_i_uid(sk));
r->idiag_inode = sock_i_ino(sk);
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] inet_diag: add cgroup id attribute
2020-03-30 8:11 [PATCH net] inet_diag: add cgroup id attribute Dmitry Yakunin
@ 2020-03-30 10:40 ` kbuild test robot
2020-03-30 15:28 ` kbuild test robot
2020-03-30 16:16 ` Eric Dumazet
2 siblings, 0 replies; 4+ messages in thread
From: kbuild test robot @ 2020-03-30 10:40 UTC (permalink / raw)
To: Dmitry Yakunin; +Cc: kbuild-all, davem, netdev, khlebnikov
[-- Attachment #1: Type: text/plain, Size: 3332 bytes --]
Hi Dmitry,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on net/master]
[also build test ERROR on linus/master v5.6]
[cannot apply to net-next/master sparc-next/master next-20200327]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Dmitry-Yakunin/inet_diag-add-cgroup-id-attribute/20200330-175504
base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git a0ba26f37ea04e025a793ef5e5ac809221728ecb
config: um-x86_64_defconfig (attached as .config)
compiler: gcc-7 (Debian 7.4.0-6) 7.4.0
reproduce:
# save the attached .config to linux build tree
make ARCH=um SUBARCH=x86_64
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
All error/warnings (new ones prefixed by >>):
net/ipv4/inet_diag.c: In function 'inet_diag_msg_attrs_fill':
>> net/ipv4/inet_diag.c:166:20: error: implicit declaration of function 'sock_cgroup_ptr'; did you mean 'task_cgroup_path'? [-Werror=implicit-function-declaration]
cgroup_id(sock_cgroup_ptr(&sk->sk_cgrp_data)),
^~~~~~~~~~~~~~~
task_cgroup_path
>> net/ipv4/inet_diag.c:166:20: warning: passing argument 1 of 'cgroup_id' makes pointer from integer without a cast [-Wint-conversion]
In file included from include/net/netprio_cgroup.h:11:0,
from include/linux/netdevice.h:42,
from include/net/inet_sock.h:19,
from include/net/icmp.h:19,
from net/ipv4/inet_diag.c:18:
include/linux/cgroup.h:308:19: note: expected 'struct cgroup *' but argument is of type 'int'
static inline u64 cgroup_id(struct cgroup *cgrp)
^~~~~~~~~
cc1: some warnings being treated as errors
vim +166 net/ipv4/inet_diag.c
142
143 if (net_admin && nla_put_u32(skb, INET_DIAG_MARK, sk->sk_mark))
144 goto errout;
145
146 if (ext & (1 << (INET_DIAG_CLASS_ID - 1)) ||
147 ext & (1 << (INET_DIAG_TCLASS - 1))) {
148 u32 classid = 0;
149
150 #ifdef CONFIG_SOCK_CGROUP_DATA
151 classid = sock_cgroup_classid(&sk->sk_cgrp_data);
152 #endif
153 /* Fallback to socket priority if class id isn't set.
154 * Classful qdiscs use it as direct reference to class.
155 * For cgroup2 classid is always zero.
156 */
157 if (!classid)
158 classid = sk->sk_priority;
159
160 if (nla_put_u32(skb, INET_DIAG_CLASS_ID, classid))
161 goto errout;
162 }
163
164 #ifdef CONFIG_CGROUPS
165 if (nla_put_u64_64bit(skb, INET_DIAG_CGROUP_ID,
> 166 cgroup_id(sock_cgroup_ptr(&sk->sk_cgrp_data)),
167 INET_DIAG_PAD))
168 goto errout;
169 #endif
170
171 r->idiag_uid = from_kuid_munged(user_ns, sock_i_uid(sk));
172 r->idiag_inode = sock_i_ino(sk);
173
174 return 0;
175 errout:
176 return 1;
177 }
178 EXPORT_SYMBOL_GPL(inet_diag_msg_attrs_fill);
179
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 8493 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] inet_diag: add cgroup id attribute
2020-03-30 8:11 [PATCH net] inet_diag: add cgroup id attribute Dmitry Yakunin
2020-03-30 10:40 ` kbuild test robot
@ 2020-03-30 15:28 ` kbuild test robot
2020-03-30 16:16 ` Eric Dumazet
2 siblings, 0 replies; 4+ messages in thread
From: kbuild test robot @ 2020-03-30 15:28 UTC (permalink / raw)
To: Dmitry Yakunin; +Cc: kbuild-all, davem, netdev, khlebnikov
[-- Attachment #1: Type: text/plain, Size: 3384 bytes --]
Hi Dmitry,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on net/master]
[also build test ERROR on linus/master v5.6]
[cannot apply to net-next/master next-20200330]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Dmitry-Yakunin/inet_diag-add-cgroup-id-attribute/20200330-175504
base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git a0ba26f37ea04e025a793ef5e5ac809221728ecb
config: mips-64r6el_defconfig (attached as .config)
compiler: mips64el-linux-gcc (GCC) 5.5.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=5.5.0 make.cross ARCH=mips
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
net/ipv4/inet_diag.c: In function 'inet_diag_msg_attrs_fill':
>> net/ipv4/inet_diag.c:166:20: error: implicit declaration of function 'sock_cgroup_ptr' [-Werror=implicit-function-declaration]
cgroup_id(sock_cgroup_ptr(&sk->sk_cgrp_data)),
^
net/ipv4/inet_diag.c:166:20: warning: passing argument 1 of 'cgroup_id' makes pointer from integer without a cast [-Wint-conversion]
In file included from include/net/netprio_cgroup.h:11:0,
from include/linux/netdevice.h:42,
from include/net/inet_sock.h:19,
from include/net/icmp.h:19,
from net/ipv4/inet_diag.c:18:
include/linux/cgroup.h:308:19: note: expected 'struct cgroup *' but argument is of type 'int'
static inline u64 cgroup_id(struct cgroup *cgrp)
^
cc1: some warnings being treated as errors
vim +/sock_cgroup_ptr +166 net/ipv4/inet_diag.c
142
143 if (net_admin && nla_put_u32(skb, INET_DIAG_MARK, sk->sk_mark))
144 goto errout;
145
146 if (ext & (1 << (INET_DIAG_CLASS_ID - 1)) ||
147 ext & (1 << (INET_DIAG_TCLASS - 1))) {
148 u32 classid = 0;
149
150 #ifdef CONFIG_SOCK_CGROUP_DATA
151 classid = sock_cgroup_classid(&sk->sk_cgrp_data);
152 #endif
153 /* Fallback to socket priority if class id isn't set.
154 * Classful qdiscs use it as direct reference to class.
155 * For cgroup2 classid is always zero.
156 */
157 if (!classid)
158 classid = sk->sk_priority;
159
160 if (nla_put_u32(skb, INET_DIAG_CLASS_ID, classid))
161 goto errout;
162 }
163
164 #ifdef CONFIG_CGROUPS
165 if (nla_put_u64_64bit(skb, INET_DIAG_CGROUP_ID,
> 166 cgroup_id(sock_cgroup_ptr(&sk->sk_cgrp_data)),
167 INET_DIAG_PAD))
168 goto errout;
169 #endif
170
171 r->idiag_uid = from_kuid_munged(user_ns, sock_i_uid(sk));
172 r->idiag_inode = sock_i_ino(sk);
173
174 return 0;
175 errout:
176 return 1;
177 }
178 EXPORT_SYMBOL_GPL(inet_diag_msg_attrs_fill);
179
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 20597 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] inet_diag: add cgroup id attribute
2020-03-30 8:11 [PATCH net] inet_diag: add cgroup id attribute Dmitry Yakunin
2020-03-30 10:40 ` kbuild test robot
2020-03-30 15:28 ` kbuild test robot
@ 2020-03-30 16:16 ` Eric Dumazet
2 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2020-03-30 16:16 UTC (permalink / raw)
To: Dmitry Yakunin, davem, netdev; +Cc: khlebnikov
On 3/30/20 1:11 AM, Dmitry Yakunin wrote:
> This patch adds cgroup v2 id to common inet diag message attributes.
> This allows investigate sockets on per cgroup basis when
> net_cls/net_prio cgroup not used.
>
> Signed-off-by: Dmitry Yakunin <zeil@yandex-team.ru>
> Reviewed-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
> ---
> include/linux/inet_diag.h | 6 +++++-
> include/uapi/linux/inet_diag.h | 1 +
> net/ipv4/inet_diag.c | 7 +++++++
> 3 files changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/inet_diag.h b/include/linux/inet_diag.h
> index c91cf2d..8bc5e7d 100644
> --- a/include/linux/inet_diag.h
> +++ b/include/linux/inet_diag.h
> @@ -66,7 +66,11 @@ static inline size_t inet_diag_msg_attrs_size(void)
> + nla_total_size(1) /* INET_DIAG_SKV6ONLY */
> #endif
> + nla_total_size(4) /* INET_DIAG_MARK */
> - + nla_total_size(4); /* INET_DIAG_CLASS_ID */
> + + nla_total_size(4) /* INET_DIAG_CLASS_ID */
> +#ifdef CONFIG_CGROUPS
> + + nla_total_size(8) /* INET_DIAG_CGROUP_ID */
nla_total_size_64bit(sizeof(u64))
> +#endif
> + ;
> }
> int inet_diag_msg_attrs_fill(struct sock *sk, struct sk_buff *skb,
> struct inet_diag_msg *r, int ext,
> diff --git a/include/uapi/linux/inet_diag.h b/include/uapi/linux/inet_diag.h
> index a1ff345..dc87ad6 100644
> --- a/include/uapi/linux/inet_diag.h
> +++ b/include/uapi/linux/inet_diag.h
> @@ -154,6 +154,7 @@ enum {
> INET_DIAG_CLASS_ID, /* request as INET_DIAG_TCLASS */
> INET_DIAG_MD5SIG,
> INET_DIAG_ULP_INFO,
> + INET_DIAG_CGROUP_ID,
> __INET_DIAG_MAX,
> };
>
> diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
> index 8c83775..ba0bb14 100644
> --- a/net/ipv4/inet_diag.c
> +++ b/net/ipv4/inet_diag.c
> @@ -161,6 +161,13 @@ int inet_diag_msg_attrs_fill(struct sock *sk, struct sk_buff *skb,
> goto errout;
> }
>
> +#ifdef CONFIG_CGROUPS
> + if (nla_put_u64_64bit(skb, INET_DIAG_CGROUP_ID,
> + cgroup_id(sock_cgroup_ptr(&sk->sk_cgrp_data)),
> + INET_DIAG_PAD))
> + goto errout;
> +#endif
> +
> r->idiag_uid = from_kuid_munged(user_ns, sock_i_uid(sk));
> r->idiag_inode = sock_i_ino(sk);
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-03-30 16:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-30 8:11 [PATCH net] inet_diag: add cgroup id attribute Dmitry Yakunin
2020-03-30 10:40 ` kbuild test robot
2020-03-30 15:28 ` kbuild test robot
2020-03-30 16:16 ` Eric Dumazet
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).