Skip to content

Commit

Permalink
net: inet: diag: expose sockets cgroup classid
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Levin, Alexander (Sasha Levin) authored and davem330 committed Aug 18, 2017
1 parent f21e507 commit 0888e37
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/uapi/linux/inet_diag.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ enum {
INET_DIAG_PAD,
INET_DIAG_MARK,
INET_DIAG_BBRINFO,
INET_DIAG_CLASS_ID,
__INET_DIAG_MAX,
};

Expand Down
11 changes: 11 additions & 0 deletions net/ipv4/inet_diag.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0888e37

Please sign in to comment.