summaryrefslogtreecommitdiff
path: root/src/netlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/netlink.c')
-rw-r--r--src/netlink.c34
1 files changed, 14 insertions, 20 deletions
diff --git a/src/netlink.c b/src/netlink.c
index 101f2d3..3157f03 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -29,9 +29,9 @@
static struct iovec iov;
static void nl_err(struct nlmsghdr *h);
-static void nl_routechange(struct daemon *daemon, struct nlmsghdr *h);
+static void nl_routechange(struct nlmsghdr *h);
-void netlink_init(struct daemon *daemon)
+void netlink_init(void)
{
struct sockaddr_nl addr;
@@ -56,19 +56,13 @@ void netlink_init(struct daemon *daemon)
}
if (daemon->netlinkfd == -1)
- die(_("cannot create netlink socket: %s"), NULL);
- else
- {
- int flags = fcntl(daemon->netlinkfd, F_GETFD);
- if (flags != -1)
- fcntl(daemon->netlinkfd, F_SETFD, flags | FD_CLOEXEC);
- }
-
+ die(_("cannot create netlink socket: %s"), NULL, EC_MISC);
+
iov.iov_len = 200;
iov.iov_base = safe_malloc(iov.iov_len);
}
-static ssize_t netlink_recv(struct daemon *daemon)
+static ssize_t netlink_recv(void)
{
struct msghdr msg;
ssize_t rc;
@@ -107,7 +101,7 @@ static ssize_t netlink_recv(struct daemon *daemon)
return rc;
}
-int iface_enumerate(struct daemon *daemon, void *parm, int (*ipv4_callback)(), int (*ipv6_callback)())
+int iface_enumerate(void *parm, int (*ipv4_callback)(), int (*ipv6_callback)())
{
struct sockaddr_nl addr;
struct nlmsghdr *h;
@@ -142,14 +136,14 @@ int iface_enumerate(struct daemon *daemon, void *parm, int (*ipv4_callback)(), i
while (1)
{
- if ((len = netlink_recv(daemon)) == -1)
+ if ((len = netlink_recv()) == -1)
return 0;
for (h = (struct nlmsghdr *)iov.iov_base; NLMSG_OK(h, (size_t)len); h = NLMSG_NEXT(h, len))
if (h->nlmsg_type == NLMSG_ERROR)
nl_err(h);
else if (h->nlmsg_seq != seq)
- nl_routechange(daemon, h); /* May be multicast arriving async */
+ nl_routechange(h); /* May be multicast arriving async */
else if (h->nlmsg_type == NLMSG_DONE)
{
#ifdef HAVE_IPV6
@@ -186,7 +180,7 @@ int iface_enumerate(struct daemon *daemon, void *parm, int (*ipv4_callback)(), i
}
if (addr.s_addr && ipv4_callback)
- if (!((*ipv4_callback)(daemon, addr, ifa->ifa_index, netmask, broadcast, parm)))
+ if (!((*ipv4_callback)(addr, ifa->ifa_index, netmask, broadcast, parm)))
return 0;
}
#ifdef HAVE_IPV6
@@ -202,7 +196,7 @@ int iface_enumerate(struct daemon *daemon, void *parm, int (*ipv4_callback)(), i
}
if (addrp && ipv6_callback)
- if (!((*ipv6_callback)(daemon, addrp, ifa->ifa_index, ifa->ifa_index, parm)))
+ if (!((*ipv6_callback)(addrp, ifa->ifa_index, ifa->ifa_index, parm)))
return 0;
}
#endif
@@ -210,18 +204,18 @@ int iface_enumerate(struct daemon *daemon, void *parm, int (*ipv4_callback)(), i
}
}
-void netlink_multicast(struct daemon *daemon)
+void netlink_multicast(void)
{
ssize_t len;
struct nlmsghdr *h;
- if ((len = netlink_recv(daemon)) != -1)
+ if ((len = netlink_recv()) != -1)
{
for (h = (struct nlmsghdr *)iov.iov_base; NLMSG_OK(h, (size_t)len); h = NLMSG_NEXT(h, len))
if (h->nlmsg_type == NLMSG_ERROR)
nl_err(h);
else
- nl_routechange(daemon, h);
+ nl_routechange(h);
}
}
@@ -237,7 +231,7 @@ static void nl_err(struct nlmsghdr *h)
This helps on DoD links, where frequently the packet which triggers dialling is
a DNS query, which then gets lost. By re-sending, we can avoid the lookup
failing. */
-static void nl_routechange(struct daemon *daemon, struct nlmsghdr *h)
+static void nl_routechange(struct nlmsghdr *h)
{
if (h->nlmsg_type == RTM_NEWROUTE && daemon->srv_save)
{