summaryrefslogtreecommitdiff
path: root/src/netlink.c
diff options
context:
space:
mode:
authorSimon Kelley <simon@thekelleys.org.uk>2020-03-19 21:56:45 +0000
committerSimon Kelley <simon@thekelleys.org.uk>2020-03-19 21:56:45 +0000
commit0506a5ed4e56863627c54aedad30ad61221292ef (patch)
tree3984978364641b09b44158f294a82e96e0386ede /src/netlink.c
parente7ee1aa0937d99b0a5942050b85708eb165e4704 (diff)
downloaddnsmasq-0506a5ed4e56863627c54aedad30ad61221292ef.tar.gz
Handle old kernels that don't do NETLINK_NO_ENOBUFS.
Deal with both old kernel header files that don't define it, and old kernels that don't implement it. Also generalise Linux kernel version handling.
Diffstat (limited to 'src/netlink.c')
-rw-r--r--src/netlink.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/netlink.c b/src/netlink.c
index a1ca5d1..3af54c4 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -27,6 +27,9 @@
#define SOL_NETLINK 270
#endif
+#ifndef NETLINK_NO_ENOBUFS
+#define NETLINK_NO_ENOBUFS 5
+#endif
/* linux 2.6.19 buggers up the headers, patch it up here. */
#ifndef IFA_RTA
@@ -79,10 +82,11 @@ void netlink_init(void)
}
if (daemon->netlinkfd == -1 ||
- setsockopt(daemon->netlinkfd, SOL_NETLINK, NETLINK_NO_ENOBUFS, &opt, sizeof(opt)) == -1 ||
+ (daemon->kernel_version >= KERNEL_VERSION(2,6,30) &&
+ setsockopt(daemon->netlinkfd, SOL_NETLINK, NETLINK_NO_ENOBUFS, &opt, sizeof(opt)) == -1) ||
getsockname(daemon->netlinkfd, (struct sockaddr *)&addr, &slen) == -1)
die(_("cannot create netlink socket: %s"), NULL, EC_MISC);
-
+
/* save pid assigned by bind() and retrieved by getsockname() */
netlink_pid = addr.nl_pid;