summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-04-11 12:49:59 +0200
committerThomas Haller <thaller@redhat.com>2018-04-11 12:50:04 +0200
commit2a3a66977936471b93526adda7faa1ac231f78d7 (patch)
tree5e62775f35e7c3841edcedd181ffaf18eaa4cad2 /lib
parentda4e707af8059fb08ac9233440732923984993dd (diff)
parentbb446bc1164ebc6056097a79a96b532845e268c8 (diff)
downloadlibnl-2a3a66977936471b93526adda7faa1ac231f78d7.tar.gz
lib/route: merge branch 'pr/184'
Diffstat (limited to 'lib')
-rw-r--r--lib/msg.c2
-rw-r--r--lib/route/link.c6
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/msg.c b/lib/msg.c
index 0a523405..4fbd2ca9 100644
--- a/lib/msg.c
+++ b/lib/msg.c
@@ -350,6 +350,8 @@ struct nl_msg *nlmsg_alloc_simple(int nlmsgtype, int flags)
struct nlmsghdr nlh = {
.nlmsg_type = nlmsgtype,
.nlmsg_flags = flags,
+ .nlmsg_seq = NL_AUTO_SEQ,
+ .nlmsg_pid = NL_AUTO_PID,
};
msg = nlmsg_inherit(&nlh);
diff --git a/lib/route/link.c b/lib/route/link.c
index de3c393d..ec19bb51 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,
@@ -1784,6 +1788,7 @@ int rtnl_link_change(struct nl_sock *sk, struct rtnl_link *orig,
if (err < 0)
return err;
+ BUG_ON(msg->nm_nlh->nlmsg_seq != NL_AUTO_SEQ);
retry:
err = nl_send_auto_complete(sk, msg);
if (err < 0)
@@ -1792,6 +1797,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;
}