mirror of https://gitee.com/openkylin/linux.git
rtnelink: Move link dump consistency check out of the loop
Calls to rtnl_dump_ifinfo() are protected by RTNL lock. So are the {list,unlist}_netdevice() calls where we bump the net->dev_base_seq number. For this reason net->dev_base_seq can't change under out feet while we're looping over links in rtnl_dump_ifinfo(). So move the check for net->dev_base_seq change (since the last time we were called) out of the loop. This way we avoid giving a wrong impression that there are concurrent updates to the link list going on while we're iterating over them. Signed-off-by: Jakub Sitnicki <jkbs@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
aa69ff9e9c
commit
d0225784be
|
@ -1621,8 +1621,6 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
|
||||||
s_h = cb->args[0];
|
s_h = cb->args[0];
|
||||||
s_idx = cb->args[1];
|
s_idx = cb->args[1];
|
||||||
|
|
||||||
cb->seq = net->dev_base_seq;
|
|
||||||
|
|
||||||
/* A hack to preserve kernel<->userspace interface.
|
/* A hack to preserve kernel<->userspace interface.
|
||||||
* The correct header is ifinfomsg. It is consistent with rtnl_getlink.
|
* The correct header is ifinfomsg. It is consistent with rtnl_getlink.
|
||||||
* However, before Linux v3.9 the code here assumed rtgenmsg and that's
|
* However, before Linux v3.9 the code here assumed rtgenmsg and that's
|
||||||
|
@ -1668,8 +1666,6 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
|
||||||
|
|
||||||
goto out_err;
|
goto out_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
nl_dump_check_consistent(cb, nlmsg_hdr(skb));
|
|
||||||
cont:
|
cont:
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
|
@ -1679,6 +1675,8 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
|
||||||
out_err:
|
out_err:
|
||||||
cb->args[1] = idx;
|
cb->args[1] = idx;
|
||||||
cb->args[0] = h;
|
cb->args[0] = h;
|
||||||
|
cb->seq = net->dev_base_seq;
|
||||||
|
nl_dump_check_consistent(cb, nlmsg_hdr(skb));
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue