ipv4: provide addr and netconf dump consistency info
Subsystems (3)
PATCH 1/2 ipv4: provide addr and netconf dump consistency info
This patch takes benefit of dev_addr_genid and 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.
--- net/ipv4/devinet.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/ipv4/devinet.c +6 -0
@@ -1499,6 +1499,8 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb) idx =0 ; head = &net->dev_index_head[h];rcu_read_lock (); + cb->seq =atomic_read (&net->ipv4.dev_addr_genid) ^ + net->dev_base_seq;hlist_for_each_entry_rcu (dev, head, index_hlist) {if (idx < s_idx) goto cont;
@@ -1519,6 +1521,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)rcu_read_unlock (); goto done; } +nl_dump_check_consistent (cb,nlmsg_hdr (skb)); } cont: idx++;
@@ -1808,6 +1811,8 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb, idx =0 ; head = &net->dev_index_head[h];rcu_read_lock (); + cb->seq =atomic_read (&net->ipv4.dev_addr_genid) ^ + net->dev_base_seq;hlist_for_each_entry_rcu (dev, head, index_hlist) {if (idx < s_idx) goto cont;
@@ -1825,6 +1830,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,rcu_read_unlock (); goto done; } +nl_dump_check_consistent (cb,nlmsg_hdr (skb)); cont: idx++; }
Signature · 1 line
1.8.0.1
PATCH 2/2 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).
--- include/net/netns/ipv6.h | 1 + net/ipv6/addrconf.c | 8 ++++++++ 2 files changed, 9 insertions(+)
include/net/netns/ipv6.h +1 -0
@@ -71,6 +71,7 @@ struct netns_ipv6 {struct fib_rules_ops *mr6_rules_ops;#endif #endif +atomic_t dev_addr_genid; };#if IS_ENABLED (CONFIG_NF_DEFRAG_IPV6 )
net/ipv6/addrconf.c +8 -0
@@ -622,6 +622,8 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb, idx =0 ; head = &net->dev_index_head[h];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) {if (idx < s_idx) goto cont;
@@ -639,6 +641,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,rcu_read_unlock (); goto done; } +nl_dump_check_consistent (cb,nlmsg_hdr (skb)); cont: idx++; }
@@ -3875,6 +3878,7 @@ static int in6_dump_addrs(struct inet6_dev *idev, struct sk_buff *skb, NLM_F_MULTI);if (err <=0 )break ; +nl_dump_check_consistent (cb,nlmsg_hdr (skb)); }break ; }
@@ -3932,6 +3936,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb, s_ip_idx = ip_idx = cb->args[2 ];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 ) { idx =0 ; head = &net->dev_index_head[h];
@@ -4409,6 +4414,8 @@ errout: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);switch (event) {
@@ -4434,6 +4441,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)dst_free (&ifp->rt->dst);break ; } +atomic_inc (&net->ipv6.dev_addr_genid); }static void ipv6_ifa_notify (int event,struct inet6_ifaddr *ifp)
Signature · 1 line
1.8.0.1
Re: [PATCH net-next 2/2] ipv6: provide addr and netconf dump consistency info
Please, drop both patches. If we dump addresses via rtnl_dump_all(), seq is not reset and thus NLM_F_DUMP_INTR is always set when switching from ipv4 to ipv6 family.
I will send a new patch.
Nicolas
Quoted 83 lines · Nicolas Dichtel
This patch adds a
dev_addr_genidfor IPv6. The goal is to use it, combined withdev_base_seqto check if a change occurs during a netlink dump.
If a change is detected, the flagNLM_F_DUMP_INTRis 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 <[email protected]>Reported-by Hongjun Li <[email protected]>Signed-off-by Nicolas Dichtel <[email protected]>--- include/net/netns/ipv6.h | 1 + net/ipv6/addrconf.c | 8 ++++++++ 2 files changed, 9 insertions(+)include/net/netns/ipv6.h +1
-0@@ -71,6 +71,7 @@ struct netns_ipv6 {struct fib_rules_ops *mr6_rules_ops;#endif #endif +atomic_t dev_addr_genid; };#if IS_ENABLED (CONFIG_NF_DEFRAG_IPV6 )net/ipv6/addrconf.c +8
-0@@ -622,6 +622,8 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb, idx =0 ; head = &net->dev_index_head[h];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) {if (idx < s_idx) goto cont;@@ -639,6 +641,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,rcu_read_unlock (); goto done; } +nl_dump_check_consistent (cb,nlmsg_hdr (skb)); cont: idx++; }@@ -3875,6 +3878,7 @@ static int in6_dump_addrs(struct inet6_dev *idev, struct sk_buff *skb, NLM_F_MULTI);if (err <=0 )break ; +nl_dump_check_consistent (cb,nlmsg_hdr (skb)); }break ; }@@ -3932,6 +3936,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb, s_ip_idx = ip_idx = cb->args[2 ];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 ) { idx =0 ; head = &net->dev_index_head[h];@@ -4409,6 +4414,8 @@ errout: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);switch (event) {@@ -4434,6 +4441,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)dst_free (&ifp->rt->dst);break ; } +atomic_inc (&net->ipv6.dev_addr_genid); }static void ipv6_ifa_notify (int event,struct inet6_ifaddr *ifp)
Signature · 14 lines
Nicolas DICHTEL 6WIND R&D Engineer Tel: +33 1 39 30 92 41 Fax: +33 1 39 30 92 11 [email protected] www.6wind.com www.6windblog.com Twitter: http://twitter.com/6windsoftware Ce courriel ainsi que toutes les pièces jointes, est uniquement destiné à son ou ses destinataires. Il contient des informations confidentielles qui sont la propriété de 6WIND. Toute révélation, distribution ou copie des informations qu'il contient est strictement interdite. Si vous avez reçu ce message par erreur, veuillez immédiatement le signaler à l'émetteur et détruire toutes les données reçues. This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and contains information that is confidential and proprietary to 6WIND. All unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.
PATCH v2 1/2 ipv4: provide addr and netconf dump consistency info
This patch takes benefit of dev_addr_genid and 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 seq and prev_seq must be reset between each family in rtnl_dump_all() because they are specific to each family.
---
v2: reset seq and prev_seq in rtnl_dump_all()
net/core/rtnetlink.c | 5 ++++- net/ipv4/devinet.c | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-)
net/core/rtnetlink.c +4 -1
@@ -1955,8 +1955,11 @@ static int rtnl_dump_all(struct sk_buff *skb, struct netlink_callback *cb)if (rtnl_msg_handlers[idx] ==NULL || rtnl_msg_handlers[idx][type].dumpit ==NULL )continue ; -if (idx > s_idx) +if (idx > s_idx) {memset (&cb->args[0 ],0 ,sizeof (cb->args)); + cb->prev_seq =0 ; + cb->seq =0 ; + }if (rtnl_msg_handlers[idx][type].dumpit (skb, cb))break ; }
net/ipv4/devinet.c +6 -0
@@ -1499,6 +1499,8 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb) idx =0 ; head = &net->dev_index_head[h];rcu_read_lock (); + cb->seq =atomic_read (&net->ipv4.dev_addr_genid) ^ + net->dev_base_seq;hlist_for_each_entry_rcu (dev, head, index_hlist) {if (idx < s_idx) goto cont;
@@ -1519,6 +1521,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)rcu_read_unlock (); goto done; } +nl_dump_check_consistent (cb,nlmsg_hdr (skb)); } cont: idx++;
@@ -1808,6 +1811,8 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb, idx =0 ; head = &net->dev_index_head[h];rcu_read_lock (); + cb->seq =atomic_read (&net->ipv4.dev_addr_genid) ^ + net->dev_base_seq;hlist_for_each_entry_rcu (dev, head, index_hlist) {if (idx < s_idx) goto cont;
@@ -1825,6 +1830,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,rcu_read_unlock (); goto done; } +nl_dump_check_consistent (cb,nlmsg_hdr (skb)); cont: idx++; }
Signature · 1 line
1.8.0.1
PATCH v2 2/2 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).
--- include/net/netns/ipv6.h | 1 + net/ipv6/addrconf.c | 8 ++++++++ 2 files changed, 9 insertions(+)
include/net/netns/ipv6.h +1 -0
@@ -71,6 +71,7 @@ struct netns_ipv6 {struct fib_rules_ops *mr6_rules_ops;#endif #endif +atomic_t dev_addr_genid; };#if IS_ENABLED (CONFIG_NF_DEFRAG_IPV6 )
net/ipv6/addrconf.c +8 -0
@@ -622,6 +622,8 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb, idx =0 ; head = &net->dev_index_head[h];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) {if (idx < s_idx) goto cont;
@@ -639,6 +641,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,rcu_read_unlock (); goto done; } +nl_dump_check_consistent (cb,nlmsg_hdr (skb)); cont: idx++; }
@@ -3875,6 +3878,7 @@ static int in6_dump_addrs(struct inet6_dev *idev, struct sk_buff *skb, NLM_F_MULTI);if (err <=0 )break ; +nl_dump_check_consistent (cb,nlmsg_hdr (skb)); }break ; }
@@ -3932,6 +3936,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb, s_ip_idx = ip_idx = cb->args[2 ];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 ) { idx =0 ; head = &net->dev_index_head[h];
@@ -4409,6 +4414,8 @@ errout: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);switch (event) {
@@ -4434,6 +4441,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)dst_free (&ifp->rt->dst);break ; } +atomic_inc (&net->ipv6.dev_addr_genid); }static void ipv6_ifa_notify (int event,struct inet6_ifaddr *ifp)
Signature · 1 line
1.8.0.1
Re: [PATCH net-next v2 2/2] ipv6: provide addr and netconf dump consistency info
From: Nicolas Dichtel <[email protected]>
Date: Fri, 22 Mar 2013 17:34:02 +0100
Quoted 4 lines
When this flag is set, it means that dump was interrupted and result may be inconsistent.
Signed-off-by Nicolas Dichtel <[email protected]>
Applied.
From: Nicolas Dichtel <[email protected]>
Date: Fri, 22 Mar 2013 17:28:42 +0100
Quoted 10 lines
This patch takes benefit of
dev_addr_genidanddev_base_seqto check if a change occurs during a netlink dump. If a change is detected, the flagNLM_F_DUMP_INTRis set in the first message after the dump was interrupted.Note that seq and
prev_seqmust be reset between each family inrtnl_dump_all()because they are specific to each family.Reported-by Junwei Zhang <[email protected]>Reported-by Hongjun Li <[email protected]>Signed-off-by Nicolas Dichtel <[email protected]>
Applied.