summaryrefslogtreecommitdiff
path: root/include/arch/x86_64/linux/mptcp.h
blob: a7dd1752a26e3f5c2bc33c07f0d8861cca6aa687 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
#ifndef _MPTCP_H
#define _MPTCP_H

#include <netinet/in.h> /* for sockaddr_in and sockaddr_in6	*/
#include <sys/socket.h> /* for struct sockaddr			*/

#include <linux/const.h>
#include <linux/types.h>
#include <linux/in.h>	  /* for sockaddr_in			*/
#include <linux/in6.h>	  /* for sockaddr_in6			*/
#include <linux/socket.h> /* for sockaddr_storage and sa_family	*/

#define MPTCP_SUBFLOW_FLAG_MCAP_REM	     _BITUL(0)
#define MPTCP_SUBFLOW_FLAG_MCAP_LOC	     _BITUL(1)
#define MPTCP_SUBFLOW_FLAG_JOIN_REM	     _BITUL(2)
#define MPTCP_SUBFLOW_FLAG_JOIN_LOC	     _BITUL(3)
#define MPTCP_SUBFLOW_FLAG_BKUP_REM	     _BITUL(4)
#define MPTCP_SUBFLOW_FLAG_BKUP_LOC	     _BITUL(5)
#define MPTCP_SUBFLOW_FLAG_FULLY_ESTABLISHED _BITUL(6)
#define MPTCP_SUBFLOW_FLAG_CONNECTED	     _BITUL(7)
#define MPTCP_SUBFLOW_FLAG_MAPVALID	     _BITUL(8)

#define MPTCP_PM_CMD_GRP_NAME "mptcp_pm_cmds"
#define MPTCP_PM_EV_GRP_NAME  "mptcp_pm_events"

#include <linux/mptcp_pm.h>

#define MPTCP_INFO_FLAG_FALLBACK	    _BITUL(0)
#define MPTCP_INFO_FLAG_REMOTE_KEY_RECEIVED _BITUL(1)

#define MPTCP_PM_EV_FLAG_DENY_JOIN_ID0 _BITUL(0)

#define MPTCP_PM_ADDR_FLAG_SIGNAL   (1 << 0)
#define MPTCP_PM_ADDR_FLAG_SUBFLOW  (1 << 1)
#define MPTCP_PM_ADDR_FLAG_BACKUP   (1 << 2)
#define MPTCP_PM_ADDR_FLAG_FULLMESH (1 << 3)
#define MPTCP_PM_ADDR_FLAG_IMPLICIT (1 << 4)

struct mptcp_info {
	__u8 mptcpi_subflows;
	__u8 mptcpi_add_addr_signal;
	__u8 mptcpi_add_addr_accepted;
	__u8 mptcpi_subflows_max;
	__u8 mptcpi_add_addr_signal_max;
	__u8 mptcpi_add_addr_accepted_max;
	__u32 mptcpi_flags;
	__u32 mptcpi_token;
	__u64 mptcpi_write_seq;
	__u64 mptcpi_snd_una;
	__u64 mptcpi_rcv_nxt;
	__u8 mptcpi_local_addr_used;
	__u8 mptcpi_local_addr_max;
	__u8 mptcpi_csum_enabled;
	__u32 mptcpi_retransmits;
	__u64 mptcpi_bytes_retrans;
	__u64 mptcpi_bytes_sent;
	__u64 mptcpi_bytes_received;
	__u64 mptcpi_bytes_acked;
	__u8 mptcpi_subflows_total;
	__u8 reserved[3];
	__u32 mptcpi_last_data_sent;
	__u32 mptcpi_last_data_recv;
	__u32 mptcpi_last_ack_recv;
};

/* MPTCP Reset reason codes, rfc8684 */
#define MPTCP_RST_EUNSPEC    0
#define MPTCP_RST_EMPTCP     1
#define MPTCP_RST_ERESOURCE  2
#define MPTCP_RST_EPROHIBIT  3
#define MPTCP_RST_EWQ2BIG    4
#define MPTCP_RST_EBADPERF   5
#define MPTCP_RST_EMIDDLEBOX 6

struct mptcp_subflow_data {
	__u32 size_subflow_data; /* size of this structure in userspace */
	__u32 num_subflows;	 /* must be 0, set by kernel */
	__u32 size_kernel;	 /* must be 0, set by kernel */
	__u32 size_user;	 /* size of one element in data[] */
} __attribute__((aligned(8)));

struct mptcp_subflow_addrs {
	union {
		__kernel_sa_family_t sa_family;
		struct sockaddr sa_local;
		struct sockaddr_in sin_local;
		struct sockaddr_in6 sin6_local;
		struct __kernel_sockaddr_storage ss_local;
	};
	union {
		struct sockaddr sa_remote;
		struct sockaddr_in sin_remote;
		struct sockaddr_in6 sin6_remote;
		struct __kernel_sockaddr_storage ss_remote;
	};
};

struct mptcp_subflow_info {
	__u32 id;
	struct mptcp_subflow_addrs addrs;
};

struct mptcp_full_info {
	__u32 size_tcpinfo_kernel; /* must be 0, set by kernel */
	__u32 size_tcpinfo_user;
	__u32 size_sfinfo_kernel; /* must be 0, set by kernel */
	__u32 size_sfinfo_user;
	__u32 num_subflows;	/* must be 0, set by kernel (real subflow count) */
	__u32 size_arrays_user; /* max subflows that userspace is interested in;
				 * the buffers at subflow_info/tcp_info
				 * are respectively at least:
				 *  size_arrays * size_sfinfo_user
				 *  size_arrays * size_tcpinfo_user
				 * bytes wide
				 */
	__aligned_u64 subflow_info;
	__aligned_u64 tcp_info;
	struct mptcp_info mptcp_info;
};

/* MPTCP socket options */
#define MPTCP_INFO	    1
#define MPTCP_TCPINFO	    2
#define MPTCP_SUBFLOW_ADDRS 3
#define MPTCP_FULL_INFO	    4

#endif /* _MPTCP_H */