Commit 23a5708d authored by Alex Elder's avatar Alex Elder Committed by David S. Miller

net: qualcomm: rmnet: avoid unnecessary IPv6 byte-swapping

In the previous patch IPv4 download checksum offload code was
updated to avoid unnecessary byte swapping, based on properties of
the Internet checksum algorithm.  This patch makes comparable
changes to the IPv6 download checksum offload handling.
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a2918a16
...@@ -123,10 +123,11 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb, ...@@ -123,10 +123,11 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb,
struct ipv6hdr *ip6h = (struct ipv6hdr *)skb->data; struct ipv6hdr *ip6h = (struct ipv6hdr *)skb->data;
void *txporthdr = skb->data + sizeof(*ip6h); void *txporthdr = skb->data + sizeof(*ip6h);
__sum16 *csum_field, pseudo_csum, csum_temp; __sum16 *csum_field, pseudo_csum, csum_temp;
u16 csum_value, csum_value_final;
__be16 ip6_hdr_csum, addend; __be16 ip6_hdr_csum, addend;
__sum16 ip6_payload_csum; __sum16 ip6_payload_csum;
__be16 ip_header_csum; __be16 ip_header_csum;
u16 csum_value_final;
__be16 csum_value;
u32 length; u32 length;
/* Checksum offload is only supported for UDP and TCP protocols; /* Checksum offload is only supported for UDP and TCP protocols;
...@@ -144,21 +145,21 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb, ...@@ -144,21 +145,21 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb,
* of the IP header from the trailer checksum. We then add the * of the IP header from the trailer checksum. We then add the
* checksum computed over the pseudo header. * checksum computed over the pseudo header.
*/ */
csum_value = ~ntohs(csum_trailer->csum_value); csum_value = ~csum_trailer->csum_value;
ip_header_csum = (__force __be16)ip_fast_csum(ip6h, sizeof(*ip6h) / 4); ip_header_csum = (__force __be16)ip_fast_csum(ip6h, sizeof(*ip6h) / 4);
ip6_hdr_csum = (__force __be16)~ntohs(ip_header_csum); ip6_hdr_csum = (__force __be16)~ip_header_csum;
ip6_payload_csum = csum16_sub((__force __sum16)csum_value, ip6_payload_csum = csum16_sub((__force __sum16)csum_value,
ip6_hdr_csum); ip6_hdr_csum);
length = (ip6h->nexthdr == IPPROTO_UDP) ? length = (ip6h->nexthdr == IPPROTO_UDP) ?
ntohs(((struct udphdr *)txporthdr)->len) : ntohs(((struct udphdr *)txporthdr)->len) :
ntohs(ip6h->payload_len); ntohs(ip6h->payload_len);
pseudo_csum = ~(csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr, pseudo_csum = ~csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr,
length, ip6h->nexthdr, 0)); length, ip6h->nexthdr, 0);
addend = (__force __be16)ntohs((__force __be16)pseudo_csum); addend = (__force __be16)pseudo_csum;
pseudo_csum = csum16_add(ip6_payload_csum, addend); pseudo_csum = csum16_add(ip6_payload_csum, addend);
addend = (__force __be16)ntohs((__force __be16)*csum_field); addend = (__force __be16)*csum_field;
csum_temp = ~csum16_sub(pseudo_csum, addend); csum_temp = ~csum16_sub(pseudo_csum, addend);
csum_value_final = (__force u16)csum_temp; csum_value_final = (__force u16)csum_temp;
...@@ -179,7 +180,7 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb, ...@@ -179,7 +180,7 @@ rmnet_map_ipv6_dl_csum_trailer(struct sk_buff *skb,
} }
} }
if (csum_value_final == ntohs((__force __be16)*csum_field)) { if (csum_value_final == (__force u16)*csum_field) {
priv->stats.csum_ok++; priv->stats.csum_ok++;
return 0; return 0;
} else { } else {
......
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