From f4f1ddccd79fd90120c9ad1c13fbcbef03983054 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 7 Nov 2019 14:08:03 -0600 Subject: [PATCH] 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. --- netutils/netlib/netlib_getarptab.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/netutils/netlib/netlib_getarptab.c b/netutils/netlib/netlib_getarptab.c index 79d076335..5ac3da1a8 100644 --- a/netutils/netlib/netlib_getarptab.c +++ b/netutils/netlib/netlib_getarptab.c @@ -41,6 +41,7 @@ #include #include +#include #include #include #include @@ -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;