summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--igmp.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/igmp.c b/igmp.c
index 1c44769..14ba516 100644
--- a/igmp.c
+++ b/igmp.c
@@ -8,6 +8,7 @@
#include <linux/bpf.h>
#include <linux/filter.h>
#include <arpa/inet.h>
+#include <errno.h>
/* Remove later */
#include <time.h>
@@ -488,6 +489,7 @@ igmp_init(struct cfg *cfg)
};
struct igmp *igmp;
int sfd;
+ int opt;
igmp = zmalloc(sizeof(*igmp));
if (!igmp)
@@ -499,14 +501,18 @@ igmp_init(struct cfg *cfg)
*/
sfd = socket(AF_PACKET, SOCK_DGRAM | SOCK_CLOEXEC, htons(ETH_P_ALL));
if (sfd < 0) {
- perror("igmp socket");
+ if (errno == EACCES)
+ verbose("igmp socket: permission denied\n");
+ else
+ error("igmp socket: %m");
goto out_free;
}
- if (setsockopt(sfd, SOL_SOCKET, SO_ATTACH_FILTER, &fprog, sizeof(fprog)) < 0) {
- error("igmp setsockopt: %m");
- goto out_fd;
- }
+ if (setsockopt(sfd, SOL_SOCKET, SO_ATTACH_FILTER, &fprog, sizeof(fprog)) < 0)
+ perrordie("igmp setsockopt(SO_ATTACH_FILTER): %m");
+
+ if (setsockopt(sfd, SOL_SOCKET, SO_LOCK_FILTER, &opt, sizeof(opt)) < 0)
+ perrordie("igmp setsockopt(SO_LOCK_FILTER): %m");
/*
struct ifreq ifreq = {