Add payload to be 32-bit aligned to fix dropped packets
Subsystems (2)
PATCH v4 1/1 Add payload to be 32-bit aligned to fix dropped packets
Update NC-SI command handler (both standard and OEM) to take into account of payload paddings in allocating skb (in case of payload size is not 32-bit aligned).
The checksum field follows payload field, without taking payload padding into account can cause checksum being truncated, leading to dropped packets.
---
v4:
- Updated existing macro for max function
v3:
- Added Macro for MAX
- Fixed the missed semicolon
v2:
- Added NC-SI spec version and section
- Removed blank line
- corrected spellings
v1:
- Initial draft
--- net/ncsi/ncsi-cmd.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
net/ncsi/ncsi-cmd.c +13 -8
@@ -213,12 +213,16 @@ static int ncsi_cmd_handler_oem(struct sk_buff *skb, {struct ncsi_cmd_oem_pkt *cmd;unsigned int len; +/* NC-SI spec DSP_0222_1.2.0, section 8.2.2.2 +* requires payload to be padded with 0 to +* 32-bit boundary before the checksum field. +* Ensure the padding bytes are accounted for in +* skb allocation +*/ +unsigned short payload =ALIGN (nca->payload,4 ); len =sizeof (struct ncsi_cmd_pkt_hdr ) +4 ; -if (nca->payload <26 ) - len +=26 ; -else - len += nca->payload; + len +=max (payload,26 ); cmd =skb_put_zero (skb, len);memcpy (&cmd->mfr_id, nca->data, nca->payload);
@@ -272,6 +276,7 @@ static struct ncsi_request *ncsi_alloc_command(struct ncsi_cmd_arg *nca)struct net_device *dev = nd->dev;int hlen =LL_RESERVED_SPACE (dev);int tlen = dev->needed_tailroom; +int payload;int len = hlen + tlen;struct sk_buff *skb;struct ncsi_request *nr;
@@ -281,14 +286,14 @@ static struct ncsi_request *ncsi_alloc_command(struct ncsi_cmd_arg *nca)return NULL ;/* NCSI command packet has 16-bytes header, payload, 4 bytes checksum. +* Payload needs padding so that the checksum field following payload is +* aligned to 32-bit boundary. * The packet needs padding if its payload is less than 26 bytes to * meet 64 bytes minimal ethernet frame length. */ len +=sizeof (struct ncsi_cmd_pkt_hdr ) +4 ; -if (nca->payload <26 ) - len +=26 ; -else - len += nca->payload; + payload =ALIGN (nca->payload,4 ); + len +=max (payload,26 );/* Allocate skb */ skb =alloc_skb (len,GFP_ATOMIC );
Signature · 1 line
2.17.1
PATCH v4 1/1 Add payload to be 32-bit aligned to fix dropped packets
Hi All,
Could you please review the patch and provide your feedback?
Thanks,
Kumar.
Quoted 92 lines · Kumar Thangavel
Update NC-SI command handler (both standard and OEM) to take into account of payload paddings in allocating skb (in case of payload size is not 32-bit aligned).
The checksum field follows payload field, without taking payload padding into account can cause checksum being truncated, leading to dropped packets.
Signed-off-by Kumar Thangavel <[email protected]>Reviewed-by Paul Menzel <[email protected]>---
v4:
- Updated existing macro for max functionv3:
- Added Macro for MAX
- Fixed the missed semicolonv2:
- Added NC-SI spec version and section
- Removed blank line
- corrected spellingsv1:
- Initial draft--- net/ncsi/ncsi-cmd.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)net/ncsi/ncsi-cmd.c +9
-4@@ -213,12 +213,16 @@ static int ncsi_cmd_handler_oem(struct sk_buff *skb, {struct ncsi_cmd_oem_pkt *cmd;unsigned int len; +/* NC-SI spec DSP_0222_1.2.0, section 8.2.2.2 +* requires payload to be padded with 0 to +* 32-bit boundary before the checksum field. +* Ensure the padding bytes are accounted for in +* skb allocation +*/ +unsigned short payload =ALIGN (nca->payload,4 ); len =sizeof (struct ncsi_cmd_pkt_hdr ) +4 ; -if (nca->payload <26 ) - len +=26 ; -else - len += nca->payload; + len +=max (payload,26 ); cmd =skb_put_zero (skb, len);memcpy (&cmd->mfr_id, nca->data, nca->payload);@@ -272,6 +276,7 @@ static struct ncsi_request *ncsi_alloc_command(struct ncsi_cmd_arg *nca)struct net_device *dev = nd->dev;int hlen =LL_RESERVED_SPACE (dev);int tlen = dev->needed_tailroom; +int payload;int len = hlen + tlen;struct sk_buff *skb;struct ncsi_request *nr;net/ncsi/ncsi-cmd.c +0
-0@@ -281,14 +286,14 @@ static struct ncsi_request *ncsi_alloc_command(struct ncsi_cmd_arg *nca)return NULL ;/* NCSI command packet has 16-bytes header, payload, 4 bytes checksum.
+ * Payload needs padding so that the checksum field following
payload isnet/ncsi/ncsi-cmd.c +3
-5+* aligned to 32-bit boundary. * The packet needs padding if its payload is less than 26 bytes to * meet 64 bytes minimal ethernet frame length. */ len +=sizeof (struct ncsi_cmd_pkt_hdr ) +4 ; -if (nca->payload <26 ) - len +=26 ; -else - len += nca->payload; + payload =ALIGN (nca->payload,4 ); + len +=max (payload,26 );/* Allocate skb */ skb =alloc_skb (len,GFP_ATOMIC ); --2.17.1
Jakub Kicinski
maintainerPATCH v4 1/1 Add payload to be 32-bit aligned to fix dropped packets
Quoted 1 line · On Wed, 3 Nov 2021 20:41:56 +0530 Kumar Thangavel wrote:
Could you please review the patch and provide your feedback?
You missed CCing netdev@ again. You need to CC the mailing list to get the patch considered for merging.
PATCH v4 1/1 Add payload to be 32-bit aligned to fix dropped packets
Hi Jakub,
Thanks for your response.
Somehow, My mails are not delivered to [email protected].
So, I removed it in my last 2 patchsets.
I will try again to CCing [email protected].
Thanks,
Kumar.
Quoted 6 lines · Jakub Kicinski
Quoted 1 line · On Wed, 3 Nov 2021 20:41:56 +0530 Kumar Thangavel wrote:
Could you please review the patch and provide your feedback?
You missed CCing netdev@ again. You need to CC the mailing list to get the patch considered for merging.
Jakub Kicinski
maintainerPATCH v4 1/1 Add payload to be 32-bit aligned to fix dropped packets
Quoted 9 lines · On Wed, 3 Nov 2021 21:43:03 +0530 Kumar Thangavel wrote:
Hi Jakub,
Thanks for your response.
Somehow, My mails are not delivered to netdev at vger.kernel.org.
So, I removed it in my last 2 patchsets.
I will try again to CCing netdev at vger.kernel.org.
For normal replies you need to use plain text, not HTML. The mailing list rejects HTML emails. But the patch should go thru, we'll see.
PATCH v4 1/1 Add payload to be 32-bit aligned to fix dropped packets
Ok Sure Jakub.
Thanks,
Kumar.
Quoted 14 lines · Jakub Kicinski
Quoted 9 lines · On Wed, 3 Nov 2021 21:43:03 +0530 Kumar Thangavel wrote:
Hi Jakub,
Thanks for your response.
Somehow, My mails are not delivered to [email protected].
So, I removed it in my last 2 patchsets.
I will try again to CCing [email protected].
For normal replies you need to use plain text, not HTML. The mailing list rejects HTML emails. But the patch should go thru, we'll see.