* [PATCH mptcp-next] mptcp: don't save tcp data_ready and write space callbacks
@ 2022-02-09 10:11 Florian Westphal
2022-02-09 23:18 ` Mat Martineau
0 siblings, 1 reply; 3+ messages in thread
From: Florian Westphal @ 2022-02-09 10:11 UTC (permalink / raw)
To: mptcp; +Cc: Florian Westphal
Assign the helpers directly rather than save/restore in the context
structure.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
net/mptcp/protocol.h | 6 ++----
net/mptcp/subflow.c | 4 ----
2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index f37f087caab3..202004473292 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -479,9 +479,7 @@ struct mptcp_subflow_context {
struct sock *tcp_sock; /* tcp sk backpointer */
struct sock *conn; /* parent mptcp_sock */
const struct inet_connection_sock_af_ops *icsk_af_ops;
- 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;
@@ -626,9 +624,9 @@ bool mptcp_subflow_active(struct mptcp_subflow_context *subflow);
static inline void mptcp_subflow_tcp_fallback(struct sock *sk,
struct mptcp_subflow_context *ctx)
{
- sk->sk_data_ready = ctx->tcp_data_ready;
+ sk->sk_data_ready = sock_def_readable;
sk->sk_state_change = ctx->tcp_state_change;
- sk->sk_write_space = ctx->tcp_write_space;
+ sk->sk_write_space = sk_stream_write_space;
sk->sk_error_report = ctx->tcp_error_report;
inet_csk(sk)->icsk_af_ops = ctx->icsk_af_ops;
diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index 485f00dcaf84..d4b4d285ffc1 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -1661,9 +1661,7 @@ static int subflow_ulp_init(struct sock *sk)
tp->is_mptcp = 1;
ctx->icsk_af_ops = icsk->icsk_af_ops;
icsk->icsk_af_ops = subflow_default_af_ops(sk);
- ctx->tcp_data_ready = sk->sk_data_ready;
ctx->tcp_state_change = sk->sk_state_change;
- ctx->tcp_write_space = sk->sk_write_space;
ctx->tcp_error_report = sk->sk_error_report;
sk->sk_data_ready = subflow_data_ready;
sk->sk_write_space = subflow_write_space;
@@ -1719,9 +1717,7 @@ static void subflow_ulp_clone(const struct request_sock *req,
new_ctx->conn_finished = 1;
new_ctx->icsk_af_ops = old_ctx->icsk_af_ops;
- new_ctx->tcp_data_ready = old_ctx->tcp_data_ready;
new_ctx->tcp_state_change = old_ctx->tcp_state_change;
- new_ctx->tcp_write_space = old_ctx->tcp_write_space;
new_ctx->tcp_error_report = old_ctx->tcp_error_report;
new_ctx->rel_write_seq = 1;
new_ctx->tcp_sock = newsk;
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH mptcp-next] mptcp: don't save tcp data_ready and write space callbacks
2022-02-09 10:11 [PATCH mptcp-next] mptcp: don't save tcp data_ready and write space callbacks Florian Westphal
@ 2022-02-09 23:18 ` Mat Martineau
2022-02-10 9:43 ` Paolo Abeni
0 siblings, 1 reply; 3+ messages in thread
From: Mat Martineau @ 2022-02-09 23:18 UTC (permalink / raw)
To: Florian Westphal; +Cc: mptcp
On Wed, 9 Feb 2022, Florian Westphal wrote:
> Assign the helpers directly rather than save/restore in the context
> structure.
>
> Signed-off-by: Florian Westphal <fw@strlen.de>
> ---
> net/mptcp/protocol.h | 6 ++----
> net/mptcp/subflow.c | 4 ----
> 2 files changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
> index f37f087caab3..202004473292 100644
> --- a/net/mptcp/protocol.h
> +++ b/net/mptcp/protocol.h
> @@ -479,9 +479,7 @@ struct mptcp_subflow_context {
> struct sock *tcp_sock; /* tcp sk backpointer */
> struct sock *conn; /* parent mptcp_sock */
> const struct inet_connection_sock_af_ops *icsk_af_ops;
> - 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;
> @@ -626,9 +624,9 @@ bool mptcp_subflow_active(struct mptcp_subflow_context *subflow);
> static inline void mptcp_subflow_tcp_fallback(struct sock *sk,
> struct mptcp_subflow_context *ctx)
> {
> - sk->sk_data_ready = ctx->tcp_data_ready;
> + sk->sk_data_ready = sock_def_readable;
> sk->sk_state_change = ctx->tcp_state_change;
> - sk->sk_write_space = ctx->tcp_write_space;
> + sk->sk_write_space = sk_stream_write_space;
> sk->sk_error_report = ctx->tcp_error_report;
>
> inet_csk(sk)->icsk_af_ops = ctx->icsk_af_ops;
> diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
> index 485f00dcaf84..d4b4d285ffc1 100644
> --- a/net/mptcp/subflow.c
> +++ b/net/mptcp/subflow.c
> @@ -1661,9 +1661,7 @@ static int subflow_ulp_init(struct sock *sk)
> tp->is_mptcp = 1;
> ctx->icsk_af_ops = icsk->icsk_af_ops;
> icsk->icsk_af_ops = subflow_default_af_ops(sk);
> - ctx->tcp_data_ready = sk->sk_data_ready;
> ctx->tcp_state_change = sk->sk_state_change;
> - ctx->tcp_write_space = sk->sk_write_space;
> ctx->tcp_error_report = sk->sk_error_report;
> sk->sk_data_ready = subflow_data_ready;
> sk->sk_write_space = subflow_write_space;
Should we add any paranoid BUG_ON() checks to confirm that these sk
members are still set to sock_def_readable/sk_stream_write_space by TCP?
I don't expect those to ever change... but it seems better to not assume.
-Mat
> @@ -1719,9 +1717,7 @@ static void subflow_ulp_clone(const struct request_sock *req,
>
> new_ctx->conn_finished = 1;
> new_ctx->icsk_af_ops = old_ctx->icsk_af_ops;
> - new_ctx->tcp_data_ready = old_ctx->tcp_data_ready;
> new_ctx->tcp_state_change = old_ctx->tcp_state_change;
> - new_ctx->tcp_write_space = old_ctx->tcp_write_space;
> new_ctx->tcp_error_report = old_ctx->tcp_error_report;
> new_ctx->rel_write_seq = 1;
> new_ctx->tcp_sock = newsk;
> --
> 2.34.1
>
>
>
--
Mat Martineau
Intel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH mptcp-next] mptcp: don't save tcp data_ready and write space callbacks
2022-02-09 23:18 ` Mat Martineau
@ 2022-02-10 9:43 ` Paolo Abeni
0 siblings, 0 replies; 3+ messages in thread
From: Paolo Abeni @ 2022-02-10 9:43 UTC (permalink / raw)
To: Mat Martineau, Florian Westphal; +Cc: mptcp
On Wed, 2022-02-09 at 15:18 -0800, Mat Martineau wrote:
> On Wed, 9 Feb 2022, Florian Westphal wrote:
>
> > Assign the helpers directly rather than save/restore in the context
> > structure.
> >
> > Signed-off-by: Florian Westphal <fw@strlen.de>
> > ---
> > net/mptcp/protocol.h | 6 ++----
> > net/mptcp/subflow.c | 4 ----
> > 2 files changed, 2 insertions(+), 8 deletions(-)
> >
> > diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
> > index f37f087caab3..202004473292 100644
> > --- a/net/mptcp/protocol.h
> > +++ b/net/mptcp/protocol.h
> > @@ -479,9 +479,7 @@ struct mptcp_subflow_context {
> > struct sock *tcp_sock; /* tcp sk backpointer */
> > struct sock *conn; /* parent mptcp_sock */
> > const struct inet_connection_sock_af_ops *icsk_af_ops;
> > - 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;
> > @@ -626,9 +624,9 @@ bool mptcp_subflow_active(struct mptcp_subflow_context *subflow);
> > static inline void mptcp_subflow_tcp_fallback(struct sock *sk,
> > struct mptcp_subflow_context *ctx)
> > {
> > - sk->sk_data_ready = ctx->tcp_data_ready;
> > + sk->sk_data_ready = sock_def_readable;
> > sk->sk_state_change = ctx->tcp_state_change;
> > - sk->sk_write_space = ctx->tcp_write_space;
> > + sk->sk_write_space = sk_stream_write_space;
> > sk->sk_error_report = ctx->tcp_error_report;
> >
> > inet_csk(sk)->icsk_af_ops = ctx->icsk_af_ops;
> > diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
> > index 485f00dcaf84..d4b4d285ffc1 100644
> > --- a/net/mptcp/subflow.c
> > +++ b/net/mptcp/subflow.c
> > @@ -1661,9 +1661,7 @@ static int subflow_ulp_init(struct sock *sk)
> > tp->is_mptcp = 1;
> > ctx->icsk_af_ops = icsk->icsk_af_ops;
> > icsk->icsk_af_ops = subflow_default_af_ops(sk);
> > - ctx->tcp_data_ready = sk->sk_data_ready;
> > ctx->tcp_state_change = sk->sk_state_change;
> > - ctx->tcp_write_space = sk->sk_write_space;
> > ctx->tcp_error_report = sk->sk_error_report;
> > sk->sk_data_ready = subflow_data_ready;
> > sk->sk_write_space = subflow_write_space;
>
>
> Should we add any paranoid BUG_ON() checks to confirm that these sk
> members are still set to sock_def_readable/sk_stream_write_space by TCP?
>
> I don't expect those to ever change... but it seems better to not assume.
Yep, better safe than sorry ;). I guess WARN_ON_ONCE() should be
enough.
Thanks!
/P
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-02-10 9:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-09 10:11 [PATCH mptcp-next] mptcp: don't save tcp data_ready and write space callbacks Florian Westphal
2022-02-09 23:18 ` Mat Martineau
2022-02-10 9:43 ` Paolo Abeni
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.