mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Sven Eckelmann <sven.eckelmann@gmx.de>, netdev <netdev@vger.kernel.org>
Cc: b.a.t.m.a.n@lists.open-mesh.org,
	devel <devel@driverdev.osuosl.org>,
	b.a.t.m.a.n@lists.open-mesh.net,
	Greg Kroah-Hartman <gregkh@suse.de>,
	linux-kernel@vger.kernel.org,
	Simon Wunderlich <siwu@hrz.tu-chemnitz.de>,
	Marek Lindner <lindner_marek@yahoo.de>
Subject: Re: [B.A.T.M.A.N.] [PATCH] drivers/staging/batman-adv: Use (pr|netdev)_<level> macro helpers
Date: Tue, 15 Jun 2010 15:58:17 -0700	[thread overview]
Message-ID: <1276642697.1586.151.camel@Joe-Laptop.home> (raw)
In-Reply-To: <201006160037.48573.sven.eckelmann@gmx.de>

On Wed, 2010-06-16 at 00:37 +0200, Sven Eckelmann wrote:
> Sven Eckelmann wrote:

Hi Sven.

> > The problem seems to be that dev_printk is used by netdev_printk (which is
> > used by netdev_info). netdev_printk will add (netdev)->dev.parent as second
> > parameter of dev_printk (and parent is NULL in our case). This macro will
> > now call dev_driver_string with NULL as parameter and just dereference
> > this null pointer.
> > 
> > Maybe it is related to something else, but at least I think that this could
> > be the cause of the crash.

Nope, I think that's exactly correct.

> As far as I understand, the netdev_* stuff is made to be used by real drivers 
> with more or less physical hardware. batman-adv is a virtual bridge used for 
> mesh networks. Like net/bridge/ it has no physical parent device and only 
> other net_devices are used inside of it - which may have real physical network 
> devices as parents.

> Please correct me if my assumption is wrong.

No correction necessary...

netdev_printk and netdev_<level> are meant to be used
with parented network devices.

I think that netdev_<level> will eventually do the right
thing when dev->dev.parent is NULL.  Right now, that'd
be a bit of an expensive test as it would be expanded in
place for every use of the macro.

Right now it's:

#define netdev_printk(level, netdev, format, args...)		\
	dev_printk(level, (netdev)->dev.parent,			\
		   "%s: " format,				\
		   netdev_name(netdev), ##args)

It could be something like:

#define netdev_printk(level, netdev, format, args...)		\
do {								\
	if ((netdev)->dev.parent)				\
		dev_printk(level, (netdev)->dev.parent, 	\
			   "%s: " format, 			\
			   netdev_name(netdev), ##args);	\
	else							\
		printk(level "%s: " format,			\
			netdev_name(netdev), ##args);		\
} while (0)

Unfortunately, that just about doubles the format string space,
so I don't really want to do that.

If/when %pV is accepted,

http://lkml.org/lkml/2010/3/4/17
http://lkml.org/lkml/2010/3/4/18

then the netdev_<level> macros will be converted to functions,
so size reduced with an added test for dev.parent == NULL without
the need to double the string space.



      reply	other threads:[~2010-06-15 22:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-02 17:10 [PATCH] drivers/staging/batman-adv: Convert MAC_FMT to %pM Joe Perches
2010-06-02 18:12 ` [PATCH] drivers/staging/batman-adv: Use (pr|netdev)_<level> macro helpers Joe Perches
2010-06-02 18:53 ` [PATCH] drivers/staging/batman-adv: Convert MAC_FMT to %pM Greg KH
2010-06-02 20:08   ` [PATCH] MAINTAINERS: Add staging/b.a.t.m.a.n Joe Perches
2010-06-02 20:17     ` Greg KH
2010-06-02 20:19       ` Randy Dunlap
2010-06-02 20:27         ` Joe Perches
2010-06-02 20:11 ` [PATCH] drivers/staging/batman-adv: Use (pr|netdev)_<level> macro helpers Joe Perches
2010-06-15 22:23   ` [B.A.T.M.A.N.] " Sven Eckelmann
2010-06-15 22:37     ` Sven Eckelmann
2010-06-15 22:58       ` Joe Perches [this message]

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=1276642697.1586.151.camel@Joe-Laptop.home \
    --to=joe@perches.com \
    --cc=b.a.t.m.a.n@lists.open-mesh.net \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@suse.de \
    --cc=lindner_marek@yahoo.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=siwu@hrz.tu-chemnitz.de \
    --cc=sven.eckelmann@gmx.de \
    /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

all inboxes | Powered by JetHome®