Commit a52fe46e authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

tcp: factorize ip_summed setting

Setting skb->ip_summed to CHECKSUM_PARTIAL can be centralized
in tcp_stream_alloc_skb() and __mptcp_do_alloc_tx_skb()
instead of being done multiple times.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f401da47
...@@ -876,6 +876,7 @@ struct sk_buff *tcp_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp, ...@@ -876,6 +876,7 @@ struct sk_buff *tcp_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp,
} }
if (likely(mem_scheduled)) { if (likely(mem_scheduled)) {
skb_reserve(skb, MAX_TCP_HEADER); skb_reserve(skb, MAX_TCP_HEADER);
skb->ip_summed = CHECKSUM_PARTIAL;
INIT_LIST_HEAD(&skb->tcp_tsorted_anchor); INIT_LIST_HEAD(&skb->tcp_tsorted_anchor);
return skb; return skb;
} }
...@@ -993,7 +994,6 @@ static struct sk_buff *tcp_build_frag(struct sock *sk, int size_goal, int flags, ...@@ -993,7 +994,6 @@ static struct sk_buff *tcp_build_frag(struct sock *sk, int size_goal, int flags,
skb->truesize += copy; skb->truesize += copy;
sk_wmem_queued_add(sk, copy); sk_wmem_queued_add(sk, copy);
sk_mem_charge(sk, copy); sk_mem_charge(sk, copy);
skb->ip_summed = CHECKSUM_PARTIAL;
WRITE_ONCE(tp->write_seq, tp->write_seq + copy); WRITE_ONCE(tp->write_seq, tp->write_seq + copy);
TCP_SKB_CB(skb)->end_seq += copy; TCP_SKB_CB(skb)->end_seq += copy;
tcp_skb_pcount_set(skb, 0); tcp_skb_pcount_set(skb, 0);
...@@ -1289,7 +1289,6 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size) ...@@ -1289,7 +1289,6 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
goto wait_for_space; goto wait_for_space;
process_backlog++; process_backlog++;
skb->ip_summed = CHECKSUM_PARTIAL;
tcp_skb_entail(sk, skb); tcp_skb_entail(sk, skb);
copy = size_goal; copy = size_goal;
......
...@@ -1590,8 +1590,6 @@ int tcp_fragment(struct sock *sk, enum tcp_queue tcp_queue, ...@@ -1590,8 +1590,6 @@ int tcp_fragment(struct sock *sk, enum tcp_queue tcp_queue,
skb_split(skb, buff, len); skb_split(skb, buff, len);
buff->ip_summed = CHECKSUM_PARTIAL;
buff->tstamp = skb->tstamp; buff->tstamp = skb->tstamp;
tcp_fragment_tstamp(skb, buff); tcp_fragment_tstamp(skb, buff);
...@@ -1676,7 +1674,6 @@ int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len) ...@@ -1676,7 +1674,6 @@ int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len)
delta_truesize = __pskb_trim_head(skb, len); delta_truesize = __pskb_trim_head(skb, len);
TCP_SKB_CB(skb)->seq += len; TCP_SKB_CB(skb)->seq += len;
skb->ip_summed = CHECKSUM_PARTIAL;
if (delta_truesize) { if (delta_truesize) {
skb->truesize -= delta_truesize; skb->truesize -= delta_truesize;
...@@ -2147,7 +2144,6 @@ static int tso_fragment(struct sock *sk, struct sk_buff *skb, unsigned int len, ...@@ -2147,7 +2144,6 @@ static int tso_fragment(struct sock *sk, struct sk_buff *skb, unsigned int len,
tcp_skb_fragment_eor(skb, buff); tcp_skb_fragment_eor(skb, buff);
buff->ip_summed = CHECKSUM_PARTIAL;
skb_split(skb, buff, len); skb_split(skb, buff, len);
tcp_fragment_tstamp(skb, buff); tcp_fragment_tstamp(skb, buff);
...@@ -2403,7 +2399,6 @@ static int tcp_mtu_probe(struct sock *sk) ...@@ -2403,7 +2399,6 @@ static int tcp_mtu_probe(struct sock *sk)
TCP_SKB_CB(nskb)->tcp_flags = TCPHDR_ACK; TCP_SKB_CB(nskb)->tcp_flags = TCPHDR_ACK;
TCP_SKB_CB(nskb)->sacked = 0; TCP_SKB_CB(nskb)->sacked = 0;
nskb->csum = 0; nskb->csum = 0;
nskb->ip_summed = CHECKSUM_PARTIAL;
tcp_insert_write_queue_before(nskb, skb, sk); tcp_insert_write_queue_before(nskb, skb, sk);
tcp_highest_sack_replace(sk, skb, nskb); tcp_highest_sack_replace(sk, skb, nskb);
...@@ -3753,7 +3748,6 @@ static int tcp_send_syn_data(struct sock *sk, struct sk_buff *syn) ...@@ -3753,7 +3748,6 @@ static int tcp_send_syn_data(struct sock *sk, struct sk_buff *syn)
syn_data = tcp_stream_alloc_skb(sk, space, sk->sk_allocation, false); syn_data = tcp_stream_alloc_skb(sk, space, sk->sk_allocation, false);
if (!syn_data) if (!syn_data)
goto fallback; goto fallback;
syn_data->ip_summed = CHECKSUM_PARTIAL;
memcpy(syn_data->cb, syn->cb, sizeof(syn->cb)); memcpy(syn_data->cb, syn->cb, sizeof(syn->cb));
if (space) { if (space) {
int copied = copy_from_iter(skb_put(syn_data, space), space, int copied = copy_from_iter(skb_put(syn_data, space), space,
......
...@@ -1174,6 +1174,7 @@ static struct sk_buff *__mptcp_do_alloc_tx_skb(struct sock *sk, gfp_t gfp) ...@@ -1174,6 +1174,7 @@ static struct sk_buff *__mptcp_do_alloc_tx_skb(struct sock *sk, gfp_t gfp)
if (likely(skb)) { if (likely(skb)) {
if (likely(__mptcp_add_ext(skb, gfp))) { if (likely(__mptcp_add_ext(skb, gfp))) {
skb_reserve(skb, MAX_TCP_HEADER); skb_reserve(skb, MAX_TCP_HEADER);
skb->ip_summed = CHECKSUM_PARTIAL;
INIT_LIST_HEAD(&skb->tcp_tsorted_anchor); INIT_LIST_HEAD(&skb->tcp_tsorted_anchor);
return skb; return skb;
} }
...@@ -1322,7 +1323,6 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk, ...@@ -1322,7 +1323,6 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
skb->truesize += copy; skb->truesize += copy;
sk_wmem_queued_add(ssk, copy); sk_wmem_queued_add(ssk, copy);
sk_mem_charge(ssk, copy); sk_mem_charge(ssk, copy);
skb->ip_summed = CHECKSUM_PARTIAL;
WRITE_ONCE(tcp_sk(ssk)->write_seq, tcp_sk(ssk)->write_seq + copy); WRITE_ONCE(tcp_sk(ssk)->write_seq, tcp_sk(ssk)->write_seq + copy);
TCP_SKB_CB(skb)->end_seq += copy; TCP_SKB_CB(skb)->end_seq += copy;
tcp_skb_pcount_set(skb, 0); tcp_skb_pcount_set(skb, 0);
......
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