Multipath TCP: Prerequisites
Subsystems (6)
v3 cover Multipath TCP: Prerequisites
v2 -> v3: Ensure sk_type alignment in struct sock (patch 2)
v1 -> v2: sk_pacing_shift left as a regular struct member (patch 2), and modified SACK space check based on recent -net fix (patch 9).
The MPTCP upstreaming community has been collaborating on an upstreamable MPTCP implementation that complies with RFC 8684. A minimal set of features to comply with the specification involves a sizeable set of code changes, so David requested that we split this work in to multiple, smaller patch sets to build up MPTCP infrastructure.
The minimal MPTCP feature set we are proposing for review in the v5.6 timeframe begins with these three parts:
Part 1 (this patch set): MPTCP prerequisites. Introduce some MPTCP definitions, additional ULP and skb extension features, TCP option space checking, and a few exported symbols.
Part 2: Single subflow implementation and self tests.
Part 3: Switch from MPTCP v0 (RFC 6824) to MPTCP v1 (new RFC 8684, publication expected in the next few days).
We plan to send those over the next week. Additional patches for multiple subflow support, path management, active backup, and other features are in the pipeline for submission after making progress with the above reviews.
Clone/fetch:
https://github.com/multipath-tcp/mptcp_net-next.git (tag: netdev-v3-part1)
Browse:
https://github.com/multipath-tcp/mptcp_net-next/tree/netdev-v3-part1
Thank you for your review. You can find us at mptcp(a)lists.01.org and
https://is.gd/mptcp_upstream
Mat Martineau (9):
net: Make sock protocol value checks more specific
sock: Make sk_protocol a 16-bit value
tcp: Define IPPROTO_MPTCP
tcp: Add MPTCP option number
tcp, ulp: Add clone operation to tcp_ulp_ops
mptcp: Add MPTCP to skb extensions
tcp: Prevent coalesce/collapse when skb has MPTCP extensions
tcp: Export TCP functions and ops struct
tcp: Check for filled TCP option space before SACK
Paolo Abeni (2):
tcp: clean ext on tx recycle
skb: add helpers to allocate ext independently from sk_buff
MAINTAINERS | 10 ++++++++ include/linux/skbuff.h | 6 +++++ include/net/mptcp.h | 43 +++++++++++++++++++++++++++++++++ include/net/sock.h | 12 ++++----- include/net/tcp.h | 22 +++++++++++++++++ include/trace/events/sock.h | 5 ++-- include/uapi/linux/in.h | 2 ++ net/ax25/af_ax25.c | 2 +- net/core/skbuff.c | 42 ++++++++++++++++++++++++++++++-- net/decnet/af_decnet.c | 2 +- net/ipv4/inet_connection_sock.c | 2 ++ net/ipv4/tcp.c | 6 ++--- net/ipv4/tcp_input.c | 10 ++++++-- net/ipv4/tcp_ipv4.c | 2 +- net/ipv4/tcp_output.c | 12 ++++++--- net/ipv4/tcp_ulp.c | 12 +++++++++ net/ipv6/tcp_ipv6.c | 6 ++--- tools/include/uapi/linux/in.h | 2 ++ 18 files changed, 173 insertions(+), 25 deletions(-) create mode 100644 include/net/mptcp.h
Signature · 1 line
2.24.1
PATCH v3 1/11 net: Make sock protocol value checks more specific
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.
--- include/net/sock.h | 1 - net/ax25/af_ax25.c | 2 +- net/decnet/af_decnet.c | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-)
include/net/sock.h +0 -1
@@ -458,7 +458,6 @@ struct sock { sk_userlocks : 4, sk_protocol : 8, sk_type : 16; -#define SK_PROTOCOL_MAX U8_MAXu16 sk_gso_max_segs;u8 sk_pacing_shift;unsigned long sk_lingertime;
net/ax25/af_ax25.c +1 -1
@@ -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))
net/decnet/af_decnet.c +1 -1
@@ -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))
Signature · 1 line
2.24.1
PATCH v3 2/11 sock: Make sk_protocol a 16-bit value
In reply to Mat MartineauMatch the 16-bit width of skbuff->protocol. Fills an 8-bit hole so sizeof(struct sock) does not change.
v2 -> v3:
- keep 'sk_type' 2 bytes aligned (Eric)
v1 -> v2:
- preserve sk_pacing_shift as bit field (Eric)
--- include/net/sock.h | 10 +++++----- include/trace/events/sock.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-)
include/net/sock.h +5 -5
@@ -451,15 +451,15 @@ struct sock {#define SK_FL_TYPE_MASK 0xffff0000#endif - unsigned int sk_padding : 1, + u8 sk_padding : 1, sk_kern_sock : 1, sk_no_check_tx : 1, sk_no_check_rx : 1, - sk_userlocks : 4, - sk_protocol : 8, - sk_type : 16; -u16 sk_gso_max_segs; + sk_userlocks : 4;u8 sk_pacing_shift; +u16 sk_type; +u16 sk_protocol; +u16 sk_gso_max_segs;unsigned long sk_lingertime;struct proto *sk_prot_creator;rwlock_t sk_callback_lock;
include/trace/events/sock.h +1 -1
@@ -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 )
Signature · 1 line
2.24.1
PATCH v3 3/11 tcp: Define IPPROTO_MPTCP
In reply to Mat MartineauTo 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.
--- 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(-)
include/trace/events/sock.h +2 -1
@@ -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) \
include/uapi/linux/in.h +2 -0
@@ -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_MPTCPIPPROTO_MAX };#endif
tools/include/uapi/linux/in.h +2 -0
@@ -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_MPTCPIPPROTO_MAX };#endif
Signature · 1 line
2.24.1
PATCH v3 4/11 tcp: Add MPTCP option number
In reply to Mat MartineauTCP option 30 is allocated for MPTCP by the IANA.
--- include/net/tcp.h | 1 + 1 file changed, 1 insertion(+)
include/net/tcp.h +1 -0
@@ -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
Signature · 1 line
2.24.1
PATCH v3 5/11 tcp, ulp: Add clone operation to tcp_ulp_ops
In reply to Mat MartineauIf 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.
--- include/net/tcp.h | 5 +++++ net/ipv4/inet_connection_sock.c | 2 ++ net/ipv4/tcp_ulp.c | 12 ++++++++++++ 3 files changed, 19 insertions(+)
include/net/tcp.h +5 -0
@@ -2145,6 +2145,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;
@@ -2155,6 +2158,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); \
net/ipv4/inet_connection_sock.c +2 -0
@@ -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;
net/ipv4/tcp_ulp.c +12 -0
@@ -130,6 +130,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);
Signature · 1 line
2.24.1
PATCH v3 6/11 mptcp: Add MPTCP to skb extensions
In reply to Mat MartineauAdd enum value for MPTCP and update config dependencies
--- MAINTAINERS | 10 ++++++++++ include/linux/skbuff.h | 3 +++ include/net/mptcp.h | 27 +++++++++++++++++++++++++++ net/core/skbuff.c | 7 +++++++ 4 files changed, 47 insertions(+) create mode 100644 include/net/mptcp.h
MAINTAINERS +10 -0
@@ -11568,6 +11568,16 @@ F: net/ipv6/calipso.c F: net/netfilter/xt_CONNSECMARK.c F: net/netfilter/xt_SECMARK.c +NETWORKING [MPTCP] +M: Mat Martineau <mathew.j.martineau(a)linux.intel.com> +M: Matthieu Baerts <matthieu.baerts(a)tessares.net> +L: netdev(a)vger.kernel.org +L: mptcp(a)lists.01.org +W: https://github.com/multipath-tcp/mptcp_net-next/wiki +B: https://github.com/multipath-tcp/mptcp_net-next/issues +S: Maintained +F: include/net/mptcp.h + NETWORKING [TCP] M: Eric Dumazet <edumazet(a)google.com> L: netdev(a)vger.kernel.org
include/linux/skbuff.h +3 -0
@@ -4091,6 +4091,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 */ };
include/net/mptcp.h new file +27 -0
@@ -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 */
net/core/skbuff.c +7 -0
@@ -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 ; }
Signature · 1 line
2.24.1
PATCH v3 7/11 tcp: Prevent coalesce/collapse when skb has MPTCP extensions
In reply to Mat MartineauThe 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.
--- 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(-)
include/net/mptcp.h +16 -0
@@ -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 */
include/net/tcp.h +8 -0
@@ -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>
@@ -978,6 +979,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 */
net/ipv4/tcp_input.c +8 -2
@@ -1422,7 +1422,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) &&
@@ -4420,6 +4420,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;
@@ -4928,10 +4931,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;
@@ -4947,7 +4952,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 ;
@@ -4990,6 +4995,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
net/ipv4/tcp_output.c +1 -1
@@ -2854,7 +2854,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;
Signature · 1 line
2.24.1
PATCH v3 8/11 tcp: Export TCP functions and ops struct
In reply to Mat MartineauMPTCP will make use of tcp_send_mss() and tcp_push() when sending data to specific TCP subflows.
tcp_request_sock_ipvX_ops and ipvX_specific will be referenced during TCP subflow creation.
--- include/net/tcp.h | 8 ++++++++ net/ipv4/tcp.c | 6 +++--- net/ipv4/tcp_ipv4.c | 2 +- net/ipv6/tcp_ipv6.c | 6 +++--- 4 files changed, 15 insertions(+), 7 deletions(-)
include/net/tcp.h +8 -0
@@ -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);
@@ -2002,6 +2005,11 @@ struct tcp_request_sock_ops { enum tcp_synack_type synack_type); }; +extern const struct tcp_request_sock_ops tcp_request_sock_ipv4_ops; +#if IS_ENABLED (CONFIG_IPV6 ) +extern const struct tcp_request_sock_ops tcp_request_sock_ipv6_ops; +#endif +#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,
net/ipv4/tcp.c +3 -3
@@ -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;
net/ipv4/tcp_ipv4.c +1 -1
@@ -1372,7 +1372,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,
net/ipv6/tcp_ipv6.c +3 -3
@@ -75,7 +75,7 @@ static void tcp_v6_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb,static int tcp_v6_do_rcv (struct sock *sk,struct sk_buff *skb);static const struct inet_connection_sock_af_ops ipv6_mapped; -static const struct inet_connection_sock_af_ops ipv6_specific; +const struct inet_connection_sock_af_ops ipv6_specific;#ifdef CONFIG_TCP_MD5SIG static const struct tcp_sock_af_ops tcp_sock_ipv6_specific;static const struct tcp_sock_af_ops tcp_sock_ipv6_mapped_specific;
@@ -785,7 +785,7 @@ struct request_sock_ops tcp6_request_sock_ops __read_mostly = { .syn_ack_timeout = tcp_syn_ack_timeout, }; -static const struct tcp_request_sock_ops tcp_request_sock_ipv6_ops = { +const struct tcp_request_sock_ops tcp_request_sock_ipv6_ops = { .mss_clamp =IPV6_MIN_MTU -sizeof (struct tcphdr ) -sizeof (struct ipv6hdr ), #ifdef CONFIG_TCP_MD5SIG
@@ -1739,7 +1739,7 @@ static struct timewait_sock_ops tcp6_timewait_sock_ops = { .twsk_destructor = tcp_twsk_destructor, }; -static const struct inet_connection_sock_af_ops ipv6_specific = { +const struct inet_connection_sock_af_ops ipv6_specific = { .queue_xmit = inet6_csk_xmit, .send_check = tcp_v6_send_check, .rebuild_header = inet6_sk_rebuild_header,
Signature · 1 line
2.24.1
PATCH v3 9/11 tcp: Check for filled TCP option space before SACK
In reply to Mat MartineauUpdate the SACK check to work with zero option space available, a case that's possible with MPTCP but not MD5+TS. Maintained only one conditional branch for insufficient SACK space.
v1 -> v2:
- Moves the check inside the SACK branch by taking recent SACK fix:
9424e2e7ad93 (tcp: md5: fix potential overestimation of TCP option space)
in to account, but modifies it to work in MPTCP scenarios beyond the MD5+TS corner case.
--- net/ipv4/tcp_output.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
net/ipv4/tcp_output.c +7 -3
@@ -751,13 +751,17 @@ static unsigned int tcp_established_options(struct sock *sk, struct sk_buff *skb eff_sacks = tp->rx_opt.num_sacks + tp->rx_opt.dsack;if (unlikely (eff_sacks)) {const unsigned int remaining =MAX_TCP_OPTION_SPACE - size; +if (unlikely (remaining <TCPOLEN_SACK_BASE_ALIGNED + +TCPOLEN_SACK_PERBLOCK )) +return size; + opts->num_sack_blocks = min_t(unsigned int, eff_sacks, (remaining -TCPOLEN_SACK_BASE_ALIGNED ) /TCPOLEN_SACK_PERBLOCK ); -if (likely (opts->num_sack_blocks)) - size +=TCPOLEN_SACK_BASE_ALIGNED + - opts->num_sack_blocks *TCPOLEN_SACK_PERBLOCK ; + + size +=TCPOLEN_SACK_BASE_ALIGNED + + opts->num_sack_blocks *TCPOLEN_SACK_PERBLOCK ; }return size;
Signature · 1 line
2.24.1
PATCH v3 10/11 tcp: clean ext on tx recycle
In reply to Mat MartineauFrom: Paolo Abeni <pabeni(a)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 an upper layer will not be aware of it, so that upper layer cannot set the ext properly.
Resetting the ext on recycle ensures that stale data is not propagated in to packet headers or elsewhere.
An alternative would be add an additional hook in tso_fragment() or in sk_stream_alloc_skb() to init the ext for upper layers that need it.
--- include/net/sock.h | 1 + 1 file changed, 1 insertion(+)
include/net/sock.h +1 -0
@@ -1474,6 +1474,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 ;
Signature · 1 line
2.24.1
PATCH v3 11/11 skb: add helpers to allocate ext independently from sk_buff
In reply to Mat MartineauFrom: Paolo Abeni <pabeni(a)redhat.com>
Currently we can allocate the extension only after the skb, this change allows the user to do the opposite, will simplify allocation failure handling from MPTCP.
--- include/linux/skbuff.h | 3 +++ net/core/skbuff.c | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-)
include/linux/skbuff.h +3 -0
@@ -4115,6 +4115,9 @@ struct skb_ext {char data[0 ]__aligned(8) ; }; +struct skb_ext *__skb_ext_alloc (void ); +void *__skb_ext_set (struct sk_buff *skb,enum skb_ext_id id, +struct skb_ext *ext);void *skb_ext_add (struct sk_buff *skb,enum skb_ext_id id);void __skb_ext_del (struct sk_buff *skb,enum skb_ext_id id);void __skb_ext_put (struct skb_ext *ext);
net/core/skbuff.c +33 -2
@@ -5983,7 +5983,14 @@ static void *skb_ext_get_ptr(struct skb_ext *ext, enum skb_ext_id id)return (void *)ext + (ext->offset[id] *SKB_EXT_ALIGN_VALUE ); } -static struct skb_ext *skb_ext_alloc (void ) +/** +* __skb_ext_alloc - allocate a new skb extensions storage +* +* Returns the newly allocated pointer. The pointer can later attached to a +* skb via __skb_ext_set(). +* Note: caller must handle the skb_ext as an opaque data. +*/ +struct skb_ext *__skb_ext_alloc (void ) {struct skb_ext *new =kmem_cache_alloc (skbuff_ext_cache,GFP_ATOMIC );
@@ -6023,6 +6030,30 @@ static struct skb_ext *skb_ext_maybe_cow(struct skb_ext *old,return new; } +/** +* __skb_ext_set - attach the specified extension storage to this skb +* @skb: buffer +* @id: extension id +* @ext: extension storage previously allocated via __skb_ext_alloc() +* +* Existing extensions, if any, are cleared. +* +* Returns the pointer to the extension. +*/ +void *__skb_ext_set (struct sk_buff *skb,enum skb_ext_id id, +struct skb_ext *ext) +{ +unsigned int newlen, newoff =SKB_EXT_CHUNKSIZEOF (*ext); + +skb_ext_put (skb); + newlen = newoff + skb_ext_type_len[id]; + ext->chunks = newlen; + ext->offset[id] = newoff; + skb->extensions = ext; + skb->active_extensions =1 << id; +return skb_ext_get_ptr (ext, id); +} +/** * skb_ext_add - allocate space for given extension, COW if needed * @skb: buffer
@@ -6056,7 +6087,7 @@ void *skb_ext_add(struct sk_buff *skb, enum skb_ext_id id) }else { newoff =SKB_EXT_CHUNKSIZEOF (*new); - new =skb_ext_alloc (); + new =__skb_ext_alloc ();if (!new)return NULL ; }
Signature · 1 line
2.24.1
Re: [PATCH net-next v3 07/11] tcp: Prevent coalesce/collapse when skb has MPTCP extensions
In reply to Mat MartineauQuoted 5 lines · Mat Martineau
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.
This seems a very pessimistic change to me.
Are you planing later to refine this limitation ?
Surely if a sender sends TSO packet, we allow all the segments being aggregated at receive side either by GRO or TCP coalescing.
David Miller
maintainerRe: [PATCH net-next v3 07/11] tcp: Prevent coalesce/collapse when skb has MPTCP extensions
From: Eric Dumazet <eric.dumazet(a)gmail.com>
Date: Wed, 18 Dec 2019 11:50:24 -0800
Quoted 6 lines · Mat Martineau
Quoted 4 lines
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.
Quoted 6 lines
This seems a very pessimistic change to me.
Are you planing later to refine this limitation ?
Surely if a sender sends TSO packet, we allow all the segments being aggregated at receive side either by GRO or TCP coalescing.
This turns off absolutely crucial functional elements of our TCP stack, and will avoid all of the machinery that avoids wastage in TCP packets sitting in the various queues. skb->truesize management, etc.
I will not apply these patches with such a non-trivial regression in place for MPTCP streams, sorry.
Re: [PATCH net-next v3 07/11] tcp: Prevent coalesce/collapse when skb has MPTCP extensions
Quoted 16 lines · David Miller
From: Eric Dumazet <eric.dumazet(a)gmail.com>
Date: Wed, 18 Dec 2019 11:50:24 -0800Quoted 6 lines · Mat Martineau
Quoted 4 lines
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.
Quoted 6 lines
This seems a very pessimistic change to me.
Are you planing later to refine this limitation ?
Surely if a sender sends TSO packet, we allow all the segments being aggregated at receive side either by GRO or TCP coalescing.
Quoted 7 lines
This turns off absolutely crucial functional elements of our TCP stack, and will avoid all of the machinery that avoids wastage in TCP packets sitting in the various queues.
skb->truesizemanagement, etc.I will not apply these patches with such a non-trivial regression in place for MPTCP streams, sorry.
Ok, understood. Not every packet has this MPTCP extension data so coalescing was not always turned off, but given the importance of avoiding this memory waste I'll confirm GRO behavior and work on maintaining coalesce/collapse with identical MPTCP extension data.
--
Mat Martineau
Intel
Re: [PATCH net-next v3 07/11] tcp: Prevent coalesce/collapse when skb has MPTCP extensions
Quoted 7 lines
Ok, understood. Not every packet has this MPTCP extension data so coalescing was not always turned off, but given the importance of avoiding
this memory waste I'll confirm GRO behavior and work on maintaining coalesce/collapse with identical MPTCP extension data.
Hi Mat
Are identical MPTCP extensions a common case?
AFAIK the data sequence number and the subflow sequence number change per packet even in a single stream scenario.
Paolo Abeni
maintainerRe: [PATCH net-next v3 07/11] tcp: Prevent coalesce/collapse when skb has MPTCP extensions
Quoted 11 lines · subashab(a)codeaurora.org
Quoted 7 lines
Ok, understood. Not every packet has this MPTCP extension data so coalescing was not always turned off, but given the importance of avoiding
this memory waste I'll confirm GRO behavior and work on maintaining coalesce/collapse with identical MPTCP extension data.
Hi Mat
Are identical MPTCP extensions a common case?
Yes, they are.
Quoted 2 lines
AFAIK the data sequence number and the subflow sequence number change per packet even in a single stream scenario.
What actually change on per packet basis is the TCP sequence number. The DSS mapping can spawn on multiple packets, and will have constand (base) sequence number and length.
Cheers,
Paolo
Paolo Abeni
maintainerRe: [MPTCP] Re: [PATCH net-next v3 07/11] tcp: Prevent coalesce/collapse when skb has MPTCP extensions
In reply to David MillerQuoted 11 lines · David Miller
From: Eric Dumazet <eric.dumazet(a)gmail.com>
Date: Wed, 18 Dec 2019 11:50:24 -0800Quoted 8 lines · Mat Martineau
Quoted 4 lines
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.
This seems a very pessimistic change to me.
Quoted 8 lines
Quoted 4 lines
Are you planing later to refine this limitation ?
Surely if a sender sends TSO packet, we allow all the segments being aggregated at receive side either by GRO or TCP coalescing.
This turns off absolutely crucial functional elements of our TCP stack, and will avoid all of the machinery that avoids wastage in TCP packets sitting in the various queues.
skb->truesizemanagement, etc.
Thank you for the feedback!
Just to clarify, with the code we have currently posted TSO trains of MPTCP packets can be aggregated by the GRO engine almost exactly as currently happens for plain TCP packets.
We still have chances to aggregate packets belonging to a MPTCP stream, as not all of them carry a DSS option.
We opted to not coalesce at the TCP level for the moment to avoid adding additional hook code inside the coalescing code.
If you are ok without such hooks in the initial version, we can handle MPTCP coalescing, too. The real work will likely land in part 2.
Would that fit you?
Thanks,
Paolo
David Miller
maintainerRe: [MPTCP] Re: [PATCH net-next v3 07/11] tcp: Prevent coalesce/collapse when skb has MPTCP extensions
From: Paolo Abeni <pabeni(a)redhat.com>
Date: Wed, 18 Dec 2019 23:15:46 +0100
Quoted 7 lines
Just to clarify, with the code we have currently posted TSO trains of MPTCP packets can be aggregated by the GRO engine almost exactly as currently happens for plain TCP packets.
We still have chances to aggregate packets belonging to a MPTCP stream, as not all of them carry a DSS option.
Quoted 7 lines
We opted to not coalesce at the TCP level for the moment to avoid adding additional hook code inside the coalescing code.
If you are ok without such hooks in the initial version, we can handle MPTCP coalescing, too. The real work will likely land in part 2.
Would that fit you?
Can't you someone encode the MPTCP metadata so that it will only apply to a range or something like that? Would that help?