ipv4: properly combine dev_base_seq and ipv4.dev_addr_genid
[ Upstream commit 081a0e3b0d4c061419d3f4679dec9f68725b17e4 ]
net->dev_base_seq and ipv4.dev_addr_genid are monotonically increasing.
If we XOR their values, we could miss to detect if both values
were changed with the same amount.
Fixes: 0465277f6b
("ipv4: provide addr and netconf dump consistency info")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
fc30793e06
commit
dcc1375d41
@@ -1798,6 +1798,21 @@ done:
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Combine dev_addr_genid and dev_base_seq to detect changes.
|
||||||
|
*/
|
||||||
|
static u32 inet_base_seq(const struct net *net)
|
||||||
|
{
|
||||||
|
u32 res = atomic_read(&net->ipv4.dev_addr_genid) +
|
||||||
|
net->dev_base_seq;
|
||||||
|
|
||||||
|
/* Must not return 0 (see nl_dump_check_consistent()).
|
||||||
|
* Chose a value far away from 0.
|
||||||
|
*/
|
||||||
|
if (!res)
|
||||||
|
res = 0x80000000;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
|
static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
|
||||||
{
|
{
|
||||||
const struct nlmsghdr *nlh = cb->nlh;
|
const struct nlmsghdr *nlh = cb->nlh;
|
||||||
@@ -1849,8 +1864,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
|
|||||||
idx = 0;
|
idx = 0;
|
||||||
head = &tgt_net->dev_index_head[h];
|
head = &tgt_net->dev_index_head[h];
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
cb->seq = atomic_read(&tgt_net->ipv4.dev_addr_genid) ^
|
cb->seq = inet_base_seq(tgt_net);
|
||||||
tgt_net->dev_base_seq;
|
|
||||||
hlist_for_each_entry_rcu(dev, head, index_hlist) {
|
hlist_for_each_entry_rcu(dev, head, index_hlist) {
|
||||||
if (idx < s_idx)
|
if (idx < s_idx)
|
||||||
goto cont;
|
goto cont;
|
||||||
@@ -2249,8 +2263,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
|
|||||||
idx = 0;
|
idx = 0;
|
||||||
head = &net->dev_index_head[h];
|
head = &net->dev_index_head[h];
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
|
cb->seq = inet_base_seq(net);
|
||||||
net->dev_base_seq;
|
|
||||||
hlist_for_each_entry_rcu(dev, head, index_hlist) {
|
hlist_for_each_entry_rcu(dev, head, index_hlist) {
|
||||||
if (idx < s_idx)
|
if (idx < s_idx)
|
||||||
goto cont;
|
goto cont;
|
||||||
|
Reference in New Issue
Block a user