inet_diag: return classid for all socket types
In commit1ec17dbd90
("inet_diag: fix reporting cgroup classid and fallback to priority") croup classid reporting was fixed. But this works only for TCP sockets because for other socket types icsk parameter can be NULL and classid code path is skipped. This change moves classid handling to inet_diag_msg_attrs_fill() function. Also inet_diag_msg_attrs_size() helper was added and addends in nlmsg_new() were reordered to save order from inet_sk_diag_fill(). Fixes:1ec17dbd90
("inet_diag: fix reporting cgroup classid and fallback to priority") Signed-off-by: Dmitry Yakunin <zeil@yandex-team.ru> Reviewed-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
b723bd9339
commit
83f73c5bb7
@@ -2,15 +2,10 @@
|
||||
#ifndef _INET_DIAG_H_
|
||||
#define _INET_DIAG_H_ 1
|
||||
|
||||
#include <net/netlink.h>
|
||||
#include <uapi/linux/inet_diag.h>
|
||||
|
||||
struct net;
|
||||
struct sock;
|
||||
struct inet_hashinfo;
|
||||
struct nlattr;
|
||||
struct nlmsghdr;
|
||||
struct sk_buff;
|
||||
struct netlink_callback;
|
||||
|
||||
struct inet_diag_handler {
|
||||
void (*dump)(struct sk_buff *skb,
|
||||
@@ -62,6 +57,17 @@ int inet_diag_bc_sk(const struct nlattr *_bc, struct sock *sk);
|
||||
|
||||
void inet_diag_msg_common_fill(struct inet_diag_msg *r, struct sock *sk);
|
||||
|
||||
static inline size_t inet_diag_msg_attrs_size(void)
|
||||
{
|
||||
return nla_total_size(1) /* INET_DIAG_SHUTDOWN */
|
||||
+ nla_total_size(1) /* INET_DIAG_TOS */
|
||||
#if IS_ENABLED(CONFIG_IPV6)
|
||||
+ nla_total_size(1) /* INET_DIAG_TCLASS */
|
||||
+ nla_total_size(1) /* INET_DIAG_SKV6ONLY */
|
||||
#endif
|
||||
+ nla_total_size(4) /* INET_DIAG_MARK */
|
||||
+ nla_total_size(4); /* INET_DIAG_CLASS_ID */
|
||||
}
|
||||
int inet_diag_msg_attrs_fill(struct sock *sk, struct sk_buff *skb,
|
||||
struct inet_diag_msg *r, int ext,
|
||||
struct user_namespace *user_ns, bool net_admin);
|
||||
|
Reference in New Issue
Block a user