nuttx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gn...@apache.org
Subject [incubator-nuttx-apps] 01/03: netlib: correct netlink usage to follow Linux convention
Date Fri, 10 Apr 2020 15:22:16 GMT
This is an automated email from the ASF dual-hosted git repository.

gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit 300bc2729a89158f616387929c4a7b0e8eeca607
Author: Xiang Xiao <xiaoxiang@xiaomi.com>
AuthorDate: Thu Apr 9 06:37:04 2020 -0400

    netlib: correct netlink usage to follow Linux convention
    
    Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
    Change-Id: Iae98b0a008dc42dddb77f47d79511ae4fb4bbfca
---
 netutils/netlib/netlib_getarptab.c |  5 ++---
 netutils/netlib/netlib_getdevs.c   | 13 +------------
 netutils/netlib/netlib_getnbtab.c  |  5 ++---
 netutils/netlib/netlib_getroute.c  |  5 +----
 4 files changed, 6 insertions(+), 22 deletions(-)

diff --git a/netutils/netlib/netlib_getarptab.c b/netutils/netlib/netlib_getarptab.c
index 39c3c66..3385eef 100644
--- a/netutils/netlib/netlib_getarptab.c
+++ b/netutils/netlib/netlib_getarptab.c
@@ -44,7 +44,6 @@
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
-#include <errno.h>
 
 #include <netpacket/netlink.h>
 
@@ -142,7 +141,7 @@ ssize_t netlib_get_arptable(FAR struct arp_entry_s *arptab,
   addr.nl_family = AF_NETLINK;
   addr.nl_pad    = 0;
   addr.nl_pid    = pid;
-  addr.nl_groups = RTM_GETNEIGH;
+  addr.nl_groups = 0;
 
   ret = bind(fd, (FAR const struct sockaddr *)&addr,
              sizeof( struct sockaddr_nl));
@@ -160,7 +159,7 @@ ssize_t netlib_get_arptable(FAR struct arp_entry_s *arptab,
 
   memset(&req, 0, sizeof(req));
   req.hdr.nlmsg_len   = NLMSG_LENGTH(sizeof(struct ndmsg));
-  req.hdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_ROOT | NLM_F_REQUEST;
+  req.hdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP;
   req.hdr.nlmsg_seq   = thiseq;
   req.hdr.nlmsg_type  = RTM_GETNEIGH;
   req.hdr.nlmsg_pid   = pid;
diff --git a/netutils/netlib/netlib_getdevs.c b/netutils/netlib/netlib_getdevs.c
index 958ec22..6093547 100644
--- a/netutils/netlib/netlib_getdevs.c
+++ b/netutils/netlib/netlib_getdevs.c
@@ -129,7 +129,7 @@ ssize_t netlib_get_devices(FAR struct netlib_device_s *devlist,
   addr.nl_family = AF_NETLINK;
   addr.nl_pad    = 0;
   addr.nl_pid    = pid;
-  addr.nl_groups = RTM_GETLINK;
+  addr.nl_groups = 0;
 
   ret = bind(fd, (FAR const struct sockaddr *)&addr,
              sizeof( struct sockaddr_nl));
@@ -256,17 +256,6 @@ ssize_t netlib_get_devices(FAR struct netlib_device_s *devlist,
             }
             break;
 
-          /* RTM_NEWROUTE provides routing information for the device
-           * (address, gateway, etc.)
-           */
-
-          case RTM_NEWROUTE:
-            {
-              fprintf(stderr, "WARNING: RTM_NEWLINK Message type not "
-                              "implemented\n");
-            }
-            break;
-
           default:
             fprintf(stderr, "ERROR: Message type %u, length %lu\n",
                     resp.hdr.nlmsg_type, (unsigned long)resp.hdr.nlmsg_len);
diff --git a/netutils/netlib/netlib_getnbtab.c b/netutils/netlib/netlib_getnbtab.c
index acb070c..bcbf8b4 100644
--- a/netutils/netlib/netlib_getnbtab.c
+++ b/netutils/netlib/netlib_getnbtab.c
@@ -44,7 +44,6 @@
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
-#include <errno.h>
 
 #include <netpacket/netlink.h>
 
@@ -143,7 +142,7 @@ ssize_t netlib_get_nbtable(FAR struct neighbor_entry_s *nbtab,
   addr.nl_family = AF_NETLINK;
   addr.nl_pad    = 0;
   addr.nl_pid    = pid;
-  addr.nl_groups = RTM_GETNEIGH;
+  addr.nl_groups = 0;
 
   ret = bind(fd, (FAR const struct sockaddr *)&addr,
              sizeof( struct sockaddr_nl));
@@ -161,7 +160,7 @@ ssize_t netlib_get_nbtable(FAR struct neighbor_entry_s *nbtab,
 
   memset(&req, 0, sizeof(req));
   req.hdr.nlmsg_len   = NLMSG_LENGTH(sizeof(struct ndmsg));
-  req.hdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_ROOT | NLM_F_REQUEST;
+  req.hdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP;
   req.hdr.nlmsg_seq   = thiseq;
   req.hdr.nlmsg_type  = RTM_GETNEIGH;
   req.hdr.nlmsg_pid   = pid;
diff --git a/netutils/netlib/netlib_getroute.c b/netutils/netlib/netlib_getroute.c
index 954f6ff..502aec4 100644
--- a/netutils/netlib/netlib_getroute.c
+++ b/netutils/netlib/netlib_getroute.c
@@ -158,7 +158,7 @@ ssize_t netlib_get_route(FAR struct rtentry *rtelist,
   addr.nl_family = AF_NETLINK;
   addr.nl_pad    = 0;
   addr.nl_pid    = pid;
-  addr.nl_groups = RTM_GETROUTE;
+  addr.nl_groups = 0;
 
   ret = bind(fd, (FAR const struct sockaddr *)&addr,
              sizeof( struct sockaddr_nl));
@@ -247,9 +247,6 @@ ssize_t netlib_get_route(FAR struct rtentry *rtelist,
             enddump = true;
             break;
 
-          case RTM_NEWLINK:
-            break;  /* Ignore any link information */
-
           case RTM_NEWROUTE:
             {
               FAR struct rtentry *dest;


Mime
View raw message