aboutsummaryrefslogtreecommitdiff
path: root/pcap-linux.c
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2022-02-04 15:30:28 -0800
committerGuy Harris <gharris@sonic.net>2022-02-04 15:30:28 -0800
commit3eca6924ac341cfe9222f547b253364995a3f3ea (patch)
treec3e8093e268d2f6fc6bded172aca6b5799391a71 /pcap-linux.c
parent9d928eb03f158ea93e6236592509bfa2885b9684 (diff)
linux: print a better message for "out of memory" errors for kernel filters.
If attempting to set a kernel filter gets ENOMEM, print a message suggesting that they increase the value of the net.core.optmem_max sysctl. See GitHub issue #1089 for an example of a complicated but not too complicated filter that exceeds the default "other/option memory per socket" maximum.
Diffstat (limited to 'pcap-linux.c')
-rw-r--r--pcap-linux.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/pcap-linux.c b/pcap-linux.c
index bd8f2b24..13851322 100644
--- a/pcap-linux.c
+++ b/pcap-linux.c
@@ -4410,7 +4410,18 @@ pcap_setfilter_linux(pcap_t *handle, struct bpf_program *filter)
* the filter for a reason other than "this kernel
* isn't configured to support socket filters.
*/
- if (errno != ENOPROTOOPT && errno != EOPNOTSUPP) {
+ if (errno == ENOMEM) {
+ /*
+ * Either a kernel memory allocation
+ * failure occurred, or there's too
+ * much "other/option memory" allocated
+ * for this socket. Suggest that they
+ * increase the "other/option memory"
+ * limit.
+ */
+ fprintf(stderr,
+ "Warning: Couldn't allocate kernel memory for filter: try increasing net.core.optmem_max with sysctl\n");
+ } else if (errno != ENOPROTOOPT && errno != EOPNOTSUPP) {
fprintf(stderr,
"Warning: Kernel filter failed: %s\n",
pcap_strerror(errno));