提交 7fbeffed 编写于 作者: A Alexander Duyck 提交者: David S. Miller

net: Update remote checksum segmentation to support use of GSO checksum

This patch addresses two main issues.

First in the case of remote checksum offload we were avoiding dealing with
scatter-gather issues.  As a result it would be possible to assemble a
series of frames that used frags instead of being linearized as they should
have if remote checksum offload was enabled.

Second I have updated the code so that we now let GSO take care of doing
the checksum on the data itself and drop the special case that was added
for remote checksum offload.
Signed-off-by: NAlexander Duyck <aduyck@mirantis.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 76443456
...@@ -3098,8 +3098,9 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb, ...@@ -3098,8 +3098,9 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
if (nskb->len == len + doffset) if (nskb->len == len + doffset)
goto perform_csum_check; goto perform_csum_check;
if (!sg && !nskb->remcsum_offload) { if (!sg) {
nskb->ip_summed = CHECKSUM_NONE; if (!nskb->remcsum_offload)
nskb->ip_summed = CHECKSUM_NONE;
SKB_GSO_CB(nskb)->csum = SKB_GSO_CB(nskb)->csum =
skb_copy_and_csum_bits(head_skb, offset, skb_copy_and_csum_bits(head_skb, offset,
skb_put(nskb, len), skb_put(nskb, len),
...@@ -3171,8 +3172,9 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb, ...@@ -3171,8 +3172,9 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
nskb->truesize += nskb->data_len; nskb->truesize += nskb->data_len;
perform_csum_check: perform_csum_check:
if (!csum && !nskb->remcsum_offload) { if (!csum) {
nskb->ip_summed = CHECKSUM_NONE; if (!nskb->remcsum_offload)
nskb->ip_summed = CHECKSUM_NONE;
SKB_GSO_CB(nskb)->csum = SKB_GSO_CB(nskb)->csum =
skb_checksum(nskb, doffset, skb_checksum(nskb, doffset,
nskb->len - doffset, 0); nskb->len - doffset, 0);
......
...@@ -66,6 +66,16 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb, ...@@ -66,6 +66,16 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,
features &= skb->dev->hw_enc_features; features &= skb->dev->hw_enc_features;
/* The only checksum offload we care about from here on out is the
* outer one so strip the existing checksum feature flags and
* instead set the flag based on our outer checksum offload value.
*/
if (remcsum) {
features &= ~NETIF_F_CSUM_MASK;
if (offload_csum)
features |= NETIF_F_HW_CSUM;
}
/* segment inner packet. */ /* segment inner packet. */
segs = gso_inner_segment(skb, features); segs = gso_inner_segment(skb, features);
if (IS_ERR_OR_NULL(segs)) { if (IS_ERR_OR_NULL(segs)) {
...@@ -116,18 +126,6 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb, ...@@ -116,18 +126,6 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,
skb->ip_summed = CHECKSUM_PARTIAL; skb->ip_summed = CHECKSUM_PARTIAL;
skb->csum_start = skb_transport_header(skb) - skb->head; skb->csum_start = skb_transport_header(skb) - skb->head;
skb->csum_offset = offsetof(struct udphdr, check); skb->csum_offset = offsetof(struct udphdr, check);
} else if (remcsum) {
/* Need to calculate checksum from scratch,
* inner checksums are never when doing
* remote_checksum_offload.
*/
skb->csum = skb_checksum(skb, udp_offset,
skb->len - udp_offset,
0);
uh->check = csum_fold(skb->csum);
if (uh->check == 0)
uh->check = CSUM_MANGLED_0;
} else { } else {
uh->check = gso_make_checksum(skb, ~uh->check); uh->check = gso_make_checksum(skb, ~uh->check);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册