-
Notifications
You must be signed in to change notification settings - Fork 892
monitor-less 802.11 interfaces now fail with an SIOCGIFINDEX error message #1508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Ok, I will try to take a look. |
Thank you. Additional information: for non-802.11 interfaces an attempt to enable wireless monitor mode still returns the correct error message. RPI4B can be used to reproduce the problem too. |
to try to get the interface index of the specified device. Does that succeed or does it fail? |
Unfortunately I don't have any devices that have the unexpected behavior. I can push a WIP branch that can add some debugging, if you can take a look. |
Ping the-tcpdump-group#1508 Signed-off-by: John Thacker <[email protected]>
If you build libpcap with that commit and link with tcpdump, this is the result I get with an interface that does support monitor mode (with some of the payload bytes omitted):
|
( |
Remote access to a test system would be helpful, I think, as I haven't been able to replicate the issue. |
Done. Guy, I have another spare device that you could use for tests if you need. |
OK, I logged in, and I noticed a strange thing. We are sending a nl80211 single message (not a multipart number), so there should be a single response. However, if I try to read all the messages from the socket, the successful reply is followed by a extra netlink message of type "ERROR", reporting error code 0, for success, which I don't see on my system:
The netlink kernel documentation claims: "Note that unless the NLM_F_ACK flag is set on the request Netlink will not respond with NLMSG_ERROR if there is no error. To avoid having to special-case this quirk it is recommended to always set NLM_F_ACK." So, obviously that "quirk" is not happening on the RPi (but is on my box), but then again the solution presents itself: set NLM_F_ACK on the request and look for it regardless. |
Thank you for looking. Does your hardware respond the same way to |
My hardware works. In any case, some more looking suggests that perhaps despite the above comment, Auto-Ack tends to be set on sockets by default, making the flag unnecessary. Adding a line to wait for the ack seems to fix it on the RPi and still works on my box, so I'll do that. |
The Linux kernel documentation for Netlink says: "Note that unless the NLM_F_ACK flag is set on the request Netlink will not respond with NLMSG_ERROR if there is no error. To avoid having to special-case this quirk it is recommended to always set NLM_F_ACK." (https://docs.kernel.org/userspace-api/netlink/intro.html#nl-msg-type) Some drivers, e.g. the built in interface on a Raspberry Pi on a recent Debian build, appear to send a NLMSG_ERROR with an error code of 0 (Success) regardless, however. Perhaps this is to avoid having to special-case whether to expect an ACK. Regardless, follow instructions and always set NLM_F_ACK, and receive messages until we get the ACK, to avoid having to special-case failure and deal with drivers that don't have the "quirk." Fix the-tcpdump-group#1508 Signed-off-by: John Thacker <[email protected]>
The Linux kernel documentation for Netlink says: "Note that unless the NLM_F_ACK flag is set on the request Netlink will not respond with NLMSG_ERROR if there is no error. To avoid having to special-case this quirk it is recommended to always set NLM_F_ACK." (https://docs.kernel.org/userspace-api/netlink/intro.html#nl-msg-type) In other places, it suggests that sockets do have Auto-ACK enabled by default, however. Regardless, follow instructions and always set NLM_F_ACK, and receive messages until we get the ACK. Fix the-tcpdump-group#1508 Signed-off-by: John Thacker <[email protected]>
Thank you. I have not worked with netlink for many years, but I can run a few additional tests tomorrow to see if everything works as expected. |
Got a bit delayed by various stuff, but I am getting there. |
The Linux kernel documentation for Netlink says: "Note that unless the NLM_F_ACK flag is set on the request Netlink will not respond with NLMSG_ERROR if there is no error. To avoid having to special-case this quirk it is recommended to always set NLM_F_ACK." (https://docs.kernel.org/userspace-api/netlink/intro.html#nl-msg-type) In other places, it suggests that sockets do have Auto-ACK enabled by default, however, which does seem to be the case (and we currently don't set it elsewhere in the code.) Receive messages until we get the ACK. Fix the-tcpdump-group#1508 Signed-off-by: John Thacker <[email protected]>
Cherry-picked. |
This is a regression after pull request #1362. @johnthacker, please review if you can. libpcap since commit 0ac887b returns a cryptic error if the 802.11 interface does not support monitor mode. Steps to reproduce:
libnl-genl-3-dev
and build tcpdump/libpcap from the current master branches.The immediate reason why the message is different is because given two interfaces (one without monitor mode support and one with), the code paths begin in
pcap_activate_linux()
and remain identical until the "Now configure the monitor interface up." block inenter_rfmon_mode()
, there theioctl(sock_fd, SIOCGIFFLAGS, &ifr)
call fails ifmon0
does not exist, in this casepcapint_fmt_errmsg_for_errno()
sets the error message, thendel_mon_if()
invokesiface_get_id()
, which attemptsioctl(fd, SIOCGIFINDEX, &ifr)
, which fails and overwrites the error message with what the user is seeing.The root cause seems to be elsewhere because the monitor-less code path should not have reached that block and the clean-up of non-existent monitor interface should not be necessary in the first place. It seems wrong that the
add_mon_if()
call just before reports success in both cases. In both casesret == 1
andtype == NL80211_IFTYPE_STATION
after the call toget_if_type()
. Commenting the call toget_if_type()
and instead setting the two variables directly (which is almost the same as reverting the commit in question) causesadd_mon_if()
to fail with the correct error message. So it seems thatget_if_type()
does not communicate with the netlink socket correctly and leaves it in a state that causes the failure to fail inadd_mon_if()
.The text was updated successfully, but these errors were encountered: