]>
git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blob - include/net/mptcp.h
1 /* SPDX-License-Identifier: GPL-2.0 */
5 * Copyright (c) 2017 - 2019, Intel Corporation.
11 #include <linux/skbuff.h>
12 #include <linux/tcp.h>
13 #include <linux/types.h>
17 /* MPTCP sk_buff extension data */
33 struct mptcp_out_options
{
34 #if IS_ENABLED(CONFIG_MPTCP)
40 #if IS_ENABLED(CONFIG_MPTCP_IPV6)
41 struct in6_addr addr6
;
53 struct mptcp_ext ext_copy
;
59 void mptcp_init(void);
61 static inline bool sk_is_mptcp(const struct sock
*sk
)
63 return tcp_sk(sk
)->is_mptcp
;
66 static inline bool rsk_is_mptcp(const struct request_sock
*req
)
68 return tcp_rsk(req
)->is_mptcp
;
71 void mptcp_parse_option(const struct sk_buff
*skb
, const unsigned char *ptr
,
72 int opsize
, struct tcp_options_received
*opt_rx
);
73 bool mptcp_syn_options(struct sock
*sk
, const struct sk_buff
*skb
,
74 unsigned int *size
, struct mptcp_out_options
*opts
);
75 void mptcp_rcv_synsent(struct sock
*sk
);
76 bool mptcp_synack_options(const struct request_sock
*req
, unsigned int *size
,
77 struct mptcp_out_options
*opts
);
78 bool mptcp_established_options(struct sock
*sk
, struct sk_buff
*skb
,
79 unsigned int *size
, unsigned int remaining
,
80 struct mptcp_out_options
*opts
);
81 void mptcp_incoming_options(struct sock
*sk
, struct sk_buff
*skb
,
82 struct tcp_options_received
*opt_rx
);
84 void mptcp_write_options(__be32
*ptr
, struct mptcp_out_options
*opts
);
86 /* move the skb extension owership, with the assumption that 'to' is
89 static inline void mptcp_skb_ext_move(struct sk_buff
*to
,
92 if (!skb_ext_exist(from
, SKB_EXT_MPTCP
))
95 if (WARN_ON_ONCE(to
->active_extensions
))
98 to
->active_extensions
= from
->active_extensions
;
99 to
->extensions
= from
->extensions
;
100 from
->active_extensions
= 0;
103 static inline bool mptcp_ext_matches(const struct mptcp_ext
*to_ext
,
104 const struct mptcp_ext
*from_ext
)
106 /* MPTCP always clears the ext when adding it to the skb, so
107 * holes do not bother us here
110 (to_ext
&& from_ext
&&
111 !memcmp(from_ext
, to_ext
, sizeof(struct mptcp_ext
)));
114 /* check if skbs can be collapsed.
115 * MPTCP collapse is allowed if neither @to or @from carry an mptcp data
116 * mapping, or if the extension of @to is the same as @from.
117 * Collapsing is not possible if @to lacks an extension, but @from carries one.
119 static inline bool mptcp_skb_can_collapse(const struct sk_buff
*to
,
120 const struct sk_buff
*from
)
122 return mptcp_ext_matches(skb_ext_find(to
, SKB_EXT_MPTCP
),
123 skb_ext_find(from
, SKB_EXT_MPTCP
));
126 bool mptcp_sk_is_subflow(const struct sock
*sk
);
128 void mptcp_seq_show(struct seq_file
*seq
);
131 static inline void mptcp_init(void)
135 static inline bool sk_is_mptcp(const struct sock
*sk
)
140 static inline bool rsk_is_mptcp(const struct request_sock
*req
)
145 static inline void mptcp_parse_option(const struct sk_buff
*skb
,
146 const unsigned char *ptr
, int opsize
,
147 struct tcp_options_received
*opt_rx
)
151 static inline bool mptcp_syn_options(struct sock
*sk
, const struct sk_buff
*skb
,
153 struct mptcp_out_options
*opts
)
158 static inline void mptcp_rcv_synsent(struct sock
*sk
)
162 static inline bool mptcp_synack_options(const struct request_sock
*req
,
164 struct mptcp_out_options
*opts
)
169 static inline bool mptcp_established_options(struct sock
*sk
,
172 unsigned int remaining
,
173 struct mptcp_out_options
*opts
)
178 static inline void mptcp_incoming_options(struct sock
*sk
,
180 struct tcp_options_received
*opt_rx
)
184 static inline void mptcp_skb_ext_move(struct sk_buff
*to
,
185 const struct sk_buff
*from
)
189 static inline bool mptcp_skb_can_collapse(const struct sk_buff
*to
,
190 const struct sk_buff
*from
)
195 static inline bool mptcp_sk_is_subflow(const struct sock
*sk
)
200 static inline void mptcp_seq_show(struct seq_file
*seq
) { }
201 #endif /* CONFIG_MPTCP */
203 #if IS_ENABLED(CONFIG_MPTCP_IPV6)
204 int mptcpv6_init(void);
205 void mptcpv6_handle_mapped(struct sock
*sk
, bool mapped
);
206 #elif IS_ENABLED(CONFIG_IPV6)
207 static inline int mptcpv6_init(void) { return 0; }
208 static inline void mptcpv6_handle_mapped(struct sock
*sk
, bool mapped
) { }
211 #endif /* __NET_MPTCP_H */