Skip to contentSkip to conversation

xen-netback: fix fragment detection in checksum setup

PATCH Superseded Paul Durrant 3 participants 11 messages Nov 28, 2013 – Nov 29, 2013

Subsystems (3)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 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).

Cc Wei Liu <[email protected]>
Cc Ian Campbell <[email protected]>
Cc David Vrabel <[email protected]>

---
v2

- Added comments noting what fragment/offset masks mean

 drivers/net/xen-netback/netback.c |   33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)
drivers/net/xen-netback/netback.c +30 -3
index 919b650..c7464d8 100644
@@ -1165,15 +1165,28 @@ static int checksum_setup_ip(struct xenvif *vif, struct sk_buff *skb,
 	struct iphdr *iph = (void *)skb->data;
 	unsigned int header_size;
 	unsigned int off;
+	bool fragment;
 	int err = -EPROTO;
 
+	fragment = false;
+
 	off = sizeof(struct iphdr);
 
 	header_size = skb->network_header + off + MAX_IPOPTLEN;
 	maybe_pull_tail(skb, header_size);
 
+	/* 3fff -> fragment offset != 0 OR more fragments */
+	if (ntohs(iph->frag_off) & 0x3fff)
+		fragment = true;
+
 	off = iph->ihl * 4;
 
+	if (fragment) {
+		if (net_ratelimit())
+			netdev_err(vif->dev, "Packet is a fragment!\n");
+		goto out;
+	}
+
 	switch (iph->protocol) {
 	case IPPROTO_TCP:
 		if (!skb_partial_csum_set(skb, off,
@@ -1237,6 +1250,7 @@ static int checksum_setup_ipv6(struct xenvif *vif, struct sk_buff *skb,
 	bool fragment;
 	bool done;
 
+	fragment = false;
 	done = false;
 
 	off = sizeof(struct ipv6hdr);
@@ -1275,9 +1289,22 @@ static int checksum_setup_ipv6(struct xenvif *vif, struct sk_buff *skb,
 			off += (hp->hdrlen+2)<<2;
 			break;
 		}
-		case IPPROTO_FRAGMENT:
-			fragment = true;
-			/* fall through */
+		case IPPROTO_FRAGMENT: {
+			struct frag_hdr *hp = (void *)(skb->data + off);
+
+			header_size = skb->network_header +
+				off +
+				sizeof(struct frag_hdr);
+			maybe_pull_tail(skb, header_size);
+
+			/* fff9 -> fragment offset != 0 OR more fragments */
+			if (ntohs(hp->frag_off) & 0xfff9)
+				fragment = true;
+
+			nexthdr = hp->nexthdr;
+			off += sizeof(struct frag_hdr);
+			break;
+		}
 		default:
 			done = true;
 			break;
Signature · 1 line
1.7.10.4
#1 lore raw

drivers/net/xen-netback/netback.c static int checksum_setup_ip(struct xenvif *vif, struct sk_buff *skb, · line 1181

Quoted 9 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).

drivers/net/xen-netback/netback.c +4 -0
+	/* 3fff -> fragment offset != 0 OR more fragments */
+	if (ntohs(iph->frag_off) & 0x3fff)
+		fragment = true;
+

What about the more self documented and faster :

if (iph->frag_off & htons(IP_OFFSET | IP_MF))

	fragment = true;
#2 lore raw
In reply to Paul Durrant

drivers/net/xen-netback/netback.c static int checksum_setup_ip(struct xenvif *vif, struct sk_buff *skb, · line 1181

Quoted 9 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).

drivers/net/xen-netback/netback.c +4 -0
+	/* 3fff -> fragment offset != 0 OR more fragments */
+	if (ntohs(iph->frag_off) & 0x3fff)
+		fragment = true;
+

What about the more self documented and faster :

if (iph->frag_off & htons(IP_OFFSET | IP_MF))

	fragment = true;
#5 lore raw
In reply to Paul Durrant
Quoted 22 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).

Cc Wei Liu <[email protected]>
Cc Ian Campbell <[email protected]>
Cc David Vrabel <[email protected]>

---
v2

- Added comments noting what fragment/offset masks mean

  drivers/net/xen-netback/netback.c |   33 ++++++++++++++++++++++++++++++---
  1 file changed, 30 insertions(+), 3 deletions(-)
drivers/net/xen-netback/netback.c +0 -0
index 919b650..c7464d8 100644

drivers/net/xen-netback/netback.c static int checksum_setup_ip(struct xenvif *vif, struct sk_buff *skb, · line 1171

Quoted 7 lines
drivers/net/xen-netback/netback.c +2 -0
@@ -1165,15 +1165,28 @@ static int checksum_setup_ip(struct xenvif *vif, struct sk_buff *skb,
  	struct iphdr *iph = (void *)skb->data;
  	unsigned int header_size;
  	unsigned int off;
+	bool fragment;
  	int err = -EPROTO;
 
+	fragment = false;

Is it better to initialize fragment directly as following? bool fragment = false;

Quoted 22 lines
drivers/net/xen-netback/netback.c +11 -0
+
  	off = sizeof(struct iphdr);
 
  	header_size = skb->network_header + off + MAX_IPOPTLEN;
  	maybe_pull_tail(skb, header_size);
 
+	/* 3fff -> fragment offset != 0 OR more fragments */
+	if (ntohs(iph->frag_off) & 0x3fff)
+		fragment = true;
+
  	off = iph->ihl * 4;
 
+	if (fragment) {
+		if (net_ratelimit())
+			netdev_err(vif->dev, "Packet is a fragment!\n");
+		goto out;
+	}
+
  	switch (iph->protocol) {
  	case IPPROTO_TCP:
  		if (!skb_partial_csum_set(skb, off,

drivers/net/xen-netback/netback.c static int checksum_setup_ipv6(struct xenvif *vif, struct sk_buff *skb, · line 1254

Quoted 5 lines
drivers/net/xen-netback/netback.c +1 -0
@@ -1237,6 +1250,7 @@ static int checksum_setup_ipv6(struct xenvif *vif, struct sk_buff *skb,
  	bool fragment;
  	bool done;
 
+	fragment = false;
  	done = false;

Same as above for "done" and "fragment"...

Thanks
Annie

#6 lore raw
In reply to Paul Durrant
Quoted 22 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).

Cc Wei Liu <[email protected]>
Cc Ian Campbell <[email protected]>
Cc David Vrabel <[email protected]>

---
v2

- Added comments noting what fragment/offset masks mean

  drivers/net/xen-netback/netback.c |   33 ++++++++++++++++++++++++++++++---
  1 file changed, 30 insertions(+), 3 deletions(-)
drivers/net/xen-netback/netback.c +0 -0
index 919b650..c7464d8 100644

drivers/net/xen-netback/netback.c static int checksum_setup_ip(struct xenvif *vif, struct sk_buff *skb, · line 1171

Quoted 7 lines
drivers/net/xen-netback/netback.c +2 -0
@@ -1165,15 +1165,28 @@ static int checksum_setup_ip(struct xenvif *vif, struct sk_buff *skb,
  	struct iphdr *iph = (void *)skb->data;
  	unsigned int header_size;
  	unsigned int off;
+	bool fragment;
  	int err = -EPROTO;
 
+	fragment = false;

Is it better to initialize fragment directly as following? bool fragment = false;

Quoted 22 lines
drivers/net/xen-netback/netback.c +11 -0
+
  	off = sizeof(struct iphdr);
 
  	header_size = skb->network_header + off + MAX_IPOPTLEN;
  	maybe_pull_tail(skb, header_size);
 
+	/* 3fff -> fragment offset != 0 OR more fragments */
+	if (ntohs(iph->frag_off) & 0x3fff)
+		fragment = true;
+
  	off = iph->ihl * 4;
 
+	if (fragment) {
+		if (net_ratelimit())
+			netdev_err(vif->dev, "Packet is a fragment!\n");
+		goto out;
+	}
+
  	switch (iph->protocol) {
  	case IPPROTO_TCP:
  		if (!skb_partial_csum_set(skb, off,

drivers/net/xen-netback/netback.c static int checksum_setup_ipv6(struct xenvif *vif, struct sk_buff *skb, · line 1254

Quoted 5 lines
drivers/net/xen-netback/netback.c +1 -0
@@ -1237,6 +1250,7 @@ static int checksum_setup_ipv6(struct xenvif *vif, struct sk_buff *skb,
  	bool fragment;
  	bool done;
 
+	fragment = false;
  	done = false;

Same as above for "done" and "fragment"...

Thanks
Annie

#7 lore raw
Quoted 43 lines

-----Original Message-----
From: annie li [mailto:[email protected]]
Sent: 29 November 2013 05:36
To: Paul Durrant
Cc: [email protected]; [email protected]; Wei Liu; Ian Campbell; David Vrabel
Subject: Re: [PATCH net v2] xen-netback: fix fragment detection in checksum setup

Quoted 1 line · Paul Durrant

The code to detect fragments in checksum_setup() was missing for IPv4

and

Quoted 8 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).

Cc Wei Liu <[email protected]>
Cc Ian Campbell <[email protected]>
Cc David Vrabel <[email protected]>
Quoted 6 lines

---
v2

- Added comments noting what fragment/offset masks mean

  drivers/net/xen-netback/netback.c |   33

++++++++++++++++++++++++++++++---

drivers/net/xen-

Quoted 3 lines
  1 file changed, 30 insertions(+), 3 deletions(-)
drivers/net/xen- renamed from drivers/net/xen-netback/netback.c +0 -0

netback/netback.c

drivers/net/xen-netback/netback.c static int checksum_setup_ip(struct xenvif *vif,

Quoted 4 lines

index 919b650..c7464d8 100644

drivers/net/xen-netback/netback.c +0 -0
@@ -1165,15 +1165,28 @@ static int checksum_setup_ip(struct xenvif *vif,

struct sk_buff *skb,

Quoted 6 lines
drivers/net/xen-netback/netback.c +1 -0
  	struct iphdr *iph = (void *)skb->data;
  	unsigned int header_size;
  	unsigned int off;
+	bool fragment;
  	int err = -EPROTO;
 
Quoted 5 lines

drivers/net/xen-netback/netback.c static int checksum_setup_ip(struct xenvif *vif, · line 1171

Quoted 1 line
drivers/net/xen-netback/netback.c +1 -0
+	fragment = false;

Is it better to initialize fragment directly as following? bool fragment = false;

I think that's a matter of personal taste. I tend to favour this style.

Paul

Quoted 33 lines

drivers/net/xen-netback/netback.c static int checksum_setup_ipv6(struct xenvif *vif,

Quoted 22 lines
drivers/net/xen-netback/netback.c +11 -0
+
  	off = sizeof(struct iphdr);
 
  	header_size = skb->network_header + off + MAX_IPOPTLEN;
  	maybe_pull_tail(skb, header_size);
 
+	/* 3fff -> fragment offset != 0 OR more fragments */
+	if (ntohs(iph->frag_off) & 0x3fff)
+		fragment = true;
+
  	off = iph->ihl * 4;
 
+	if (fragment) {
+		if (net_ratelimit())
+			netdev_err(vif->dev, "Packet is a fragment!\n");
+		goto out;
+	}
+
  	switch (iph->protocol) {
  	case IPPROTO_TCP:
  		if (!skb_partial_csum_set(skb, off,
@@ -1237,6 +1250,7 @@ static int checksum_setup_ipv6(struct xenvif *vif,

struct sk_buff *skb,

drivers/net/xen-netback/netback.c static int checksum_setup_ipv6(struct xenvif *vif, struct sk_buff *skb, · line 1254

Quoted 5 lines
drivers/net/xen-netback/netback.c +1 -0
  	bool fragment;
  	bool done;
 
+	fragment = false;
  	done = false;

Same as above for "done" and "fragment"...

Thanks
Annie

#8 lore raw
In reply to annie li
Quoted 43 lines

-----Original Message-----
From: annie li [mailto:[email protected]]
Sent: 29 November 2013 05:36
To: Paul Durrant
Cc: [email protected]; [email protected]; Wei Liu; Ian Campbell; David Vrabel
Subject: Re: [PATCH net v2] xen-netback: fix fragment detection in checksum setup

Quoted 1 line · Paul Durrant

The code to detect fragments in checksum_setup() was missing for IPv4

and

Quoted 8 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).

Cc Wei Liu <[email protected]>
Cc Ian Campbell <[email protected]>
Cc David Vrabel <[email protected]>
Quoted 6 lines

---
v2

- Added comments noting what fragment/offset masks mean

  drivers/net/xen-netback/netback.c |   33

++++++++++++++++++++++++++++++---

drivers/net/xen-

Quoted 3 lines
  1 file changed, 30 insertions(+), 3 deletions(-)
drivers/net/xen- renamed from drivers/net/xen-netback/netback.c +0 -0

netback/netback.c

drivers/net/xen-netback/netback.c static int checksum_setup_ip(struct xenvif *vif,

Quoted 4 lines

index 919b650..c7464d8 100644

drivers/net/xen-netback/netback.c +0 -0
@@ -1165,15 +1165,28 @@ static int checksum_setup_ip(struct xenvif *vif,

struct sk_buff *skb,

Quoted 6 lines
drivers/net/xen-netback/netback.c +1 -0
  	struct iphdr *iph = (void *)skb->data;
  	unsigned int header_size;
  	unsigned int off;
+	bool fragment;
  	int err = -EPROTO;
 
Quoted 5 lines

drivers/net/xen-netback/netback.c static int checksum_setup_ip(struct xenvif *vif, · line 1171

Quoted 1 line
drivers/net/xen-netback/netback.c +1 -0
+	fragment = false;

Is it better to initialize fragment directly as following? bool fragment = false;

I think that's a matter of personal taste. I tend to favour this style.

Paul

Quoted 33 lines

drivers/net/xen-netback/netback.c static int checksum_setup_ipv6(struct xenvif *vif,

Quoted 22 lines
drivers/net/xen-netback/netback.c +11 -0
+
  	off = sizeof(struct iphdr);
 
  	header_size = skb->network_header + off + MAX_IPOPTLEN;
  	maybe_pull_tail(skb, header_size);
 
+	/* 3fff -> fragment offset != 0 OR more fragments */
+	if (ntohs(iph->frag_off) & 0x3fff)
+		fragment = true;
+
  	off = iph->ihl * 4;
 
+	if (fragment) {
+		if (net_ratelimit())
+			netdev_err(vif->dev, "Packet is a fragment!\n");
+		goto out;
+	}
+
  	switch (iph->protocol) {
  	case IPPROTO_TCP:
  		if (!skb_partial_csum_set(skb, off,
@@ -1237,6 +1250,7 @@ static int checksum_setup_ipv6(struct xenvif *vif,

struct sk_buff *skb,

drivers/net/xen-netback/netback.c static int checksum_setup_ipv6(struct xenvif *vif, struct sk_buff *skb, · line 1254

Quoted 5 lines
drivers/net/xen-netback/netback.c +1 -0
  	bool fragment;
  	bool done;
 
+	fragment = false;
  	done = false;

Same as above for "done" and "fragment"...

Thanks
Annie

#9 lore raw
Quoted 43 lines · Paul Durrant
Quoted 43 lines

-----Original Message-----
From: annie li [mailto:[email protected]]
Sent: 29 November 2013 05:36
To: Paul Durrant
Cc: [email protected]; [email protected]; Wei Liu; Ian Campbell; David Vrabel
Subject: Re: [PATCH net v2] xen-netback: fix fragment detection in checksum setup

Quoted 1 line · Paul Durrant

The code to detect fragments in checksum_setup() was missing for IPv4

and

Quoted 8 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).

Cc Wei Liu <[email protected]>
Cc Ian Campbell <[email protected]>
Cc David Vrabel <[email protected]>
Quoted 6 lines

---
v2

- Added comments noting what fragment/offset masks mean

   drivers/net/xen-netback/netback.c |   33

++++++++++++++++++++++++++++++---

drivers/net/xen-

Quoted 3 lines
   1 file changed, 30 insertions(+), 3 deletions(-)
drivers/net/xen- renamed from drivers/net/xen-netback/netback.c +0 -0

netback/netback.c

drivers/net/xen-netback/netback.c static int checksum_setup_ip(struct xenvif *vif,

Quoted 4 lines

index 919b650..c7464d8 100644

drivers/net/xen-netback/netback.c +0 -0
@@ -1165,15 +1165,28 @@ static int checksum_setup_ip(struct xenvif *vif,

struct sk_buff *skb,

Quoted 6 lines
drivers/net/xen-netback/netback.c +1 -0
   	struct iphdr *iph = (void *)skb->data;
   	unsigned int header_size;
   	unsigned int off;
+	bool fragment;
   	int err = -EPROTO;
 
Quoted 6 lines
Quoted 4 lines

drivers/net/xen-netback/netback.c static int checksum_setup_ip(struct xenvif *vif, · line 1171

Quoted 1 line
drivers/net/xen-netback/netback.c +1 -0
+	fragment = false;

Is it better to initialize fragment directly as following? bool fragment = false;

I think that's a matter of personal taste. I tend to favour this style.

That is OK, I point this out because it is inconsistent with other variable initialization in netback.c.

Thanks
Annie

Quoted 37 lines
Quoted 27 lines

drivers/net/xen-netback/netback.c static int checksum_setup_ipv6(struct xenvif *vif,

Quoted 23 lines
drivers/net/xen-netback/netback.c +11 -0
+
   	off = sizeof(struct iphdr);
 
   	header_size = skb->network_header + off + MAX_IPOPTLEN;
   	maybe_pull_tail(skb, header_size);
 
+	/* 3fff -> fragment offset != 0 OR more fragments */
+	if (ntohs(iph->frag_off) & 0x3fff)
+		fragment = true;
+
   	off = iph->ihl * 4;
 
+	if (fragment) {
+		if (net_ratelimit())
+			netdev_err(vif->dev, "Packet is a fragment!\n");
+		goto out;
+	}
+
   	switch (iph->protocol) {
   	case IPPROTO_TCP:
   		if (!skb_partial_csum_set(skb, off,
@@ -1237,6 +1250,7 @@ static int checksum_setup_ipv6(struct xenvif *vif,

struct sk_buff *skb,

Quoted 3 lines
drivers/net/xen-netback/netback.c +0 -0
   	bool fragment;
   	bool done;
 
Quoted 6 lines

drivers/net/xen-netback/netback.c static int checksum_setup_ipv6(struct xenvif *vif, struct sk_buff *skb, · line 1254

Quoted 2 lines
drivers/net/xen-netback/netback.c +1 -0
+	fragment = false;
   	done = false;

Same as above for "done" and "fragment"...

Thanks
Annie

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#10 lore raw
In reply to Paul Durrant
Quoted 43 lines · Paul Durrant
Quoted 43 lines

-----Original Message-----
From: annie li [mailto:[email protected]]
Sent: 29 November 2013 05:36
To: Paul Durrant
Cc: [email protected]; [email protected]; Wei Liu; Ian Campbell; David Vrabel
Subject: Re: [PATCH net v2] xen-netback: fix fragment detection in checksum setup

Quoted 1 line · Paul Durrant

The code to detect fragments in checksum_setup() was missing for IPv4

and

Quoted 8 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).

Cc Wei Liu <[email protected]>
Cc Ian Campbell <[email protected]>
Cc David Vrabel <[email protected]>
Quoted 6 lines

---
v2

- Added comments noting what fragment/offset masks mean

   drivers/net/xen-netback/netback.c |   33

++++++++++++++++++++++++++++++---

drivers/net/xen-

Quoted 3 lines
   1 file changed, 30 insertions(+), 3 deletions(-)
drivers/net/xen- renamed from drivers/net/xen-netback/netback.c +0 -0

netback/netback.c

drivers/net/xen-netback/netback.c static int checksum_setup_ip(struct xenvif *vif,

Quoted 4 lines

index 919b650..c7464d8 100644

drivers/net/xen-netback/netback.c +0 -0
@@ -1165,15 +1165,28 @@ static int checksum_setup_ip(struct xenvif *vif,

struct sk_buff *skb,

Quoted 6 lines
drivers/net/xen-netback/netback.c +1 -0
   	struct iphdr *iph = (void *)skb->data;
   	unsigned int header_size;
   	unsigned int off;
+	bool fragment;
   	int err = -EPROTO;
 
Quoted 6 lines
Quoted 4 lines

drivers/net/xen-netback/netback.c static int checksum_setup_ip(struct xenvif *vif, · line 1171

Quoted 1 line
drivers/net/xen-netback/netback.c +1 -0
+	fragment = false;

Is it better to initialize fragment directly as following? bool fragment = false;

I think that's a matter of personal taste. I tend to favour this style.

That is OK, I point this out because it is inconsistent with other variable initialization in netback.c.

Thanks
Annie

Quoted 37 lines
Quoted 27 lines

drivers/net/xen-netback/netback.c static int checksum_setup_ipv6(struct xenvif *vif,

Quoted 23 lines
drivers/net/xen-netback/netback.c +11 -0
+
   	off = sizeof(struct iphdr);
 
   	header_size = skb->network_header + off + MAX_IPOPTLEN;
   	maybe_pull_tail(skb, header_size);
 
+	/* 3fff -> fragment offset != 0 OR more fragments */
+	if (ntohs(iph->frag_off) & 0x3fff)
+		fragment = true;
+
   	off = iph->ihl * 4;
 
+	if (fragment) {
+		if (net_ratelimit())
+			netdev_err(vif->dev, "Packet is a fragment!\n");
+		goto out;
+	}
+
   	switch (iph->protocol) {
   	case IPPROTO_TCP:
   		if (!skb_partial_csum_set(skb, off,
@@ -1237,6 +1250,7 @@ static int checksum_setup_ipv6(struct xenvif *vif,

struct sk_buff *skb,

Quoted 3 lines
drivers/net/xen-netback/netback.c +0 -0
   	bool fragment;
   	bool done;
 
Quoted 6 lines

drivers/net/xen-netback/netback.c static int checksum_setup_ipv6(struct xenvif *vif, struct sk_buff *skb, · line 1254

Quoted 2 lines
drivers/net/xen-netback/netback.c +1 -0
+	fragment = false;
   	done = false;

Same as above for "done" and "fragment"...

Thanks
Annie

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw
In reply to Eric Dumazet
Quoted 23 lines

-----Original Message-----
From: Eric Dumazet [mailto:[email protected]]
Sent: 28 November 2013 17:29
To: Paul Durrant
Cc: [email protected]; [email protected]; Wei Liu; Ian Campbell; David Vrabel
Subject: Re: [PATCH net v2] xen-netback: fix fragment detection in checksum setup

Quoted 1 line · Paul Durrant

The code to detect fragments in checksum_setup() was missing for IPv4

and

drivers/net/xen-netback/netback.c static int checksum_setup_ip(struct xenvif *vif, struct sk_buff *skb, · line 1181

Quoted 8 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).

drivers/net/xen-netback/netback.c +4 -0
+	/* 3fff -> fragment offset != 0 OR more fragments */
+	if (ntohs(iph->frag_off) & 0x3fff)
+		fragment = true;
+

What about the more self documented and faster :

Quoted 3 lines

if (iph->frag_off & htons(IP_OFFSET | IP_MF))

	fragment = true;

Nicer definitely. I'll need to add the equivalent def for IP6_OFFSET to use the same style of test there.

Thanks,

Paul

#4 lore raw
In reply to Eric Dumazet
Quoted 23 lines

-----Original Message-----
From: Eric Dumazet [mailto:[email protected]]
Sent: 28 November 2013 17:29
To: Paul Durrant
Cc: [email protected]; [email protected]; Wei Liu; Ian Campbell; David Vrabel
Subject: Re: [PATCH net v2] xen-netback: fix fragment detection in checksum setup

Quoted 1 line · Paul Durrant

The code to detect fragments in checksum_setup() was missing for IPv4

and

drivers/net/xen-netback/netback.c static int checksum_setup_ip(struct xenvif *vif, struct sk_buff *skb, · line 1181

Quoted 8 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).

drivers/net/xen-netback/netback.c +4 -0
+	/* 3fff -> fragment offset != 0 OR more fragments */
+	if (ntohs(iph->frag_off) & 0x3fff)
+		fragment = true;
+

What about the more self documented and faster :

Quoted 3 lines

if (iph->frag_off & htons(IP_OFFSET | IP_MF))

	fragment = true;

Nicer definitely. I'll need to add the equivalent def for IP6_OFFSET to use the same style of test there.

Thanks,

Paul