Commit 2030abdd authored by Steve Wise's avatar Steve Wise Committed by Doug Ledford

rxe: correctly calculate iCRC for unaligned payloads

If RoCE PDUs being sent or received contain pad bytes, then the iCRC
is miscalculated, resulting in PDUs being emitted by RXE with an incorrect
iCRC, as well as ingress PDUs being dropped due to erroneously detecting
a bad iCRC in the PDU.  The fix is to include the pad bytes, if any,
in iCRC computations.

Note: This bug has caused broken on-the-wire compatibility with actual
hardware RoCE devices since the soft-RoCE driver was first put into the
mainstream kernel.  Fixing it will create an incompatibility with the
original soft-RoCE devices, but is necessary to be compatible with real
hardware devices.

Fixes: 8700e3e7 ("Soft RoCE driver")
Signed-off-by: default avatarSteve Wise <larrystevenwise@gmail.com>
Link: https://lore.kernel.org/r/20191203020319.15036-2-larrystevenwise@gmail.comSigned-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 71bbac6e
...@@ -389,7 +389,7 @@ void rxe_rcv(struct sk_buff *skb) ...@@ -389,7 +389,7 @@ void rxe_rcv(struct sk_buff *skb)
calc_icrc = rxe_icrc_hdr(pkt, skb); calc_icrc = rxe_icrc_hdr(pkt, skb);
calc_icrc = rxe_crc32(rxe, calc_icrc, (u8 *)payload_addr(pkt), calc_icrc = rxe_crc32(rxe, calc_icrc, (u8 *)payload_addr(pkt),
payload_size(pkt)); payload_size(pkt) + bth_pad(pkt));
calc_icrc = (__force u32)cpu_to_be32(~calc_icrc); calc_icrc = (__force u32)cpu_to_be32(~calc_icrc);
if (unlikely(calc_icrc != pack_icrc)) { if (unlikely(calc_icrc != pack_icrc)) {
if (skb->protocol == htons(ETH_P_IPV6)) if (skb->protocol == htons(ETH_P_IPV6))
......
...@@ -500,6 +500,12 @@ static int fill_packet(struct rxe_qp *qp, struct rxe_send_wqe *wqe, ...@@ -500,6 +500,12 @@ static int fill_packet(struct rxe_qp *qp, struct rxe_send_wqe *wqe,
if (err) if (err)
return err; return err;
} }
if (bth_pad(pkt)) {
u8 *pad = payload_addr(pkt) + paylen;
memset(pad, 0, bth_pad(pkt));
crc = rxe_crc32(rxe, crc, pad, bth_pad(pkt));
}
} }
p = payload_addr(pkt) + paylen + bth_pad(pkt); p = payload_addr(pkt) + paylen + bth_pad(pkt);
......
...@@ -732,6 +732,13 @@ static enum resp_states read_reply(struct rxe_qp *qp, ...@@ -732,6 +732,13 @@ static enum resp_states read_reply(struct rxe_qp *qp,
if (err) if (err)
pr_err("Failed copying memory\n"); pr_err("Failed copying memory\n");
if (bth_pad(&ack_pkt)) {
struct rxe_dev *rxe = to_rdev(qp->ibqp.device);
u8 *pad = payload_addr(&ack_pkt) + payload;
memset(pad, 0, bth_pad(&ack_pkt));
icrc = rxe_crc32(rxe, icrc, pad, bth_pad(&ack_pkt));
}
p = payload_addr(&ack_pkt) + payload + bth_pad(&ack_pkt); p = payload_addr(&ack_pkt) + payload + bth_pad(&ack_pkt);
*p = ~icrc; *p = ~icrc;
......
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