* [PATCH 26/39]: netdev: netdev_priv() can now be sane again.
@ 2008-07-03 7:04 David Miller
2008-07-03 11:23 ` Krzysztof Halasa
0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2008-07-03 7:04 UTC (permalink / raw)
To: netdev; +Cc: vinay, krkumar2, mchan, Matheos.Worku, linux-wireless
The private area of a netdev is now at a fixed offset once more.
Unfortunately, some assumptions that netdev_priv() == netdev->priv
crept back into the tree. In particular this happened in the
loopback driver. Make it use netdev->ml_priv.
Signed-off-by: David S. Miller <davem@davemloft.net>
---
drivers/net/loopback.c | 8 ++++----
include/linux/netdevice.h | 4 +++-
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index 41b774b..49f6bc0 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -153,7 +153,7 @@ static int loopback_xmit(struct sk_buff *skb, struct net_device *dev)
dev->last_rx = jiffies;
/* it's OK to use per_cpu_ptr() because BHs are off */
- pcpu_lstats = netdev_priv(dev);
+ pcpu_lstats = dev->ml_priv;
lb_stats = per_cpu_ptr(pcpu_lstats, smp_processor_id());
lb_stats->bytes += skb->len;
lb_stats->packets++;
@@ -171,7 +171,7 @@ static struct net_device_stats *get_stats(struct net_device *dev)
unsigned long packets = 0;
int i;
- pcpu_lstats = netdev_priv(dev);
+ pcpu_lstats = dev->ml_priv;
for_each_possible_cpu(i) {
const struct pcpu_lstats *lb_stats;
@@ -207,13 +207,13 @@ static int loopback_dev_init(struct net_device *dev)
if (!lstats)
return -ENOMEM;
- dev->priv = lstats;
+ dev->ml_priv = lstats;
return 0;
}
static void loopback_dev_free(struct net_device *dev)
{
- struct pcpu_lstats *lstats = netdev_priv(dev);
+ struct pcpu_lstats *lstats = dev->ml_priv;
free_percpu(lstats);
free_netdev(dev);
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index df44e44..8558046 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -809,7 +809,9 @@ void dev_net_set(struct net_device *dev, struct net *net)
*/
static inline void *netdev_priv(const struct net_device *dev)
{
- return dev->priv;
+ return (char *)dev + ((sizeof(struct net_device)
+ + NETDEV_ALIGN_CONST)
+ & ~NETDEV_ALIGN_CONST);
}
/* Set the sysfs physical device reference for the network logical device
--
1.5.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 26/39]: netdev: netdev_priv() can now be sane again.
2008-07-03 7:04 [PATCH 26/39]: netdev: netdev_priv() can now be sane again David Miller
@ 2008-07-03 11:23 ` Krzysztof Halasa
2008-07-03 11:26 ` David Miller
0 siblings, 1 reply; 5+ messages in thread
From: Krzysztof Halasa @ 2008-07-03 11:23 UTC (permalink / raw)
To: David Miller
Cc: netdev, vinay, krkumar2, mchan, Matheos.Worku, linux-wireless
David Miller <davem@davemloft.net> writes:
> The private area of a netdev is now at a fixed offset once more.
>
> Unfortunately, some assumptions that netdev_priv() == netdev->priv
> crept back into the tree. In particular this happened in the
> loopback driver.
Perhaps the netdev_priv() should be renamed to avoid confusion?
--
Krzysztof Halasa
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 26/39]: netdev: netdev_priv() can now be sane again.
2008-07-03 11:23 ` Krzysztof Halasa
@ 2008-07-03 11:26 ` David Miller
2008-07-03 14:18 ` Krzysztof Halasa
0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2008-07-03 11:26 UTC (permalink / raw)
To: khc; +Cc: netdev, vinay, krkumar2, mchan, Matheos.Worku, linux-wireless
From: Krzysztof Halasa <khc@pm.waw.pl>
Date: Thu, 03 Jul 2008 13:23:32 +0200
> David Miller <davem@davemloft.net> writes:
>
> > The private area of a netdev is now at a fixed offset once more.
> >
> > Unfortunately, some assumptions that netdev_priv() == netdev->priv
> > crept back into the tree. In particular this happened in the
> > loopback driver.
>
> Perhaps the netdev_priv() should be renamed to avoid confusion?
If all drivers call netdev_priv(), there is no confusion :)
I plan to rename dev->priv to dev->_priv and fix all the fallout.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 26/39]: netdev: netdev_priv() can now be sane again.
2008-07-03 11:26 ` David Miller
@ 2008-07-03 14:18 ` Krzysztof Halasa
2008-07-03 22:55 ` David Miller
0 siblings, 1 reply; 5+ messages in thread
From: Krzysztof Halasa @ 2008-07-03 14:18 UTC (permalink / raw)
To: David Miller
Cc: netdev, vinay, krkumar2, mchan, Matheos.Worku, linux-wireless
David Miller <davem@davemloft.net> writes:
> If all drivers call netdev_priv(), there is no confusion :)
>
> I plan to rename dev->priv to dev->_priv and fix all the fallout.
Do you mean practically deleting dev->priv? That would make sense.
--
Krzysztof Halasa
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 26/39]: netdev: netdev_priv() can now be sane again.
2008-07-03 14:18 ` Krzysztof Halasa
@ 2008-07-03 22:55 ` David Miller
0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2008-07-03 22:55 UTC (permalink / raw)
To: khc; +Cc: netdev, vinay, krkumar2, mchan, Matheos.Worku, linux-wireless
From: Krzysztof Halasa <khc@pm.waw.pl>
Date: Thu, 03 Jul 2008 16:18:21 +0200
> David Miller <davem@davemloft.net> writes:
>
> > If all drivers call netdev_priv(), there is no confusion :)
> >
> > I plan to rename dev->priv to dev->_priv and fix all the fallout.
>
> Do you mean practically deleting dev->priv? That would make sense.
Yes, that's the basic idea. It's probably the only way to
prevent this problem in the future.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-07-03 22:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-03 7:04 [PATCH 26/39]: netdev: netdev_priv() can now be sane again David Miller
2008-07-03 11:23 ` Krzysztof Halasa
2008-07-03 11:26 ` David Miller
2008-07-03 14:18 ` Krzysztof Halasa
2008-07-03 22:55 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox