summaryrefslogtreecommitdiffstats
path: root/drivers/net/xen-netfront.c
diff options
context:
space:
mode:
authorPaul Durrant <Paul.Durrant@citrix.com>2014-01-09 05:02:48 -0500
committerDavid S. Miller <davem@davemloft.net>2014-01-14 17:24:19 -0500
commitb5cf66cd114ca24757ccf7c1f3e4d8ed86fe868c (patch)
tree66260c1adbda75fb290ca7085337045c91706aef /drivers/net/xen-netfront.c
parent2721637c1c0f644d7d67d0698c4a32b440d7f0f8 (diff)
xen-netfront: use new skb_checksum_setup function
Use skb_checksum_setup to set up partial checksum offsets rather then a private implementation. Signed-off-by: Paul Durrant <paul.durrant@citrix.com> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com> Cc: David Vrabel <david.vrabel@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/xen-netfront.c')
-rw-r--r--drivers/net/xen-netfront.c48
1 files changed, 3 insertions, 45 deletions
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index e59acb1daa23..c41537b577a4 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -859,9 +859,7 @@ static RING_IDX xennet_fill_frags(struct netfront_info *np,
859 859
860static int checksum_setup(struct net_device *dev, struct sk_buff *skb) 860static int checksum_setup(struct net_device *dev, struct sk_buff *skb)
861{ 861{
862 struct iphdr *iph; 862 bool recalculate_partial_csum = false;
863 int err = -EPROTO;
864 int recalculate_partial_csum = 0;
865 863
866 /* 864 /*
867 * A GSO SKB must be CHECKSUM_PARTIAL. However some buggy 865 * A GSO SKB must be CHECKSUM_PARTIAL. However some buggy
@@ -873,54 +871,14 @@ static int checksum_setup(struct net_device *dev, struct sk_buff *skb)
873 struct netfront_info *np = netdev_priv(dev); 871 struct netfront_info *np = netdev_priv(dev);
874 np->rx_gso_checksum_fixup++; 872 np->rx_gso_checksum_fixup++;
875 skb->ip_summed = CHECKSUM_PARTIAL; 873 skb->ip_summed = CHECKSUM_PARTIAL;
876 recalculate_partial_csum = 1; 874 recalculate_partial_csum = true;
877 } 875 }
878 876
879 /* A non-CHECKSUM_PARTIAL SKB does not require setup. */ 877 /* A non-CHECKSUM_PARTIAL SKB does not require setup. */
880 if (skb->ip_summed != CHECKSUM_PARTIAL) 878 if (skb->ip_summed != CHECKSUM_PARTIAL)
881 return 0; 879 return 0;
882 880
883 if (skb->protocol != htons(ETH_P_IP)) 881 return skb_checksum_setup(skb, recalculate_partial_csum);
884 goto out;
885
886 iph = (void *)skb->data;
887
888 switch (iph->protocol) {
889 case IPPROTO_TCP:
890 if (!skb_partial_csum_set(skb, 4 * iph->ihl,
891 offsetof(struct tcphdr, check)))
892 goto out;
893
894 if (recalculate_partial_csum) {
895 struct tcphdr *tcph = tcp_hdr(skb);
896 tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr,
897 skb->len - iph->ihl*4,
898 IPPROTO_TCP, 0);
899 }
900 break;
901 case IPPROTO_UDP:
902 if (!skb_partial_csum_set(skb, 4 * iph->ihl,
903 offsetof(struct udphdr, check)))
904 goto out;
905
906 if (recalculate_partial_csum) {
907 struct udphdr *udph = udp_hdr(skb);
908 udph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr,
909 skb->len - iph->ihl*4,
910 IPPROTO_UDP, 0);
911 }
912 break;
913 default:
914 if (net_ratelimit())
915 pr_err("Attempting to checksum a non-TCP/UDP packet, dropping a protocol %d packet\n",
916 iph->protocol);
917 goto out;
918 }
919
920 err = 0;
921
922out:
923 return err;
924} 882}
925 883
926static int handle_incoming_queue(struct net_device *dev, 884static int handle_incoming_queue(struct net_device *dev,