host-device cannot use linux wireless devices
rfenlon opened this issue · comments
When configured to use a wireless device (e.g. wlo1) host-device fails to change the network namespace with an invalid argument
response (see netlink/link_linux.go:922). Consider conditionally doing the equivalent of iw phy <my-phy> set netns name <my-namespace>
when it's a wireless device.
I dug into this a little bit and found that the linux vendor dependency github.com/vishvananda/netlink does not support sending nl80211 messages to netlink. Here is an example of a working netlink request message to change the namespace of a phy using file descriptor for the new network namespace :
-------------------------- BEGIN NETLINK MESSAGE ---------------------------
[NETLINK HEADER] 16 octets
.nlmsg_len = 36
.type = 32 <0x20>
.flags = 5 <REQUEST,ACK>
.seq = 1697642139
.port = -2016371064
[GENERIC NETLINK HEADER] 4 octets
.cmd = 49 <NL80211_CMD_SET_WIPHY_NETNS>
.version = 0
.unused = 0
[PAYLOAD] 16 octets
08 00 01 00 01 00 00 00 08 00 db 00 04 00 00 00 ................ <NL80211_ATTR_WIPHY 0x01> and <NL80211_ATTR_NETNS_FD 0xdb>
--------------------------- END NETLINK MESSAGE ---------------------------
I'm not a kernel developer so I'm having trouble finding the following:
- netlink header type = 32 // unknown what Generic Netlink Family ID is tied to 32
- payload // I know 2 octets = NL80211_ATTR_WIPHY, 4 octets = device index, 2 octets = NL80211_ATTR_NETNS_FD, 4 octets = file descriptor. I don't know what the remaining 4 octets are doing.