diff options
author | David Ahern <dsa@cumulusnetworks.com> | 2017-03-23 19:51:20 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen@networkplumber.org> | 2017-04-14 16:00:15 -0700 |
commit | 3ad6d176389d4157bf4146cfea41337f08cfa62f (patch) | |
tree | 22ec7bc9e25f4382959a92fab610ff3813247aa2 | |
parent | dfb60ddd297dbc362003a26261a69eaf7cfa74b7 (diff) | |
download | platform_external_iproute2-3ad6d176389d4157bf4146cfea41337f08cfa62f.tar.gz platform_external_iproute2-3ad6d176389d4157bf4146cfea41337f08cfa62f.tar.bz2 platform_external_iproute2-3ad6d176389d4157bf4146cfea41337f08cfa62f.zip |
netlink: Add flag to suppress print of nlmsg error
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>
-rw-r--r-- | include/libnetlink.h | 1 | ||||
-rw-r--r-- | lib/libnetlink.c | 3 |
2 files changed, 3 insertions, 1 deletions
diff --git a/include/libnetlink.h b/include/libnetlink.h index bd0267df..c43ab0a2 100644 --- a/include/libnetlink.h +++ b/include/libnetlink.h @@ -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; }; diff --git a/lib/libnetlink.c b/lib/libnetlink.c index 9303b668..5b75b2db 100644 --- a/lib/libnetlink.c +++ b/lib/libnetlink.c @@ -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"); } } |