Commit 3e385172 authored by Yousuk Seung's avatar Yousuk Seung Committed by Kleber Sacilotto de Souza

tcp: refactor tcp_ecn_check_ce to remove sk type cast

BugLink: https://bugs.launchpad.net/bugs/1791953

[ Upstream commit f4c9f85f ]

Refactor tcp_ecn_check_ce and __tcp_ecn_check_ce to accept struct sock*
instead of tcp_sock* to clean up type casts. This is a pure refactor
patch.
Signed-off-by: default avatarYousuk Seung <ysseung@google.com>
Signed-off-by: default avatarNeal Cardwell <ncardwell@google.com>
Signed-off-by: default avatarYuchung Cheng <ycheng@google.com>
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Acked-by: default avatarSoheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 2db7b8b6
...@@ -228,8 +228,10 @@ static void tcp_ecn_withdraw_cwr(struct tcp_sock *tp) ...@@ -228,8 +228,10 @@ static void tcp_ecn_withdraw_cwr(struct tcp_sock *tp)
tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR; tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR;
} }
static void __tcp_ecn_check_ce(struct tcp_sock *tp, const struct sk_buff *skb) static void __tcp_ecn_check_ce(struct sock *sk, const struct sk_buff *skb)
{ {
struct tcp_sock *tp = tcp_sk(sk);
switch (TCP_SKB_CB(skb)->ip_dsfield & INET_ECN_MASK) { switch (TCP_SKB_CB(skb)->ip_dsfield & INET_ECN_MASK) {
case INET_ECN_NOT_ECT: case INET_ECN_NOT_ECT:
/* Funny extension: if ECT is not set on a segment, /* Funny extension: if ECT is not set on a segment,
...@@ -237,31 +239,31 @@ static void __tcp_ecn_check_ce(struct tcp_sock *tp, const struct sk_buff *skb) ...@@ -237,31 +239,31 @@ static void __tcp_ecn_check_ce(struct tcp_sock *tp, const struct sk_buff *skb)
* it is probably a retransmit. * it is probably a retransmit.
*/ */
if (tp->ecn_flags & TCP_ECN_SEEN) if (tp->ecn_flags & TCP_ECN_SEEN)
tcp_enter_quickack_mode((struct sock *)tp, 1); tcp_enter_quickack_mode(sk, 1);
break; break;
case INET_ECN_CE: case INET_ECN_CE:
if (tcp_ca_needs_ecn((struct sock *)tp)) if (tcp_ca_needs_ecn(sk))
tcp_ca_event((struct sock *)tp, CA_EVENT_ECN_IS_CE); tcp_ca_event(sk, CA_EVENT_ECN_IS_CE);
if (!(tp->ecn_flags & TCP_ECN_DEMAND_CWR)) { if (!(tp->ecn_flags & TCP_ECN_DEMAND_CWR)) {
/* Better not delay acks, sender can have a very low cwnd */ /* Better not delay acks, sender can have a very low cwnd */
tcp_enter_quickack_mode((struct sock *)tp, 1); tcp_enter_quickack_mode(sk, 1);
tp->ecn_flags |= TCP_ECN_DEMAND_CWR; tp->ecn_flags |= TCP_ECN_DEMAND_CWR;
} }
tp->ecn_flags |= TCP_ECN_SEEN; tp->ecn_flags |= TCP_ECN_SEEN;
break; break;
default: default:
if (tcp_ca_needs_ecn((struct sock *)tp)) if (tcp_ca_needs_ecn(sk))
tcp_ca_event((struct sock *)tp, CA_EVENT_ECN_NO_CE); tcp_ca_event(sk, CA_EVENT_ECN_NO_CE);
tp->ecn_flags |= TCP_ECN_SEEN; tp->ecn_flags |= TCP_ECN_SEEN;
break; break;
} }
} }
static void tcp_ecn_check_ce(struct tcp_sock *tp, const struct sk_buff *skb) static void tcp_ecn_check_ce(struct sock *sk, const struct sk_buff *skb)
{ {
if (tp->ecn_flags & TCP_ECN_OK) if (tcp_sk(sk)->ecn_flags & TCP_ECN_OK)
__tcp_ecn_check_ce(tp, skb); __tcp_ecn_check_ce(sk, skb);
} }
static void tcp_ecn_rcv_synack(struct tcp_sock *tp, const struct tcphdr *th) static void tcp_ecn_rcv_synack(struct tcp_sock *tp, const struct tcphdr *th)
...@@ -675,7 +677,7 @@ static void tcp_event_data_recv(struct sock *sk, struct sk_buff *skb) ...@@ -675,7 +677,7 @@ static void tcp_event_data_recv(struct sock *sk, struct sk_buff *skb)
} }
icsk->icsk_ack.lrcvtime = now; icsk->icsk_ack.lrcvtime = now;
tcp_ecn_check_ce(tp, skb); tcp_ecn_check_ce(sk, skb);
if (skb->len >= 128) if (skb->len >= 128)
tcp_grow_window(sk, skb); tcp_grow_window(sk, skb);
...@@ -4363,7 +4365,7 @@ static void tcp_data_queue_ofo(struct sock *sk, struct sk_buff *skb) ...@@ -4363,7 +4365,7 @@ static void tcp_data_queue_ofo(struct sock *sk, struct sk_buff *skb)
struct sk_buff *skb1; struct sk_buff *skb1;
u32 seq, end_seq; u32 seq, end_seq;
tcp_ecn_check_ce(tp, skb); tcp_ecn_check_ce(sk, skb);
if (unlikely(tcp_try_rmem_schedule(sk, skb, skb->truesize))) { if (unlikely(tcp_try_rmem_schedule(sk, skb, skb->truesize))) {
NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPOFODROP); NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPOFODROP);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment