diff options
author | Thomas Haller <thaller@redhat.com> | 2014-01-31 13:15:13 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-01-31 13:46:13 (GMT) |
commit | b70174668b9867de573cf51471bc98bfe7fd2bc3 (patch) | |
tree | 2d308ef88688bb87f1a9570dfeab732f21299444 /lib/route | |
parent | 4c7a3074bbd1a9dc0cb4d6b3566fafe464dcec0b (diff) | |
download | libnl-b70174668b9867de573cf51471bc98bfe7fd2bc3.zip libnl-b70174668b9867de573cf51471bc98bfe7fd2bc3.tar.gz libnl-b70174668b9867de573cf51471bc98bfe7fd2bc3.tar.bz2 |
route: fix return value of nl_rtgen_request()
According to documentation, nl_rtgen_request() returns 0 on success,
but before it returned the number of bytes sent.
Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'lib/route')
-rw-r--r-- | lib/route/rtnl.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/route/rtnl.c b/lib/route/rtnl.c index 82397e9..6a55ca1 100644 --- a/lib/route/rtnl.c +++ b/lib/route/rtnl.c @@ -34,15 +34,20 @@ * Fills out a routing netlink request message and sends it out * using nl_send_simple(). * - * @return 0 on success or a negative error code. + * @return 0 on success or a negative error code. Due to a bug in + * older versions, this returned the number of bytes sent. So for + * compatibility, treat positive return values as success too. */ int nl_rtgen_request(struct nl_sock *sk, int type, int family, int flags) { + int err; struct rtgenmsg gmsg = { .rtgen_family = family, }; - return nl_send_simple(sk, type, flags, &gmsg, sizeof(gmsg)); + err = nl_send_simple(sk, type, flags, &gmsg, sizeof(gmsg)); + + return err >= 0 ? 0 : err; } /** @} */ |