RDMA/rxe: Use sizeof instead of hard code number
authorzhenwei pi <pizhenwei@bytedance.com>
Thu, 22 Aug 2024 06:52:21 +0000 (14:52 +0800)
committerJason Gunthorpe <jgg@nvidia.com>
Fri, 23 Aug 2024 14:42:38 +0000 (11:42 -0300)
Use 'sizeof(union rdma_network_hdr)' instead of hard code GRH length
for GSI and UD.

Link: https://patch.msgid.link/r/20240822065223.1117056-2-pizhenwei@bytedance.com
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/sw/rxe/rxe_resp.c

index 6596a85723c9a515667f987758ef00fceb8d8298..bf8f4bc8c5c8f25c5a7893ece73f7be40d5c39d4 100644 (file)
@@ -351,7 +351,7 @@ static enum resp_states rxe_resp_check_length(struct rxe_qp *qp,
 
                for (i = 0; i < qp->resp.wqe->dma.num_sge; i++)
                        recv_buffer_len += qp->resp.wqe->dma.sge[i].length;
-               if (payload + 40 > recv_buffer_len) {
+               if (payload + sizeof(union rdma_network_hdr) > recv_buffer_len) {
                        rxe_dbg_qp(qp, "The receive buffer is too small for this UD packet.\n");
                        return RESPST_ERR_LENGTH;
                }