1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2 #ifndef _UAPI_MPTCP_H
3 #define _UAPI_MPTCP_H
4 
5 #include <linux/const.h>
6 #include <linux/types.h>
7 
8 #define MPTCP_SUBFLOW_FLAG_MCAP_REM		_BITUL(0)
9 #define MPTCP_SUBFLOW_FLAG_MCAP_LOC		_BITUL(1)
10 #define MPTCP_SUBFLOW_FLAG_JOIN_REM		_BITUL(2)
11 #define MPTCP_SUBFLOW_FLAG_JOIN_LOC		_BITUL(3)
12 #define MPTCP_SUBFLOW_FLAG_BKUP_REM		_BITUL(4)
13 #define MPTCP_SUBFLOW_FLAG_BKUP_LOC		_BITUL(5)
14 #define MPTCP_SUBFLOW_FLAG_FULLY_ESTABLISHED	_BITUL(6)
15 #define MPTCP_SUBFLOW_FLAG_CONNECTED		_BITUL(7)
16 #define MPTCP_SUBFLOW_FLAG_MAPVALID		_BITUL(8)
17 
18 enum {
19 	MPTCP_SUBFLOW_ATTR_UNSPEC,
20 	MPTCP_SUBFLOW_ATTR_TOKEN_REM,
21 	MPTCP_SUBFLOW_ATTR_TOKEN_LOC,
22 	MPTCP_SUBFLOW_ATTR_RELWRITE_SEQ,
23 	MPTCP_SUBFLOW_ATTR_MAP_SEQ,
24 	MPTCP_SUBFLOW_ATTR_MAP_SFSEQ,
25 	MPTCP_SUBFLOW_ATTR_SSN_OFFSET,
26 	MPTCP_SUBFLOW_ATTR_MAP_DATALEN,
27 	MPTCP_SUBFLOW_ATTR_FLAGS,
28 	MPTCP_SUBFLOW_ATTR_ID_REM,
29 	MPTCP_SUBFLOW_ATTR_ID_LOC,
30 	MPTCP_SUBFLOW_ATTR_PAD,
31 	__MPTCP_SUBFLOW_ATTR_MAX
32 };
33 
34 #define MPTCP_SUBFLOW_ATTR_MAX (__MPTCP_SUBFLOW_ATTR_MAX - 1)
35 
36 /* netlink interface */
37 #define MPTCP_PM_NAME		"mptcp_pm"
38 #define MPTCP_PM_CMD_GRP_NAME	"mptcp_pm_cmds"
39 #define MPTCP_PM_EV_GRP_NAME	"mptcp_pm_events"
40 #define MPTCP_PM_VER		0x1
41 
42 /*
43  * ATTR types defined for MPTCP
44  */
45 enum {
46 	MPTCP_PM_ATTR_UNSPEC,
47 
48 	MPTCP_PM_ATTR_ADDR,				/* nested address */
49 	MPTCP_PM_ATTR_RCV_ADD_ADDRS,			/* u32 */
50 	MPTCP_PM_ATTR_SUBFLOWS,				/* u32 */
51 
52 	__MPTCP_PM_ATTR_MAX
53 };
54 
55 #define MPTCP_PM_ATTR_MAX (__MPTCP_PM_ATTR_MAX - 1)
56 
57 enum {
58 	MPTCP_PM_ADDR_ATTR_UNSPEC,
59 
60 	MPTCP_PM_ADDR_ATTR_FAMILY,			/* u16 */
61 	MPTCP_PM_ADDR_ATTR_ID,				/* u8 */
62 	MPTCP_PM_ADDR_ATTR_ADDR4,			/* struct in_addr */
63 	MPTCP_PM_ADDR_ATTR_ADDR6,			/* struct in6_addr */
64 	MPTCP_PM_ADDR_ATTR_PORT,			/* u16 */
65 	MPTCP_PM_ADDR_ATTR_FLAGS,			/* u32 */
66 	MPTCP_PM_ADDR_ATTR_IF_IDX,			/* s32 */
67 
68 	__MPTCP_PM_ADDR_ATTR_MAX
69 };
70 
71 #define MPTCP_PM_ADDR_ATTR_MAX (__MPTCP_PM_ADDR_ATTR_MAX - 1)
72 
73 #define MPTCP_PM_ADDR_FLAG_SIGNAL			(1 << 0)
74 #define MPTCP_PM_ADDR_FLAG_SUBFLOW			(1 << 1)
75 #define MPTCP_PM_ADDR_FLAG_BACKUP			(1 << 2)
76 #define MPTCP_PM_ADDR_FLAG_FULLMESH			(1 << 3)
77 
78 enum {
79 	MPTCP_PM_CMD_UNSPEC,
80 
81 	MPTCP_PM_CMD_ADD_ADDR,
82 	MPTCP_PM_CMD_DEL_ADDR,
83 	MPTCP_PM_CMD_GET_ADDR,
84 	MPTCP_PM_CMD_FLUSH_ADDRS,
85 	MPTCP_PM_CMD_SET_LIMITS,
86 	MPTCP_PM_CMD_GET_LIMITS,
87 	MPTCP_PM_CMD_SET_FLAGS,
88 
89 	__MPTCP_PM_CMD_AFTER_LAST
90 };
91 
92 #define MPTCP_INFO_FLAG_FALLBACK		_BITUL(0)
93 #define MPTCP_INFO_FLAG_REMOTE_KEY_RECEIVED	_BITUL(1)
94 
95 struct mptcp_info {
96 	__u8	mptcpi_subflows;
97 	__u8	mptcpi_add_addr_signal;
98 	__u8	mptcpi_add_addr_accepted;
99 	__u8	mptcpi_subflows_max;
100 	__u8	mptcpi_add_addr_signal_max;
101 	__u8	mptcpi_add_addr_accepted_max;
102 	__u32	mptcpi_flags;
103 	__u32	mptcpi_token;
104 	__u64	mptcpi_write_seq;
105 	__u64	mptcpi_snd_una;
106 	__u64	mptcpi_rcv_nxt;
107 	__u8	mptcpi_local_addr_used;
108 	__u8	mptcpi_local_addr_max;
109 	__u8	mptcpi_csum_enabled;
110 };
111 
112 /*
113  * MPTCP_EVENT_CREATED: token, family, saddr4 | saddr6, daddr4 | daddr6,
114  *                      sport, dport
115  * A new MPTCP connection has been created. It is the good time to allocate
116  * memory and send ADD_ADDR if needed. Depending on the traffic-patterns
117  * it can take a long time until the MPTCP_EVENT_ESTABLISHED is sent.
118  *
119  * MPTCP_EVENT_ESTABLISHED: token, family, saddr4 | saddr6, daddr4 | daddr6,
120  *			    sport, dport
121  * A MPTCP connection is established (can start new subflows).
122  *
123  * MPTCP_EVENT_CLOSED: token
124  * A MPTCP connection has stopped.
125  *
126  * MPTCP_EVENT_ANNOUNCED: token, rem_id, family, daddr4 | daddr6 [, dport]
127  * A new address has been announced by the peer.
128  *
129  * MPTCP_EVENT_REMOVED: token, rem_id
130  * An address has been lost by the peer.
131  *
132  * MPTCP_EVENT_SUB_ESTABLISHED: token, family, saddr4 | saddr6,
133  *                              daddr4 | daddr6, sport, dport, backup,
134  *                              if_idx [, error]
135  * A new subflow has been established. 'error' should not be set.
136  *
137  * MPTCP_EVENT_SUB_CLOSED: token, family, saddr4 | saddr6, daddr4 | daddr6,
138  *                         sport, dport, backup, if_idx [, error]
139  * A subflow has been closed. An error (copy of sk_err) could be set if an
140  * error has been detected for this subflow.
141  *
142  * MPTCP_EVENT_SUB_PRIORITY: token, family, saddr4 | saddr6, daddr4 | daddr6,
143  *                           sport, dport, backup, if_idx [, error]
144  *       The priority of a subflow has changed. 'error' should not be set.
145  */
146 enum mptcp_event_type {
147 	MPTCP_EVENT_UNSPEC = 0,
148 	MPTCP_EVENT_CREATED = 1,
149 	MPTCP_EVENT_ESTABLISHED = 2,
150 	MPTCP_EVENT_CLOSED = 3,
151 
152 	MPTCP_EVENT_ANNOUNCED = 6,
153 	MPTCP_EVENT_REMOVED = 7,
154 
155 	MPTCP_EVENT_SUB_ESTABLISHED = 10,
156 	MPTCP_EVENT_SUB_CLOSED = 11,
157 
158 	MPTCP_EVENT_SUB_PRIORITY = 13,
159 };
160 
161 enum mptcp_event_attr {
162 	MPTCP_ATTR_UNSPEC = 0,
163 
164 	MPTCP_ATTR_TOKEN,	/* u32 */
165 	MPTCP_ATTR_FAMILY,	/* u16 */
166 	MPTCP_ATTR_LOC_ID,	/* u8 */
167 	MPTCP_ATTR_REM_ID,	/* u8 */
168 	MPTCP_ATTR_SADDR4,	/* be32 */
169 	MPTCP_ATTR_SADDR6,	/* struct in6_addr */
170 	MPTCP_ATTR_DADDR4,	/* be32 */
171 	MPTCP_ATTR_DADDR6,	/* struct in6_addr */
172 	MPTCP_ATTR_SPORT,	/* be16 */
173 	MPTCP_ATTR_DPORT,	/* be16 */
174 	MPTCP_ATTR_BACKUP,	/* u8 */
175 	MPTCP_ATTR_ERROR,	/* u8 */
176 	MPTCP_ATTR_FLAGS,	/* u16 */
177 	MPTCP_ATTR_TIMEOUT,	/* u32 */
178 	MPTCP_ATTR_IF_IDX,	/* s32 */
179 	MPTCP_ATTR_RESET_REASON,/* u32 */
180 	MPTCP_ATTR_RESET_FLAGS, /* u32 */
181 
182 	__MPTCP_ATTR_AFTER_LAST
183 };
184 
185 #define MPTCP_ATTR_MAX (__MPTCP_ATTR_AFTER_LAST - 1)
186 
187 /* MPTCP Reset reason codes, rfc8684 */
188 #define MPTCP_RST_EUNSPEC	0
189 #define MPTCP_RST_EMPTCP	1
190 #define MPTCP_RST_ERESOURCE	2
191 #define MPTCP_RST_EPROHIBIT	3
192 #define MPTCP_RST_EWQ2BIG	4
193 #define MPTCP_RST_EBADPERF	5
194 #define MPTCP_RST_EMIDDLEBOX	6
195 
196 #endif /* _UAPI_MPTCP_H */
197