* [PATCH net-next] rtnelink: Move link dump consistency check out of the loop
@ 2017-08-09 15:39 Jakub Sitnicki
2017-08-14 2:44 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Sitnicki @ 2017-08-09 15:39 UTC (permalink / raw)
To: netdev; +Cc: David S. Miller
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>
---
net/core/rtnetlink.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 9201e36..6b7888e 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1644,8 +1644,6 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
s_h = cb->args[0];
s_idx = cb->args[1];
- cb->seq = net->dev_base_seq;
-
/* A hack to preserve kernel<->userspace interface.
* The correct header is ifinfomsg. It is consistent with rtnl_getlink.
* However, before Linux v3.9 the code here assumed rtgenmsg and that's
@@ -1691,8 +1689,6 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
goto out_err;
}
-
- nl_dump_check_consistent(cb, nlmsg_hdr(skb));
cont:
idx++;
}
@@ -1702,6 +1698,8 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
out_err:
cb->args[1] = idx;
cb->args[0] = h;
+ cb->seq = net->dev_base_seq;
+ nl_dump_check_consistent(cb, nlmsg_hdr(skb));
return err;
}
--
2.9.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] rtnelink: Move link dump consistency check out of the loop
2017-08-09 15:39 [PATCH net-next] rtnelink: Move link dump consistency check out of the loop Jakub Sitnicki
@ 2017-08-14 2:44 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-08-14 2:44 UTC (permalink / raw)
To: jkbs; +Cc: netdev
From: Jakub Sitnicki <jkbs@redhat.com>
Date: Wed, 9 Aug 2017 17:39:12 +0200
> 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>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-08-14 2:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-09 15:39 [PATCH net-next] rtnelink: Move link dump consistency check out of the loop Jakub Sitnicki
2017-08-14 2:44 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.