Skip to content

Commit edebc84

Browse files
rpearsonhpe-designjgunthorpe
authored andcommitted
RDMA/rxe: Fix small problem in network_type patch
The patch referenced below has a typo that results in using the wrong L2 header size for outbound traffic. (V4 <-> V6). It also breaks kernel-side RC traffic because they use AVs that use RDMA_NETWORK_XXX enums instead of RXE_NETWORK_TYPE_XXX enums. Fix this by transcoding between these enum types. Fixes: e0d696d ("RDMA/rxe: Move the definitions for rxe_av.network_type to uAPI") Link: https://lore.kernel.org/r/20201016211343.22906-1-rpearson@hpe.com Signed-off-by: Bob Pearson <rpearson@hpe.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent 3650b22 commit edebc84

2 files changed

Lines changed: 32 additions & 5 deletions

File tree

‎drivers/infiniband/sw/rxe/rxe_av.c‎

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,24 @@ void rxe_init_av(struct rdma_ah_attr *attr, struct rxe_av *av)
1616

1717
int rxe_av_chk_attr(struct rxe_dev *rxe, struct rdma_ah_attr *attr)
1818
{
19+
const struct ib_global_route *grh = rdma_ah_read_grh(attr);
1920
struct rxe_port *port;
21+
int type;
2022

2123
port = &rxe->port;
2224

2325
if (rdma_ah_get_ah_flags(attr) & IB_AH_GRH) {
24-
u8 sgid_index = rdma_ah_read_grh(attr)->sgid_index;
26+
if (grh->sgid_index > port->attr.gid_tbl_len) {
27+
pr_warn("invalid sgid index = %d\n",
28+
grh->sgid_index);
29+
return -EINVAL;
30+
}
2531

26-
if (sgid_index > port->attr.gid_tbl_len) {
27-
pr_warn("invalid sgid index = %d\n", sgid_index);
32+
type = rdma_gid_attr_network_type(grh->sgid_attr);
33+
if (type < RDMA_NETWORK_IPV4 ||
34+
type > RDMA_NETWORK_IPV6) {
35+
pr_warn("invalid network type for rdma_rxe = %d\n",
36+
type);
2837
return -EINVAL;
2938
}
3039
}
@@ -65,11 +74,29 @@ void rxe_av_to_attr(struct rxe_av *av, struct rdma_ah_attr *attr)
6574
void rxe_av_fill_ip_info(struct rxe_av *av, struct rdma_ah_attr *attr)
6675
{
6776
const struct ib_gid_attr *sgid_attr = attr->grh.sgid_attr;
77+
int ibtype;
78+
int type;
6879

6980
rdma_gid2ip((struct sockaddr *)&av->sgid_addr, &sgid_attr->gid);
7081
rdma_gid2ip((struct sockaddr *)&av->dgid_addr,
7182
&rdma_ah_read_grh(attr)->dgid);
72-
av->network_type = rdma_gid_attr_network_type(sgid_attr);
83+
84+
ibtype = rdma_gid_attr_network_type(sgid_attr);
85+
86+
switch (ibtype) {
87+
case RDMA_NETWORK_IPV4:
88+
type = RXE_NETWORK_TYPE_IPV4;
89+
break;
90+
case RDMA_NETWORK_IPV6:
91+
type = RXE_NETWORK_TYPE_IPV4;
92+
break;
93+
default:
94+
/* not reached - checked in rxe_av_chk_attr */
95+
type = 0;
96+
break;
97+
}
98+
99+
av->network_type = type;
73100
}
74101

75102
struct rxe_av *rxe_get_av(struct rxe_pkt_info *pkt)

‎drivers/infiniband/sw/rxe/rxe_net.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ struct sk_buff *rxe_init_packet(struct rxe_dev *rxe, struct rxe_av *av,
442442
if (IS_ERR(attr))
443443
return NULL;
444444

445-
if (av->network_type == RXE_NETWORK_TYPE_IPV6)
445+
if (av->network_type == RXE_NETWORK_TYPE_IPV4)
446446
hdr_len = ETH_HLEN + sizeof(struct udphdr) +
447447
sizeof(struct iphdr);
448448
else

0 commit comments

Comments
 (0)