Closed champtar closed 1 month ago
We can actually do the move + rename in 1 call, with the interface being up before the call
# ip link show eno4
71: eno4: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
link/ether e4:43:4b:c0:d0:d3 brd ff:ff:ff:ff:ff:ff
altname enp24s0f3
# ip netns add testns
# strace -f -yy -v -s1000 ip link set netns testns name testintf dev eno4
sendmsg(3<NETLINK:[ROUTE:303456]>, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base=[{nlmsg_len=56, nlmsg_type=RTM_NEWLINK, nlmsg_flags=NLM_F_REQUEST|NLM_F_ACK, nlmsg_seq=1723584129, nlmsg_pid=0}, {ifi_family=AF_UNSPEC, ifi_type=ARPHRD_NETROM, ifi_index=if_nametoindex("eno4"), ifi_flags=0, ifi_change=0}, [[{nla_len=8, nla_type=IFLA_NET_NS_FD}, 4</run/netns/testns>], [{nla_len=13, nla_type=IFLA_IFNAME}, "testintf"]]], iov_len=56}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 56
# ip -n testns link
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
71: testintf: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether e4:43:4b:c0:d0:d3 brd ff:ff:ff:ff:ff:ff
altname enp24s0f3
This is on RHEL 9.4, trying to find out when it was introduced
Live rename is allowed since https://github.com/torvalds/linux/commit/bd039b5ea2a91ea707ee8539df26456bd5be80af (and for some devices since https://github.com/torvalds/linux/commit/8065a779f17e94536a1c4dcee4f9d88011672f97)
Since https://github.com/containernetworking/plugins/pull/1002 the host-device plugin renames the interface before moving it.
This doesn't play too well with udev and NetworkManager, see https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1599
Would it be possible to use a temporary netns, ie move to a temp netns, rename, move to the dest ns ? @adrianchiris FYI