From 4e2f5dfa6484a90d8c01f5d5f9c46dddab8d86e9 Mon Sep 17 00:00:00 2001 From: Tuetuopay Date: Mon, 9 Apr 2018 16:21:41 +0200 Subject: [PATCH 41/76] 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 --- lib/route/link.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/route/link.c b/lib/route/link.c index de3c393..40165e5 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; } -- 1.8.3.1