ipv6: provide addr and netconf dump consistency info
This patch adds a dev_addr_genid for IPv6. The goal is to use it, combined with dev_base_seq to check if a change occurs during a netlink dump. If a change is detected, the flag NLM_F_DUMP_INTR is set in the first message after the dump was interrupted. Note that only dump of unicast addresses is checked (multicast and anycast are not checked). Reported-by: Junwei Zhang <junwei.zhang@6wind.com> Reported-by: Hongjun Li <hongjun.li@6wind.com> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
0465277f6b
commit
63998ac24f
|
@ -71,6 +71,7 @@ struct netns_ipv6 {
|
||||||
struct fib_rules_ops *mr6_rules_ops;
|
struct fib_rules_ops *mr6_rules_ops;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
atomic_t dev_addr_genid;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
|
#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
|
||||||
|
|
|
@ -621,6 +621,8 @@ 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) ^
|
||||||
|
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;
|
||||||
|
@ -638,6 +640,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
nl_dump_check_consistent(cb, nlmsg_hdr(skb));
|
||||||
cont:
|
cont:
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
|
@ -3874,6 +3877,7 @@ static int in6_dump_addrs(struct inet6_dev *idev, struct sk_buff *skb,
|
||||||
NLM_F_MULTI);
|
NLM_F_MULTI);
|
||||||
if (err <= 0)
|
if (err <= 0)
|
||||||
break;
|
break;
|
||||||
|
nl_dump_check_consistent(cb, nlmsg_hdr(skb));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3931,6 +3935,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
|
||||||
s_ip_idx = ip_idx = cb->args[2];
|
s_ip_idx = ip_idx = cb->args[2];
|
||||||
|
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
|
cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
|
||||||
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 = &net->dev_index_head[h];
|
head = &net->dev_index_head[h];
|
||||||
|
@ -4407,6 +4412,8 @@ errout:
|
||||||
|
|
||||||
static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
|
static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
|
||||||
{
|
{
|
||||||
|
struct net *net = dev_net(ifp->idev->dev);
|
||||||
|
|
||||||
inet6_ifa_notify(event ? : RTM_NEWADDR, ifp);
|
inet6_ifa_notify(event ? : RTM_NEWADDR, ifp);
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
@ -4432,6 +4439,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
|
||||||
dst_free(&ifp->rt->dst);
|
dst_free(&ifp->rt->dst);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
atomic_inc(&net->ipv6.dev_addr_genid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
|
static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
|
||||||
|
|
Loading…
Reference in New Issue