Skip to content

Commit 1d3ccff

Browse files
yousukseungZhengShunQian
authored andcommitted
tcp: refactor tcp_ecn_check_ce to remove sk type cast
[ Upstream commit f4c9f85 ] 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: Yousuk Seung <[email protected]> Signed-off-by: Neal Cardwell <[email protected]> Signed-off-by: Yuchung Cheng <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Acked-by: Soheil Hassas Yeganeh <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 0cc52d6 commit 1d3ccff

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

net/ipv4/tcp_input.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -229,40 +229,42 @@ static void tcp_ecn_withdraw_cwr(struct tcp_sock *tp)
229229
tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR;
230230
}
231231

232-
static void __tcp_ecn_check_ce(struct tcp_sock *tp, const struct sk_buff *skb)
232+
static void __tcp_ecn_check_ce(struct sock *sk, const struct sk_buff *skb)
233233
{
234+
struct tcp_sock *tp = tcp_sk(sk);
235+
234236
switch (TCP_SKB_CB(skb)->ip_dsfield & INET_ECN_MASK) {
235237
case INET_ECN_NOT_ECT:
236238
/* Funny extension: if ECT is not set on a segment,
237239
* and we already seen ECT on a previous segment,
238240
* it is probably a retransmit.
239241
*/
240242
if (tp->ecn_flags & TCP_ECN_SEEN)
241-
tcp_enter_quickack_mode((struct sock *)tp, 1);
243+
tcp_enter_quickack_mode(sk, 1);
242244
break;
243245
case INET_ECN_CE:
244-
if (tcp_ca_needs_ecn((struct sock *)tp))
245-
tcp_ca_event((struct sock *)tp, CA_EVENT_ECN_IS_CE);
246+
if (tcp_ca_needs_ecn(sk))
247+
tcp_ca_event(sk, CA_EVENT_ECN_IS_CE);
246248

247249
if (!(tp->ecn_flags & TCP_ECN_DEMAND_CWR)) {
248250
/* Better not delay acks, sender can have a very low cwnd */
249-
tcp_enter_quickack_mode((struct sock *)tp, 1);
251+
tcp_enter_quickack_mode(sk, 1);
250252
tp->ecn_flags |= TCP_ECN_DEMAND_CWR;
251253
}
252254
tp->ecn_flags |= TCP_ECN_SEEN;
253255
break;
254256
default:
255-
if (tcp_ca_needs_ecn((struct sock *)tp))
256-
tcp_ca_event((struct sock *)tp, CA_EVENT_ECN_NO_CE);
257+
if (tcp_ca_needs_ecn(sk))
258+
tcp_ca_event(sk, CA_EVENT_ECN_NO_CE);
257259
tp->ecn_flags |= TCP_ECN_SEEN;
258260
break;
259261
}
260262
}
261263

262-
static void tcp_ecn_check_ce(struct tcp_sock *tp, const struct sk_buff *skb)
264+
static void tcp_ecn_check_ce(struct sock *sk, const struct sk_buff *skb)
263265
{
264-
if (tp->ecn_flags & TCP_ECN_OK)
265-
__tcp_ecn_check_ce(tp, skb);
266+
if (tcp_sk(sk)->ecn_flags & TCP_ECN_OK)
267+
__tcp_ecn_check_ce(sk, skb);
266268
}
267269

268270
static void tcp_ecn_rcv_synack(struct tcp_sock *tp, const struct tcphdr *th)
@@ -676,7 +678,7 @@ static void tcp_event_data_recv(struct sock *sk, struct sk_buff *skb)
676678
}
677679
icsk->icsk_ack.lrcvtime = now;
678680

679-
tcp_ecn_check_ce(tp, skb);
681+
tcp_ecn_check_ce(sk, skb);
680682

681683
if (skb->len >= 128)
682684
tcp_grow_window(sk, skb);
@@ -4367,7 +4369,7 @@ static void tcp_data_queue_ofo(struct sock *sk, struct sk_buff *skb)
43674369
struct sk_buff *skb1;
43684370
u32 seq, end_seq;
43694371

4370-
tcp_ecn_check_ce(tp, skb);
4372+
tcp_ecn_check_ce(sk, skb);
43714373

43724374
if (unlikely(tcp_try_rmem_schedule(sk, skb, skb->truesize))) {
43734375
NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPOFODROP);

0 commit comments

Comments
 (0)