mptcp: handle socket errors
Subsystems (2)
Paolo Abeni
cover mptcp: handle socket errors
This introduces the initial support for msk-level socket error handling.
Currently subflow socket errors are always ignored. That is almost correct - I think - because the single subflow status does not affect the msk-level connection.
There a couple of notable exceptions:
- fallen-back msk
- error at connect time on the MPC subflow
both should be propagated at msk level.
patch 1 implement the relevant infra
patch 2 is actuall a bug fix, for some edge cases that become apparent testing the above.
I'll push a bunch of pktdrill test case which will cover the above.
Paolo Abeni (2):
mptcp: deliver ssk errors to msk
mptcp: fix poll after shutdown
net/mptcp/protocol.c | 11 ++++++++++- net/mptcp/protocol.h | 4 ++++ net/mptcp/subflow.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-)
Signature · 1 line
2.26.2
Paolo Abeni
PATCH 1/2 mptcp: deliver ssk errors to msk
Currently all errors received on msk subflows are ignored. We need to catch at least the errors on connect() and on fallback sockets.
Use a custom sk_error_report callback at subflow level, and do the real action under the msk socket lock - via the usual sock_owned_by_user()/release_callback() schema.
--- net/mptcp/protocol.c | 7 +++++++ net/mptcp/protocol.h | 4 ++++ net/mptcp/subflow.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+)
net/mptcp/protocol.c +7 -0
@@ -2944,6 +2944,8 @@ static void mptcp_release_cb(struct sock *sk)mptcp_push_pending (sk,0 );spin_lock_bh (&sk->sk_lock.slock); } +if (test_and_clear_bit (MPTCP_ERROR_REPORT , &mptcp_sk (sk)->flags)) +__mptcp_error_report (sk);/* clear any wmem reservation and errors */ __mptcp_update_wmem (sk);
@@ -3356,6 +3358,11 @@ static __poll_t mptcp_poll(struct file *file, struct socket *sock,if (sk->sk_shutdown &RCV_SHUTDOWN ) mask |=EPOLLIN |EPOLLRDNORM |EPOLLRDHUP ; +/* This barrier is coupled with smp_wmb() in tcp_reset() */ +smp_rmb (); +if (sk->sk_err) + mask |=EPOLLERR ; +return mask; }
net/mptcp/protocol.h +4 -0
@@ -102,6 +102,7 @@#define MPTCP_WORK_CLOSE_SUBFLOW 5#define MPTCP_PUSH_PENDING 6#define MPTCP_CLEAN_UNA 7 +#define MPTCP_ERROR_REPORT 8static inline bool before64 (__u64 seq1,__u64 seq2) {
@@ -436,6 +437,7 @@ struct mptcp_subflow_context {void (*tcp_data_ready)(struct sock *sk);void (*tcp_state_change)(struct sock *sk);void (*tcp_write_space)(struct sock *sk); +void (*tcp_error_report)(struct sock *sk);struct rcu_head rcu; };
@@ -560,6 +562,7 @@ static inline void mptcp_subflow_tcp_fallback(struct sock *sk, sk->sk_data_ready = ctx->tcp_data_ready; sk->sk_state_change = ctx->tcp_state_change; sk->sk_write_space = ctx->tcp_write_space; + sk->sk_error_report = ctx->tcp_error_report;inet_csk (sk)->icsk_af_ops = ctx->icsk_af_ops; }
@@ -587,6 +590,7 @@ bool mptcp_finish_join(struct sock *sk);bool mptcp_schedule_work (struct sock *sk);void __mptcp_check_push (struct sock *sk,struct sock *ssk);void __mptcp_data_acked (struct sock *sk); +void __mptcp_error_report (struct sock *sk);void mptcp_subflow_eof (struct sock *sk);bool mptcp_update_rcv_data_fin (struct mptcp_sock *msk,u64 data_fin_seq,bool use_64bit);void __mptcp_flush_join_list (struct mptcp_sock *msk);
net/mptcp/subflow.c +43 -0
64 lines not on this page · raw message
Signature · 1 line
2.26.2
Paolo Abeni
PATCH 2/2 mptcp: fix poll after shutdown
In reply to Paolo AbeniThe current mptcp_poll() implementation gives unexpected results after shutdown(SEND_SHUTDOWN) and after receiving a MP_RESET.
Set the correct mask.
--- net/mptcp/protocol.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/mptcp/protocol.c +3 -1
@@ -3322,7 +3322,7 @@ static __poll_t mptcp_check_writeable(struct mptcp_sock *msk)struct sock *sk = (struct sock *)msk;if (unlikely (sk->sk_shutdown &SEND_SHUTDOWN )) -return 0 ; +return EPOLLOUT |EPOLLWRNORM ;if (sk_stream_is_writeable (sk))return EPOLLOUT |EPOLLWRNORM ;
@@ -3355,6 +3355,8 @@ static __poll_t mptcp_poll(struct file *file, struct socket *sock, mask |=mptcp_check_readable (msk); mask |=mptcp_check_writeable (msk); } +if (sk->sk_shutdown ==SHUTDOWN_MASK || state ==TCP_CLOSE ) + mask |=EPOLLHUP ;if (sk->sk_shutdown &RCV_SHUTDOWN ) mask |=EPOLLIN |EPOLLRDNORM |EPOLLRDHUP ;
Signature · 1 line
2.26.2
Mat Martineau
Quoted 18 lines · Paolo Abeni
This introduces the initial support for msk-level socket error handling.
Currently subflow socket errors are always ignored. That is almost correct - I think - because the single subflow status does not affect the msk-level connection.
There a couple of notable exceptions:
- fallen-back msk
- error at connect time on the MPC subflow
both should be propagated at msk level.patch 1 implement the relevant infra
patch 2 is actuall a bug fix, for some edge cases that become apparent testing the above.I'll push a bunch of pktdrill test case which will cover the above.
Quoted 11 lines
Paolo Abeni (2):
mptcp: deliver ssk errors to msk
mptcp: fix poll after shutdownnet/mptcp/protocol.c | 11 ++++++++++- net/mptcp/protocol.h | 4 ++++ net/mptcp/subflow.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-)Signature · 1 line
2.26.2
Hi Paolo -
Both patches look good to me, and local build & selftests were good. Thanks!
--
Mat Martineau
Intel
Matthieu Baerts
Hi Paolo, Mat,
Quoted 12 lines · Paolo Abeni
This introduces the initial support for msk-level socket error handling.
Currently subflow socket errors are always ignored. That is almost correct - I think - because the single subflow status does not affect the msk-level connection.
There a couple of notable exceptions:
- fallen-back msk
- error at connect time on the MPC subflow
both should be propagated at msk level.
Quoted 5 lines
patch 1 implement the relevant infra
patch 2 is actuall a bug fix, for some edge cases that become apparent testing the above.I'll push a bunch of pktdrill test case which will cover the above.
Thank you for your patches, new pktdrill tests and the reviews! I just added them in our tree with Mat's RvB tags (and slightly modified the commit message of patch 2/2 as discussed on IRC).
- d55492a9942b: mptcp: deliver ssk errors to msk
- 330d6265d893: mptcp: fix poll after shutdown
- Results: 130bfe7ce033..f3a1a5d5ef41
Tests + export are in progress!
Cheers,
Matt
Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions www.tessares.net