netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: More vlan tests before registering netdevice
@ 2014-12-31  6:35 Yuval Mintz
  2015-01-02 20:56 ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Yuval Mintz @ 2014-12-31  6:35 UTC (permalink / raw)
  To: davem; +Cc: netdev, Yuval Mintz

When register_netdevice() is called, netdevice's vlan filtering feature
and supplied callbacks are checked to see the vlan implementation is
not buggy.
This adds an additional test - see that the vlan_features were filled
correctly, as the vlan devices inherits those as its own features;
Incorrect values set there would later prevent the vlan interface from being
registered itself [as it doesn't implement the filtering ndos].

Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
---
Hi Dave,

Not sure why take such a defensive approach regarding this feature.
Perhaps it would have been better to simply remove these checks altogether.

Cheers,
Yuval
---

 net/core/dev.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 3f191da..8a663b2 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6253,10 +6253,11 @@ int register_netdevice(struct net_device *dev)
 		}
 	}
 
-	if (((dev->hw_features | dev->features) &
-	     NETIF_F_HW_VLAN_CTAG_FILTER) &&
-	    (!dev->netdev_ops->ndo_vlan_rx_add_vid ||
-	     !dev->netdev_ops->ndo_vlan_rx_kill_vid)) {
+	if ((((dev->hw_features | dev->features) &
+	      NETIF_F_HW_VLAN_CTAG_FILTER) &&
+	     (!dev->netdev_ops->ndo_vlan_rx_add_vid ||
+	      !dev->netdev_ops->ndo_vlan_rx_kill_vid)) ||
+	    (dev->vlan_features & NETIF_F_HW_VLAN_CTAG_FILTER) {
 		netdev_WARN(dev, "Buggy VLAN acceleration in driver!\n");
 		ret = -EINVAL;
 		goto err_uninit;
-- 
1.9.3

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

* Re: [PATCH net-next] net: More vlan tests before registering netdevice
  2014-12-31  6:35 [PATCH net-next] net: More vlan tests before registering netdevice Yuval Mintz
@ 2015-01-02 20:56 ` David Miller
  2015-01-02 20:57   ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2015-01-02 20:56 UTC (permalink / raw)
  To: Yuval.Mintz; +Cc: netdev

From: Yuval Mintz <Yuval.Mintz@qlogic.com>
Date: Wed, 31 Dec 2014 08:35:36 +0200

> When register_netdevice() is called, netdevice's vlan filtering feature
> and supplied callbacks are checked to see the vlan implementation is
> not buggy.
> This adds an additional test - see that the vlan_features were filled
> correctly, as the vlan devices inherits those as its own features;
> Incorrect values set there would later prevent the vlan interface from being
> registered itself [as it doesn't implement the filtering ndos].
> 
> Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
 ...
> Not sure why take such a defensive approach regarding this feature.
> Perhaps it would have been better to simply remove these checks altogether.

I guess this is fine as a defensive test, so I'll apply this.

But do you actually know of any devices which have violated this rule
either now or in the past?  I quickly tried to audit the entire tree
for this right now and found no problems.

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

* Re: [PATCH net-next] net: More vlan tests before registering netdevice
  2015-01-02 20:56 ` David Miller
@ 2015-01-02 20:57   ` David Miller
  2015-01-04  6:32     ` Yuval Mintz
  0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2015-01-02 20:57 UTC (permalink / raw)
  To: Yuval.Mintz; +Cc: netdev

From: David Miller <davem@davemloft.net>
Date: Fri, 02 Jan 2015 15:56:21 -0500 (EST)

> From: Yuval Mintz <Yuval.Mintz@qlogic.com>
> Date: Wed, 31 Dec 2014 08:35:36 +0200
> 
>> When register_netdevice() is called, netdevice's vlan filtering feature
>> and supplied callbacks are checked to see the vlan implementation is
>> not buggy.
>> This adds an additional test - see that the vlan_features were filled
>> correctly, as the vlan devices inherits those as its own features;
>> Incorrect values set there would later prevent the vlan interface from being
>> registered itself [as it doesn't implement the filtering ndos].
>> 
>> Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
>  ...
>> Not sure why take such a defensive approach regarding this feature.
>> Perhaps it would have been better to simply remove these checks altogether.
> 
> I guess this is fine as a defensive test, so I'll apply this.

Actually, reverted.

Nothing makes me more angry than a patch that wasn't even build tested:

net/core/dev.c: In function ‘register_netdevice’:
net/core/dev.c:6285:57: error: expected ‘)’ before ‘{’ token
net/core/dev.c:6378:1: error: expected expression before ‘}’ token
net/core/dev.c:6277:4: error: label ‘out’ used but not defined
net/core/dev.c:6378:1: warning: control reaches end of non-void function [-Wreturn-type]

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

* RE: [PATCH net-next] net: More vlan tests before registering netdevice
  2015-01-02 20:57   ` David Miller
@ 2015-01-04  6:32     ` Yuval Mintz
  0 siblings, 0 replies; 4+ messages in thread
From: Yuval Mintz @ 2015-01-04  6:32 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

> > I guess this is fine as a defensive test, so I'll apply this.
> > But do you actually know of any devices which have violated this rule either 
> > now or in the past?
> > I quickly tried to audit the entire tree for this right now and found no problems.
> 
> Actually, reverted.
> 
> Nothing makes me more angry than a patch that wasn't even build tested:
> 
> net/core/dev.c: In function ‘register_netdevice’:
> net/core/dev.c:6285:57: error: expected ‘)’ before ‘{’ token
> net/core/dev.c:6378:1: error: expected expression before ‘}’ token
> net/core/dev.c:6277:4: error: label ‘out’ used but not defined
> net/core/dev.c:6378:1: warning: control reaches end of non-void function [-
> Wreturn-type]

Sorry about that.
Don't know how that happened, but obviously I can't make any excuses.

Regarding your previous question - I hit it while implementing vlan filtering
offload on a new [yet-to-be-published] qlogic driver; Don't know if anyone
actually had that issue in-tree.

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

end of thread, other threads:[~2015-01-04  6:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-31  6:35 [PATCH net-next] net: More vlan tests before registering netdevice Yuval Mintz
2015-01-02 20:56 ` David Miller
2015-01-02 20:57   ` David Miller
2015-01-04  6:32     ` Yuval Mintz

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).