Created on 2016-10-27 18:14 by mturon, last changed 2016-10-28 07:06 by mturon. This issue is now closed.
Messages (3) | |||
---|---|---|---|
msg279558 - (view) | Author: Martin Turon (mturon) | Date: 2016-10-27 18:14 | |
When binding to AF_PACKET linux kernel sockets, the interface name is not passed in when given -- it is always "". This causes problems, for example, receiving packets to a "monitor0" interface doesn't work. diff -r a6548e230ed6 Modules/socketmodule.c --- a/Modules/socketmodule.c Thu Oct 27 19:33:22 2016 +0300 +++ b/Modules/socketmodule.c Thu Oct 27 11:13:12 2016 -0700 @@ -1344,6 +1344,7 @@ { struct sockaddr_ll *a = (struct sockaddr_ll *)addr; char *ifname = ""; + // ^^ ifname should be set to interface name passed in via sockaddr. struct ifreq ifr; /* need to look up interface name give index */ if (a->sll_ifindex) { |
|||
msg279562 - (view) | Author: Martin Turon (mturon) | Date: 2016-10-27 18:43 | |
Just for clarity, the high level bug is that when binding to an interface using AF_PACKET, transmissions work, but receive does not: sock = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, ETH_P_IEEE802154) sock.bind(("monitor0", ETH_P_IEEE802154)) sock.send(test_frame) # transmission works fine pkt = sock.recv(127) # never receives, though C test works fine The same test written in C that calls ioctl(sockfd, SIOCGIFNAME, &ifr) to lookup ifindex for bind from ifname="monitor0" works fine. |
|||
msg279587 - (view) | Author: Martin Turon (mturon) | Date: 2016-10-28 07:06 | |
If I bind to port 0, it works for both tx and rx. Sorry for the false alarm! sock.bind(("monitor0", 0)) |
History | |||
---|---|---|---|
Date | User | Action | Args |
2016-10-28 07:06:10 | mturon | set | status: open -> closed messages: + msg279587 |
2016-10-27 18:43:42 | mturon | set | messages: + msg279562 |
2016-10-27 18:14:58 | mturon | create |