mirror of
https://gitee.com/openharmony/third_party_libnl
synced 2024-11-30 13:40:43 +00:00
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
This commit is contained in:
parent
da4e707af8
commit
4e2f5dfa64
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user