All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 1/2] ipv4: provide addr and netconf dump consistency info
@ 2013-03-22 14:42 Nicolas Dichtel
  2013-03-22 14:42 ` [PATCH net-next 2/2] ipv6: " Nicolas Dichtel
  0 siblings, 1 reply; 15+ messages in thread
From: Nicolas Dichtel @ 2013-03-22 14:42 UTC (permalink / raw)
  To: netdev; +Cc: davem, junwei.zhang, hongjun.li, Nicolas Dichtel

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.

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>
---
 net/ipv4/devinet.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index af57bba..158ca5e 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -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++;
 		}
-- 
1.8.0.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [PATCH iproute2] libnetlink: check flag NLM_F_DUMP_INTR during dumps
@ 2013-03-22 14:45 Nicolas Dichtel
  2013-03-22 14:59 ` Eric Dumazet
  0 siblings, 1 reply; 15+ messages in thread
From: Nicolas Dichtel @ 2013-03-22 14:45 UTC (permalink / raw)
  To: shemminger; +Cc: netdev, Nicolas Dichtel

When this flag is set, it means that dump was interrupted and result may be
wrong. Ask user to restart.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 lib/libnetlink.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index f262959..91991cf 100644
--- a/lib/libnetlink.c
+++ b/lib/libnetlink.c
@@ -230,6 +230,12 @@ int rtnl_dump_filter_l(struct rtnl_handle *rth,
 				    h->nlmsg_seq != rth->dump)
 					goto skip_it;
 
+				if (h->nlmsg_flags & NLM_F_DUMP_INTR) {
+					fprintf(stderr,
+						"Dump was interrupted, please restart.\n");
+					return -1;
+				}
+
 				if (h->nlmsg_type == NLMSG_DONE) {
 					found_done = 1;
 					break; /* process next filter */
-- 
1.8.0.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2013-03-24 21:17 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-22 14:42 [PATCH net-next 1/2] ipv4: provide addr and netconf dump consistency info Nicolas Dichtel
2013-03-22 14:42 ` [PATCH net-next 2/2] ipv6: " Nicolas Dichtel
2013-03-22 16:22   ` Nicolas Dichtel
2013-03-22 16:28     ` [PATCH net-next v2 1/2] ipv4: " Nicolas Dichtel
2013-03-22 16:28       ` [PATCH net-next v2 2/2] ipv6: " Nicolas Dichtel
2013-03-24 21:16       ` [PATCH net-next v2 1/2] ipv4: " David Miller
2013-03-22 14:45 [PATCH iproute2] libnetlink: check flag NLM_F_DUMP_INTR during dumps Nicolas Dichtel
2013-03-22 14:59 ` Eric Dumazet
2013-03-22 15:03   ` Nicolas Dichtel
2013-03-22 15:14     ` Eric Dumazet
2013-03-22 15:22       ` Thomas Graf
2013-03-22 15:42         ` [PATCH iproute2 v2] " Nicolas Dichtel
2013-03-22 15:49           ` Eric Dumazet
2013-03-22 16:34             ` [PATCH iproute2 v3] " Nicolas Dichtel
2013-03-24 21:17               ` [PATCH net-next v2 2/2] ipv6: provide addr and netconf dump consistency info 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.