]> git.ipfire.org Git - thirdparty/libnl.git/commitdiff
route: fix return value of nl_rtgen_request()
authorThomas Haller <thaller@redhat.com>
Fri, 31 Jan 2014 13:15:13 +0000 (14:15 +0100)
committerThomas Haller <thaller@redhat.com>
Fri, 31 Jan 2014 13:46:13 +0000 (14:46 +0100)
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>
lib/route/rtnl.c

index 82397e9ef0a4b73724859fe7ad7ee409c4819af3..6a55ca1a84fc7f1b6ca66550c79d0ff962ec0281 100644 (file)
  * 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;
 }
 
 /** @} */