Skip to content

Commit a051091

Browse files
committed
Merge branch 'tcp_metrics-netlink-specs' into main
Jakub Kicinski says: ==================== tcp_metrics: add netlink protocol spec in YAML Add a netlink protocol spec for the tcp_metrics generic netlink family. First patch adjusts the uAPI header guards to make it easier to build tools/ with non-system headers. v1: https://lore.kernel.org/all/[email protected] ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 1778480 + 8567462 commit a051091

File tree

3 files changed

+189
-3
lines changed

3 files changed

+189
-3
lines changed
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
2+
3+
name: tcp_metrics
4+
5+
protocol: genetlink-legacy
6+
7+
doc: |
8+
Management interface for TCP metrics.
9+
10+
c-family-name: tcp-metrics-genl-name
11+
c-version-name: tcp-metrics-genl-version
12+
max-by-define: true
13+
kernel-policy: global
14+
15+
definitions:
16+
-
17+
name: tcp-fastopen-cookie-max
18+
type: const
19+
value: 16
20+
21+
attribute-sets:
22+
-
23+
name: tcp-metrics
24+
name-prefix: tcp-metrics-attr-
25+
attributes:
26+
-
27+
name: addr-ipv4
28+
type: u32
29+
byte-order: big-endian
30+
display-hint: ipv4
31+
-
32+
name: addr-ipv6
33+
type: binary
34+
checks:
35+
min-len: 16
36+
byte-order: big-endian
37+
display-hint: ipv6
38+
-
39+
name: age
40+
type: u64
41+
-
42+
name: tw-tsval
43+
type: u32
44+
doc: unused
45+
-
46+
name: tw-ts-stamp
47+
type: s32
48+
doc: unused
49+
-
50+
name: vals
51+
type: nest
52+
nested-attributes: metrics
53+
-
54+
name: fopen-mss
55+
type: u16
56+
-
57+
name: fopen-syn-drops
58+
type: u16
59+
-
60+
name: fopen-syn-drop-ts
61+
type: u64
62+
-
63+
name: fopen-cookie
64+
type: binary
65+
checks:
66+
min-len: tcp-fastopen-cookie-max
67+
-
68+
name: saddr-ipv4
69+
type: u32
70+
byte-order: big-endian
71+
display-hint: ipv4
72+
-
73+
name: saddr-ipv6
74+
type: binary
75+
checks:
76+
min-len: 16
77+
byte-order: big-endian
78+
display-hint: ipv6
79+
-
80+
name: pad
81+
type: pad
82+
83+
-
84+
name: metrics
85+
# Intentionally don't define the name-prefix, see below.
86+
doc: |
87+
Attributes with metrics. Note that the values here do not match
88+
the TCP_METRIC_* defines in the kernel, because kernel defines
89+
are off-by one (e.g. rtt is defined as enum 0, while netlink carries
90+
attribute type 1).
91+
attributes:
92+
-
93+
name: rtt
94+
type: u32
95+
doc: |
96+
Round Trip Time (RTT), in msecs with 3 bits fractional
97+
(left-shift by 3 to get the msec value).
98+
-
99+
name: rttvar
100+
type: u32
101+
doc: |
102+
Round Trip Time VARiance (RTT), in msecs with 2 bits fractional
103+
(left-shift by 2 to get the msec value).
104+
-
105+
name: ssthresh
106+
type: u32
107+
doc: Slow Start THRESHold.
108+
-
109+
name: cwnd
110+
type: u32
111+
doc: Congestion Window.
112+
-
113+
name: reodering
114+
type: u32
115+
doc: Reodering metric.
116+
-
117+
name: rtt-us
118+
type: u32
119+
doc: |
120+
Round Trip Time (RTT), in usecs, with 3 bits fractional
121+
(left-shift by 3 to get the msec value).
122+
-
123+
name: rttvar-us
124+
type: u32
125+
doc: |
126+
Round Trip Time (RTT), in usecs, with 2 bits fractional
127+
(left-shift by 3 to get the msec value).
128+
129+
operations:
130+
list:
131+
-
132+
name: get
133+
doc: Retrieve metrics.
134+
attribute-set: tcp-metrics
135+
136+
dont-validate: [ strict, dump ]
137+
138+
do:
139+
request: &sel_attrs
140+
attributes:
141+
- addr-ipv4
142+
- addr-ipv6
143+
- saddr-ipv4
144+
- saddr-ipv6
145+
reply: &all_attrs
146+
attributes:
147+
- addr-ipv4
148+
- addr-ipv6
149+
- saddr-ipv4
150+
- saddr-ipv6
151+
- age
152+
- vals
153+
- fopen-mss
154+
- fopen-syn-drops
155+
- fopen-syn-drop-ts
156+
- fopen-cookie
157+
dump:
158+
reply: *all_attrs
159+
160+
-
161+
name: del
162+
doc: Delete metrics.
163+
attribute-set: tcp-metrics
164+
165+
dont-validate: [ strict, dump ]
166+
flags: [ admin-perm ]
167+
168+
do:
169+
request: *sel_attrs

