RDMA/rxe: Add the support that rxe can work in net namespace
Subsystems (3)
v3 cover RDMA/rxe: Add the support that rxe can work in net namespace
Currently rxe does not work correctly in network namespaces.
When the rdma_rxe module is loaded, a UDP socket listening on port 4791 is created in init_net. When users run:
ip link add ... type rxe
inside another network namespace, the RXE RDMA link is created but it cannot function properly because the underlying UDP socket belongs to init_net. Other network namespaces cannot use that socket.
To address this issue, this series introduces net namespace support for rxe and moves socket management to be per network namespace.
The series first introduces per-net namespace management for the IPv4 and IPv6 sockets used by rxe. The sockets are created when the network namespace becomes active and are released when the namespace is destroyed.
Based on this infrastructure, rxe RDMA links are then created and destroyed within each network namespace. This ensures that both the UDP sockets and RDMA links are correctly scoped to the namespace in which they are used.
With these changes, rxe RDMA links can be created and used both in init_net and in other network namespaces, and resources are properly cleaned up during namespace teardown.
The series also includes a selftest to verify RXE functionality in network namespaces.
V2 -> V3: Fix build warnings
V1 -> V2: Fix the problems based on David Ahern.
Zhu Yanjun (4):
RDMA/nldev: Add dellink function pointer
RDMA/rxe: Add net namespace support for IPv4/IPv6 sockets RDMA/rxe: Support RDMA link creation and destruction per net namespace RDMA/rxe: Add testcase for net namespace rxe
MAINTAINERS | 1 + drivers/infiniband/core/nldev.c | 6 + drivers/infiniband/sw/rxe/Makefile | 3 +- drivers/infiniband/sw/rxe/rxe.c | 38 ++++- drivers/infiniband/sw/rxe/rxe_net.c | 145 +++++++++++++----- drivers/infiniband/sw/rxe/rxe_net.h | 9 +- drivers/infiniband/sw/rxe/rxe_ns.c | 136 ++++++++++++++++ drivers/infiniband/sw/rxe/rxe_ns.h | 17 ++ include/rdma/rdma_netlink.h | 2 + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/rdma/Makefile | 7 + tools/testing/selftests/rdma/config | 3 + tools/testing/selftests/rdma/rxe_ipv6.sh | 47 ++++++ .../selftests/rdma/rxe_rping_between_netns.sh | 57 +++++++ .../selftests/rdma/rxe_socket_with_netns.sh | 64 ++++++++ .../rdma/rxe_test_NETDEV_UNREGISTER.sh | 38 +++++ 16 files changed, 527 insertions(+), 47 deletions(-) create mode 100644 drivers/infiniband/sw/rxe/rxe_ns.c create mode 100644 drivers/infiniband/sw/rxe/rxe_ns.h create mode 100644 tools/testing/selftests/rdma/Makefile create mode 100644 tools/testing/selftests/rdma/config create mode 100755 tools/testing/selftests/rdma/rxe_ipv6.sh create mode 100755 tools/testing/selftests/rdma/rxe_rping_between_netns.sh create mode 100755 tools/testing/selftests/rdma/rxe_socket_with_netns.sh create mode 100755 tools/testing/selftests/rdma/rxe_test_NETDEV_UNREGISTER.sh
Signature · 1 line
2.52.0
PATCH v3 1/4 RDMA/nldev: Add dellink function pointer
The newlink function pointer is added. And the sock listening on port 4791 is added in the newlink function. So the dellink function is needed to remove the sock.
--- drivers/infiniband/core/nldev.c | 6 ++++++ include/rdma/rdma_netlink.h | 2 ++ 2 files changed, 8 insertions(+)
drivers/infiniband/core/nldev.c +6 -0
@@ -1824,6 +1824,12 @@ static int nldev_dellink(struct sk_buff *skb, struct nlmsghdr *nlh,return -EINVAL ; } +if (device->link_ops) { + err = device->link_ops->dellink (device); +if (err) +return err; + } +ib_unregister_device_and_put (device);return 0 ; }
include/rdma/rdma_netlink.h +2 -0
@@ -5,6 +5,7 @@#include <linux/netlink.h> #include <uapi/rdma/rdma_netlink.h> +#include <rdma/ib_verbs.h> struct ib_device ;
@@ -126,6 +127,7 @@ struct rdma_link_ops {struct list_head list;const char *type;int (*newlink)(const char *ibdev_name,struct net_device *ndev); +int (*dellink)(struct ib_device *dev); };void rdma_link_register (struct rdma_link_ops *ops);
Signature · 1 line
2.52.0
PATCH v3 2/4 RDMA/rxe: Add net namespace support for IPv4/IPv6 sockets
In reply to Zhu YanjunAdd a net namespace implementation file to rxe to manage the lifecycle of IPv4 and IPv6 sockets per network namespace.
This implementation handles the creation and destruction of the sockets both for init_net and for dynamically created network namespaces. The sockets are initialized when a namespace becomes active and are properly released when the namespace is removed.
This change provides the infrastructure needed for rxe to operate correctly in environments using multiple network namespaces.
--- drivers/infiniband/sw/rxe/Makefile | 3 +- drivers/infiniband/sw/rxe/rxe_ns.c | 134 +++++++++++++++++++++++++++++ drivers/infiniband/sw/rxe/rxe_ns.h | 17 ++++ 3 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 drivers/infiniband/sw/rxe/rxe_ns.c create mode 100644 drivers/infiniband/sw/rxe/rxe_ns.h
drivers/infiniband/sw/rxe/Makefile +2 -1
@@ -22,6 +22,7 @@ rdma_rxe-y := \ rxe_mcast.o \ rxe_task.o \ rxe_net.o \ - rxe_hw_counters.o + rxe_hw_counters.o \ + rxe_ns.o rdma_rxe-$(CONFIG_INFINIBAND_ON_DEMAND_PAGING) += rxe_odp.o
drivers/infiniband/sw/rxe/rxe_ns.c new file +134 -0
134 lines not on this page · raw message
drivers/infiniband/sw/rxe/rxe_ns.h new file +17 -0
@@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB +/* +* Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved. +* Copyright (c) 2015 System Fabric Works, Inc. All rights reserved. +*/ + +#ifndef RXE_NS_H +#define RXE_NS_H + +struct sock *rxe_ns_pernet_sk4 (struct net *net); +struct sock *rxe_ns_pernet_sk6 (struct net *net); +void rxe_ns_pernet_set_sk4 (struct net *net,struct sock *sk); +void rxe_ns_pernet_set_sk6 (struct net *net,struct sock *sk); +int __init rxe_namespace_init (void ); +void __exit rxe_namespace_exit(void); + +#endif /* RXE_NS_H */
Signature · 1 line
2.52.0
PATCH v3 3/4 RDMA/rxe: Support RDMA link creation and destruction per net namespace
In reply to Zhu YanjunAfter introducing dellink handling and per-net namespace management for IPv4 and IPv6 sockets, extend rxe to create and destroy RDMA links within each network namespace.
With this change, RDMA links can be instantiated both in init_net and in other network namespaces. The lifecycle of the RDMA link is now tied to the corresponding namespace and is properly cleaned up when the namespace or link is removed.
This ensures rxe behaves correctly in multi-namespace environments and keeps socket and RDMA link resources consistent across namespace creation and teardown.
--- drivers/infiniband/sw/rxe/rxe.c | 38 +++++++- drivers/infiniband/sw/rxe/rxe_net.c | 145 +++++++++++++++++++++------- drivers/infiniband/sw/rxe/rxe_net.h | 9 +- drivers/infiniband/sw/rxe/rxe_ns.c | 60 ++++++------ drivers/infiniband/sw/rxe/rxe_ns.h | 4 +- 5 files changed, 179 insertions(+), 77 deletions(-)
drivers/infiniband/sw/rxe/rxe.c +33 -5
@@ -8,6 +8,8 @@#include <net/addrconf.h> #include "rxe.h" #include "rxe_loc.h" +#include "rxe_net.h" +#include "rxe_ns.h" MODULE_AUTHOR ("Bob Pearson, Frank Zago, John Groves, Kamal Heib" );MODULE_DESCRIPTION ("Soft RDMA transport" );
@@ -200,6 +202,8 @@ void rxe_set_mtu(struct rxe_dev *rxe, unsigned int ndev_mtu) port->mtu_cap =ib_mtu_enum_to_int (mtu); } +static struct rdma_link_ops rxe_link_ops; +/* called by ifc layer to create new rxe device. * The caller should allocate memory for rxe by calling ib_alloc_device. */
@@ -208,6 +212,7 @@ int rxe_add(struct rxe_dev *rxe, unsigned int mtu, const char *ibdev_name, {rxe_init (rxe, ndev);rxe_set_mtu (rxe, mtu); + rxe->ib_dev.link_ops = &rxe_link_ops;return rxe_register_device (rxe, ibdev_name, ndev); }
@@ -231,6 +236,10 @@ static int rxe_newlink(const char *ibdev_name, struct net_device *ndev) goto err; } + err =rxe_net_init (ndev); +if (err) +return err; + err =rxe_net_add (ibdev_name, ndev);if (err) {rxe_err ("failed to add %s\n" , ndev->name);
@@ -240,9 +249,17 @@ static int rxe_newlink(const char *ibdev_name, struct net_device *ndev)return err; } +static int rxe_dellink (struct ib_device *dev) +{ +rxe_net_del (dev); + +return 0 ; +} +static struct rdma_link_ops rxe_link_ops = { .type ="rxe" , .newlink = rxe_newlink, + .dellink = rxe_dellink, };static int __init rxe_module_init (void )
@@ -253,15 +270,24 @@ static int __init rxe_module_init(void)if (err)return err; - err =rxe_net_init (); -if (err) { -rxe_destroy_wq (); -return err; - } + err =rxe_namespace_init (); +if (err) + goto err_destroy_wq; + + err =rxe_register_notifier (); +if (err) + goto err_namespace_exit;rdma_link_register (&rxe_link_ops); +pr_info ("loaded\n" );return 0 ; + +err_namespace_exit: +rxe_namespace_exit (); +err_destroy_wq: +rxe_destroy_wq (); +return err; } static void __exit rxe_module_exit(void)
@@ -271,6 +297,8 @@ static void __exit rxe_module_exit(void)rxe_net_exit ();rxe_destroy_wq (); +rxe_namespace_exit (); +pr_info ("unloaded\n" ); }
drivers/infiniband/sw/rxe/rxe_net.c +110 -35
269 lines not on this page · raw message
drivers/infiniband/sw/rxe/rxe_net.h +3 -6
@@ -11,14 +11,11 @@#include <net/if_inet6.h> #include <linux/module.h> -struct rxe_recv_sockets { -struct socket *sk4; -struct socket *sk6; -}; -int rxe_net_add (const char *ibdev_name,struct net_device *ndev); +void rxe_net_del (struct ib_device *dev); -int rxe_net_init (void ); +int rxe_register_notifier (void ); +int rxe_net_init (struct net_device *ndev);void rxe_net_exit (void );#endif /* RXE_NET_H */
drivers/infiniband/sw/rxe/rxe_ns.c +31 -29
102 lines not on this page · raw message
drivers/infiniband/sw/rxe/rxe_ns.h +2 -2
@@ -11,7 +11,7 @@ struct sock *rxe_ns_pernet_sk4(struct net *net);struct sock *rxe_ns_pernet_sk6 (struct net *net);void rxe_ns_pernet_set_sk4 (struct net *net,struct sock *sk);void rxe_ns_pernet_set_sk6 (struct net *net,struct sock *sk); -int __init rxe_namespace_init (void ); -void __exit rxe_namespace_exit(void); +int rxe_namespace_init (void ); +void rxe_namespace_exit (void );#endif /* RXE_NS_H */
Signature · 1 line
2.52.0
PATCH v3 4/4 RDMA/rxe: Add testcase for net namespace rxe
In reply to Zhu YanjunAdd 4 testcases for rxe with net namespace.
--- MAINTAINERS | 1 + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/rdma/Makefile | 7 ++ tools/testing/selftests/rdma/config | 3 + tools/testing/selftests/rdma/rxe_ipv6.sh | 47 ++++++++++++++ .../selftests/rdma/rxe_rping_between_netns.sh | 57 +++++++++++++++++ .../selftests/rdma/rxe_socket_with_netns.sh | 64 +++++++++++++++++++ .../rdma/rxe_test_NETDEV_UNREGISTER.sh | 38 +++++++++++ 8 files changed, 218 insertions(+) create mode 100644 tools/testing/selftests/rdma/Makefile create mode 100644 tools/testing/selftests/rdma/config create mode 100755 tools/testing/selftests/rdma/rxe_ipv6.sh create mode 100755 tools/testing/selftests/rdma/rxe_rping_between_netns.sh create mode 100755 tools/testing/selftests/rdma/rxe_socket_with_netns.sh create mode 100755 tools/testing/selftests/rdma/rxe_test_NETDEV_UNREGISTER.sh
MAINTAINERS +1 -0
@@ -24493,6 +24493,7 @@ L: [email protected] S: Supported F: drivers/infiniband/sw/rxe/ F: include/uapi/rdma/rdma_user_rxe.h +F: tools/testing/selftests/rdma/ SOFTLOGIC 6x10 MPEG CODEC M: Bluecherry Maintainers <[email protected]>
tools/testing/selftests/Makefile +1 -0
@@ -94,6 +94,7 @@ TARGETS += proc TARGETS += pstore TARGETS += ptrace TARGETS += openat2 +TARGETS += rdma TARGETS += resctrl TARGETS += riscv TARGETS += rlimits
tools/testing/selftests/rdma/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0 +TEST_PROGS := rxe_rping_between_netns.sh \ + rxe_ipv6.sh \ + rxe_socket_with_netns.sh \ + rxe_test_NETDEV_UNREGISTER.sh + +include ../lib.mk
tools/testing/selftests/rdma/config new file +3 -0
@@ -0,0 +1,3 @@ +CONFIG_TUN +CONFIG_VETH +CONFIG_RDMA_RXE
tools/testing/selftests/rdma/rxe_ipv6.sh new file +47 -0
47 lines not on this page · raw message
tools/testing/selftests/rdma/rxe_rping_between_netns.sh new file +57 -0
57 lines not on this page · raw message
tools/testing/selftests/rdma/rxe_socket_with_netns.sh new file +64 -0
64 lines not on this page · raw message
tools/testing/selftests/rdma/rxe_test_NETDEV_UNREGISTER.sh new file +38 -0
@@ -0,0 +1,38 @@ +#!/bin/sh + +# Notes: +# +# 1. Before running this script, please disable the firewall, as it may +# block UDP port 4791. + +# 2. This test script depends on the veth and tun drivers. Before running +# the script, please verify that both drivers are available by executing: +# +# modinfo tun +# modinfo veth +# +# Make sure these commands return valid module information. + +# Trigger NETDEV_UNREGISTER +exec > /dev/null +ip tuntap add mode tun tun0 +ip -4 a +ip addr add 1.1.1.1/24 dev tun0 +ip link set tun0 up +ip -4 a +rdma link add rxe0 type rxe netdev tun0 +rdma link +ss -lun | grep :4791 + +ip l +ip addr del 1.1.1.1/24 dev tun0 +ip tuntap del mode tun tun0 + +rdma link +if ss -lun | grep :4791; then + echo "error" + exit 1 +fi + +modprobe -v -r tun +modprobe -v -r rdma_rxe
Signature · 1 line
2.52.0
Re: [PATCH v3 4/4] RDMA/rxe: Add testcase for net namespace rxe
Quoted 1 line · Zhu Yanjun
Add 4 testcases for rxe with net namespace.
The selftest result is as below:
"
# make -C tools/testing/selftests/ TARGETS=rdma run_tests
make: Entering directory '/root/Development/linux/tools/testing/selftests'
make[1]: Nothing to be done for 'all'.
TAP version 13
1..4
# timeout set to 45 # selftests: rdma: rxe_rping_between_netns.sh # server DISCONNECT EVENT... # wait for RDMA_READ_ADV state 10 ok 1 selftests: rdma: rxe_rping_between_netns.sh # timeout set to 45 # selftests: rdma: rxe_ipv6.sh ok 2 selftests: rdma: rxe_ipv6.sh # timeout set to 45 # selftests: rdma: rxe_socket_with_netns.sh ok 3 selftests: rdma: rxe_socket_with_netns.sh # timeout set to 45 # selftests: rdma: rxe_test_NETDEV_UNREGISTER.sh ok 4 selftests: rdma: rxe_test_NETDEV_UNREGISTER.sh make: Leaving directory '/root/Development/linux/tools/testing/selftests'
"
Zhu Yanjun
Quoted 295 lines
Signed-off-by Zhu Yanjun <[email protected]>--- MAINTAINERS | 1 + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/rdma/Makefile | 7 ++ tools/testing/selftests/rdma/config | 3 + tools/testing/selftests/rdma/rxe_ipv6.sh | 47 ++++++++++++++ .../selftests/rdma/rxe_rping_between_netns.sh | 57 +++++++++++++++++ .../selftests/rdma/rxe_socket_with_netns.sh | 64 +++++++++++++++++++ .../rdma/rxe_test_NETDEV_UNREGISTER.sh | 38 +++++++++++ 8 files changed, 218 insertions(+)create mode 100644
tools/testing/selftests/rdma/Makefile
create mode 100644tools/testing/selftests/rdma/config
create mode 100755tools/testing/selftests/rdma/rxe_ipv6.shcreate mode 100755tools/testing/selftests/rdma/rxe_rping_between_netns.shcreate mode 100755tools/testing/selftests/rdma/rxe_socket_with_netns.shcreate mode 100755tools/testing/selftests/rdma/rxe_test_NETDEV_UNREGISTER.shMAINTAINERS +1
-0@@ -24493,6 +24493,7 @@ L: [email protected] S: Supported F: drivers/infiniband/sw/rxe/ F: include/uapi/rdma/rdma_user_rxe.h +F: tools/testing/selftests/rdma/ SOFTLOGIC 6x10 MPEG CODEC M: Bluecherry Maintainers <[email protected]>tools/testing/selftests/Makefile +1
-0@@ -94,6 +94,7 @@ TARGETS += proc TARGETS += pstore TARGETS += ptrace TARGETS += openat2 +TARGETS += rdma TARGETS += resctrl TARGETS += riscv TARGETS += rlimitstools/testing/selftests/rdma/Makefile new file +7
-0@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0 +TEST_PROGS := rxe_rping_between_netns.sh \ + rxe_ipv6.sh \ + rxe_socket_with_netns.sh \ + rxe_test_NETDEV_UNREGISTER.sh + +include ../lib.mktools/testing/selftests/rdma/config new file +3
-0@@ -0,0 +1,3 @@ +CONFIG_TUN +CONFIG_VETH +CONFIG_RDMA_RXEtools/testing/selftests/rdma/rxe_ipv6.sh new file +47
-0@@ -0,0 +1,47 @@ +#!/bin/sh + +# Notes: +# +# 1. Before running this script, please disable the firewall, as it may +# block UDP port 4791. + +# 2. This test script depends on the veth and tun drivers. Before running +# the script, please verify that both drivers are available by executing: +# +# modinfo tun +# modinfo veth +# +# Make sure these commands return valid module information. + +# 3. ipv6 test. +# While RXE is conventionally deployed over IPv4, it maintains +# native support for IPv6. However, IPv6 implementations typically +# receive less validation and performance tuning in standard use cases. +exec > /dev/null +# 1) create ipv6 net namespace +ip netns add net6 +ip link add veth0 type veth peer name veth1 +ip link set veth1 netns net6 +ip netns exec net6 ip addr add 2001:db8::1/64 dev veth1 +ip netns exec net6 ip link set veth1 up + +# 2) Add rdma link +ip netns exec net6 rdma link add rxe6 type rxe netdev veth1 + +# 3) check IPv6 UDP 4791 listening port +if ! ip netns exec net6 ss -ul6n | grep :4791; then + echo "Error: udp port 4791 exists" + exit 1 +fi + +# 4) Delete rxe link +ip netns exec net6 rdma link del rxe6 +if ip netns exec net6 ss -ul6n | grep :4791; then # result should be null + echo "Error: udp port 4791 exists" + exit 1 +fi + +# 5) delete net6 +ip netns del net6 + +modprobe -v -r rdma_rxetools/testing/selftests/rdma/rxe_rping_between_netns.sh new file +57
-0@@ -0,0 +1,57 @@ +#!/bin/sh + +# Notes: +# +# 1. Before running this script, please disable the firewall, as it may +# block UDP port 4791. + +# 2. This test script depends on the veth and tun drivers. Before running +# the script, please verify that both drivers are available by executing: +# +# modinfo veth +# +# Make sure these commands return valid module information. + +#1. Check if rping can work or not +exec > /dev/null +ip netns add test1 +ip netns ls +ip link add veth-a type veth peer name veth-b +ip l +ip link set veth-a netns test1 +ip l +ip netns exec test1 ip l set veth-a up +ip netns exec test1 ip addr add 1.1.1.1/24 dev veth-a +ip netns exec test1 ip l +ip netns exec test1 ip -4 a +ip netns exec test1 rdma link add rxe0 type rxe netdev veth-a + +#check if socket exist or not +ip netns exec test1 ss -lun | grep :4791 + +ip netns exec test1 rdma link +ip link set veth-b up +ip addr add 1.1.1.2/24 dev veth-b +ping -c 3 1.1.1.1 || exit 1 +ip netns exec test1 rping -s -a 1.1.1.1& +rdma link add rxe1 type rxe netdev veth-b +rdma link + +#check if socket exist or not +ss -lun | grep :4791 + +rping -c -a 1.1.1.1 -d -v -C 3 || exit 1 +ip netns ls +rdma link del rxe1 + +#check if socket exist or not +ss -lun | grep :4791 + +ip netns exec test1 ss -lun | grep :4791 +ip netns exec test1 rdma link del rxe0 +ip netns exec test1 ss -lun | grep :4791 +ip netns del test1 +ip netns ls + +modprobe -v -r veth +modprobe -v -r rdma_rxetools/testing/selftests/rdma/rxe_socket_with_netns.sh new file +64
-0@@ -0,0 +1,64 @@ +#!/bin/sh + +# Notes: +# +# 1. Before running this script, please disable the firewall, as it may +# block UDP port 4791. + +# 2. This test script depends on the veth and tun drivers. Before running +# the script, please verify that both drivers are available by executing: +# +# modinfo tun +# +# Make sure these commands return valid module information. + +# Check if socket exist or not +exec > /dev/null +ip tuntap add mode tun tun0 +ip -4 a +ip addr add 1.1.1.1/24 dev tun0 +ip link set tun0 up +ip -4 a +rdma link add rxe0 type rxe netdev tun0 +rdma link +ret=`ss -lun | grep :4791` +if [ X"$ret" == X"" ]; then + echo "Error: udp port 4791 does not exist" + exit 1 +fi + +ip tuntap add mode tun tun1 +ip -4 a +ip addr add 2.2.2.2/24 dev tun1 +ip link set tun1 up +rdma link add rxe1 type rxe netdev tun1 +rdma link +ret=`ss -lun | grep :4791` +if [ X"$ret" == X"" ]; then + echo "Error: udp port 4791 does not exist" + exit 1 +fi + +rdma link del rxe1 +rdma link +ret=`ss -lun | grep :4791` +if [ X"$ret" == X"" ]; then + echo "Error: udp port 4791 doese not exist" + exit 1 +fi + +rdma link del rxe0 +rdma link +if ss -lun | grep :4791; then + echo "Error: udp port 4791 exists" + exit 1 +fi + +ip addr del 2.2.2.2/24 dev tun1 +ip tuntap del mode tun tun1 + +ip addr del 1.1.1.1/24 dev tun0 +ip tuntap del mode tun tun0 + +modprobe -v -r tun +modprobe -v -r rdma_rxetools/testing/selftests/rdma/rxe_test_NETDEV_UNREGISTER.sh new file +38
-0@@ -0,0 +1,38 @@ +#!/bin/sh + +# Notes: +# +# 1. Before running this script, please disable the firewall, as it may +# block UDP port 4791. + +# 2. This test script depends on the veth and tun drivers. Before running +# the script, please verify that both drivers are available by executing: +# +# modinfo tun +# modinfo veth +# +# Make sure these commands return valid module information. + +# Trigger NETDEV_UNREGISTER +exec > /dev/null +ip tuntap add mode tun tun0 +ip -4 a +ip addr add 1.1.1.1/24 dev tun0 +ip link set tun0 up +ip -4 a +rdma link add rxe0 type rxe netdev tun0 +rdma link +ss -lun | grep :4791 + +ip l +ip addr del 1.1.1.1/24 dev tun0 +ip tuntap del mode tun tun0 + +rdma link +if ss -lun | grep :4791; then + echo "error" + exit 1 +fi + +modprobe -v -r tun +modprobe -v -r rdma_rxe
Signature · 2 lines
Best Regards, Yanjun.Zhu
Re: [PATCH v3 2/4] RDMA/rxe: Add net namespace support for IPv4/IPv6 sockets
In reply to Zhu YanjunQuoted 4 lines · Zhu Yanjun
drivers/infiniband/sw/rxe/rxe_ns.c new file +4
-0+/* +* Called for every existing and added network namespaces +*/ +static int __net_init rxe_ns_init (struct net *net)
drivers/infiniband/sw/rxe/rxe_ns.c line 43
Quoted 10 lines
drivers/infiniband/sw/rxe/rxe_ns.c new file +10
-0+{ +/* +* create (if not present) and access data item in network namespace +* (net) using the id (net_id) +*/ +struct rxe_ns_sock *ns_sk =net_generic (net, rxe_pernet_id); + +rcu_assign_pointer (ns_sk->rxe_sk4,NULL );/* initialize sock 4 socket */ +rcu_assign_pointer (ns_sk->rxe_sk6,NULL );/* initialize sock 6 socket */ +synchronize_rcu ();
As I stated in the last review, this is init is not needded. drop it.
See the net/core/net_namespace.c:
static int ops_init(const struct pernet_operations *ops, struct net *net)
{
struct net_generic *ng;
int err = -ENOMEM;
void *data = NULL;
if (ops->id) {
data = kzalloc(ops->size, GFP_KERNEL);
if (!data)
goto out;
err = net_assign_generic(net, *ops->id, data);
if (err)
goto cleanup;
}from there the request is to add a comment about deferred socket created to explain why _init and _exit are assymetrical.
drivers/infiniband/sw/rxe/rxe_ns.c line 55
Quoted 12 lines
drivers/infiniband/sw/rxe/rxe_ns.c new file +12
-0+ +return 0 ; +} + +static void __net_exit rxe_ns_exit(struct net *net) +{ +/* +* called when the network namespace is removed +*/ +struct rxe_ns_sock *ns_sk =net_generic (net, rxe_pernet_id); +struct sock *rxe_sk4 =NULL ; +struct sock *rxe_sk6 =NULL ;
again, init is not needed. They are set below before use.
I am beginning to think you dropped my review comments from the last round ....
drivers/infiniband/sw/rxe/rxe_ns.c line 66
Quoted 11 lines
drivers/infiniband/sw/rxe/rxe_ns.c new file +11
-0+ +rcu_read_lock (); + rxe_sk4 =rcu_dereference (ns_sk->rxe_sk4); + rxe_sk6 =rcu_dereference (ns_sk->rxe_sk6); +rcu_read_unlock (); + +/* close socket */ +if (rxe_sk4 && rxe_sk4->sk_socket) { +udp_tunnel_sock_release (rxe_sk4->sk_socket); +rcu_assign_pointer (ns_sk->rxe_sk4,NULL ); +synchronize_rcu ();
yea, I commented on this too.
I am not wasting any more time on this version. Either address my comments from v1 or explain why you should not in that email.
Re: [PATCH v3 2/4] RDMA/rxe: Add net namespace support for IPv4/IPv6 sockets
Quoted 68 lines · David Ahern
Quoted 4 lines · Zhu Yanjun
drivers/infiniband/sw/rxe/rxe_ns.c new file +4
-0+/* +* Called for every existing and added network namespaces +*/ +static int __net_init rxe_ns_init (struct net *net)drivers/infiniband/sw/rxe/rxe_ns.c line 43
Quoted 10 lines
drivers/infiniband/sw/rxe/rxe_ns.c new file +10
-0+{ +/* +* create (if not present) and access data item in network namespace +* (net) using the id (net_id) +*/ +struct rxe_ns_sock *ns_sk =net_generic (net, rxe_pernet_id); + +rcu_assign_pointer (ns_sk->rxe_sk4,NULL );/* initialize sock 4 socket */ +rcu_assign_pointer (ns_sk->rxe_sk6,NULL );/* initialize sock 6 socket */ +synchronize_rcu ();As I stated in the last review, this is init is not needded. drop it.
See the
net/core/net_namespace.c:static int
ops_init(const struct pernet_operations *ops, struct net *net){ struct net_generic *ng; int err = -ENOMEM; void *data = NULL; if (ops->id) { data = kzalloc(ops->size, GFP_KERNEL); if (!data) goto out; err = net_assign_generic(net, *ops->id, data); if (err) goto cleanup; }from there the request is to add a comment about deferred socket created to explain why
_initand_exitare assymetrical.drivers/infiniband/sw/rxe/rxe_ns.c line 55
Quoted 12 lines
drivers/infiniband/sw/rxe/rxe_ns.c new file +12
-0+ +return 0 ; +} + +static void __net_exit rxe_ns_exit(struct net *net) +{ +/* +* called when the network namespace is removed +*/ +struct rxe_ns_sock *ns_sk =net_generic (net, rxe_pernet_id); +struct sock *rxe_sk4 =NULL ; +struct sock *rxe_sk6 =NULL ;again, init is not needed. They are set below before use.
I am beginning to think you dropped my review comments from the last round ....
drivers/infiniband/sw/rxe/rxe_ns.c line 66
Quoted 11 lines
drivers/infiniband/sw/rxe/rxe_ns.c new file +11
-0+ +rcu_read_lock (); + rxe_sk4 =rcu_dereference (ns_sk->rxe_sk4); + rxe_sk6 =rcu_dereference (ns_sk->rxe_sk6); +rcu_read_unlock (); + +/* close socket */ +if (rxe_sk4 && rxe_sk4->sk_socket) { +udp_tunnel_sock_release (rxe_sk4->sk_socket); +rcu_assign_pointer (ns_sk->rxe_sk4,NULL ); +synchronize_rcu ();yea, I commented on this too.
Quoted 2 lines
I am not wasting any more time on this version. Either address my comments from v1 or explain why you should not in that email.
Hi, David
All the above changes are included in "[PATCH v3 3/4] RDMA/rxe: Support RDMA link creation and destruction per net namespace".
Please let me know if you have any further comments on "[PATCH v3 3/4] RDMA/rxe: Support RDMA link creation and destruction per net namespace".
If there are no additional comments, I plan to move these changes into "[PATCH v3 2/4] RDMA/rxe: Add net namespace support for IPv4/IPv6 sockets" and send out a new version of the patch series.
Thanks a lot.
Zhu Yanjun
Signature · 2 lines
Best Regards, Yanjun.Zhu