History

inet_diag: fix reporting cgroup classid and fallback to priority

Field idiag_ext in struct inet_diag_req_v2 used as bitmap of requested extensions has only 8 bits. Thus extensions starting from DCTCPINFO cannot be requested directly. Some of them included into response unconditionally or hook into some of lower 8 bits. Extension INET_DIAG_CLASS_ID has not way to request from the beginning. This patch bundle it with INET_DIAG_TCLASS (ipv6 tos), fixes space reservation, and documents behavior for other extensions. Also this patch adds fallback to reporting socket priority. This filed is more widely used for traffic classification because ipv4 sockets automatically maps TOS to priority and default qdisc pfifo_fast knows about that. But priority could be changed via setsockopt SO_PRIORITY so INET_DIAG_TOS isn't enough for predicting class. Also cgroup2 obsoletes net_cls classid (it always zero), but we cannot reuse this field for reporting cgroup2 id because it is 64-bit (ino+gen). So, after this patch INET_DIAG_CLASS_ID will report socket priority for most common setup when net_cls isn't set and/or cgroup2 in use.

Konstantin Khlebnikov committed 7 years ago

Commit 1ec17db1 parent 4ffcbfa3 files · +21 −6Browse files

Showing the changes to include/uapi/linux (1 of 3 files). Show all

Unified · Split

include/uapi/linux/inet_diag.h+11−5
@@ -137,15 +137,21 @@ enum { · 136 unmodified lines
137 INET_DIAG_TCLASS,137 INET_DIAG_TCLASS,
138 INET_DIAG_SKMEMINFO,138 INET_DIAG_SKMEMINFO,
139 INET_DIAG_SHUTDOWN,139 INET_DIAG_SHUTDOWN,
140 INET_DIAG_DCTCPINFO,140
141 INET_DIAG_PROTOCOL, /* response attribute only */141 /*
142 * Next extenstions cannot be requested in struct inet_diag_req_v2:
143 * its field idiag_ext has only 8 bits.
144 */
145
146 INET_DIAG_DCTCPINFO, /* request as INET_DIAG_VEGASINFO */
147 INET_DIAG_PROTOCOL, /* response attribute only */
142 INET_DIAG_SKV6ONLY,148 INET_DIAG_SKV6ONLY,
143 INET_DIAG_LOCALS,149 INET_DIAG_LOCALS,
144 INET_DIAG_PEERS,150 INET_DIAG_PEERS,
145 INET_DIAG_PAD,151 INET_DIAG_PAD,
146 INET_DIAG_MARK,152 INET_DIAG_MARK, /* only with CAP_NET_ADMIN */
147 INET_DIAG_BBRINFO,153 INET_DIAG_BBRINFO, /* request as INET_DIAG_VEGASINFO */
148 INET_DIAG_CLASS_ID,154 INET_DIAG_CLASS_ID, /* request as INET_DIAG_TCLASS */
149 INET_DIAG_MD5SIG,155 INET_DIAG_MD5SIG,
150 __INET_DIAG_MAX,156 __INET_DIAG_MAX,
151};157};