include/uapi/linux/tcp_metrics.h

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
22
/* tcp_metrics.h - TCP Metrics Interface */
33

4-
#ifndef _LINUX_TCP_METRICS_H
5-
#define _LINUX_TCP_METRICS_H
4+
#ifndef _UAPI_LINUX_TCP_METRICS_H
5+
#define _UAPI_LINUX_TCP_METRICS_H
66

77
#include <linux/types.h>
88

@@ -27,6 +27,22 @@ enum tcp_metric_index {
2727

2828
#define TCP_METRIC_MAX (__TCP_METRIC_MAX - 1)
2929

30+
/* Re-define enum tcp_metric_index, again, using the values carried
31+
* as netlink attribute types.
32+
*/
33+
enum {
34+
TCP_METRICS_A_METRICS_RTT = 1,
35+
TCP_METRICS_A_METRICS_RTTVAR,
36+
TCP_METRICS_A_METRICS_SSTHRESH,
37+
TCP_METRICS_A_METRICS_CWND,
38+
TCP_METRICS_A_METRICS_REODERING,
39+
TCP_METRICS_A_METRICS_RTT_US,
40+
TCP_METRICS_A_METRICS_RTTVAR_US,
41+
42+
__TCP_METRICS_A_METRICS_MAX
43+
};
44+
#define TCP_METRICS_A_METRICS_MAX (__TCP_METRICS_A_METRICS_MAX - 1)
45+
3046
enum {
3147
TCP_METRICS_ATTR_UNSPEC,
3248
TCP_METRICS_ATTR_ADDR_IPV4, /* u32 */
@@ -58,4 +74,4 @@ enum {
5874

5975
#define TCP_METRICS_CMD_MAX (__TCP_METRICS_CMD_MAX - 1)
6076

61-
#endif /* _LINUX_TCP_METRICS_H */
77+
#endif /* _UAPI_LINUX_TCP_METRICS_H */

tools/net/ynl/Makefile.deps

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ CFLAGS_nfsd:=$(call get_hdr_inc,_LINUX_NFSD_NETLINK_H,nfsd_netlink.h)
2626
CFLAGS_ovs_datapath:=$(call get_hdr_inc,__LINUX_OPENVSWITCH_H,openvswitch.h)
2727
CFLAGS_ovs_flow:=$(call get_hdr_inc,__LINUX_OPENVSWITCH_H,openvswitch.h)
2828
CFLAGS_ovs_vport:=$(call get_hdr_inc,__LINUX_OPENVSWITCH_H,openvswitch.h)
29+
CFLAGS_tcp_metrics:=$(call get_hdr_inc,_LINUX_TCP_METRICS_H,tcp_metrics.h)

0 commit comments

Comments
 (0)