* [RFC PATCH v3 01/10] net: Make sock protocol value checks more specific
2019-10-09 23:07 [RFC PATCH v3 00/10] Multipath TCP prerequisites Mat Martineau
@ 2019-10-09 23:08 ` Mat Martineau
2019-10-09 23:08 ` [RFC PATCH v3 02/10] sock: Make sk_protocol a 16-bit value Mat Martineau
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Mat Martineau @ 2019-10-09 23:08 UTC (permalink / raw)
To: netdev, edumazet
Cc: Mat Martineau, cpaasch, fw, pabeni, peter.krystad, dcaratti,
matthieu.baerts
SK_PROTOCOL_MAX is only used in two places, for DECNet and AX.25. The
limits have more to do with the those protocol definitions than they do
with the data type of sk_protocol, so remove SK_PROTOCOL_MAX and use
U8_MAX directly.
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
---
include/net/sock.h | 1 -
net/ax25/af_ax25.c | 2 +-
net/decnet/af_decnet.c | 2 +-
3 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/include/net/sock.h b/include/net/sock.h
index ab905c4b1f0e..f8f99925a3d0 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -459,7 +459,6 @@ struct sock {
sk_userlocks : 4,
sk_protocol : 8,
sk_type : 16;
-#define SK_PROTOCOL_MAX U8_MAX
u16 sk_gso_max_segs;
u8 sk_pacing_shift;
unsigned long sk_lingertime;
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index bb222b882b67..be5772f43816 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -808,7 +808,7 @@ static int ax25_create(struct net *net, struct socket *sock, int protocol,
struct sock *sk;
ax25_cb *ax25;
- if (protocol < 0 || protocol > SK_PROTOCOL_MAX)
+ if (protocol < 0 || protocol > U8_MAX)
return -EINVAL;
if (!net_eq(net, &init_net))
diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
index 0ea75286abf4..7c0c769a8b26 100644
--- a/net/decnet/af_decnet.c
+++ b/net/decnet/af_decnet.c
@@ -670,7 +670,7 @@ static int dn_create(struct net *net, struct socket *sock, int protocol,
{
struct sock *sk;
- if (protocol < 0 || protocol > SK_PROTOCOL_MAX)
+ if (protocol < 0 || protocol > U8_MAX)
return -EINVAL;
if (!net_eq(net, &init_net))
--
2.23.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [RFC PATCH v3 02/10] sock: Make sk_protocol a 16-bit value
2019-10-09 23:07 [RFC PATCH v3 00/10] Multipath TCP prerequisites Mat Martineau
2019-10-09 23:08 ` [RFC PATCH v3 01/10] net: Make sock protocol value checks more specific Mat Martineau
@ 2019-10-09 23:08 ` Mat Martineau
2019-10-09 23:08 ` [RFC PATCH v3 03/10] tcp: Define IPPROTO_MPTCP Mat Martineau
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Mat Martineau @ 2019-10-09 23:08 UTC (permalink / raw)
To: netdev, edumazet
Cc: Mat Martineau, cpaasch, fw, pabeni, peter.krystad, dcaratti,
matthieu.baerts
Match the 16-bit width of skbuff->protocol. Fills an 8-bit hole so
sizeof(struct sock) does not change.
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
---
include/net/sock.h | 4 ++--
include/trace/events/sock.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/net/sock.h b/include/net/sock.h
index f8f99925a3d0..4850c10461b8 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -457,10 +457,10 @@ struct sock {
sk_no_check_tx : 1,
sk_no_check_rx : 1,
sk_userlocks : 4,
- sk_protocol : 8,
+ sk_pacing_shift : 8,
sk_type : 16;
+ u16 sk_protocol;
u16 sk_gso_max_segs;
- u8 sk_pacing_shift;
unsigned long sk_lingertime;
struct proto *sk_prot_creator;
rwlock_t sk_callback_lock;
diff --git a/include/trace/events/sock.h b/include/trace/events/sock.h
index a0c4b8a30966..dc749c651318 100644
--- a/include/trace/events/sock.h
+++ b/include/trace/events/sock.h
@@ -147,7 +147,7 @@ TRACE_EVENT(inet_sock_set_state,
__field(__u16, sport)
__field(__u16, dport)
__field(__u16, family)
- __field(__u8, protocol)
+ __field(__u16, protocol)
__array(__u8, saddr, 4)
__array(__u8, daddr, 4)
__array(__u8, saddr_v6, 16)
--
2.23.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [RFC PATCH v3 03/10] tcp: Define IPPROTO_MPTCP
2019-10-09 23:07 [RFC PATCH v3 00/10] Multipath TCP prerequisites Mat Martineau
2019-10-09 23:08 ` [RFC PATCH v3 01/10] net: Make sock protocol value checks more specific Mat Martineau
2019-10-09 23:08 ` [RFC PATCH v3 02/10] sock: Make sk_protocol a 16-bit value Mat Martineau
@ 2019-10-09 23:08 ` Mat Martineau
2019-10-09 23:08 ` [RFC PATCH v3 04/10] tcp: Add MPTCP option number Mat Martineau
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Mat Martineau @ 2019-10-09 23:08 UTC (permalink / raw)
To: netdev, edumazet
Cc: Mat Martineau, cpaasch, fw, pabeni, peter.krystad, dcaratti,
matthieu.baerts
To open a MPTCP socket with socket(AF_INET, SOCK_STREAM, IPPROTO_MPTCP),
IPPROTO_MPTCP needs a value that differs from IPPROTO_TCP. The existing
IPPROTO numbers mostly map directly to IANA-specified protocol numbers.
MPTCP does not have a protocol number allocated because MPTCP packets
use the TCP protocol number. Use private number not used OTA.
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
---
include/trace/events/sock.h | 3 ++-
include/uapi/linux/in.h | 2 ++
tools/include/uapi/linux/in.h | 2 ++
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/trace/events/sock.h b/include/trace/events/sock.h
index dc749c651318..bfbcba315a12 100644
--- a/include/trace/events/sock.h
+++ b/include/trace/events/sock.h
@@ -19,7 +19,8 @@
#define inet_protocol_names \
EM(IPPROTO_TCP) \
EM(IPPROTO_DCCP) \
- EMe(IPPROTO_SCTP)
+ EM(IPPROTO_SCTP) \
+ EMe(IPPROTO_MPTCP)
#define tcp_state_names \
EM(TCP_ESTABLISHED) \
diff --git a/include/uapi/linux/in.h b/include/uapi/linux/in.h
index e7ad9d350a28..44df6dc1ff1d 100644
--- a/include/uapi/linux/in.h
+++ b/include/uapi/linux/in.h
@@ -76,6 +76,8 @@ enum {
#define IPPROTO_MPLS IPPROTO_MPLS
IPPROTO_RAW = 255, /* Raw IP packets */
#define IPPROTO_RAW IPPROTO_RAW
+ IPPROTO_MPTCP = 262, /* Multipath TCP connection */
+#define IPPROTO_MPTCP IPPROTO_MPTCP
IPPROTO_MAX
};
#endif
diff --git a/tools/include/uapi/linux/in.h b/tools/include/uapi/linux/in.h
index e7ad9d350a28..44df6dc1ff1d 100644
--- a/tools/include/uapi/linux/in.h
+++ b/tools/include/uapi/linux/in.h
@@ -76,6 +76,8 @@ enum {
#define IPPROTO_MPLS IPPROTO_MPLS
IPPROTO_RAW = 255, /* Raw IP packets */
#define IPPROTO_RAW IPPROTO_RAW
+ IPPROTO_MPTCP = 262, /* Multipath TCP connection */
+#define IPPROTO_MPTCP IPPROTO_MPTCP
IPPROTO_MAX
};
#endif
--
2.23.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [RFC PATCH v3 04/10] tcp: Add MPTCP option number
2019-10-09 23:07 [RFC PATCH v3 00/10] Multipath TCP prerequisites Mat Martineau
` (2 preceding siblings ...)
2019-10-09 23:08 ` [RFC PATCH v3 03/10] tcp: Define IPPROTO_MPTCP Mat Martineau
@ 2019-10-09 23:08 ` Mat Martineau
2019-10-09 23:08 ` [RFC PATCH v3 05/10] tcp, ulp: Add clone operation to tcp_ulp_ops Mat Martineau
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Mat Martineau @ 2019-10-09 23:08 UTC (permalink / raw)
To: netdev, edumazet
Cc: Mat Martineau, cpaasch, fw, pabeni, peter.krystad, dcaratti,
matthieu.baerts
TCP option 30 is allocated for MPTCP by the IANA.
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
---
include/net/tcp.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/net/tcp.h b/include/net/tcp.h
index c9a3f9688223..382e245a7909 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -182,6 +182,7 @@ void tcp_time_wait(struct sock *sk, int state, int timeo);
#define TCPOPT_SACK 5 /* SACK Block */
#define TCPOPT_TIMESTAMP 8 /* Better RTT estimations/PAWS */
#define TCPOPT_MD5SIG 19 /* MD5 Signature (RFC2385) */
+#define TCPOPT_MPTCP 30 /* Multipath TCP (RFC6824) */
#define TCPOPT_FASTOPEN 34 /* Fast open (RFC7413) */
#define TCPOPT_EXP 254 /* Experimental */
/* Magic number to be after the option value for sharing TCP
--
2.23.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [RFC PATCH v3 05/10] tcp, ulp: Add clone operation to tcp_ulp_ops
2019-10-09 23:07 [RFC PATCH v3 00/10] Multipath TCP prerequisites Mat Martineau
` (3 preceding siblings ...)
2019-10-09 23:08 ` [RFC PATCH v3 04/10] tcp: Add MPTCP option number Mat Martineau
@ 2019-10-09 23:08 ` Mat Martineau
2019-10-09 23:08 ` [RFC PATCH v3 06/10] mptcp: Add MPTCP to skb extensions Mat Martineau
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Mat Martineau @ 2019-10-09 23:08 UTC (permalink / raw)
To: netdev, edumazet
Cc: Mat Martineau, cpaasch, fw, pabeni, peter.krystad, dcaratti,
matthieu.baerts
If ULP is used on a listening socket, icsk_ulp_ops and icsk_ulp_data are
copied when the listener is cloned. Sometimes the clone is immediately
deleted, which will invoke the release op on the clone and likely
corrupt the listening socket's icsk_ulp_data.
The clone operation is invoked immediately after the clone is copied and
gives the ULP type an opportunity to set up the clone socket and its
icsk_ulp_data.
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
---
include/net/tcp.h | 5 +++++
net/ipv4/inet_connection_sock.c | 2 ++
net/ipv4/tcp_ulp.c | 12 ++++++++++++
3 files changed, 19 insertions(+)
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 382e245a7909..16c9f21243ca 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -2126,6 +2126,9 @@ struct tcp_ulp_ops {
/* diagnostic */
int (*get_info)(const struct sock *sk, struct sk_buff *skb);
size_t (*get_info_size)(const struct sock *sk);
+ /* clone ulp */
+ void (*clone)(const struct request_sock *req, struct sock *newsk,
+ const gfp_t priority);
char name[TCP_ULP_NAME_MAX];
struct module *owner;
@@ -2136,6 +2139,8 @@ int tcp_set_ulp(struct sock *sk, const char *name);
void tcp_get_available_ulp(char *buf, size_t len);
void tcp_cleanup_ulp(struct sock *sk);
void tcp_update_ulp(struct sock *sk, struct proto *p);
+void tcp_clone_ulp(const struct request_sock *req,
+ struct sock *newsk, const gfp_t priority);
#define MODULE_ALIAS_TCP_ULP(name) \
__MODULE_INFO(alias, alias_userspace, name); \
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index a9183543ca30..64857672e0b5 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -810,6 +810,8 @@ struct sock *inet_csk_clone_lock(const struct sock *sk,
/* Deinitialize accept_queue to trap illegal accesses. */
memset(&newicsk->icsk_accept_queue, 0, sizeof(newicsk->icsk_accept_queue));
+ tcp_clone_ulp(req, newsk, priority);
+
security_inet_csk_clone(newsk, req);
}
return newsk;
diff --git a/net/ipv4/tcp_ulp.c b/net/ipv4/tcp_ulp.c
index 4849edb62d52..27f949846450 100644
--- a/net/ipv4/tcp_ulp.c
+++ b/net/ipv4/tcp_ulp.c
@@ -127,6 +127,18 @@ void tcp_cleanup_ulp(struct sock *sk)
icsk->icsk_ulp_ops = NULL;
}
+void tcp_clone_ulp(const struct request_sock *req, struct sock *newsk,
+ const gfp_t priority)
+{
+ struct inet_connection_sock *icsk = inet_csk(newsk);
+
+ if (!icsk->icsk_ulp_ops)
+ return;
+
+ if (icsk->icsk_ulp_ops->clone)
+ icsk->icsk_ulp_ops->clone(req, newsk, priority);
+}
+
static int __tcp_set_ulp(struct sock *sk, const struct tcp_ulp_ops *ulp_ops)
{
struct inet_connection_sock *icsk = inet_csk(sk);
--
2.23.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [RFC PATCH v3 06/10] mptcp: Add MPTCP to skb extensions
2019-10-09 23:07 [RFC PATCH v3 00/10] Multipath TCP prerequisites Mat Martineau
` (4 preceding siblings ...)
2019-10-09 23:08 ` [RFC PATCH v3 05/10] tcp, ulp: Add clone operation to tcp_ulp_ops Mat Martineau
@ 2019-10-09 23:08 ` Mat Martineau
2019-10-09 23:08 ` [RFC PATCH v3 07/10] tcp: Prevent coalesce/collapse when skb has MPTCP extensions Mat Martineau
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Mat Martineau @ 2019-10-09 23:08 UTC (permalink / raw)
To: netdev, edumazet
Cc: Mat Martineau, cpaasch, fw, pabeni, peter.krystad, dcaratti,
matthieu.baerts
Add enum value for MPTCP and update config dependencies
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
include/linux/skbuff.h | 3 +++
include/net/mptcp.h | 27 +++++++++++++++++++++++++++
net/core/skbuff.c | 7 +++++++
3 files changed, 37 insertions(+)
create mode 100644 include/net/mptcp.h
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 0a58402a166e..618ee4b3ab7f 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -4068,6 +4068,9 @@ enum skb_ext_id {
#endif
#if IS_ENABLED(CONFIG_NET_TC_SKB_EXT)
TC_SKB_EXT,
+#endif
+#if IS_ENABLED(CONFIG_MPTCP)
+ SKB_EXT_MPTCP,
#endif
SKB_EXT_NUM, /* must be last */
};
diff --git a/include/net/mptcp.h b/include/net/mptcp.h
new file mode 100644
index 000000000000..f9f668ac4339
--- /dev/null
+++ b/include/net/mptcp.h
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Multipath TCP
+ *
+ * Copyright (c) 2017 - 2019, Intel Corporation.
+ */
+
+#ifndef __NET_MPTCP_H
+#define __NET_MPTCP_H
+
+#include <linux/types.h>
+
+/* MPTCP sk_buff extension data */
+struct mptcp_ext {
+ u64 data_ack;
+ u64 data_seq;
+ u32 subflow_seq;
+ u16 data_len;
+ u8 use_map:1,
+ dsn64:1,
+ data_fin:1,
+ use_ack:1,
+ ack64:1,
+ __unused:2;
+};
+
+#endif /* __NET_MPTCP_H */
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 529133611ea2..b2dc326f748b 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -68,6 +68,7 @@
#include <net/ip6_checksum.h>
#include <net/xfrm.h>
#include <net/mpls.h>
+#include <net/mptcp.h>
#include <linux/uaccess.h>
#include <trace/events/skb.h>
@@ -4109,6 +4110,9 @@ static const u8 skb_ext_type_len[] = {
#if IS_ENABLED(CONFIG_NET_TC_SKB_EXT)
[TC_SKB_EXT] = SKB_EXT_CHUNKSIZEOF(struct tc_skb_ext),
#endif
+#if IS_ENABLED(CONFIG_MPTCP)
+ [SKB_EXT_MPTCP] = SKB_EXT_CHUNKSIZEOF(struct mptcp_ext),
+#endif
};
static __always_inline unsigned int skb_ext_total_length(void)
@@ -4122,6 +4126,9 @@ static __always_inline unsigned int skb_ext_total_length(void)
#endif
#if IS_ENABLED(CONFIG_NET_TC_SKB_EXT)
skb_ext_type_len[TC_SKB_EXT] +
+#endif
+#if IS_ENABLED(CONFIG_MPTCP)
+ skb_ext_type_len[SKB_EXT_MPTCP] +
#endif
0;
}
--
2.23.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [RFC PATCH v3 07/10] tcp: Prevent coalesce/collapse when skb has MPTCP extensions
2019-10-09 23:07 [RFC PATCH v3 00/10] Multipath TCP prerequisites Mat Martineau
` (5 preceding siblings ...)
2019-10-09 23:08 ` [RFC PATCH v3 06/10] mptcp: Add MPTCP to skb extensions Mat Martineau
@ 2019-10-09 23:08 ` Mat Martineau
2019-10-09 23:08 ` [RFC PATCH v3 08/10] tcp: Export TCP functions and ops struct Mat Martineau
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Mat Martineau @ 2019-10-09 23:08 UTC (permalink / raw)
To: netdev, edumazet
Cc: Mat Martineau, cpaasch, fw, pabeni, peter.krystad, dcaratti,
matthieu.baerts
The MPTCP extension data needs to be preserved as it passes through the
TCP stack. Make sure that these skbs are not appended to others during
coalesce or collapse, so the data remains associated with the payload of
the given skb.
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
---
include/net/mptcp.h | 16 ++++++++++++++++
include/net/tcp.h | 8 ++++++++
net/ipv4/tcp_input.c | 10 ++++++++--
net/ipv4/tcp_output.c | 2 +-
4 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/include/net/mptcp.h b/include/net/mptcp.h
index f9f668ac4339..43ddfdf9e4a3 100644
--- a/include/net/mptcp.h
+++ b/include/net/mptcp.h
@@ -8,6 +8,7 @@
#ifndef __NET_MPTCP_H
#define __NET_MPTCP_H
+#include <linux/skbuff.h>
#include <linux/types.h>
/* MPTCP sk_buff extension data */
@@ -24,4 +25,19 @@ struct mptcp_ext {
__unused:2;
};
+#ifdef CONFIG_MPTCP
+
+static inline bool mptcp_skb_ext_exist(const struct sk_buff *skb)
+{
+ return skb_ext_exist(skb, SKB_EXT_MPTCP);
+}
+
+#else
+
+static inline bool mptcp_skb_ext_exist(const struct sk_buff *skb)
+{
+ return false;
+}
+
+#endif /* CONFIG_MPTCP */
#endif /* __NET_MPTCP_H */
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 16c9f21243ca..414fe1749c0f 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -39,6 +39,7 @@
#include <net/tcp_states.h>
#include <net/inet_ecn.h>
#include <net/dst.h>
+#include <net/mptcp.h>
#include <linux/seq_file.h>
#include <linux/memcontrol.h>
@@ -961,6 +962,13 @@ static inline bool tcp_skb_can_collapse_to(const struct sk_buff *skb)
return likely(!TCP_SKB_CB(skb)->eor);
}
+static inline bool tcp_skb_can_collapse(const struct sk_buff *to,
+ const struct sk_buff *from)
+{
+ return likely(tcp_skb_can_collapse_to(to) &&
+ !mptcp_skb_ext_exist(from));
+}
+
/* Events passed to congestion control interface */
enum tcp_ca_event {
CA_EVENT_TX_START, /* first transmit when no packets in flight */
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 3578357abe30..e3870479c429 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -1420,7 +1420,7 @@ static struct sk_buff *tcp_shift_skb_data(struct sock *sk, struct sk_buff *skb,
if ((TCP_SKB_CB(prev)->sacked & TCPCB_TAGBITS) != TCPCB_SACKED_ACKED)
goto fallback;
- if (!tcp_skb_can_collapse_to(prev))
+ if (!tcp_skb_can_collapse(prev, skb))
goto fallback;
in_sack = !after(start_seq, TCP_SKB_CB(skb)->seq) &&
@@ -4418,6 +4418,9 @@ static bool tcp_try_coalesce(struct sock *sk,
if (TCP_SKB_CB(from)->seq != TCP_SKB_CB(to)->end_seq)
return false;
+ if (mptcp_skb_ext_exist(from))
+ return false;
+
#ifdef CONFIG_TLS_DEVICE
if (from->decrypted != to->decrypted)
return false;
@@ -4926,10 +4929,12 @@ tcp_collapse(struct sock *sk, struct sk_buff_head *list, struct rb_root *root,
/* The first skb to collapse is:
* - not SYN/FIN and
+ * - does not include a MPTCP skb extension
* - bloated or contains data before "start" or
* overlaps to the next one.
*/
if (!(TCP_SKB_CB(skb)->tcp_flags & (TCPHDR_SYN | TCPHDR_FIN)) &&
+ !mptcp_skb_ext_exist(skb) &&
(tcp_win_from_space(sk, skb->truesize) > skb->len ||
before(TCP_SKB_CB(skb)->seq, start))) {
end_of_skbs = false;
@@ -4945,7 +4950,7 @@ tcp_collapse(struct sock *sk, struct sk_buff_head *list, struct rb_root *root,
/* Decided to skip this, advance start seq. */
start = TCP_SKB_CB(skb)->end_seq;
}
- if (end_of_skbs ||
+ if (end_of_skbs || mptcp_skb_ext_exist(skb) ||
(TCP_SKB_CB(skb)->tcp_flags & (TCPHDR_SYN | TCPHDR_FIN)))
return;
@@ -4988,6 +4993,7 @@ tcp_collapse(struct sock *sk, struct sk_buff_head *list, struct rb_root *root,
skb = tcp_collapse_one(sk, skb, list, root);
if (!skb ||
skb == tail ||
+ mptcp_skb_ext_exist(skb) ||
(TCP_SKB_CB(skb)->tcp_flags & (TCPHDR_SYN | TCPHDR_FIN)))
goto end;
#ifdef CONFIG_TLS_DEVICE
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index fec6d67bfd14..8469a109f0aa 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2853,7 +2853,7 @@ static void tcp_retrans_try_collapse(struct sock *sk, struct sk_buff *to,
if (!tcp_can_collapse(sk, skb))
break;
- if (!tcp_skb_can_collapse_to(to))
+ if (!tcp_skb_can_collapse(to, skb))
break;
space -= skb->len;
--
2.23.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [RFC PATCH v3 08/10] tcp: Export TCP functions and ops struct
2019-10-09 23:07 [RFC PATCH v3 00/10] Multipath TCP prerequisites Mat Martineau
` (6 preceding siblings ...)
2019-10-09 23:08 ` [RFC PATCH v3 07/10] tcp: Prevent coalesce/collapse when skb has MPTCP extensions Mat Martineau
@ 2019-10-09 23:08 ` Mat Martineau
2019-10-09 23:08 ` [RFC PATCH v3 09/10] tcp: Check for filled TCP option space before SACK Mat Martineau
2019-10-09 23:08 ` [RFC PATCH v3 10/10] tcp: clean ext on tx recycle Mat Martineau
9 siblings, 0 replies; 11+ messages in thread
From: Mat Martineau @ 2019-10-09 23:08 UTC (permalink / raw)
To: netdev, edumazet
Cc: Mat Martineau, cpaasch, fw, pabeni, peter.krystad, dcaratti,
matthieu.baerts
MPTCP will make use of tcp_send_mss() and tcp_push() when sending
data to specific TCP subflows.
tcp_request_sock_ipv4_ops will be referenced during TCP subflow
creation.
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: Peter Krystad <peter.krystad@linux.intel.com>
---
include/net/tcp.h | 5 +++++
net/ipv4/tcp.c | 6 +++---
net/ipv4/tcp_ipv4.c | 2 +-
3 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 414fe1749c0f..7f254765074f 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -330,6 +330,9 @@ int tcp_sendpage_locked(struct sock *sk, struct page *page, int offset,
size_t size, int flags);
ssize_t do_tcp_sendpages(struct sock *sk, struct page *page, int offset,
size_t size, int flags);
+int tcp_send_mss(struct sock *sk, int *size_goal, int flags);
+void tcp_push(struct sock *sk, int flags, int mss_now, int nonagle,
+ int size_goal);
void tcp_release_cb(struct sock *sk);
void tcp_wfree(struct sk_buff *skb);
void tcp_write_timer_handler(struct sock *sk);
@@ -1983,6 +1986,8 @@ struct tcp_request_sock_ops {
enum tcp_synack_type synack_type);
};
+extern const struct tcp_request_sock_ops tcp_request_sock_ipv4_ops;
+
#ifdef CONFIG_SYN_COOKIES
static inline __u32 cookie_init_sequence(const struct tcp_request_sock_ops *ops,
const struct sock *sk, struct sk_buff *skb,
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index f98a1882e537..f273ff308b87 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -690,8 +690,8 @@ static bool tcp_should_autocork(struct sock *sk, struct sk_buff *skb,
refcount_read(&sk->sk_wmem_alloc) > skb->truesize;
}
-static void tcp_push(struct sock *sk, int flags, int mss_now,
- int nonagle, int size_goal)
+void tcp_push(struct sock *sk, int flags, int mss_now,
+ int nonagle, int size_goal)
{
struct tcp_sock *tp = tcp_sk(sk);
struct sk_buff *skb;
@@ -925,7 +925,7 @@ static unsigned int tcp_xmit_size_goal(struct sock *sk, u32 mss_now,
return max(size_goal, mss_now);
}
-static int tcp_send_mss(struct sock *sk, int *size_goal, int flags)
+int tcp_send_mss(struct sock *sk, int *size_goal, int flags)
{
int mss_now;
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 5cb0e7f065ea..ea926e4c13f1 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1369,7 +1369,7 @@ struct request_sock_ops tcp_request_sock_ops __read_mostly = {
.syn_ack_timeout = tcp_syn_ack_timeout,
};
-static const struct tcp_request_sock_ops tcp_request_sock_ipv4_ops = {
+const struct tcp_request_sock_ops tcp_request_sock_ipv4_ops = {
.mss_clamp = TCP_MSS_DEFAULT,
#ifdef CONFIG_TCP_MD5SIG
.req_md5_lookup = tcp_v4_md5_lookup,
--
2.23.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [RFC PATCH v3 09/10] tcp: Check for filled TCP option space before SACK
2019-10-09 23:07 [RFC PATCH v3 00/10] Multipath TCP prerequisites Mat Martineau
` (7 preceding siblings ...)
2019-10-09 23:08 ` [RFC PATCH v3 08/10] tcp: Export TCP functions and ops struct Mat Martineau
@ 2019-10-09 23:08 ` Mat Martineau
2019-10-09 23:08 ` [RFC PATCH v3 10/10] tcp: clean ext on tx recycle Mat Martineau
9 siblings, 0 replies; 11+ messages in thread
From: Mat Martineau @ 2019-10-09 23:08 UTC (permalink / raw)
To: netdev, edumazet
Cc: Mat Martineau, cpaasch, fw, pabeni, peter.krystad, dcaratti,
matthieu.baerts
The SACK code would potentially add four bytes to the expected
TCP option size even if all option space was already used.
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
---
net/ipv4/tcp_output.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 8469a109f0aa..512e521101e1 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -748,6 +748,9 @@ static unsigned int tcp_established_options(struct sock *sk, struct sk_buff *skb
size += TCPOLEN_TSTAMP_ALIGNED;
}
+ if (size + TCPOLEN_SACK_BASE_ALIGNED >= MAX_TCP_OPTION_SPACE)
+ return size;
+
eff_sacks = tp->rx_opt.num_sacks + tp->rx_opt.dsack;
if (unlikely(eff_sacks)) {
const unsigned int remaining = MAX_TCP_OPTION_SPACE - size;
--
2.23.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [RFC PATCH v3 10/10] tcp: clean ext on tx recycle
2019-10-09 23:07 [RFC PATCH v3 00/10] Multipath TCP prerequisites Mat Martineau
` (8 preceding siblings ...)
2019-10-09 23:08 ` [RFC PATCH v3 09/10] tcp: Check for filled TCP option space before SACK Mat Martineau
@ 2019-10-09 23:08 ` Mat Martineau
9 siblings, 0 replies; 11+ messages in thread
From: Mat Martineau @ 2019-10-09 23:08 UTC (permalink / raw)
To: netdev, edumazet
Cc: Paolo Abeni, cpaasch, fw, peter.krystad, dcaratti, matthieu.baerts
From: Paolo Abeni <pabeni@redhat.com>
Otherwise we will find stray/unexpected/old extensions
value on next iteration.
On tcp_write_xmit() we can end-up splitting an already queued
skb in two parts, via tso_fragment(). The newly created skb
can be allocated via the tx cache and the mptcp stack will not
be aware of it, so nobody set properly the MPTCP ext.
End result, we transmit the skb using an hold MPTCP DSS map
and that confuses the rx side/corrupt the stream. It requires
some concurrent conditions, so it's not deterministic.
Resetting the ext on recycle fixes all the current mptcp self tests
issues.
Apparently only MPTCP has issues with this kind of stray ext,
so an alternative would be add an additional mptcp hook in
tso_fragment() or in sk_stream_alloc_skb() to always init
the ext.
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
include/net/sock.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/net/sock.h b/include/net/sock.h
index 4850c10461b8..84ea0efe7952 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1470,6 +1470,7 @@ static inline void sk_wmem_free_skb(struct sock *sk, struct sk_buff *skb)
sk_mem_uncharge(sk, skb->truesize);
if (static_branch_unlikely(&tcp_tx_skb_cache_key) &&
!sk->sk_tx_skb_cache && !skb_cloned(skb)) {
+ skb_ext_reset(skb);
skb_zcopy_clear(skb, true);
sk->sk_tx_skb_cache = skb;
return;
--
2.23.0
^ permalink raw reply related [flat|nested] 11+ messages in thread