Skip to content

Commit

Permalink
route: fix return value of nl_rtgen_request()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
thom311 committed Jan 31, 2014
1 parent 4c7a307 commit b701746
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/route/rtnl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/** @} */
Expand Down

0 comments on commit b701746

Please sign in to comment.