mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-02-20 18:29:07 +07:00
net: tcp: refactor reinitialization of congestion control
We can just move this to an extra function and make the code a bit more readable, no functional change. Joint work with Florian Westphal. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Daniel Borkmann <dborkman@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
e715b6d3a5
commit
29ba4fffd3
@ -107,6 +107,18 @@ void tcp_init_congestion_control(struct sock *sk)
|
|||||||
icsk->icsk_ca_ops->init(sk);
|
icsk->icsk_ca_ops->init(sk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void tcp_reinit_congestion_control(struct sock *sk,
|
||||||
|
const struct tcp_congestion_ops *ca)
|
||||||
|
{
|
||||||
|
struct inet_connection_sock *icsk = inet_csk(sk);
|
||||||
|
|
||||||
|
tcp_cleanup_congestion_control(sk);
|
||||||
|
icsk->icsk_ca_ops = ca;
|
||||||
|
|
||||||
|
if (sk->sk_state != TCP_CLOSE && icsk->icsk_ca_ops->init)
|
||||||
|
icsk->icsk_ca_ops->init(sk);
|
||||||
|
}
|
||||||
|
|
||||||
/* Manage refcounts on socket close. */
|
/* Manage refcounts on socket close. */
|
||||||
void tcp_cleanup_congestion_control(struct sock *sk)
|
void tcp_cleanup_congestion_control(struct sock *sk)
|
||||||
{
|
{
|
||||||
@ -262,21 +274,13 @@ int tcp_set_congestion_control(struct sock *sk, const char *name)
|
|||||||
#endif
|
#endif
|
||||||
if (!ca)
|
if (!ca)
|
||||||
err = -ENOENT;
|
err = -ENOENT;
|
||||||
|
|
||||||
else if (!((ca->flags & TCP_CONG_NON_RESTRICTED) ||
|
else if (!((ca->flags & TCP_CONG_NON_RESTRICTED) ||
|
||||||
ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)))
|
ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)))
|
||||||
err = -EPERM;
|
err = -EPERM;
|
||||||
|
|
||||||
else if (!try_module_get(ca->owner))
|
else if (!try_module_get(ca->owner))
|
||||||
err = -EBUSY;
|
err = -EBUSY;
|
||||||
|
else
|
||||||
else {
|
tcp_reinit_congestion_control(sk, ca);
|
||||||
tcp_cleanup_congestion_control(sk);
|
|
||||||
icsk->icsk_ca_ops = ca;
|
|
||||||
|
|
||||||
if (sk->sk_state != TCP_CLOSE && icsk->icsk_ca_ops->init)
|
|
||||||
icsk->icsk_ca_ops->init(sk);
|
|
||||||
}
|
|
||||||
out:
|
out:
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
return err;
|
return err;
|
||||||
|
Loading…
Reference in New Issue
Block a user