From 933ac55cce10686552ec451514eb5c2473d076c3 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sat, 9 Aug 2014 12:32:55 -0700 Subject: [PATCH] monitor: Try to enable PACKET_MR_ALLMULTI on netlink monitor device --- monitor/nlmon.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/monitor/nlmon.c b/monitor/nlmon.c index 55e9f287..9350a3a4 100644 --- a/monitor/nlmon.c +++ b/monitor/nlmon.c @@ -1144,6 +1144,7 @@ static struct l_io *open_packet(const char *name) { struct l_io *io; struct sockaddr_ll sll; + struct packet_mreq mr; struct ifreq ifr; int fd; @@ -1172,6 +1173,19 @@ static struct l_io *open_packet(const char *name) return NULL; } + memset(&mr, 0, sizeof(mr)); + mr.mr_ifindex = ifr.ifr_ifindex; + mr.mr_type = PACKET_MR_ALLMULTI; + + if (setsockopt(fd, SOL_PACKET, PACKET_ADD_MEMBERSHIP, + &mr, sizeof(mr) < 0)) { + perror("Failed to enable all multicast"); + if (errno != EINVAL) { + close(fd); + return NULL; + } + } + io = l_io_new(fd); l_io_set_close_on_destroy(io, true);