Commit 96a1b033 authored by Terry S. Duncan's avatar Terry S. Duncan Committed by David S. Miller

net/ncsi: Ensure 32-bit boundary for data cksum

The NCSI spec indicates that if the data does not end on a 32 bit
boundary, one to three padding bytes equal to 0x00 shall be present to
align the checksum field to a 32-bit boundary.
Signed-off-by: default avatarTerry S. Duncan <terry.s.duncan@linux.intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4651d180
...@@ -54,7 +54,7 @@ static void ncsi_cmd_build_header(struct ncsi_pkt_hdr *h, ...@@ -54,7 +54,7 @@ static void ncsi_cmd_build_header(struct ncsi_pkt_hdr *h,
checksum = ncsi_calculate_checksum((unsigned char *)h, checksum = ncsi_calculate_checksum((unsigned char *)h,
sizeof(*h) + nca->payload); sizeof(*h) + nca->payload);
pchecksum = (__be32 *)((void *)h + sizeof(struct ncsi_pkt_hdr) + pchecksum = (__be32 *)((void *)h + sizeof(struct ncsi_pkt_hdr) +
nca->payload); ALIGN(nca->payload, 4));
*pchecksum = htonl(checksum); *pchecksum = htonl(checksum);
} }
......
...@@ -47,7 +47,8 @@ static int ncsi_validate_rsp_pkt(struct ncsi_request *nr, ...@@ -47,7 +47,8 @@ static int ncsi_validate_rsp_pkt(struct ncsi_request *nr,
if (ntohs(h->code) != NCSI_PKT_RSP_C_COMPLETED || if (ntohs(h->code) != NCSI_PKT_RSP_C_COMPLETED ||
ntohs(h->reason) != NCSI_PKT_RSP_R_NO_ERROR) { ntohs(h->reason) != NCSI_PKT_RSP_R_NO_ERROR) {
netdev_dbg(nr->ndp->ndev.dev, netdev_dbg(nr->ndp->ndev.dev,
"NCSI: non zero response/reason code\n"); "NCSI: non zero response/reason code %04xh, %04xh\n",
ntohs(h->code), ntohs(h->reason));
return -EPERM; return -EPERM;
} }
...@@ -55,7 +56,7 @@ static int ncsi_validate_rsp_pkt(struct ncsi_request *nr, ...@@ -55,7 +56,7 @@ static int ncsi_validate_rsp_pkt(struct ncsi_request *nr,
* sender doesn't support checksum according to NCSI * sender doesn't support checksum according to NCSI
* specification. * specification.
*/ */
pchecksum = (__be32 *)((void *)(h + 1) + payload - 4); pchecksum = (__be32 *)((void *)(h + 1) + ALIGN(payload, 4) - 4);
if (ntohl(*pchecksum) == 0) if (ntohl(*pchecksum) == 0)
return 0; return 0;
...@@ -63,7 +64,9 @@ static int ncsi_validate_rsp_pkt(struct ncsi_request *nr, ...@@ -63,7 +64,9 @@ static int ncsi_validate_rsp_pkt(struct ncsi_request *nr,
sizeof(*h) + payload - 4); sizeof(*h) + payload - 4);
if (*pchecksum != htonl(checksum)) { if (*pchecksum != htonl(checksum)) {
netdev_dbg(nr->ndp->ndev.dev, "NCSI: checksum mismatched\n"); netdev_dbg(nr->ndp->ndev.dev,
"NCSI: checksum mismatched; recd: %08x calc: %08x\n",
*pchecksum, htonl(checksum));
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment