kernel-netlink: Use recv() instead of recvfrom()
authorMartin Willi <martin@revosec.ch>
Wed, 9 Jul 2014 14:04:16 +0000 (16:04 +0200)
committerMartin Willi <martin@revosec.ch>
Wed, 24 Sep 2014 09:19:59 +0000 (11:19 +0200)
As we are not interested in the returned address, there is really no need
in passing that argument.

src/libhydra/plugins/kernel_netlink/kernel_netlink_shared.c

index 30d5aaa..4274991 100644 (file)
@@ -65,7 +65,7 @@ METHOD(netlink_socket_t, netlink_send, status_t,
        private_netlink_socket_t *this, struct nlmsghdr *in, struct nlmsghdr **out,
        size_t *out_len)
 {
-       int len, addr_len;
+       int len;
        struct sockaddr_nl addr;
        chunk_t result = chunk_empty, tmp;
        struct nlmsghdr *msg, peek;
@@ -113,14 +113,7 @@ METHOD(netlink_socket_t, netlink_send, status_t,
                tmp.ptr = buf;
                msg = (struct nlmsghdr*)tmp.ptr;
 
-               memset(&addr, 0, sizeof(addr));
-               addr.nl_family = AF_NETLINK;
-               addr.nl_pid = getpid();
-               addr.nl_groups = 0;
-               addr_len = sizeof(addr);
-
-               len = recvfrom(this->socket, tmp.ptr, tmp.len, 0,
-                                          (struct sockaddr*)&addr, &addr_len);
+               len = recv(this->socket, tmp.ptr, tmp.len, 0);
 
                if (len < 0)
                {
@@ -161,8 +154,7 @@ METHOD(netlink_socket_t, netlink_send, status_t,
 
                /* NLM_F_MULTI flag does not seem to be set correctly, we use sequence
                 * numbers to detect multi header messages */
-               len = recvfrom(this->socket, &peek, sizeof(peek), MSG_PEEK | MSG_DONTWAIT,
-                                          (struct sockaddr*)&addr, &addr_len);
+               len = recv(this->socket, &peek, sizeof(peek), MSG_PEEK | MSG_DONTWAIT);
 
                if (len == sizeof(peek) && peek.nlmsg_seq == this->seq)
                {