]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
netlink: Add flag to suppress print of nlmsg error
authorDavid Ahern <dsa@cumulusnetworks.com>
Fri, 24 Mar 2017 02:51:20 +0000 (19:51 -0700)
committerStephen Hemminger <stephen@networkplumber.org>
Fri, 14 Apr 2017 23:00:15 +0000 (16:00 -0700)
Allow callers of the dump API to handle nlmsg errors (e.g., an
unsupported feature). Setting RTNL_HANDLE_F_SUPPRESS_NLERR in the
rtnl_handle avoids unnecessary messages to the users in some case.
For example,

  RTNETLINK answers: Operation not supported

when probing for support of a new feature.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
include/libnetlink.h
lib/libnetlink.c

index bd0267dfcc02ad1898f17d1ec2275a23312187aa..c43ab0a2d9d9a19fffa133536fb96e9daa1b3237 100644 (file)
@@ -21,6 +21,7 @@ struct rtnl_handle {
        int                     proto;
        FILE                   *dump_fp;
 #define RTNL_HANDLE_F_LISTEN_ALL_NSID          0x01
+#define RTNL_HANDLE_F_SUPPRESS_NLERR           0x02
        int                     flags;
 };
 
index 9303b6686e2c8b4d950ec12eb96eb1a499e68bfc..5b75b2db4e0b4cfd603d9b9d0edc4cdde5ed8a7d 100644 (file)
@@ -299,7 +299,8 @@ static void rtnl_dump_error(const struct rtnl_handle *rth,
                     errno == EOPNOTSUPP))
                        return;
 
-               perror("RTNETLINK answers");
+               if (!(rth->flags & RTNL_HANDLE_F_SUPPRESS_NLERR))
+                       perror("RTNETLINK answers");
        }
 }