aboutsummaryrefslogtreecommitdiff
path: root/pcap-linux.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2017-01-10 10:24:49 -0800
committerGuy Harris <guy@alum.mit.edu>2017-01-10 10:24:49 -0800
commit791213ea55023eff575a1014fbd9698006550a63 (patch)
treef0803c39045d868d862b4320ddea4b5d3e1996c9 /pcap-linux.c
parentd95ba074255aa9cd997d053517366db25549dad3 (diff)
Ignore ENOENT in reset_kernel_filter().
It means "there was no filter on the socket"; as the goal of this routine is to remove whatever filter is on the socket, it means that the goal has been achieved by virtue of there not having been a filter there in the first place, so just return 0, meaning "success". See GitHub issue #549.
Diffstat (limited to 'pcap-linux.c')
-rw-r--r--pcap-linux.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/pcap-linux.c b/pcap-linux.c
index 6b56d58c..4b1dc75e 100644
--- a/pcap-linux.c
+++ b/pcap-linux.c
@@ -6866,6 +6866,7 @@ set_kernel_filter(pcap_t *handle, struct sock_fprog *fcode)
static int
reset_kernel_filter(pcap_t *handle)
{
+ int ret;
/*
* setsockopt() barfs unless it get a dummy parameter.
* valgrind whines unless the value is initialized,
@@ -6874,7 +6875,14 @@ reset_kernel_filter(pcap_t *handle)
*/
int dummy = 0;
- return setsockopt(handle->fd, SOL_SOCKET, SO_DETACH_FILTER,
+ ret = setsockopt(handle->fd, SOL_SOCKET, SO_DETACH_FILTER,
&dummy, sizeof(dummy));
+ /*
+ * Ignore ENOENT - it means "we don't have a filter", so there
+ * was no filter to remove, and there's still no filter.
+ */
+ if (ret == -1 && errno != ENOENT)
+ return -1;
+ return 0;
}
#endif