diff options
author | WANG Cong <xiyou.wangcong@gmail.com> | 2014-06-02 19:12:02 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-06-05 03:51:47 -0400 |
commit | ebbe495f19d565bb39be31ca28126a222b6a66dd (patch) | |
tree | 83588417e8efb7e6a73ed916cdfcb1a99b6265ac /net/ipv4 | |
parent | 4cb28970a23ff209199b0a4358d68efe82c8f493 (diff) |
ipv4: use skb frags api in udp4_hwcsum()
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/udp.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 8d8c33d84c9a..185ed3e59802 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
@@ -727,13 +727,12 @@ EXPORT_SYMBOL(udp_flush_pending_frames); | |||
727 | void udp4_hwcsum(struct sk_buff *skb, __be32 src, __be32 dst) | 727 | void udp4_hwcsum(struct sk_buff *skb, __be32 src, __be32 dst) |
728 | { | 728 | { |
729 | struct udphdr *uh = udp_hdr(skb); | 729 | struct udphdr *uh = udp_hdr(skb); |
730 | struct sk_buff *frags = skb_shinfo(skb)->frag_list; | ||
731 | int offset = skb_transport_offset(skb); | 730 | int offset = skb_transport_offset(skb); |
732 | int len = skb->len - offset; | 731 | int len = skb->len - offset; |
733 | int hlen = len; | 732 | int hlen = len; |
734 | __wsum csum = 0; | 733 | __wsum csum = 0; |
735 | 734 | ||
736 | if (!frags) { | 735 | if (!skb_has_frag_list(skb)) { |
737 | /* | 736 | /* |
738 | * Only one fragment on the socket. | 737 | * Only one fragment on the socket. |
739 | */ | 738 | */ |
@@ -742,15 +741,17 @@ void udp4_hwcsum(struct sk_buff *skb, __be32 src, __be32 dst) | |||
742 | uh->check = ~csum_tcpudp_magic(src, dst, len, | 741 | uh->check = ~csum_tcpudp_magic(src, dst, len, |
743 | IPPROTO_UDP, 0); | 742 | IPPROTO_UDP, 0); |
744 | } else { | 743 | } else { |
744 | struct sk_buff *frags; | ||
745 | |||
745 | /* | 746 | /* |
746 | * HW-checksum won't work as there are two or more | 747 | * HW-checksum won't work as there are two or more |
747 | * fragments on the socket so that all csums of sk_buffs | 748 | * fragments on the socket so that all csums of sk_buffs |
748 | * should be together | 749 | * should be together |
749 | */ | 750 | */ |
750 | do { | 751 | skb_walk_frags(skb, frags) { |
751 | csum = csum_add(csum, frags->csum); | 752 | csum = csum_add(csum, frags->csum); |
752 | hlen -= frags->len; | 753 | hlen -= frags->len; |
753 | } while ((frags = frags->next)); | 754 | } |
754 | 755 | ||
755 | csum = skb_checksum(skb, offset, hlen, csum); | 756 | csum = skb_checksum(skb, offset, hlen, csum); |
756 | skb->ip_summed = CHECKSUM_NONE; | 757 | skb->ip_summed = CHECKSUM_NONE; |