[issue28545] socket.bind to AF_PACKET should use passed interface name
Martin Turon added the comment: If I bind to port 0, it works for both tx and rx. Sorry for the false alarm! sock.bind(("monitor0", 0)) -- status: open -> closed ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28545> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28545] socket.bind to AF_PACKET should use passed interface name
Martin Turon added the comment: 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, ) to lookup ifindex for bind from ifname="monitor0" works fine. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28545> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28545] socket.bind to AF_PACKET should use passed interface name
New submission from Martin Turon: 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.cThu Oct 27 19:33:22 2016 +0300 +++ b/Modules/socketmodule.cThu 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) { -- messages: 279558 nosy: mturon priority: normal severity: normal status: open title: socket.bind to AF_PACKET should use passed interface name ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28545> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com