summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTuetuopay <tuetuopay@me.com>2018-04-09 16:21:41 +0200
committerThomas Haller <thaller@redhat.com>2018-04-11 12:35:41 +0200
commit4e2f5dfa6484a90d8c01f5d5f9c46dddab8d86e9 (patch)
tree70cb6aecc3f9b3d959d1cb784320c6a31f19f261 /lib
parentda4e707af8059fb08ac9233440732923984993dd (diff)
downloadlibnl-4e2f5dfa6484a90d8c01f5d5f9c46dddab8d86e9.tar.gz
route/link: fix sequence number handling in rtnl_link_change()
When rtnl_link_change() fails with -NLE_OPNOTSUPP, it retries with RTM_SETLINK operation. However, it also needs to re-adjust the sequence number. Otherwise, the second request might fail with NLE_SEQ_MISMATCH, although it actually succeeded. [thaller@redhat.com: changed commit message] https://github.com/thom311/libnl/issues/179 https://github.com/thom311/libnl/pull/184
Diffstat (limited to 'lib')
-rw-r--r--lib/route/link.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/route/link.c b/lib/route/link.c
index de3c393d..40165e59 100644
--- a/lib/route/link.c
+++ b/lib/route/link.c
@@ -1772,6 +1772,10 @@ errout:
* @note The link name can only be changed if the link has been put
* in opertional down state. (~IF_UP)
*
+ * @note On versions up to 3.4.0, \c NLE_SEQ_MISMATCH would be returned if the
+ * kernel does not supports \c RTM_NEWLINK. It is advised to ignore the
+ * error code if you cannot upgrade the library.
+ *
* @return 0 on success or a negative error code.
*/
int rtnl_link_change(struct nl_sock *sk, struct rtnl_link *orig,
@@ -1792,6 +1796,7 @@ retry:
err = wait_for_ack(sk);
if (err == -NLE_OPNOTSUPP && msg->nm_nlh->nlmsg_type == RTM_NEWLINK) {
msg->nm_nlh->nlmsg_type = RTM_SETLINK;
+ msg->nm_nlh->nlmsg_seq = NL_AUTO_SEQ;
goto retry;
}