To avoid the following failure when trying to load the rdma_rxe module while IPv6 is disabled, Add a check to make sure that IPv6 is enabled before trying to create the IPv6 UDP tunnel. $ modprobe rdma_rxe modprobe: ERROR: could not insert 'rdma_rxe': Operation not permitted Fixes: dfdd6158ca2c ("IB/rxe: Fix kernel panic in udp_setup_tunnel") Signed-off-by: Kamal Heib <kamalheib1@xxxxxxxxx> --- drivers/infiniband/sw/rxe/rxe_net.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c index 01662727dca0..f353fc18769f 100644 --- a/drivers/infiniband/sw/rxe/rxe_net.c +++ b/drivers/infiniband/sw/rxe/rxe_net.c @@ -617,12 +617,14 @@ static int rxe_net_ipv6_init(void) { #if IS_ENABLED(CONFIG_IPV6) - recv_sockets.sk6 = rxe_setup_udp_tunnel(&init_net, - htons(ROCE_V2_UDP_DPORT), true); - if (IS_ERR(recv_sockets.sk6)) { - recv_sockets.sk6 = NULL; - pr_err("Failed to create IPv6 UDP tunnel\n"); - return -1; + if (ipv6_mod_enabled()) { + recv_sockets.sk6 = rxe_setup_udp_tunnel(&init_net, + htons(ROCE_V2_UDP_DPORT), true); + if (IS_ERR(recv_sockets.sk6)) { + recv_sockets.sk6 = NULL; + pr_err("Failed to create IPv6 UDP tunnel\n"); + return -1; + } } #endif return 0; -- 2.26.3