Skip to content

Commit 29a9493

Browse files
nealcardwellAlexei Starovoitov
authored andcommitted
tcp: simplify tcp_set_congestion_control(): Always reinitialize
Now that the previous patches ensure that all call sites for tcp_set_congestion_control() want to initialize congestion control, we can simplify tcp_set_congestion_control() by removing the reinit argument and the code to support it. Signed-off-by: Neal Cardwell <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Acked-by: Yuchung Cheng <[email protected]> Acked-by: Kevin Yang <[email protected]> Cc: Lawrence Brakmo <[email protected]>
1 parent e7b10a4 commit 29a9493

File tree

4 files changed

+5
-13
lines changed

4 files changed

+5
-13
lines changed

include/net/tcp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ void tcp_get_available_congestion_control(char *buf, size_t len);
11041104
void tcp_get_allowed_congestion_control(char *buf, size_t len);
11051105
int tcp_set_allowed_congestion_control(char *allowed);
11061106
int tcp_set_congestion_control(struct sock *sk, const char *name, bool load,
1107-
bool reinit, bool cap_net_admin);
1107+
bool cap_net_admin);
11081108
u32 tcp_slow_start(struct tcp_sock *tp, u32 acked);
11091109
void tcp_cong_avoid_ai(struct tcp_sock *tp, u32 w, u32 acked);
11101110

net/core/filter.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4451,8 +4451,7 @@ static int _bpf_setsockopt(struct sock *sk, int level, int optname,
44514451
strncpy(name, optval, min_t(long, optlen,
44524452
TCP_CA_NAME_MAX-1));
44534453
name[TCP_CA_NAME_MAX-1] = 0;
4454-
ret = tcp_set_congestion_control(sk, name, false,
4455-
true, true);
4454+
ret = tcp_set_congestion_control(sk, name, false, true);
44564455
} else {
44574456
struct inet_connection_sock *icsk = inet_csk(sk);
44584457
struct tcp_sock *tp = tcp_sk(sk);

net/ipv4/tcp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3050,7 +3050,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level, int optname,
30503050
name[val] = 0;
30513051

30523052
lock_sock(sk);
3053-
err = tcp_set_congestion_control(sk, name, true, true,
3053+
err = tcp_set_congestion_control(sk, name, true,
30543054
ns_capable(sock_net(sk)->user_ns,
30553055
CAP_NET_ADMIN));
30563056
release_sock(sk);

net/ipv4/tcp_cong.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ int tcp_set_allowed_congestion_control(char *val)
341341
* already initialized.
342342
*/
343343
int tcp_set_congestion_control(struct sock *sk, const char *name, bool load,
344-
bool reinit, bool cap_net_admin)
344+
bool cap_net_admin)
345345
{
346346
struct inet_connection_sock *icsk = inet_csk(sk);
347347
const struct tcp_congestion_ops *ca;
@@ -365,15 +365,8 @@ int tcp_set_congestion_control(struct sock *sk, const char *name, bool load,
365365
if (!ca) {
366366
err = -ENOENT;
367367
} else if (!load) {
368-
const struct tcp_congestion_ops *old_ca = icsk->icsk_ca_ops;
369-
370368
if (bpf_try_module_get(ca, ca->owner)) {
371-
if (reinit) {
372-
tcp_reinit_congestion_control(sk, ca);
373-
} else {
374-
icsk->icsk_ca_ops = ca;
375-
bpf_module_put(old_ca, old_ca->owner);
376-
}
369+
tcp_reinit_congestion_control(sk, ca);
377370
} else {
378371
err = -EBUSY;
379372
}

0 commit comments

Comments
 (0)