aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/xen-netback/netback.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index 01a33cc58cf1..9f7184404263 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -1156,7 +1156,6 @@ static int netbk_set_skb_gso(struct xenvif *vif,
1156static int checksum_setup(struct xenvif *vif, struct sk_buff *skb) 1156static int checksum_setup(struct xenvif *vif, struct sk_buff *skb)
1157{ 1157{
1158 struct iphdr *iph; 1158 struct iphdr *iph;
1159 unsigned char *th;
1160 int err = -EPROTO; 1159 int err = -EPROTO;
1161 int recalculate_partial_csum = 0; 1160 int recalculate_partial_csum = 0;
1162 1161
@@ -1180,28 +1179,26 @@ static int checksum_setup(struct xenvif *vif, struct sk_buff *skb)
1180 goto out; 1179 goto out;
1181 1180
1182 iph = (void *)skb->data; 1181 iph = (void *)skb->data;
1183 th = skb->data + 4 * iph->ihl;
1184 if (th >= skb_tail_pointer(skb))
1185 goto out;
1186
1187 skb_set_transport_header(skb, 4 * iph->ihl);
1188 skb->csum_start = th - skb->head;
1189 switch (iph->protocol) { 1182 switch (iph->protocol) {
1190 case IPPROTO_TCP: 1183 case IPPROTO_TCP:
1191 skb->csum_offset = offsetof(struct tcphdr, check); 1184 if (!skb_partial_csum_set(skb, 4 * iph->ihl,
1185 offsetof(struct tcphdr, check)))
1186 goto out;
1192 1187
1193 if (recalculate_partial_csum) { 1188 if (recalculate_partial_csum) {
1194 struct tcphdr *tcph = (struct tcphdr *)th; 1189 struct tcphdr *tcph = tcp_hdr(skb);
1195 tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, 1190 tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr,
1196 skb->len - iph->ihl*4, 1191 skb->len - iph->ihl*4,
1197 IPPROTO_TCP, 0); 1192 IPPROTO_TCP, 0);
1198 } 1193 }
1199 break; 1194 break;
1200 case IPPROTO_UDP: 1195 case IPPROTO_UDP:
1201 skb->csum_offset = offsetof(struct udphdr, check); 1196 if (!skb_partial_csum_set(skb, 4 * iph->ihl,
1197 offsetof(struct udphdr, check)))
1198 goto out;
1202 1199
1203 if (recalculate_partial_csum) { 1200 if (recalculate_partial_csum) {
1204 struct udphdr *udph = (struct udphdr *)th; 1201 struct udphdr *udph = udp_hdr(skb);
1205 udph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, 1202 udph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr,
1206 skb->len - iph->ihl*4, 1203 skb->len - iph->ihl*4,
1207 IPPROTO_UDP, 0); 1204 IPPROTO_UDP, 0);
@@ -1215,9 +1212,6 @@ static int checksum_setup(struct xenvif *vif, struct sk_buff *skb)
1215 goto out; 1212 goto out;
1216 } 1213 }
1217 1214
1218 if ((th + skb->csum_offset + 2) > skb_tail_pointer(skb))
1219 goto out;
1220
1221 err = 0; 1215 err = 0;
1222 1216
1223out: 1217out: