Skip to content

Commit 04317da

Browse files
edumazetdavem330
authored andcommitted
tcp: introduce TCP_SKB_CB(skb)->tcp_tw_isn
TCP_SKB_CB(skb)->when has different meaning in output and input paths. In output path, it contains a timestamp. In input path, it contains an ISN, chosen by tcp_timewait_state_process() Lets add a different name to ease code comprehension. Note that 'when' field will disappear in following patch, as skb_mstamp already contains timestamp, the anonymous union will promptly disappear as well. Signed-off-by: Eric Dumazet <[email protected]> Acked-by: Yuchung Cheng <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2ba3894 commit 04317da

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

include/net/tcp.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,12 @@ struct tcp_skb_cb {
698698
} header; /* For incoming frames */
699699
__u32 seq; /* Starting sequence number */
700700
__u32 end_seq; /* SEQ + FIN + SYN + datalen */
701-
__u32 when; /* used to compute rtt's */
701+
union {
702+
/* used in output path */
703+
__u32 when; /* used to compute rtt's */
704+
/* used in input path */
705+
__u32 tcp_tw_isn; /* isn chosen by tcp_timewait_state_process() */
706+
};
702707
__u8 tcp_flags; /* TCP header flags. (tcp[13]) */
703708

704709
__u8 sacked; /* State flags for SACK/FACK. */

net/ipv4/tcp_input.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5906,7 +5906,7 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops,
59065906
struct request_sock *req;
59075907
struct tcp_sock *tp = tcp_sk(sk);
59085908
struct dst_entry *dst = NULL;
5909-
__u32 isn = TCP_SKB_CB(skb)->when;
5909+
__u32 isn = TCP_SKB_CB(skb)->tcp_tw_isn;
59105910
bool want_cookie = false, fastopen;
59115911
struct flowi fl;
59125912
struct tcp_fastopen_cookie foc = { .len = -1 };

net/ipv4/tcp_ipv4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1627,7 +1627,7 @@ int tcp_v4_rcv(struct sk_buff *skb)
16271627
TCP_SKB_CB(skb)->end_seq = (TCP_SKB_CB(skb)->seq + th->syn + th->fin +
16281628
skb->len - th->doff * 4);
16291629
TCP_SKB_CB(skb)->ack_seq = ntohl(th->ack_seq);
1630-
TCP_SKB_CB(skb)->when = 0;
1630+
TCP_SKB_CB(skb)->tcp_tw_isn = 0;
16311631
TCP_SKB_CB(skb)->ip_dsfield = ipv4_get_dsfield(iph);
16321632
TCP_SKB_CB(skb)->sacked = 0;
16331633

net/ipv4/tcp_minisocks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ tcp_timewait_state_process(struct inet_timewait_sock *tw, struct sk_buff *skb,
232232
u32 isn = tcptw->tw_snd_nxt + 65535 + 2;
233233
if (isn == 0)
234234
isn++;
235-
TCP_SKB_CB(skb)->when = isn;
235+
TCP_SKB_CB(skb)->tcp_tw_isn = isn;
236236
return TCP_TW_SYN;
237237
}
238238

net/ipv6/tcp_ipv6.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ static void tcp_v6_init_req(struct request_sock *req, struct sock *sk,
738738
ipv6_addr_type(&ireq->ir_v6_rmt_addr) & IPV6_ADDR_LINKLOCAL)
739739
ireq->ir_iif = inet6_iif(skb);
740740

741-
if (!TCP_SKB_CB(skb)->when &&
741+
if (!TCP_SKB_CB(skb)->tcp_tw_isn &&
742742
(ipv6_opt_accepted(sk, skb) || np->rxopt.bits.rxinfo ||
743743
np->rxopt.bits.rxoinfo || np->rxopt.bits.rxhlim ||
744744
np->rxopt.bits.rxohlim || np->repflow)) {
@@ -1412,7 +1412,7 @@ static int tcp_v6_rcv(struct sk_buff *skb)
14121412
TCP_SKB_CB(skb)->end_seq = (TCP_SKB_CB(skb)->seq + th->syn + th->fin +
14131413
skb->len - th->doff*4);
14141414
TCP_SKB_CB(skb)->ack_seq = ntohl(th->ack_seq);
1415-
TCP_SKB_CB(skb)->when = 0;
1415+
TCP_SKB_CB(skb)->tcp_tw_isn = 0;
14161416
TCP_SKB_CB(skb)->ip_dsfield = ipv6_get_dsfield(hdr);
14171417
TCP_SKB_CB(skb)->sacked = 0;
14181418

0 commit comments

Comments
 (0)