xen-netback: make sure skb linear area covers checksum field
Subsystems (3)
PATCH 1/1 xen-netback: make sure skb linear area covers checksum field
skb_partial_csum_set requires that the linear area of the skb covers the checksum field. The checksum setup code in netback was only doing that pullup in the case when the pseudo header checksum was being recalculated though. This patch makes that pullup unconditional. (I pullup the whole transport header just for simplicity; the requirement is only for the check field but in the case of UDP this is the last field in the header and in the case of TCP it's the last but one).
The lack of pullup manifested as failures running Microsoft HCK network tests on a pair of Windows 8 VMs and it has been verified that this patch fixes the problem.
--- drivers/net/xen-netback/netback.c | 60 +++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 32 deletions(-)
drivers/net/xen-netback/netback.c +28 -32
@@ -1199,42 +1199,40 @@ static int checksum_setup_ip(struct xenvif *vif, struct sk_buff *skb,switch (ip_hdr (skb)->protocol) {case IPPROTO_TCP : + err =maybe_pull_tail (skb, + off +sizeof (struct tcphdr ), +MAX_IP_HDR_LEN ); +if (err <0 ) + goto out; +if (!skb_partial_csum_set (skb, off, offsetof(struct tcphdr , check))) goto out; -if (recalculate_partial_csum) { - err =maybe_pull_tail (skb, - off +sizeof (struct tcphdr ), -MAX_IP_HDR_LEN ); -if (err <0 ) - goto out; - +if (recalculate_partial_csum)tcp_hdr (skb)->check = ~csum_tcpudp_magic (ip_hdr (skb)->saddr,ip_hdr (skb)->daddr, skb->len - off,IPPROTO_TCP ,0 ); - }break ;case IPPROTO_UDP : + err =maybe_pull_tail (skb, + off +sizeof (struct udphdr ), +MAX_IP_HDR_LEN ); +if (err <0 ) + goto out; +if (!skb_partial_csum_set (skb, off, offsetof(struct udphdr , check))) goto out; -if (recalculate_partial_csum) { - err =maybe_pull_tail (skb, - off +sizeof (struct udphdr ), -MAX_IP_HDR_LEN ); -if (err <0 ) - goto out; - +if (recalculate_partial_csum)udp_hdr (skb)->check = ~csum_tcpudp_magic (ip_hdr (skb)->saddr,ip_hdr (skb)->daddr, skb->len - off,IPPROTO_UDP ,0 ); - }break ;default : goto out;
@@ -1342,42 +1340,40 @@ static int checksum_setup_ipv6(struct xenvif *vif, struct sk_buff *skb,switch (nexthdr) {case IPPROTO_TCP : + err =maybe_pull_tail (skb, + off +sizeof (struct tcphdr ), +MAX_IPV6_HDR_LEN ); +if (err <0 ) + goto out; +if (!skb_partial_csum_set (skb, off, offsetof(struct tcphdr , check))) goto out; -if (recalculate_partial_csum) { - err =maybe_pull_tail (skb, - off +sizeof (struct tcphdr ), -MAX_IPV6_HDR_LEN ); -if (err <0 ) - goto out; - +if (recalculate_partial_csum)tcp_hdr (skb)->check = ~csum_ipv6_magic (&ipv6_hdr (skb)->saddr, &ipv6_hdr (skb)->daddr, skb->len - off,IPPROTO_TCP ,0 ); - }break ;case IPPROTO_UDP : + err =maybe_pull_tail (skb, + off +sizeof (struct udphdr ), +MAX_IPV6_HDR_LEN ); +if (err <0 ) + goto out; +if (!skb_partial_csum_set (skb, off, offsetof(struct udphdr , check))) goto out; -if (recalculate_partial_csum) { - err =maybe_pull_tail (skb, - off +sizeof (struct udphdr ), -MAX_IPV6_HDR_LEN ); -if (err <0 ) - goto out; - +if (recalculate_partial_csum)udp_hdr (skb)->check = ~csum_ipv6_magic (&ipv6_hdr (skb)->saddr, &ipv6_hdr (skb)->daddr, skb->len - off,IPPROTO_UDP ,0 ); - }break ;default : goto out;
Signature · 1 line
1.7.10.4
Quoted 9 lines
Quoted 1 line
Quoted 1 line · Paul Durrant
skb_partial_csum_setrequires that the linear area of the skb covers the checksum field. The checksum setup code in netback was only doing that pullup in the case when the pseudo header checksum was being recalculated though. This patch makes that pullup unconditional. (I pullup the whole transport header just for simplicity; the requirement is only for the check field but in the case of UDP this is the last field in the header and in the case of TCP it's the last but one).
Quoted 4 lines
The lack of pullup manifested as failures running Microsoft HCK network tests on a pair of Windows 8 VMs and it has been verified that this patch fixes the problem.
(or Reported-by, whatever you like better)
Quoted 1 line
Signed-off-by Paul Durrant <[email protected]>
Quoted 136 lines
Cc Wei Liu <[email protected]>Cc Ian Campbell <[email protected]>Cc David Vrabel <[email protected]>--- drivers/net/xen-netback/netback.c | 60 +++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 32 deletions(-)drivers/net/xen-netback/netback.c +14
-16@@ -1199,42 +1199,40 @@ static int checksum_setup_ip(struct xenvif *vif, struct sk_buff *skb, switch (ip_hdr(skb)->protocol) {case IPPROTO_TCP : + err =maybe_pull_tail (skb, + off +sizeof (struct tcphdr ), +MAX_IP_HDR_LEN ); +if (err <0 ) + goto out; +if (!skb_partial_csum_set (skb, off, offsetof(struct tcphdr , check))) goto out; -if (recalculate_partial_csum) { - err =maybe_pull_tail (skb, - off +sizeof (struct tcphdr ), -MAX_IP_HDR_LEN ); -if (err <0 ) - goto out; - +if (recalculate_partial_csum)tcp_hdr (skb)->check = ~csum_tcpudp_magic (ip_hdr (skb)->saddr,ip_hdr (skb)->daddr, skb->len - off,IPPROTO_TCP ,0 ); - }break ;case IPPROTO_UDP : + err =maybe_pull_tail (skb, + off +sizeof (struct udphdr ), +MAX_IP_HDR_LEN ); +if (err <0 ) + goto out; +if (!skb_partial_csum_set (skb, off, offsetof(struct udphdr , check))) goto out; -if (recalculate_partial_csum) { - err =maybe_pull_tail (skb, - off +sizeof (struct udphdr ), -MAX_IP_HDR_LEN ); -if (err <0 ) - goto out; - +if (recalculate_partial_csum)udp_hdr (skb)->check = ~csum_tcpudp_magic (ip_hdr (skb)->saddr,ip_hdr (skb)->daddr, skb->len - off,IPPROTO_UDP ,0 ); - }break ;default :drivers/net/xen-netback/netback.c +14
-16goto out;@@ -1342,42 +1340,40 @@ static int checksum_setup_ipv6(struct xenvif *vif, struct sk_buff *skb, switch (nexthdr) {case IPPROTO_TCP : + err =maybe_pull_tail (skb, + off +sizeof (struct tcphdr ), +MAX_IPV6_HDR_LEN ); +if (err <0 ) + goto out; +if (!skb_partial_csum_set (skb, off, offsetof(struct tcphdr , check))) goto out; -if (recalculate_partial_csum) { - err =maybe_pull_tail (skb, - off +sizeof (struct tcphdr ), -MAX_IPV6_HDR_LEN ); -if (err <0 ) - goto out; - +if (recalculate_partial_csum)tcp_hdr (skb)->check = ~csum_ipv6_magic (&ipv6_hdr (skb)->saddr, &ipv6_hdr (skb)->daddr, skb->len - off,IPPROTO_TCP ,0 ); - }break ;case IPPROTO_UDP : + err =maybe_pull_tail (skb, + off +sizeof (struct udphdr ), +MAX_IPV6_HDR_LEN ); +if (err <0 ) + goto out; +if (!skb_partial_csum_set (skb, off, offsetof(struct udphdr , check))) goto out; -if (recalculate_partial_csum) { - err =maybe_pull_tail (skb, - off +sizeof (struct udphdr ), -MAX_IPV6_HDR_LEN ); -if (err <0 ) - goto out; - +if (recalculate_partial_csum)udp_hdr (skb)->check = ~csum_ipv6_magic (&ipv6_hdr (skb)->saddr, &ipv6_hdr (skb)->daddr, skb->len - off,IPPROTO_UDP ,0 ); - }break ;default :goto out;
Signature · 7 lines
1.7.10.4 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 9 lines
Quoted 1 line
Quoted 1 line · Paul Durrant
skb_partial_csum_setrequires that the linear area of the skb covers the checksum field. The checksum setup code in netback was only doing that pullup in the case when the pseudo header checksum was being recalculated though. This patch makes that pullup unconditional. (I pullup the whole transport header just for simplicity; the requirement is only for the check field but in the case of UDP this is the last field in the header and in the case of TCP it's the last but one).
Quoted 4 lines
The lack of pullup manifested as failures running Microsoft HCK network tests on a pair of Windows 8 VMs and it has been verified that this patch fixes the problem.
(or Reported-by, whatever you like better)
Quoted 1 line
Signed-off-by Paul Durrant <[email protected]>
Quoted 136 lines
Cc Wei Liu <[email protected]>Cc Ian Campbell <[email protected]>Cc David Vrabel <[email protected]>--- drivers/net/xen-netback/netback.c | 60 +++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 32 deletions(-)drivers/net/xen-netback/netback.c +14
-16@@ -1199,42 +1199,40 @@ static int checksum_setup_ip(struct xenvif *vif, struct sk_buff *skb, switch (ip_hdr(skb)->protocol) {case IPPROTO_TCP : + err =maybe_pull_tail (skb, + off +sizeof (struct tcphdr ), +MAX_IP_HDR_LEN ); +if (err <0 ) + goto out; +if (!skb_partial_csum_set (skb, off, offsetof(struct tcphdr , check))) goto out; -if (recalculate_partial_csum) { - err =maybe_pull_tail (skb, - off +sizeof (struct tcphdr ), -MAX_IP_HDR_LEN ); -if (err <0 ) - goto out; - +if (recalculate_partial_csum)tcp_hdr (skb)->check = ~csum_tcpudp_magic (ip_hdr (skb)->saddr,ip_hdr (skb)->daddr, skb->len - off,IPPROTO_TCP ,0 ); - }break ;case IPPROTO_UDP : + err =maybe_pull_tail (skb, + off +sizeof (struct udphdr ), +MAX_IP_HDR_LEN ); +if (err <0 ) + goto out; +if (!skb_partial_csum_set (skb, off, offsetof(struct udphdr , check))) goto out; -if (recalculate_partial_csum) { - err =maybe_pull_tail (skb, - off +sizeof (struct udphdr ), -MAX_IP_HDR_LEN ); -if (err <0 ) - goto out; - +if (recalculate_partial_csum)udp_hdr (skb)->check = ~csum_tcpudp_magic (ip_hdr (skb)->saddr,ip_hdr (skb)->daddr, skb->len - off,IPPROTO_UDP ,0 ); - }break ;default :drivers/net/xen-netback/netback.c +14
-16goto out;@@ -1342,42 +1340,40 @@ static int checksum_setup_ipv6(struct xenvif *vif, struct sk_buff *skb, switch (nexthdr) {case IPPROTO_TCP : + err =maybe_pull_tail (skb, + off +sizeof (struct tcphdr ), +MAX_IPV6_HDR_LEN ); +if (err <0 ) + goto out; +if (!skb_partial_csum_set (skb, off, offsetof(struct tcphdr , check))) goto out; -if (recalculate_partial_csum) { - err =maybe_pull_tail (skb, - off +sizeof (struct tcphdr ), -MAX_IPV6_HDR_LEN ); -if (err <0 ) - goto out; - +if (recalculate_partial_csum)tcp_hdr (skb)->check = ~csum_ipv6_magic (&ipv6_hdr (skb)->saddr, &ipv6_hdr (skb)->daddr, skb->len - off,IPPROTO_TCP ,0 ); - }break ;case IPPROTO_UDP : + err =maybe_pull_tail (skb, + off +sizeof (struct udphdr ), +MAX_IPV6_HDR_LEN ); +if (err <0 ) + goto out; +if (!skb_partial_csum_set (skb, off, offsetof(struct udphdr , check))) goto out; -if (recalculate_partial_csum) { - err =maybe_pull_tail (skb, - off +sizeof (struct udphdr ), -MAX_IPV6_HDR_LEN ); -if (err <0 ) - goto out; - +if (recalculate_partial_csum)udp_hdr (skb)->check = ~csum_ipv6_magic (&ipv6_hdr (skb)->saddr, &ipv6_hdr (skb)->daddr, skb->len - off,IPPROTO_UDP ,0 ); - }break ;default :goto out;
Signature · 7 lines
1.7.10.4 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
From: Paul Durrant <[email protected]>
Date: Wed, 11 Dec 2013 16:37:40 +0000
Quoted 8 lines
skb_partial_csum_setrequires that the linear area of the skb covers the checksum field. The checksum setup code in netback was only doing that pullup in the case when the pseudo header checksum was being recalculated though. This patch makes that pullup unconditional. (I pullup the whole transport header just for simplicity; the requirement is only for the check field but in the case of UDP this is the last field in the header and in the case of TCP it's the last but one).
Quoted 5 lines
The lack of pullup manifested as failures running Microsoft HCK network tests on a pair of Windows 8 VMs and it has been verified that this patch fixes the problem.
Signed-off-by Paul Durrant <[email protected]>
Applied, thank you.
From: Paul Durrant <[email protected]>
Date: Wed, 11 Dec 2013 16:37:40 +0000
Quoted 8 lines
skb_partial_csum_setrequires that the linear area of the skb covers the checksum field. The checksum setup code in netback was only doing that pullup in the case when the pseudo header checksum was being recalculated though. This patch makes that pullup unconditional. (I pullup the whole transport header just for simplicity; the requirement is only for the check field but in the case of UDP this is the last field in the header and in the case of TCP it's the last but one).
Quoted 5 lines
The lack of pullup manifested as failures running Microsoft HCK network tests on a pair of Windows 8 VMs and it has been verified that this patch fixes the problem.
Signed-off-by Paul Durrant <[email protected]>
Applied, thank you.