Commit 76443456 authored by Alexander Duyck's avatar Alexander Duyck Committed by David S. Miller

net: Move GSO csum into SKB_GSO_CB

This patch moves the checksum maintained by GSO out of skb->csum and into
the GSO context block in order to allow for us to work on outer checksums
while maintaining the inner checksum offsets in the case of the inner
checksum being offloaded, while the outer checksums will be computed.

While updating the code I also did a minor cleanu-up on gso_make_checksum.
The change is mostly to make it so that we store the values and compute the
checksum instead of computing the checksum and then storing the values we
needed to update.
Signed-off-by: default avatarAlexander Duyck <aduyck@mirantis.com>
Acked-by: default avatarTom Herbert <tom@herbertland.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bef3c6c9
...@@ -3549,6 +3549,7 @@ static inline struct sec_path *skb_sec_path(struct sk_buff *skb) ...@@ -3549,6 +3549,7 @@ static inline struct sec_path *skb_sec_path(struct sk_buff *skb)
struct skb_gso_cb { struct skb_gso_cb {
int mac_offset; int mac_offset;
int encap_level; int encap_level;
__wsum csum;
__u16 csum_start; __u16 csum_start;
}; };
#define SKB_SGO_CB_OFFSET 32 #define SKB_SGO_CB_OFFSET 32
...@@ -3585,15 +3586,14 @@ static inline int gso_pskb_expand_head(struct sk_buff *skb, int extra) ...@@ -3585,15 +3586,14 @@ static inline int gso_pskb_expand_head(struct sk_buff *skb, int extra)
*/ */
static inline __sum16 gso_make_checksum(struct sk_buff *skb, __wsum res) static inline __sum16 gso_make_checksum(struct sk_buff *skb, __wsum res)
{ {
int plen = SKB_GSO_CB(skb)->csum_start - skb_headroom(skb) - unsigned char *csum_start = skb_transport_header(skb);
skb_transport_offset(skb); int plen = (skb->head + SKB_GSO_CB(skb)->csum_start) - csum_start;
__wsum partial; __wsum partial = SKB_GSO_CB(skb)->csum;
partial = csum_partial(skb_transport_header(skb), plen, skb->csum); SKB_GSO_CB(skb)->csum = res;
skb->csum = res; SKB_GSO_CB(skb)->csum_start = csum_start - skb->head;
SKB_GSO_CB(skb)->csum_start -= plen;
return csum_fold(partial); return csum_fold(csum_partial(csum_start, plen, partial));
} }
static inline bool skb_is_gso(const struct sk_buff *skb) static inline bool skb_is_gso(const struct sk_buff *skb)
......
...@@ -3100,11 +3100,12 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb, ...@@ -3100,11 +3100,12 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
if (!sg && !nskb->remcsum_offload) { if (!sg && !nskb->remcsum_offload) {
nskb->ip_summed = CHECKSUM_NONE; nskb->ip_summed = CHECKSUM_NONE;
nskb->csum = skb_copy_and_csum_bits(head_skb, offset, SKB_GSO_CB(nskb)->csum =
skb_put(nskb, len), skb_copy_and_csum_bits(head_skb, offset,
len, 0); skb_put(nskb, len),
len, 0);
SKB_GSO_CB(nskb)->csum_start = SKB_GSO_CB(nskb)->csum_start =
skb_headroom(nskb) + doffset; skb_headroom(nskb) + doffset;
continue; continue;
} }
...@@ -3171,11 +3172,12 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb, ...@@ -3171,11 +3172,12 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
perform_csum_check: perform_csum_check:
if (!csum && !nskb->remcsum_offload) { if (!csum && !nskb->remcsum_offload) {
nskb->csum = skb_checksum(nskb, doffset,
nskb->len - doffset, 0);
nskb->ip_summed = CHECKSUM_NONE; nskb->ip_summed = CHECKSUM_NONE;
SKB_GSO_CB(nskb)->csum =
skb_checksum(nskb, doffset,
nskb->len - doffset, 0);
SKB_GSO_CB(nskb)->csum_start = SKB_GSO_CB(nskb)->csum_start =
skb_headroom(nskb) + doffset; skb_headroom(nskb) + doffset;
} }
} while ((offset += len) < head_skb->len); } while ((offset += len) < head_skb->len);
......
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