From: Andrey Savochkin <saw@swsoft.com>
To: netdev@vger.kernel.org
Cc: Kirill Korotaev <dev@openvz.org>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
Subject: [patch 7/7] net_device list cleanup: debugging
Date: Mon, 3 Jul 2006 12:18:57 +0400 [thread overview]
Message-ID: <20060630165508.I22285@castle.nmd.msu.ru> (raw)
In-Reply-To: <20060630150823.A22285@castle.nmd.msu.ru>; from "Andrey Savochkin" on Fri, Jun 30, 2006 at 03:08:23PM
Optional code to catch cases when loop cursor is used after for_each_netdev
loop: often it's a sign of a bug, since it isn't guaranteed to point to a
device.
Signed-off-by: Andrey Savochkin <saw@swsoft.com>
---
If anyone wants to keep this under some debug config option,
let me know which one.
netdevice.h | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletion(-)
--- ./include/linux/netdevice.h.vedevbase-dbg Mon Jul 3 16:16:51 2006
+++ ./include/linux/netdevice.h Mon Jul 3 16:16:51 2006
@@ -560,7 +560,13 @@ extern struct net_device loopback_dev;
extern struct list_head dev_base_head; /* All devices */
extern rwlock_t dev_base_lock; /* Device list lock */
-#define for_each_netdev(p) list_for_each_entry(p, &dev_base_head, dev_list)
+#define for_each_netdev(pos) \
+for (pos = list_entry(dev_base_head.next, typeof(*pos), dev_list); \
+ prefetch(pos->dev_list.next), \
+ &pos->dev_list != &dev_base_head ? : \
+ ({ void *__check_dev_use_after_for_each_netdev; \
+ pos = __check_dev_use_after_for_each_netdev; 0; }); \
+ pos = list_entry(pos->dev_list.next, typeof(*pos), dev_list))
/*
* When possible, it is preferrable to use for_each_netdev() loop
next prev parent reply other threads:[~2006-07-03 16:32 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-03 8:18 [patch 1/7] net_device list cleanup: core Andrey Savochkin
2006-07-03 8:18 ` [patch 2/7] net_device list cleanup: proc seq_file output Andrey Savochkin
2006-07-03 8:18 ` [patch 3/7] net_device list cleanup: netlink_dump Andrey Savochkin
2006-07-03 8:18 ` [patch 4/7] net_device list cleanup: drivers and non-IP protocols Andrey Savochkin
2006-07-07 19:18 ` Stephen Hemminger
2006-07-03 8:18 ` [patch 5/7] net_device list cleanup: arch-dependent code and block devices Andrey Savochkin
2006-07-03 8:18 ` [patch 6/7] net_device list cleanup: dev_base removal Andrey Savochkin
2006-07-03 8:18 ` Andrey Savochkin [this message]
2006-07-03 17:46 ` [patch 1/7] net_device list cleanup: core Christoph Hellwig
2006-07-04 7:24 ` Andrey Savochkin
2006-07-04 9:10 ` Christoph Hellwig
2006-07-04 14:50 ` Andrey Savochkin
2006-07-04 16:35 ` Alexey Kuznetsov
2006-07-05 8:26 ` Andrey Savochkin
2006-07-07 4:34 ` YOSHIFUJI Hideaki / 吉藤英明
2006-07-07 7:54 ` Andrey Savochkin
2006-07-07 16:48 ` YOSHIFUJI Hideaki / 吉藤英明
2006-07-10 6:53 ` Andrey Savochkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060630165508.I22285@castle.nmd.msu.ru \
--to=saw@swsoft.com \
--cc=dev@openvz.org \
--cc=ebiederm@xmission.com \
--cc=kuznet@ms2.inr.ac.ru \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).