xen-netback: fix fragment detection in checksum setup
Subsystems (4)
PATCH v4 1/1 xen-netback: fix fragment detection in checksum setup
The code to detect fragments in checksum_setup() was missing for IPv4 and too eager for IPv6. (It transpires that Windows seems to send IPv6 packets with a fragment header even if they are not a fragment - i.e. offset is zero, and M bit is not set).
This patch also incorporates a fix to callers of maybe_pull_tail() where skb->network_header was being erroneously added to the length argument.
---
v4
- Re-work maybe_pull_tail() to have a failure path and update mac and network header pointers on success.
- Re-work callers of maybe_pull_tail() to handle failures and allow for movement of skb header pointers.
- Incorporate fixes from patch "Fix pull size in checksum_setup_ip" since it also modifies callers of maybe_pull_tail().
- Remove error messages in checksum routines that could be triggered by frontends
v3
- Use defined values for 'fragment offset' and 'more fragments'
v2
- Added comments noting what fragment/offset masks mean
drivers/net/xen-netback/netback.c | 215 ++++++++++++++++++++----------------- include/linux/ipv6.h | 1 + include/net/ipv6.h | 3 +- 3 files changed, 120 insertions(+), 99 deletions(-)
drivers/net/xen-netback/netback.c +117 -98
@@ -1149,49 +1149,62 @@ static int xenvif_set_skb_gso(struct xenvif *vif,return 0 ; } -static inline void maybe_pull_tail (struct sk_buff *skb,unsigned int len) +static inline bool maybe_pull_tail (struct sk_buff *skb,unsigned int len, +unsigned int max) { -if (skb_is_nonlinear (skb) &&skb_headlen (skb) < len) { -/* If we need to pullup then pullup to the max, so we -* won't need to do it again. -*/ -int target =min_t (int, skb->len,MAX_TCP_HEADER ); -__pskb_pull_tail (skb, target -skb_headlen (skb)); - } +if (skb_headlen (skb) >= len) +return true; + +/* If we need to pullup then pullup to the max, so we +* won't need to do it again. +*/ +if (max > skb->len) + max = skb->len; + +__pskb_pull_tail (skb, max -skb_headlen (skb)); + +return skb_headlen (skb) >= len; } +/* This value should be large enough to cover a tagged ethernet header plus +* maximally sized IP and TCP or UDP headers. +*/ +#define MAX_IP_HDR_LEN 128 +static int checksum_setup_ip (struct xenvif *vif,struct sk_buff *skb,int recalculate_partial_csum) { -struct iphdr *iph = (void *)skb->data; -unsigned int header_size;unsigned int off; +bool fragment;int err = -EPROTO ; - off =sizeof (struct iphdr ); + fragment = false; - header_size = skb->network_header + off +MAX_IPOPTLEN ; -maybe_pull_tail (skb, header_size); +if (!maybe_pull_tail (skb,sizeof (struct iphdr ),MAX_IP_HDR_LEN )) + goto out; + +if (ip_hdr (skb)->frag_off &htons (IP_OFFSET |IP_MF )) + fragment = true; - off = iph->ihl *4 ; + off =ip_hdrlen (skb); -switch (iph->protocol) { +switch (ip_hdr (skb)->protocol) {case IPPROTO_TCP :if (!skb_partial_csum_set (skb, off, offsetof(struct tcphdr , check))) goto out;if (recalculate_partial_csum) { -struct tcphdr *tcph =tcp_hdr (skb); - - header_size = skb->network_header + - off + -sizeof (struct tcphdr ); -maybe_pull_tail (skb, header_size); - - tcph->check = ~csum_tcpudp_magic (iph->saddr, iph->daddr, - skb->len - off, -IPPROTO_TCP ,0 ); +if (!maybe_pull_tail (skb, + off +sizeof (struct tcphdr ), +MAX_IP_HDR_LEN )) + goto out; + +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 :
@@ -1200,24 +1213,19 @@ static int checksum_setup_ip(struct xenvif *vif, struct sk_buff *skb, goto out;if (recalculate_partial_csum) { -struct udphdr *udph =udp_hdr (skb); - - header_size = skb->network_header + - off + -sizeof (struct udphdr ); -maybe_pull_tail (skb, header_size); - - udph->check = ~csum_tcpudp_magic (iph->saddr, iph->daddr, - skb->len - off, -IPPROTO_UDP ,0 ); +if (!maybe_pull_tail (skb, + off +sizeof (struct udphdr ), +MAX_IP_HDR_LEN )) + goto out; + +udp_hdr (skb)->check = + ~csum_tcpudp_magic (ip_hdr (skb)->saddr, +ip_hdr (skb)->daddr, + skb->len - off, +IPPROTO_UDP ,0 ); }break ;default : -if (net_ratelimit ()) -netdev_err (vif->dev, -"Attempting to checksum a non-TCP/UDP packet, " -"dropping a protocol %d packet\n" , - iph->protocol); goto out; }
@@ -1227,75 +1235,93 @@ out:return err; } +/* This value should be large enough to cover a tagged ethernet header plus +* an IPv6 header, all options, and a maximal TCP or UDP header. +*/ +#define MAX_IPV6_HDR_LEN 256 + +#define OPT_HDR (type, skb, off) \ + (type *)(skb_network_header(skb) + (off)) +static int checksum_setup_ipv6 (struct xenvif *vif,struct sk_buff *skb,int recalculate_partial_csum) {int err = -EPROTO ; -struct ipv6hdr *ipv6h = (void *)skb->data;u8 nexthdr; -unsigned int header_size;unsigned int off; +unsigned int len;bool fragment;bool done; + fragment = false; done = false; off =sizeof (struct ipv6hdr ); - header_size = skb->network_header + off; -maybe_pull_tail (skb, header_size); +if (!maybe_pull_tail (skb, off,MAX_IPV6_HDR_LEN )) + goto out; - nexthdr = ipv6h->nexthdr; + nexthdr =ipv6_hdr (skb)->nexthdr; -while ((off <=sizeof (struct ipv6hdr ) +ntohs (ipv6h->payload_len)) && - !done) { + len =sizeof (struct ipv6hdr ) +ntohs (ipv6_hdr (skb)->payload_len); +while (off <= len && !done) {switch (nexthdr) {case IPPROTO_DSTOPTS :case IPPROTO_HOPOPTS :case IPPROTO_ROUTING : { -struct ipv6_opt_hdr *hp = (void *)(skb->data + off); +struct ipv6_opt_hdr *hp; - header_size = skb->network_header + - off + -sizeof (struct ipv6_opt_hdr ); -maybe_pull_tail (skb, header_size); +if (!maybe_pull_tail (skb, + off + +sizeof (struct ipv6_opt_hdr ), +MAX_IPV6_HDR_LEN )) + goto out; + hp = OPT_HDR(struct ipv6_opt_hdr, skb, off); nexthdr = hp->nexthdr; off +=ipv6_optlen (hp);break ; }case IPPROTO_AH : { -struct ip_auth_hdr *hp = (void *)(skb->data + off); +struct ip_auth_hdr *hp; + +if (!maybe_pull_tail (skb, + off + +sizeof (struct ip_auth_hdr ), +MAX_IPV6_HDR_LEN )) + goto out; + + hp = OPT_HDR(struct ip_auth_hdr, skb, off); + nexthdr = hp->nexthdr; + off +=ipv6_authlen (hp); +break ; + } +case IPPROTO_FRAGMENT : { +struct frag_hdr *hp; + +if (!maybe_pull_tail (skb, + off + +sizeof (struct frag_hdr ), +MAX_IPV6_HDR_LEN )) + goto out; + + hp = OPT_HDR(struct frag_hdr, skb, off); - header_size = skb->network_header + - off + -sizeof (struct ip_auth_hdr ); -maybe_pull_tail (skb, header_size); +if (hp->frag_off &htons (IP6_OFFSET |IP6_MF )) + fragment = true; nexthdr = hp->nexthdr; - off += (hp->hdrlen+2 )<<2 ; + off +=sizeof (struct frag_hdr );break ; } -case IPPROTO_FRAGMENT : - fragment = true; -/* fall through */ default : done = true;break ; } } -if (!done) { -if (net_ratelimit ()) -netdev_err (vif->dev,"Failed to parse packet header\n" ); +if (!done || fragment) goto out; - } - -if (fragment) { -if (net_ratelimit ()) -netdev_err (vif->dev,"Packet is a fragment!\n" ); - goto out; - }switch (nexthdr) {case IPPROTO_TCP :
@@ -1304,17 +1330,16 @@ static int checksum_setup_ipv6(struct xenvif *vif, struct sk_buff *skb, goto out;if (recalculate_partial_csum) { -struct tcphdr *tcph =tcp_hdr (skb); - - header_size = skb->network_header + - off + -sizeof (struct tcphdr ); -maybe_pull_tail (skb, header_size); - - tcph->check = ~csum_ipv6_magic (&ipv6h->saddr, - &ipv6h->daddr, - skb->len - off, -IPPROTO_TCP ,0 ); +if (!maybe_pull_tail (skb, + off +sizeof (struct tcphdr ), +MAX_IPV6_HDR_LEN )) + goto out; + +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 :
@@ -1323,25 +1348,19 @@ static int checksum_setup_ipv6(struct xenvif *vif, struct sk_buff *skb, goto out;if (recalculate_partial_csum) { -struct udphdr *udph =udp_hdr (skb); - - header_size = skb->network_header + - off + -sizeof (struct udphdr ); -maybe_pull_tail (skb, header_size); - - udph->check = ~csum_ipv6_magic (&ipv6h->saddr, - &ipv6h->daddr, - skb->len - off, -IPPROTO_UDP ,0 ); +if (!maybe_pull_tail (skb, + off +sizeof (struct udphdr ), +MAX_IPV6_HDR_LEN )) + goto out; + +udp_hdr (skb)->check = + ~csum_ipv6_magic (&ipv6_hdr (skb)->saddr, + &ipv6_hdr (skb)->daddr, + skb->len - off, +IPPROTO_UDP ,0 ); }break ;default : -if (net_ratelimit ()) -netdev_err (vif->dev, -"Attempting to checksum a non-TCP/UDP packet, " -"dropping a protocol %d packet\n" , - nexthdr); goto out; }
include/linux/ipv6.h +1 -0
@@ -4,6 +4,7 @@#include <uapi/linux/ipv6.h> #define ipv6_optlen (p) (((p)->hdrlen+1) << 3) +#define ipv6_authlen (p) (((p)->hdrlen+2) << 2)/* * This structure contains configuration options per IPv6 link. */
include/net/ipv6.h +2 -1
@@ -110,7 +110,8 @@ struct frag_hdr {__be32 identification; }; -#define IP6_MF 0x0001 +#define IP6_MF 0x0001 +#define IP6_OFFSET 0xFFF8#include <net/sock.h>
Signature · 1 line
1.7.10.4
David Miller
maintainerYou sent two copies of this patch, is there a difference between them?
David Miller
maintainerYou sent two copies of this patch, is there a difference between them?
Quoted 11 lines
-----Original Message-----
From: [email protected] [mailto:netdev- [email protected]] On Behalf Of David Miller
Sent: 02 December 2013 18:46
To: Paul Durrant
Cc: [email protected]; [email protected]; Zoltan Kiss; Wei Liu; Ian Campbell; David Vrabel
Subject: Re: [PATCH net v4] xen-netback: fix fragment detection in checksum setup
Quoted 2 lines
You sent two copies of this patch, is there a difference between them?
Sorry. The SMTP server was playing up. The two copies are identical.
Paul
Quoted 11 lines
-----Original Message-----
From: [email protected] [mailto:netdev- [email protected]] On Behalf Of David Miller
Sent: 02 December 2013 18:46
To: Paul Durrant
Cc: [email protected]; [email protected]; Zoltan Kiss; Wei Liu; Ian Campbell; David Vrabel
Subject: Re: [PATCH net v4] xen-netback: fix fragment detection in checksum setup
Quoted 2 lines
You sent two copies of this patch, is there a difference between them?
Sorry. The SMTP server was playing up. The two copies are identical.
Paul
David Miller
maintainerFrom: Paul Durrant <[email protected]>
Date: Mon, 2 Dec 2013 17:35:15 +0000
Quoted 7 lines
The code to detect fragments in
checksum_setup()was missing for IPv4 and too eager for IPv6. (It transpires that Windows seems to send IPv6 packets with a fragment header even if they are not a fragment - i.e. offset is zero, and M bit is not set).
This patch also incorporates a fix to callers ofmaybe_pull_tail()whereskb->network_headerwas being erroneously added to the length argument.
Quoted 6 lines
Signed-off-by Paul Durrant <[email protected]>Signed-off-by Zoltan Kiss <[email protected]>Cc Wei Liu <[email protected]>Cc Ian Campbell <[email protected]>Cc David Vrabel <[email protected]>cc David Miller <[email protected]>
This addresses my concerned, Ian and Wei please review.
David Miller
maintainerFrom: Paul Durrant <[email protected]>
Date: Mon, 2 Dec 2013 17:35:15 +0000
Quoted 7 lines
The code to detect fragments in
checksum_setup()was missing for IPv4 and too eager for IPv6. (It transpires that Windows seems to send IPv6 packets with a fragment header even if they are not a fragment - i.e. offset is zero, and M bit is not set).
This patch also incorporates a fix to callers ofmaybe_pull_tail()whereskb->network_headerwas being erroneously added to the length argument.
Quoted 6 lines
Signed-off-by Paul Durrant <[email protected]>Signed-off-by Zoltan Kiss <[email protected]>Cc Wei Liu <[email protected]>Cc Ian Campbell <[email protected]>Cc David Vrabel <[email protected]>cc David Miller <[email protected]>
This addresses my concerned, Ian and Wei please review.
Quoted 79 lines · Paul Durrant
The code to detect fragments in
checksum_setup()was missing for IPv4 and too eager for IPv6. (It transpires that Windows seems to send IPv6 packets with a fragment header even if they are not a fragment - i.e. offset is zero, and M bit is not set).
This patch also incorporates a fix to callers ofmaybe_pull_tail()whereskb->network_headerwas being erroneously added to the length argument.Signed-off-by Paul Durrant <[email protected]>Signed-off-by Zoltan Kiss <[email protected]>Cc Wei Liu <[email protected]>Cc Ian Campbell <[email protected]>Cc David Vrabel <[email protected]>cc David Miller <[email protected]>---
v4
- Re-workmaybe_pull_tail()to have a failure path and update mac and network header pointers on success.
- Re-work callers ofmaybe_pull_tail()to handle failures and allow for movement of skb header pointers.
- Incorporate fixes from patch "Fix pull size inchecksum_setup_ip" since it also modifies callers ofmaybe_pull_tail().
- Remove error messages in checksum routines that could be triggered by frontendsv3
- Use defined values for 'fragment offset' and 'more fragments'v2
- Added comments noting what fragment/offset masks meandrivers/net/xen-netback/netback.c | 215 ++++++++++++++++++++----------------- include/linux/ipv6.h | 1 + include/net/ipv6.h | 3 +- 3 files changed, 120 insertions(+), 99 deletions(-)drivers/net/xen-netback/netback.c +20
-10@@ -1149,49 +1149,62 @@ static int xenvif_set_skb_gso(struct xenvif *vif,return 0 ; } -static inline void maybe_pull_tail (struct sk_buff *skb,unsigned int len) +static inline bool maybe_pull_tail (struct sk_buff *skb,unsigned int len, +unsigned int max) { -if (skb_is_nonlinear (skb) &&skb_headlen (skb) < len) { -/* If we need to pullup then pullup to the max, so we -* won't need to do it again. -*/ -int target =min_t (int, skb->len,MAX_TCP_HEADER ); -__pskb_pull_tail (skb, target -skb_headlen (skb)); - } +if (skb_headlen (skb) >= len) +return true; + +/* If we need to pullup then pullup to the max, so we +* won't need to do it again. +*/ +if (max > skb->len) + max = skb->len; + +__pskb_pull_tail (skb, max -skb_headlen (skb)); + +return skb_headlen (skb) >= len; } +/* This value should be large enough to cover a tagged ethernet header plus +* maximally sized IP and TCP or UDP headers. +*/ +#define MAX_IP_HDR_LEN 128 +static int checksum_setup_ip (struct xenvif *vif,struct sk_buff *skb,int recalculate_partial_csum) { -struct iphdr *iph = (void *)skb->data; -unsigned int header_size;unsigned int off; +bool fragment;
drivers/net/xen-netback/netback.c static int xenvif_set_skb_gso(struct xenvif *vif, · line 1185
Quoted 10 lines
drivers/net/xen-netback/netback.c +4
-3int err = -EPROTO ; - off =sizeof (struct iphdr ); + fragment = false; - header_size = skb->network_header + off +MAX_IPOPTLEN ; -maybe_pull_tail (skb, header_size); +if (!maybe_pull_tail (skb,sizeof (struct iphdr ),MAX_IP_HDR_LEN )) + goto out; +
I think you need to correctly update err to reflect this failure. Using -EPROTO will wrongly blame frontend while it is backend that's failing to process the packet.
Wei.
Quoted 79 lines · Paul Durrant
The code to detect fragments in
checksum_setup()was missing for IPv4 and too eager for IPv6. (It transpires that Windows seems to send IPv6 packets with a fragment header even if they are not a fragment - i.e. offset is zero, and M bit is not set).
This patch also incorporates a fix to callers ofmaybe_pull_tail()whereskb->network_headerwas being erroneously added to the length argument.Signed-off-by Paul Durrant <[email protected]>Signed-off-by Zoltan Kiss <[email protected]>Cc Wei Liu <[email protected]>Cc Ian Campbell <[email protected]>Cc David Vrabel <[email protected]>cc David Miller <[email protected]>---
v4
- Re-workmaybe_pull_tail()to have a failure path and update mac and network header pointers on success.
- Re-work callers ofmaybe_pull_tail()to handle failures and allow for movement of skb header pointers.
- Incorporate fixes from patch "Fix pull size inchecksum_setup_ip" since it also modifies callers ofmaybe_pull_tail().
- Remove error messages in checksum routines that could be triggered by frontendsv3
- Use defined values for 'fragment offset' and 'more fragments'v2
- Added comments noting what fragment/offset masks meandrivers/net/xen-netback/netback.c | 215 ++++++++++++++++++++----------------- include/linux/ipv6.h | 1 + include/net/ipv6.h | 3 +- 3 files changed, 120 insertions(+), 99 deletions(-)drivers/net/xen-netback/netback.c +20
-10@@ -1149,49 +1149,62 @@ static int xenvif_set_skb_gso(struct xenvif *vif,return 0 ; } -static inline void maybe_pull_tail (struct sk_buff *skb,unsigned int len) +static inline bool maybe_pull_tail (struct sk_buff *skb,unsigned int len, +unsigned int max) { -if (skb_is_nonlinear (skb) &&skb_headlen (skb) < len) { -/* If we need to pullup then pullup to the max, so we -* won't need to do it again. -*/ -int target =min_t (int, skb->len,MAX_TCP_HEADER ); -__pskb_pull_tail (skb, target -skb_headlen (skb)); - } +if (skb_headlen (skb) >= len) +return true; + +/* If we need to pullup then pullup to the max, so we +* won't need to do it again. +*/ +if (max > skb->len) + max = skb->len; + +__pskb_pull_tail (skb, max -skb_headlen (skb)); + +return skb_headlen (skb) >= len; } +/* This value should be large enough to cover a tagged ethernet header plus +* maximally sized IP and TCP or UDP headers. +*/ +#define MAX_IP_HDR_LEN 128 +static int checksum_setup_ip (struct xenvif *vif,struct sk_buff *skb,int recalculate_partial_csum) { -struct iphdr *iph = (void *)skb->data; -unsigned int header_size;unsigned int off; +bool fragment;
drivers/net/xen-netback/netback.c static int xenvif_set_skb_gso(struct xenvif *vif, · line 1185
Quoted 10 lines
drivers/net/xen-netback/netback.c +4
-3int err = -EPROTO ; - off =sizeof (struct iphdr ); + fragment = false; - header_size = skb->network_header + off +MAX_IPOPTLEN ; -maybe_pull_tail (skb, header_size); +if (!maybe_pull_tail (skb,sizeof (struct iphdr ),MAX_IP_HDR_LEN )) + goto out; +
I think you need to correctly update err to reflect this failure. Using -EPROTO will wrongly blame frontend while it is backend that's failing to process the packet.
Wei.
Quoted 100 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 03 December 2013 14:03
To: Paul Durrant
Cc: [email protected]; [email protected]; Zoltan Kiss; Wei Liu; Ian Campbell; David Vrabel; David Miller
Subject: Re: [PATCH net v4] xen-netback: fix fragment detection in checksum setupQuoted 1 line · Paul Durrant
The code to detect fragments in
checksum_setup()was missing for IPv4and
Quoted 5 lines
too eager for IPv6. (It transpires that Windows seems to send IPv6 packets with a fragment header even if they are not a fragment - i.e. offset is zero, and M bit is not set).
This patch also incorporates a fix to callers ofmaybe_pull_tail()whereskb->network_headerwas being erroneously added to the lengthargument.
Quoted 7 lines
Signed-off-by Paul Durrant <[email protected]>Signed-off-by Zoltan Kiss <[email protected]>Cc Wei Liu <[email protected]>Cc Ian Campbell <[email protected]>Cc David Vrabel <[email protected]>cc David Miller <[email protected]>Quoted 9 lines
---
v4
- Re-workmaybe_pull_tail()to have a failure path and update mac and network header pointers on success.
- Re-work callers ofmaybe_pull_tail()to handle failures and allow for movement of skb header pointers.
- Incorporate fixes from patch "Fix pull size inchecksum_setup_ip" since it also modifies callers ofmaybe_pull_tail().
- Remove error messages in checksum routines that could be triggered byfrontends
Quoted 8 lines
v3
- Use defined values for 'fragment offset' and 'more fragments'v2
- Added comments noting what fragment/offset masks meandrivers/net/xen-netback/netback.c | 215 ++++++++++++++++++++-----------------
drivers/net/xen-
Quoted 5 lines
include/linux/ipv6.h | 1 + include/net/ipv6.h | 3 +- 3 files changed, 120 insertions(+), 99 deletions(-)drivers/net/xen- renamed from drivers/net/xen-netback/netback.c +0
-0
netback/netback.cQuoted 23 lines
index 64f0e0d..e3d7216 100644
drivers/net/xen-netback/netback.c +7
-8@@ -1149,49 +1149,62 @@ static int xenvif_set_skb_gso(struct xenvif *vif,return 0 ; } -static inline void maybe_pull_tail (struct sk_buff *skb,unsigned int len) +static inline bool maybe_pull_tail (struct sk_buff *skb,unsigned int len, +unsigned int max) { -if (skb_is_nonlinear (skb) &&skb_headlen (skb) < len) { -/* If we need to pullup then pullup to the max, so we -* won't need to do it again. -*/ -int target =min_t (int, skb->len,MAX_TCP_HEADER ); -__pskb_pull_tail (skb, target -skb_headlen (skb)); - } +if (skb_headlen (skb) >= len) +return true; + +/* If we need to pullup then pullup to the max, so we +* won't need to do it again. drivers/net/xen-netback/netback.c static int xenvif_set_skb_gso(struct xenvif *vif, · line 1169
Quoted 10 lines
drivers/net/xen-netback/netback.c +8
-0+*/ +if (max > skb->len) + max = skb->len; + +__pskb_pull_tail (skb, max -skb_headlen (skb)); + +return skb_headlen (skb) >= len; } +/* This value should be large enough to cover a tagged ethernet header plus
Quoted 16 lines
drivers/net/xen-netback/netback.c +6
-3+* maximally sized IP and TCP or UDP headers. +*/ +#define MAX_IP_HDR_LEN 128 +static int checksum_setup_ip (struct xenvif *vif,struct sk_buff *skb,int recalculate_partial_csum) { -struct iphdr *iph = (void *)skb->data; -unsigned int header_size;unsigned int off; +bool fragment;int err = -EPROTO ; - off =sizeof (struct iphdr ); + fragment = false;
Quoted 10 lines
drivers/net/xen-netback/netback.c static int xenvif_set_skb_gso(struct xenvif *vif, · line 1185
Quoted 5 lines
drivers/net/xen-netback/netback.c +3
-2- header_size = skb->network_header + off +MAX_IPOPTLEN ; -maybe_pull_tail (skb, header_size); +if (!maybe_pull_tail (skb,sizeof (struct iphdr ),MAX_IP_HDR_LEN )) + goto out; +I think you need to correctly update err to reflect this failure. Using
-EPROTOwill wrongly blame frontend while it is backend that's failing to process the packet.
But a failure should only occur if the packet is malformed, so that would be a frontend error wouldn't it?
Paul
Quoted 100 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 03 December 2013 14:03
To: Paul Durrant
Cc: [email protected]; [email protected]; Zoltan Kiss; Wei Liu; Ian Campbell; David Vrabel; David Miller
Subject: Re: [PATCH net v4] xen-netback: fix fragment detection in checksum setupQuoted 1 line · Paul Durrant
The code to detect fragments in
checksum_setup()was missing for IPv4and
Quoted 5 lines
too eager for IPv6. (It transpires that Windows seems to send IPv6 packets with a fragment header even if they are not a fragment - i.e. offset is zero, and M bit is not set).
This patch also incorporates a fix to callers ofmaybe_pull_tail()whereskb->network_headerwas being erroneously added to the lengthargument.
Quoted 7 lines
Signed-off-by Paul Durrant <[email protected]>Signed-off-by Zoltan Kiss <[email protected]>Cc Wei Liu <[email protected]>Cc Ian Campbell <[email protected]>Cc David Vrabel <[email protected]>cc David Miller <[email protected]>Quoted 9 lines
---
v4
- Re-workmaybe_pull_tail()to have a failure path and update mac and network header pointers on success.
- Re-work callers ofmaybe_pull_tail()to handle failures and allow for movement of skb header pointers.
- Incorporate fixes from patch "Fix pull size inchecksum_setup_ip" since it also modifies callers ofmaybe_pull_tail().
- Remove error messages in checksum routines that could be triggered byfrontends
Quoted 8 lines
v3
- Use defined values for 'fragment offset' and 'more fragments'v2
- Added comments noting what fragment/offset masks meandrivers/net/xen-netback/netback.c | 215 ++++++++++++++++++++-----------------
drivers/net/xen-
Quoted 5 lines
include/linux/ipv6.h | 1 + include/net/ipv6.h | 3 +- 3 files changed, 120 insertions(+), 99 deletions(-)drivers/net/xen- renamed from drivers/net/xen-netback/netback.c +0
-0
netback/netback.cQuoted 23 lines
index 64f0e0d..e3d7216 100644
drivers/net/xen-netback/netback.c +7
-8@@ -1149,49 +1149,62 @@ static int xenvif_set_skb_gso(struct xenvif *vif,return 0 ; } -static inline void maybe_pull_tail (struct sk_buff *skb,unsigned int len) +static inline bool maybe_pull_tail (struct sk_buff *skb,unsigned int len, +unsigned int max) { -if (skb_is_nonlinear (skb) &&skb_headlen (skb) < len) { -/* If we need to pullup then pullup to the max, so we -* won't need to do it again. -*/ -int target =min_t (int, skb->len,MAX_TCP_HEADER ); -__pskb_pull_tail (skb, target -skb_headlen (skb)); - } +if (skb_headlen (skb) >= len) +return true; + +/* If we need to pullup then pullup to the max, so we +* won't need to do it again. drivers/net/xen-netback/netback.c static int xenvif_set_skb_gso(struct xenvif *vif, · line 1169
Quoted 10 lines
drivers/net/xen-netback/netback.c +8
-0+*/ +if (max > skb->len) + max = skb->len; + +__pskb_pull_tail (skb, max -skb_headlen (skb)); + +return skb_headlen (skb) >= len; } +/* This value should be large enough to cover a tagged ethernet header plus
Quoted 16 lines
drivers/net/xen-netback/netback.c +6
-3+* maximally sized IP and TCP or UDP headers. +*/ +#define MAX_IP_HDR_LEN 128 +static int checksum_setup_ip (struct xenvif *vif,struct sk_buff *skb,int recalculate_partial_csum) { -struct iphdr *iph = (void *)skb->data; -unsigned int header_size;unsigned int off; +bool fragment;int err = -EPROTO ; - off =sizeof (struct iphdr ); + fragment = false;
Quoted 10 lines
drivers/net/xen-netback/netback.c static int xenvif_set_skb_gso(struct xenvif *vif, · line 1185
Quoted 5 lines
drivers/net/xen-netback/netback.c +3
-2- header_size = skb->network_header + off +MAX_IPOPTLEN ; -maybe_pull_tail (skb, header_size); +if (!maybe_pull_tail (skb,sizeof (struct iphdr ),MAX_IP_HDR_LEN )) + goto out; +I think you need to correctly update err to reflect this failure. Using
-EPROTOwill wrongly blame frontend while it is backend that's failing to process the packet.
But a failure should only occur if the packet is malformed, so that would be a frontend error wouldn't it?
Paul
On Tue, Dec 03, 2013 at 02:05:17PM +0000, Paul Durrant wrote:
[...]
Quoted 12 lines
Quoted 11 lines
drivers/net/xen-netback/netback.c static int xenvif_set_skb_gso(struct xenvif *vif, · line 1185
Quoted 6 lines
drivers/net/xen-netback/netback.c +3
-2- header_size = skb->network_header + off +MAX_IPOPTLEN ; -maybe_pull_tail (skb, header_size); +if (!maybe_pull_tail (skb,sizeof (struct iphdr ),MAX_IP_HDR_LEN )) + goto out; +I think you need to correctly update err to reflect this failure. Using
-EPROTOwill wrongly blame frontend while it is backend that's failing to process the packet.
Quoted 2 lines
But a failure should only occur if the packet is malformed, so that would be a frontend error wouldn't it?
__pskb_pull_tail may fail due to malloc failure.
However the return value of __pskb_pull_tail cannot reflect the wether the failure is due to malformed packet or OOM. Not sure what's the best solution here. What's the malformed packet you were talking about?
Wei.
Quoted 1 line
Paul
On Tue, Dec 03, 2013 at 02:05:17PM +0000, Paul Durrant wrote:
[...]
Quoted 12 lines
Quoted 11 lines
drivers/net/xen-netback/netback.c static int xenvif_set_skb_gso(struct xenvif *vif, · line 1185
Quoted 6 lines
drivers/net/xen-netback/netback.c +3
-2- header_size = skb->network_header + off +MAX_IPOPTLEN ; -maybe_pull_tail (skb, header_size); +if (!maybe_pull_tail (skb,sizeof (struct iphdr ),MAX_IP_HDR_LEN )) + goto out; +I think you need to correctly update err to reflect this failure. Using
-EPROTOwill wrongly blame frontend while it is backend that's failing to process the packet.
Quoted 2 lines
But a failure should only occur if the packet is malformed, so that would be a frontend error wouldn't it?
__pskb_pull_tail may fail due to malloc failure.
However the return value of __pskb_pull_tail cannot reflect the wether the failure is due to malformed packet or OOM. Not sure what's the best solution here. What's the malformed packet you were talking about?
Wei.
Quoted 1 line
Paul
Quoted 24 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 03 December 2013 14:29
To: Paul Durrant
Cc: Wei Liu; [email protected]; [email protected]; Zoltan Kiss; Ian Campbell; David Vrabel; David Miller
Subject: Re: [PATCH net v4] xen-netback: fix fragment detection in checksum setupOn Tue, Dec 03, 2013 at 02:05:17PM +0000, Paul Durrant wrote:
[...]Quoted 12 lines
Quoted 11 lines
drivers/net/xen-netback/netback.c static int xenvif_set_skb_gso(struct xenvif *vif, · line 1185
Quoted 6 lines
drivers/net/xen-netback/netback.c +3
-2- header_size = skb->network_header + off +MAX_IPOPTLEN ; -maybe_pull_tail (skb, header_size); +if (!maybe_pull_tail (skb,sizeof (struct iphdr ),MAX_IP_HDR_LEN )) + goto out; +I think you need to correctly update err to reflect this failure. Using
-EPROTOwill wrongly blame frontend while it is backend that's failing to process the packet.Quoted 1 line
But a failure should only occur if the packet is malformed, so that would be
Quoted 9 lines
a frontend error wouldn't it?
Quoted 1 line
__pskb_pull_tailmay fail due to malloc failure.However the return value of
__pskb_pull_tailcannot reflect the wether the failure is due to malformed packet or OOM. Not sure what's the best solution here. What's the malformed packet you were talking about?
For example, the pull would fail if the packet had an either_type of IP but didn't contain an IP header, or perhaps an IPv6 packet that had an incomplete option header sequence. I would have thought such a packet was a more likely cause of failure than OOM, so -EPROTO seems a reasonable best guess.
Paul
Quoted 24 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 03 December 2013 14:29
To: Paul Durrant
Cc: Wei Liu; [email protected]; [email protected]; Zoltan Kiss; Ian Campbell; David Vrabel; David Miller
Subject: Re: [PATCH net v4] xen-netback: fix fragment detection in checksum setupOn Tue, Dec 03, 2013 at 02:05:17PM +0000, Paul Durrant wrote:
[...]Quoted 12 lines
Quoted 11 lines
drivers/net/xen-netback/netback.c static int xenvif_set_skb_gso(struct xenvif *vif, · line 1185
Quoted 6 lines
drivers/net/xen-netback/netback.c +3
-2- header_size = skb->network_header + off +MAX_IPOPTLEN ; -maybe_pull_tail (skb, header_size); +if (!maybe_pull_tail (skb,sizeof (struct iphdr ),MAX_IP_HDR_LEN )) + goto out; +I think you need to correctly update err to reflect this failure. Using
-EPROTOwill wrongly blame frontend while it is backend that's failing to process the packet.Quoted 1 line
But a failure should only occur if the packet is malformed, so that would be
Quoted 9 lines
a frontend error wouldn't it?
Quoted 1 line
__pskb_pull_tailmay fail due to malloc failure.However the return value of
__pskb_pull_tailcannot reflect the wether the failure is due to malformed packet or OOM. Not sure what's the best solution here. What's the malformed packet you were talking about?
For example, the pull would fail if the packet had an either_type of IP but didn't contain an IP header, or perhaps an IPv6 packet that had an incomplete option header sequence. I would have thought such a packet was a more likely cause of failure than OOM, so -EPROTO seems a reasonable best guess.
Paul
Quoted 34 lines · Paul Durrant
Quoted 24 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 03 December 2013 14:29
To: Paul Durrant
Cc: Wei Liu; [email protected]; [email protected]; Zoltan Kiss; Ian Campbell; David Vrabel; David Miller
Subject: Re: [PATCH net v4] xen-netback: fix fragment detection in checksum setupOn Tue, Dec 03, 2013 at 02:05:17PM +0000, Paul Durrant wrote:
[...]Quoted 12 lines
Quoted 11 lines
drivers/net/xen-netback/netback.c static int xenvif_set_skb_gso(struct xenvif *vif, · line 1185
Quoted 6 lines
drivers/net/xen-netback/netback.c +3
-2- header_size = skb->network_header + off +MAX_IPOPTLEN ; -maybe_pull_tail (skb, header_size); +if (!maybe_pull_tail (skb,sizeof (struct iphdr ),MAX_IP_HDR_LEN )) + goto out; +I think you need to correctly update err to reflect this failure. Using
-EPROTOwill wrongly blame frontend while it is backend that's failing to process the packet.Quoted 1 line
But a failure should only occur if the packet is malformed, so that would be
Quoted 9 lines
a frontend error wouldn't it?
Quoted 1 line
__pskb_pull_tailmay fail due to malloc failure.However the return value of
__pskb_pull_tailcannot reflect the wether the failure is due to malformed packet or OOM. Not sure what's the best solution here. What's the malformed packet you were talking about?
Quoted 5 lines
For example, the pull would fail if the packet had an
either_typeof IP but didn't contain an IP header, or perhaps an IPv6 packet that had an incomplete option header sequence. I would have thought such a packet was a more likely cause of failure than OOM, so-EPROTOseems a reasonable best guess.
How? __pskb_pull_tail doesn't seem to care about upper layer protocols. And maybe_pull_tail has already done some lenght comparisions.
Wei.
Quoted 2 lines
Paul
Quoted 34 lines · Paul Durrant
Quoted 24 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 03 December 2013 14:29
To: Paul Durrant
Cc: Wei Liu; [email protected]; [email protected]; Zoltan Kiss; Ian Campbell; David Vrabel; David Miller
Subject: Re: [PATCH net v4] xen-netback: fix fragment detection in checksum setupOn Tue, Dec 03, 2013 at 02:05:17PM +0000, Paul Durrant wrote:
[...]Quoted 12 lines
Quoted 11 lines
drivers/net/xen-netback/netback.c static int xenvif_set_skb_gso(struct xenvif *vif, · line 1185
Quoted 6 lines
drivers/net/xen-netback/netback.c +3
-2- header_size = skb->network_header + off +MAX_IPOPTLEN ; -maybe_pull_tail (skb, header_size); +if (!maybe_pull_tail (skb,sizeof (struct iphdr ),MAX_IP_HDR_LEN )) + goto out; +I think you need to correctly update err to reflect this failure. Using
-EPROTOwill wrongly blame frontend while it is backend that's failing to process the packet.Quoted 1 line
But a failure should only occur if the packet is malformed, so that would be
Quoted 9 lines
a frontend error wouldn't it?
Quoted 1 line
__pskb_pull_tailmay fail due to malloc failure.However the return value of
__pskb_pull_tailcannot reflect the wether the failure is due to malformed packet or OOM. Not sure what's the best solution here. What's the malformed packet you were talking about?
Quoted 5 lines
For example, the pull would fail if the packet had an
either_typeof IP but didn't contain an IP header, or perhaps an IPv6 packet that had an incomplete option header sequence. I would have thought such a packet was a more likely cause of failure than OOM, so-EPROTOseems a reasonable best guess.
How? __pskb_pull_tail doesn't seem to care about upper layer protocols. And maybe_pull_tail has already done some lenght comparisions.
Wei.
Quoted 2 lines
Paul
Quoted 49 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 03 December 2013 14:58
To: Paul Durrant
Cc: Wei Liu; [email protected]; [email protected]; Zoltan Kiss; Ian Campbell; David Vrabel; David Miller
Subject: Re: [PATCH net v4] xen-netback: fix fragment detection in checksum setupQuoted 5 lines · Paul Durrant
Quoted 5 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 03 December 2013 14:29
To: Paul Durrant
Cc: Wei Liu; [email protected]; [email protected]; ZoltanKiss;
Quoted 2 lines
Quoted 2 lines
Ian Campbell; David Vrabel; David Miller
Subject: Re: [PATCH net v4] xen-netback: fix fragment detection inchecksum
Quoted 6 lines
Quoted 6 lines
setup
On Tue, Dec 03, 2013 at 02:05:17PM +0000, Paul Durrant wrote:
[...]Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +0
-1- header_size = skb->network_header + off +
MAX_IPOPTLEN;Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +1
-1- maybe_pull_tail(skb, header_size); + if (!maybe_pull_tail(skb, sizeof(struct iphdr),
MAX_IP_HDR_LEN))Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ goto out; +I think you need to correctly update err to reflect this failure. Using
-EPROTOwill wrongly blame frontend while it is backend that's failing to process the packet.But a failure should only occur if the packet is malformed, so that would
be
Quoted 10 lines
Quoted 9 lines
a frontend error wouldn't it?
Quoted 1 line
__pskb_pull_tailmay fail due to malloc failure.However the return value of
__pskb_pull_tailcannot reflect the wether the failure is due to malformed packet or OOM. Not sure what's the best solution here. What's the malformed packet you were talking about?
Quoted 9 lines
Quoted 5 lines
For example, the pull would fail if the packet had an
either_typeof IP but didn't contain an IP header, or perhaps an IPv6 packet that had an incomplete option header sequence. I would have thought such a packet was a more likely cause of failure than OOM, so-EPROTOseems a reasonable best guess.How?
__pskb_pull_taildoesn't seem to care about upper layer protocols. Andmaybe_pull_tailhas already done some lenght comparisions.
No, __pskb_pull_tail() doesn't care but the final check in maybe_pull_tail() means it will return false if skb_headlen() is not at least as big as what it was asked for. So if we try to pull up an IP header and there's fewer bytes than that available then we hit the error condition. Or maybe I'm missing something.
Paul
Quoted 49 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 03 December 2013 14:58
To: Paul Durrant
Cc: Wei Liu; [email protected]; [email protected]; Zoltan Kiss; Ian Campbell; David Vrabel; David Miller
Subject: Re: [PATCH net v4] xen-netback: fix fragment detection in checksum setupQuoted 5 lines · Paul Durrant
Quoted 5 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 03 December 2013 14:29
To: Paul Durrant
Cc: Wei Liu; [email protected]; [email protected]; ZoltanKiss;
Quoted 2 lines
Quoted 2 lines
Ian Campbell; David Vrabel; David Miller
Subject: Re: [PATCH net v4] xen-netback: fix fragment detection inchecksum
Quoted 6 lines
Quoted 6 lines
setup
On Tue, Dec 03, 2013 at 02:05:17PM +0000, Paul Durrant wrote:
[...]Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +0
-1- header_size = skb->network_header + off +
MAX_IPOPTLEN;Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +1
-1- maybe_pull_tail(skb, header_size); + if (!maybe_pull_tail(skb, sizeof(struct iphdr),
MAX_IP_HDR_LEN))Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ goto out; +I think you need to correctly update err to reflect this failure. Using
-EPROTOwill wrongly blame frontend while it is backend that's failing to process the packet.But a failure should only occur if the packet is malformed, so that would
be
Quoted 10 lines
Quoted 9 lines
a frontend error wouldn't it?
Quoted 1 line
__pskb_pull_tailmay fail due to malloc failure.However the return value of
__pskb_pull_tailcannot reflect the wether the failure is due to malformed packet or OOM. Not sure what's the best solution here. What's the malformed packet you were talking about?
Quoted 9 lines
Quoted 5 lines
For example, the pull would fail if the packet had an
either_typeof IP but didn't contain an IP header, or perhaps an IPv6 packet that had an incomplete option header sequence. I would have thought such a packet was a more likely cause of failure than OOM, so-EPROTOseems a reasonable best guess.How?
__pskb_pull_taildoesn't seem to care about upper layer protocols. Andmaybe_pull_tailhas already done some lenght comparisions.
No, __pskb_pull_tail() doesn't care but the final check in maybe_pull_tail() means it will return false if skb_headlen() is not at least as big as what it was asked for. So if we try to pull up an IP header and there's fewer bytes than that available then we hit the error condition. Or maybe I'm missing something.
Paul
Quoted 59 lines · Paul Durrant
Quoted 49 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 03 December 2013 14:58
To: Paul Durrant
Cc: Wei Liu; [email protected]; [email protected]; Zoltan Kiss; Ian Campbell; David Vrabel; David Miller
Subject: Re: [PATCH net v4] xen-netback: fix fragment detection in checksum setupQuoted 5 lines · Paul Durrant
Quoted 5 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 03 December 2013 14:29
To: Paul Durrant
Cc: Wei Liu; [email protected]; [email protected]; ZoltanKiss;
Quoted 2 lines
Quoted 2 lines
Ian Campbell; David Vrabel; David Miller
Subject: Re: [PATCH net v4] xen-netback: fix fragment detection inchecksum
Quoted 6 lines
Quoted 6 lines
setup
On Tue, Dec 03, 2013 at 02:05:17PM +0000, Paul Durrant wrote:
[...]Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +0
-1- header_size = skb->network_header + off +
MAX_IPOPTLEN;Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +1
-1- maybe_pull_tail(skb, header_size); + if (!maybe_pull_tail(skb, sizeof(struct iphdr),
MAX_IP_HDR_LEN))Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ goto out; +I think you need to correctly update err to reflect this failure. Using
-EPROTOwill wrongly blame frontend while it is backend that's failing to process the packet.But a failure should only occur if the packet is malformed, so that would
be
Quoted 10 lines
Quoted 9 lines
a frontend error wouldn't it?
Quoted 1 line
__pskb_pull_tailmay fail due to malloc failure.However the return value of
__pskb_pull_tailcannot reflect the wether the failure is due to malformed packet or OOM. Not sure what's the best solution here. What's the malformed packet you were talking about?Quoted 9 lines
Quoted 5 lines
For example, the pull would fail if the packet had an
either_typeof IP but didn't contain an IP header, or perhaps an IPv6 packet that had an incomplete option header sequence. I would have thought such a packet was a more likely cause of failure than OOM, so-EPROTOseems a reasonable best guess.How?
__pskb_pull_taildoesn't seem to care about upper layer protocols. Andmaybe_pull_tailhas already done some lenght comparisions.
Quoted 5 lines
No,
__pskb_pull_tail()doesn't care but the final check inmaybe_pull_tail()means it will return false ifskb_headlen()is not at least as big as what it was asked for. So if we try to pull up an IP header and there's fewer bytes than that available then we hit the error condition. Or maybe I'm missing something.
OK, we'er still on the same boat here. ;-)
Would it make sense to make maybe_pull_tail to return int to reflect __pskb_pull_fail? In that case we can distinguish backend failure and frontend failure.
I pay extra attention to this as we often have no access to frontend and we probably don't want to blame frontend for non-existent misbehavior.
Wei.
Quoted 2 lines
Paul
Quoted 59 lines · Paul Durrant
Quoted 49 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 03 December 2013 14:58
To: Paul Durrant
Cc: Wei Liu; [email protected]; [email protected]; Zoltan Kiss; Ian Campbell; David Vrabel; David Miller
Subject: Re: [PATCH net v4] xen-netback: fix fragment detection in checksum setupQuoted 5 lines · Paul Durrant
Quoted 5 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 03 December 2013 14:29
To: Paul Durrant
Cc: Wei Liu; [email protected]; [email protected]; ZoltanKiss;
Quoted 2 lines
Quoted 2 lines
Ian Campbell; David Vrabel; David Miller
Subject: Re: [PATCH net v4] xen-netback: fix fragment detection inchecksum
Quoted 6 lines
Quoted 6 lines
setup
On Tue, Dec 03, 2013 at 02:05:17PM +0000, Paul Durrant wrote:
[...]Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +0
-1- header_size = skb->network_header + off +
MAX_IPOPTLEN;Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +1
-1- maybe_pull_tail(skb, header_size); + if (!maybe_pull_tail(skb, sizeof(struct iphdr),
MAX_IP_HDR_LEN))Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ goto out; +I think you need to correctly update err to reflect this failure. Using
-EPROTOwill wrongly blame frontend while it is backend that's failing to process the packet.But a failure should only occur if the packet is malformed, so that would
be
Quoted 10 lines
Quoted 9 lines
a frontend error wouldn't it?
Quoted 1 line
__pskb_pull_tailmay fail due to malloc failure.However the return value of
__pskb_pull_tailcannot reflect the wether the failure is due to malformed packet or OOM. Not sure what's the best solution here. What's the malformed packet you were talking about?Quoted 9 lines
Quoted 5 lines
For example, the pull would fail if the packet had an
either_typeof IP but didn't contain an IP header, or perhaps an IPv6 packet that had an incomplete option header sequence. I would have thought such a packet was a more likely cause of failure than OOM, so-EPROTOseems a reasonable best guess.How?
__pskb_pull_taildoesn't seem to care about upper layer protocols. Andmaybe_pull_tailhas already done some lenght comparisions.
Quoted 5 lines
No,
__pskb_pull_tail()doesn't care but the final check inmaybe_pull_tail()means it will return false ifskb_headlen()is not at least as big as what it was asked for. So if we try to pull up an IP header and there's fewer bytes than that available then we hit the error condition. Or maybe I'm missing something.
OK, we'er still on the same boat here. ;-)
Would it make sense to make maybe_pull_tail to return int to reflect __pskb_pull_fail? In that case we can distinguish backend failure and frontend failure.
I pay extra attention to this as we often have no access to frontend and we probably don't want to blame frontend for non-existent misbehavior.
Wei.
Quoted 2 lines
Paul
Quoted 76 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 03 December 2013 15:13
To: Paul Durrant
Cc: Wei Liu; [email protected]; [email protected]; Zoltan Kiss; Ian Campbell; David Vrabel; David Miller
Subject: Re: [PATCH net v4] xen-netback: fix fragment detection in checksum setupQuoted 5 lines · Paul Durrant
Quoted 5 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 03 December 2013 14:58
To: Paul Durrant
Cc: Wei Liu; [email protected]; [email protected]; ZoltanKiss;
Quoted 2 lines
Quoted 2 lines
Ian Campbell; David Vrabel; David Miller
Subject: Re: [PATCH net v4] xen-netback: fix fragment detection inchecksum
Quoted 19 lines
Quoted 19 lines
setup
Quoted 5 lines · Paul Durrant
Quoted 5 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 03 December 2013 14:29
To: Paul Durrant
Cc: Wei Liu; [email protected]; [email protected]; ZoltanKiss;
Quoted 2 lines
Quoted 2 lines
Ian Campbell; David Vrabel; David Miller
Subject: Re: [PATCH net v4] xen-netback: fix fragment detection inchecksum
Quoted 6 lines
Quoted 6 lines
setup
On Tue, Dec 03, 2013 at 02:05:17PM +0000, Paul Durrant wrote:
[...]Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +0
-1- header_size = skb->network_header + off +
MAX_IPOPTLEN;Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +1
-1- maybe_pull_tail(skb, header_size); + if (!maybe_pull_tail(skb, sizeof(struct iphdr),
MAX_IP_HDR_LEN))Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ goto out; +I think you need to correctly update err to reflect this failure. Using
-EPROTOwill wrongly blame frontend while it is backendthat's
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
failing to process the packet.
But a failure should only occur if the packet is malformed, so that
would
Quoted 7 lines
Quoted 7 lines
be
Quoted 6 lines
Quoted 6 lines
a frontend error wouldn't it?
Quoted 1 line
__pskb_pull_tailmay fail due to malloc failure.However the return value of
__pskb_pull_tailcannot reflect thewether
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
the failure is due to malformed packet or OOM. Not sure what's the
best
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
solution here. What's the malformed packet you were talking about?
For example, the pull would fail if the packet had an
either_typeof IP but didn't contain an IP header, or perhaps an IPv6 packet that had an incomplete option header sequence. I would have thought such a packet was a more likely cause of failure than OOM, so-EPROTOseemsa
Quoted 6 lines
Quoted 5 lines
Quoted 1 line
reasonable best guess.
How?
__pskb_pull_taildoesn't seem to care about upper layer protocols. Andmaybe_pull_tailhas already done some lenght comparisions.
Quoted 8 lines
Quoted 5 lines
No,
__pskb_pull_tail()doesn't care but the final check inmaybe_pull_tail()means it will return false ifskb_headlen()is not at least as big as what it was asked for. So if we try to pull up an IP header and there's fewer bytes than that available then we hit the error condition. Or maybe I'm missing something.OK, we'er still on the same boat here. ;-)
Good. I was beginning to worry. :-)
Quoted 7 lines
Would it make sense to make
maybe_pull_tailto return int to reflect__pskb_pull_fail? In that case we can distinguish backend failure and frontend failure.I pay extra attention to this as we often have no access to frontend and we probably don't want to blame frontend for non-existent misbehavior.
Ok. That sounds fair enough. I'll do that.
Paul
Quoted 76 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 03 December 2013 15:13
To: Paul Durrant
Cc: Wei Liu; [email protected]; [email protected]; Zoltan Kiss; Ian Campbell; David Vrabel; David Miller
Subject: Re: [PATCH net v4] xen-netback: fix fragment detection in checksum setupQuoted 5 lines · Paul Durrant
Quoted 5 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 03 December 2013 14:58
To: Paul Durrant
Cc: Wei Liu; [email protected]; [email protected]; ZoltanKiss;
Quoted 2 lines
Quoted 2 lines
Ian Campbell; David Vrabel; David Miller
Subject: Re: [PATCH net v4] xen-netback: fix fragment detection inchecksum
Quoted 19 lines
Quoted 19 lines
setup
Quoted 5 lines · Paul Durrant
Quoted 5 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 03 December 2013 14:29
To: Paul Durrant
Cc: Wei Liu; [email protected]; [email protected]; ZoltanKiss;
Quoted 2 lines
Quoted 2 lines
Ian Campbell; David Vrabel; David Miller
Subject: Re: [PATCH net v4] xen-netback: fix fragment detection inchecksum
Quoted 6 lines
Quoted 6 lines
setup
On Tue, Dec 03, 2013 at 02:05:17PM +0000, Paul Durrant wrote:
[...]Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +0
-1- header_size = skb->network_header + off +
MAX_IPOPTLEN;Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +1
-1- maybe_pull_tail(skb, header_size); + if (!maybe_pull_tail(skb, sizeof(struct iphdr),
MAX_IP_HDR_LEN))Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ goto out; +I think you need to correctly update err to reflect this failure. Using
-EPROTOwill wrongly blame frontend while it is backendthat's
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
failing to process the packet.
But a failure should only occur if the packet is malformed, so that
would
Quoted 7 lines
Quoted 7 lines
be
Quoted 6 lines
Quoted 6 lines
a frontend error wouldn't it?
Quoted 1 line
__pskb_pull_tailmay fail due to malloc failure.However the return value of
__pskb_pull_tailcannot reflect thewether
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
the failure is due to malformed packet or OOM. Not sure what's the
best
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
solution here. What's the malformed packet you were talking about?
For example, the pull would fail if the packet had an
either_typeof IP but didn't contain an IP header, or perhaps an IPv6 packet that had an incomplete option header sequence. I would have thought such a packet was a more likely cause of failure than OOM, so-EPROTOseemsa
Quoted 6 lines
Quoted 5 lines
Quoted 1 line
reasonable best guess.
How?
__pskb_pull_taildoesn't seem to care about upper layer protocols. Andmaybe_pull_tailhas already done some lenght comparisions.
Quoted 8 lines
Quoted 5 lines
No,
__pskb_pull_tail()doesn't care but the final check inmaybe_pull_tail()means it will return false ifskb_headlen()is not at least as big as what it was asked for. So if we try to pull up an IP header and there's fewer bytes than that available then we hit the error condition. Or maybe I'm missing something.OK, we'er still on the same boat here. ;-)
Good. I was beginning to worry. :-)
Quoted 7 lines
Would it make sense to make
maybe_pull_tailto return int to reflect__pskb_pull_fail? In that case we can distinguish backend failure and frontend failure.I pay extra attention to this as we often have no access to frontend and we probably don't want to blame frontend for non-existent misbehavior.
Ok. That sounds fair enough. I'll do that.
Paul