libnetutils/packet.c - fix a raw socket reception race
A socket created bound to a specific protocol can receive packets before it's bound to a specific interface/mac. It's best to rely on the bind(). This replicates the way packet sockets are created in external/android-clat. See: ring.c ring_create() and clatd.c configure_packet_socket() Test: builds, atest Bug: 155297277 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I569d2b81a396f352ab5d1b71bd5ad0d96217aab1
This commit is contained in:
parent
b7f370c014
commit
0129aaae86
1 changed files with 1 additions and 1 deletions
|
@ -40,7 +40,7 @@
|
|||
int fatal(const char*);
|
||||
|
||||
int open_raw_socket(const char* ifname __unused, uint8_t hwaddr[ETH_ALEN], int if_index) {
|
||||
int s = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP));
|
||||
int s = socket(PF_PACKET, SOCK_DGRAM, 0);
|
||||
if (s < 0) return fatal("socket(PF_PACKET)");
|
||||
|
||||
struct sockaddr_ll bindaddr = {
|
||||
|
|
Loading…
Reference in a new issue