Skip to contentSkip to conversation

net: ethernet: sun: niu set correct packet size in skb

PATCH David Miller 2 participants 3 messages May 3, 2018 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

David Miller

author maintainer
#1 lore raw
In reply to a message not in the archive

From: Rob Taglang <[email protected]>
Date: Thu, 03 May 2018 11:06:04 -0400

Quoted 29 lines

Currently, skb->len and skb->data_len are set to the page size, not the packet size. This causes the frame check sequence to not be located at the "end" of the packet resulting in ethernet frame check errors. The driver does work currently, but stricter kernel facing networking solutions like OpenVSwitch will drop these packets as invalid.

These changes set the packet size correctly so that these errors no longer occur. The length does not include the frame check sequence, so that subtraction was removed.

Tested on Oracle/SUN Multithreaded 10-Gigabit Ethernet Network Controller [108e:abcd].

This is a resubmission after subscribing to the list; I think it got caught in a spam filter since I can't see my message in the archive, but if not and this is just pissing off a maintainer I'm really sorry.

---
drivers/net/ethernet/sun/niu.c | 5 ++---

1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/ethernet/sun/niu.c +0 -0
index f081de4..88c1247 100644

drivers/net/ethernet/sun/niu.c static int niu_process_rx_pkt(struct napi_struct · line 3447

Quoted 6 lines
drivers/net/ethernet/sun/niu.c +1 -1
@@ -3443,7 +3443,7 @@ static int niu_process_rx_pkt(struct napi_struct
 *napi, struct niu *np,
 
               len = (val & RCR_ENTRY_L2_LEN) >>
                       RCR_ENTRY_L2_LEN_SHIFT;
- len -= ETH_FCS_LEN;
+ append_size = len + ETH_HLEN + ETH_FCS_LEN;

This patch is severely corrupted by your email client.

Please fix this, send the patch to yourself as a test, and only repost the patch here on the list once you can successfully apply the patch contained in the test email.

Thanks.

#2 lore raw

Ah, gotcha. Should I make a new thread?

Patch should be properly formatted below.

Thanks,
Rob

---
 drivers/net/ethernet/sun/niu.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/ethernet/sun/niu.c +2 -3
index f081de4..88c1247 100644
@@ -3443,7 +3443,7 @@ static int niu_process_rx_pkt(struct napi_struct *napi, struct niu *np,
 
 		len = (val & RCR_ENTRY_L2_LEN) >>
 			RCR_ENTRY_L2_LEN_SHIFT;
-		len -= ETH_FCS_LEN;
+		append_size = len + ETH_HLEN + ETH_FCS_LEN;
 
 		addr = (val & RCR_ENTRY_PKT_BUF_ADDR) <<
 			RCR_ENTRY_PKT_BUF_ADDR_SHIFT;
@@ -3453,7 +3453,6 @@ static int niu_process_rx_pkt(struct napi_struct *napi, struct niu *np,
 					 RCR_ENTRY_PKTBUFSZ_SHIFT];
 
 		off = addr & ~PAGE_MASK;
-		append_size = rcr_size;
 		if (num_rcr == 1) {
 			int ptype;
 
@@ -3466,7 +3465,7 @@ static int niu_process_rx_pkt(struct napi_struct *napi, struct niu *np,
 			else
 				skb_checksum_none_assert(skb);
 		} else if (!(val & RCR_ENTRY_MULTI))
-			append_size = len - skb->len;
+			append_size = append_size - skb->len;
 
 		niu_rx_skb_append(skb, page, off, append_size, rcr_size);
 		if ((page->index + rp->rbr_block_size) - rcr_size == addr) {
Quoted 46 lines · David Miller

From: Rob Taglang <[email protected]>
Date: Thu, 03 May 2018 11:06:04 -0400

Quoted 29 lines

Currently, skb->len and skb->data_len are set to the page size, not the packet size. This causes the frame check sequence to not be located at the "end" of the packet resulting in ethernet frame check errors. The driver does work currently, but stricter kernel facing networking solutions like OpenVSwitch will drop these packets as invalid.

These changes set the packet size correctly so that these errors no longer occur. The length does not include the frame check sequence, so that subtraction was removed.

Tested on Oracle/SUN Multithreaded 10-Gigabit Ethernet Network Controller [108e:abcd].

This is a resubmission after subscribing to the list; I think it got caught in a spam filter since I can't see my message in the archive, but if not and this is just pissing off a maintainer I'm really sorry.

---
drivers/net/ethernet/sun/niu.c | 5 ++---

1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/ethernet/sun/niu.c +0 -0
index f081de4..88c1247 100644

drivers/net/ethernet/sun/niu.c static int niu_process_rx_pkt(struct napi_struct · line 3447

Quoted 6 lines
drivers/net/ethernet/sun/niu.c +1 -1
@@ -3443,7 +3443,7 @@ static int niu_process_rx_pkt(struct napi_struct
 *napi, struct niu *np,
 
               len = (val & RCR_ENTRY_L2_LEN) >>
                       RCR_ENTRY_L2_LEN_SHIFT;
- len -= ETH_FCS_LEN;
+ append_size = len + ETH_HLEN + ETH_FCS_LEN;

This patch is severely corrupted by your email client.

Please fix this, send the patch to yourself as a test, and only repost the patch here on the list once you can successfully apply the patch contained in the test email.

Thanks.

author maintainer
#3 lore raw

From: [email protected]
Date: Thu, 03 May 2018 16:38:04 -0400

Quoted 1 line

Ah, gotcha. Should I make a new thread?

Yes, please do.

Thank you.