]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.14.60/tcp-refactor-tcp_ecn_check_ce-to-remove-sk-type-cast.patch
Fixes for 5.10
[thirdparty/kernel/stable-queue.git] / releases / 4.14.60 / tcp-refactor-tcp_ecn_check_ce-to-remove-sk-type-cast.patch
CommitLineData
2c643bb0
GKH
1From foo@baz Wed Aug 1 08:19:32 CEST 2018
2From: Yousuk Seung <ysseung@google.com>
3Date: Mon, 4 Jun 2018 15:29:51 -0700
4Subject: tcp: refactor tcp_ecn_check_ce to remove sk type cast
5
6From: Yousuk Seung <ysseung@google.com>
7
8[ Upstream commit f4c9f85f3b2cb7669830cd04d0be61192a4d2436 ]
9
10Refactor tcp_ecn_check_ce and __tcp_ecn_check_ce to accept struct sock*
11instead of tcp_sock* to clean up type casts. This is a pure refactor
12patch.
13
14Signed-off-by: Yousuk Seung <ysseung@google.com>
15Signed-off-by: Neal Cardwell <ncardwell@google.com>
16Signed-off-by: Yuchung Cheng <ycheng@google.com>
17Signed-off-by: Eric Dumazet <edumazet@google.com>
18Acked-by: Soheil Hassas Yeganeh <soheil@google.com>
19Signed-off-by: David S. Miller <davem@davemloft.net>
20Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
21---
22 net/ipv4/tcp_input.c | 26 ++++++++++++++------------
23 1 file changed, 14 insertions(+), 12 deletions(-)
24
25--- a/net/ipv4/tcp_input.c
26+++ b/net/ipv4/tcp_input.c
27@@ -250,8 +250,10 @@ static void tcp_ecn_withdraw_cwr(struct
28 tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR;
29 }
30
31-static void __tcp_ecn_check_ce(struct tcp_sock *tp, const struct sk_buff *skb)
32+static void __tcp_ecn_check_ce(struct sock *sk, const struct sk_buff *skb)
33 {
34+ struct tcp_sock *tp = tcp_sk(sk);
35+
36 switch (TCP_SKB_CB(skb)->ip_dsfield & INET_ECN_MASK) {
37 case INET_ECN_NOT_ECT:
38 /* Funny extension: if ECT is not set on a segment,
39@@ -259,31 +261,31 @@ static void __tcp_ecn_check_ce(struct tc
40 * it is probably a retransmit.
41 */
42 if (tp->ecn_flags & TCP_ECN_SEEN)
43- tcp_enter_quickack_mode((struct sock *)tp, 1);
44+ tcp_enter_quickack_mode(sk, 1);
45 break;
46 case INET_ECN_CE:
47- if (tcp_ca_needs_ecn((struct sock *)tp))
48- tcp_ca_event((struct sock *)tp, CA_EVENT_ECN_IS_CE);
49+ if (tcp_ca_needs_ecn(sk))
50+ tcp_ca_event(sk, CA_EVENT_ECN_IS_CE);
51
52 if (!(tp->ecn_flags & TCP_ECN_DEMAND_CWR)) {
53 /* Better not delay acks, sender can have a very low cwnd */
54- tcp_enter_quickack_mode((struct sock *)tp, 1);
55+ tcp_enter_quickack_mode(sk, 1);
56 tp->ecn_flags |= TCP_ECN_DEMAND_CWR;
57 }
58 tp->ecn_flags |= TCP_ECN_SEEN;
59 break;
60 default:
61- if (tcp_ca_needs_ecn((struct sock *)tp))
62- tcp_ca_event((struct sock *)tp, CA_EVENT_ECN_NO_CE);
63+ if (tcp_ca_needs_ecn(sk))
64+ tcp_ca_event(sk, CA_EVENT_ECN_NO_CE);
65 tp->ecn_flags |= TCP_ECN_SEEN;
66 break;
67 }
68 }
69
70-static void tcp_ecn_check_ce(struct tcp_sock *tp, const struct sk_buff *skb)
71+static void tcp_ecn_check_ce(struct sock *sk, const struct sk_buff *skb)
72 {
73- if (tp->ecn_flags & TCP_ECN_OK)
74- __tcp_ecn_check_ce(tp, skb);
75+ if (tcp_sk(sk)->ecn_flags & TCP_ECN_OK)
76+ __tcp_ecn_check_ce(sk, skb);
77 }
78
79 static void tcp_ecn_rcv_synack(struct tcp_sock *tp, const struct tcphdr *th)
80@@ -710,7 +712,7 @@ static void tcp_event_data_recv(struct s
81 }
82 icsk->icsk_ack.lrcvtime = now;
83
84- tcp_ecn_check_ce(tp, skb);
85+ tcp_ecn_check_ce(sk, skb);
86
87 if (skb->len >= 128)
88 tcp_grow_window(sk, skb);
89@@ -4443,7 +4445,7 @@ static void tcp_data_queue_ofo(struct so
90 u32 seq, end_seq;
91 bool fragstolen;
92
93- tcp_ecn_check_ce(tp, skb);
94+ tcp_ecn_check_ce(sk, skb);
95
96 if (unlikely(tcp_try_rmem_schedule(sk, skb, skb->truesize))) {
97 NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPOFODROP);