Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
mptcp: propagate TCP_CONGESTION sockopt to subflows
Browse files Browse the repository at this point in the history
mptcp sets the CC set by socket option from the meta flow on the
subflows when they are created, but already existing subflows do not get
updated.

This patch propagates any CC change through setsockopt to already
existing subflows.

Fixes: 62c7c2e (mptcp: allow app to change congestion control)
Signed-off-by: Tim Froidcoeur <tim.froidcoeur@tessares.net>
Signed-off-by: Christoph Paasch <cpaasch@apple.com>
  • Loading branch information
TimFroidcoeur authored and cpaasch committed Jan 22, 2020
1 parent ec533a3 commit e8f2499
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
4 changes: 4 additions & 0 deletions include/net/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,8 @@ void tcp_get_available_congestion_control(char *buf, size_t len);
void tcp_get_allowed_congestion_control(char *buf, size_t len);
int tcp_set_allowed_congestion_control(char *allowed);
int tcp_set_congestion_control(struct sock *sk, const char *name, bool load, bool reinit);
int __tcp_set_congestion_control(struct sock *sk, const char *name, bool load,
bool reinit);
u32 tcp_slow_start(struct tcp_sock *tp, u32 acked);
void tcp_cong_avoid_ai(struct tcp_sock *tp, u32 w, u32 acked);

Expand Down Expand Up @@ -2077,6 +2079,8 @@ struct tcp_sock_ops {
void (*time_wait)(struct sock *sk, int state, int timeo);
void (*cleanup_rbuf)(struct sock *sk, int copied);
void (*cwnd_validate)(struct sock *sk, bool is_cwnd_limited);
int (*set_cong_ctrl)(struct sock *sk, const char *name, bool load,
bool reinit);
};
extern const struct tcp_sock_ops tcp_specific;

Expand Down
1 change: 1 addition & 0 deletions net/ipv4/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ const struct tcp_sock_ops tcp_specific = {
.time_wait = tcp_time_wait,
.cleanup_rbuf = tcp_cleanup_rbuf,
.cwnd_validate = tcp_cwnd_validate,
.set_cong_ctrl = __tcp_set_congestion_control,
};

/* Address-family independent initialization for a tcp_sock.
Expand Down
9 changes: 8 additions & 1 deletion net/ipv4/tcp_cong.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,19 @@ int tcp_set_allowed_congestion_control(char *val)
return ret;
}

int tcp_set_congestion_control(struct sock *sk, const char *name, bool load,
bool reinit)
{
return tcp_sk(sk)->ops->set_cong_ctrl(sk, name, load, reinit);
}

/* Change congestion control for socket. If load is false, then it is the
* responsibility of the caller to call tcp_init_congestion_control or
* tcp_reinit_congestion_control (if the current congestion control was
* already initialized.
*/
int tcp_set_congestion_control(struct sock *sk, const char *name, bool load, bool reinit)
int __tcp_set_congestion_control(struct sock *sk, const char *name, bool load,
bool reinit)
{
struct inet_connection_sock *icsk = inet_csk(sk);
const struct tcp_congestion_ops *ca;
Expand Down
20 changes: 20 additions & 0 deletions net/mptcp/mptcp_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,24 @@ static void mptcp_set_state(struct sock *sk)
}
}

static int mptcp_set_congestion_control(struct sock *meta_sk, const char *name,
bool load, bool reinit)
{
struct mptcp_tcp_sock *mptcp;
int err, result = 0;

result = __tcp_set_congestion_control(meta_sk, name, load, reinit);

mptcp_for_each_sub(tcp_sk(meta_sk)->mpcb, mptcp) {
struct sock *sk_it = mptcp_to_sock(mptcp);

err = __tcp_set_congestion_control(sk_it, name, load, reinit);
if (err)
result = err;
}
return result;
}

static void mptcp_assign_congestion_control(struct sock *sk)
{
struct inet_connection_sock *icsk = inet_csk(sk);
Expand Down Expand Up @@ -1127,6 +1145,7 @@ static const struct tcp_sock_ops mptcp_meta_specific = {
.retransmit_timer = mptcp_meta_retransmit_timer,
.time_wait = mptcp_time_wait,
.cleanup_rbuf = mptcp_cleanup_rbuf,
.set_cong_ctrl = mptcp_set_congestion_control,
};

static const struct tcp_sock_ops mptcp_sub_specific = {
Expand All @@ -1144,6 +1163,7 @@ static const struct tcp_sock_ops mptcp_sub_specific = {
.retransmit_timer = mptcp_sub_retransmit_timer,
.time_wait = tcp_time_wait,
.cleanup_rbuf = tcp_cleanup_rbuf,
.set_cong_ctrl = __tcp_set_congestion_control,
};

static int mptcp_alloc_mpcb(struct sock *meta_sk, __u64 remote_key,
Expand Down

0 comments on commit e8f2499

Please sign in to comment.