Commit 59a646d6 authored by David S. Miller's avatar David S. Miller

Merge branch 'inet-fix-NLM_F_DUMP_INTR-logic'

Eric Dumazet says:

====================
inet: fix NLM_F_DUMP_INTR logic

Make sure NLM_F_DUMP_INTR is generated if dev_base_seq and
dev_addr_genid are changed by the same amount.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 97dde840 e898e4cd
...@@ -1825,6 +1825,21 @@ static int in_dev_dump_addr(struct in_device *in_dev, struct sk_buff *skb, ...@@ -1825,6 +1825,21 @@ static int in_dev_dump_addr(struct in_device *in_dev, struct sk_buff *skb,
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;
...@@ -1876,8 +1891,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -1876,8 +1891,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;
...@@ -2278,8 +2292,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb, ...@@ -2278,8 +2292,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;
......
...@@ -708,6 +708,22 @@ static int inet6_netconf_get_devconf(struct sk_buff *in_skb, ...@@ -708,6 +708,22 @@ static int inet6_netconf_get_devconf(struct sk_buff *in_skb,
return err; return err;
} }
/* Combine dev_addr_genid and dev_base_seq to detect changes.
*/
static u32 inet6_base_seq(const struct net *net)
{
u32 res = atomic_read(&net->ipv6.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 inet6_netconf_dump_devconf(struct sk_buff *skb, static int inet6_netconf_dump_devconf(struct sk_buff *skb,
struct netlink_callback *cb) struct netlink_callback *cb)
{ {
...@@ -741,8 +757,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb, ...@@ -741,8 +757,7 @@ static int inet6_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->ipv6.dev_addr_genid) ^ cb->seq = inet6_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;
...@@ -5362,7 +5377,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb, ...@@ -5362,7 +5377,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
} }
rcu_read_lock(); rcu_read_lock();
cb->seq = atomic_read(&tgt_net->ipv6.dev_addr_genid) ^ tgt_net->dev_base_seq; cb->seq = inet6_base_seq(tgt_net);
for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) { for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
idx = 0; idx = 0;
head = &tgt_net->dev_index_head[h]; head = &tgt_net->dev_index_head[h];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment