netutils/netlib/netlib_getarptab.c: Per an old Linux Journal article, the nl_pid fild of struct sockaddr_nl should be set to the PID of the task that created the Netlink socket. Also fixes a warning.

This commit is contained in:
Gregory Nutt 2019-11-07 14:08:03 -06:00
parent 91276ba94e
commit f4f1ddccd7

View File

@ -41,6 +41,7 @@
#include <sys/socket.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <errno.h>
@ -135,11 +136,13 @@ ssize_t netlib_get_arptable(FAR struct arp_entry_s *arptab, unsigned int nentrie
/* Bind the socket so that we can use send() and receive() */
memset(&addr, 0, sizeof(struct sockaddr_nl));
addr.nl_family = AF_NETLINK;
addr.nl_pad = 0;
addr.nl_pid = getpid();
addr.nl_groups = RTM_GETNEIGH;
ret = bind(fd, &addr, sizeof( struct sockaddr_nl));
ret = bind(fd, (FAR const struct sockaddr *)&addr,
sizeof( struct sockaddr_nl));
if (fd < 0)
{
int errcode = errno;