netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: jbohac@suse.cz
Cc: kaber@trash.net, netdev@vger.kernel.org, pedro.netdev@dondevamos.com
Subject: Re: [PATCH 1/2] vlan: only create special VLAN 0 once
Date: Sun, 05 Jun 2011 14:28:23 -0700 (PDT)	[thread overview]
Message-ID: <20110605.142823.1727360496050285755.davem@davemloft.net> (raw)
In-Reply-To: <20110603200738.GA24804@midget.suse.cz>

From: Jiri Bohac <jbohac@suse.cz>
Date: Fri, 3 Jun 2011 22:07:38 +0200

> Commit ad1afb00 registers a VLAN with vid == 0 for every device to handle
> 802.1p frames.  This is currently done on every NETDEV_UP event and the special
> vlan is never unregistered.  This may have strange effects on drivers
> implementning ndo_vlan_rx_add_vid(). E.g. bonding will allocate a linked-list
> element each time, causing a memory leak.
> 
> Only register the special VLAN once on NETDEV_REGISTER.
> 
> Signed-off-by: Jiri Bohac <jbohac@suse.cz>

I recognize the problem, but this solution isn't all that good.

I am pretty sure that the hardware device driver methods that
implement ndo_vlan_rx_add_vid() assume that the device is up.
Because most drivers completely reset the chip when the
interface is brought up and this will likely clear out the
VLAN ID tables in the chip.

Second, now even devices which don't ever get brought up will
have the VLAN ID 0 thing allocated.

Probably the thing to do is to remove the VLAN ID 0 entry on
NETDEV_DOWN.

Something like:

diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index c7a581a..135019d 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -379,6 +379,14 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
 		dev->netdev_ops->ndo_vlan_rx_add_vid(dev, 0);
 	}
 
+	if ((event == NETDEV_DOWN) &&
+	    (dev->features & NETIF_F_HW_VLAN_FILTER) &&
+	    dev->netdev_ops->ndo_vlan_rx_kill_vid) {
+		pr_info("8021q: removing VLAN 0 from HW filter on device %s\n",
+			dev->name);
+		dev->netdev_ops->ndo_vlan_rx_kill_vid(dev, 0);
+	}
+
 	grp = rtnl_dereference(dev->vlgrp);
 	if (!grp)
 		goto out;

  parent reply	other threads:[~2011-06-05 21:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-03 20:07 [PATCH 1/2] vlan: only create special VLAN 0 once Jiri Bohac
2011-06-03 20:14 ` [PATCH 2/2] bonding: restore NETIF_F_VLAN_CHALLENGED properly in bond_del_vlan() Jiri Bohac
2011-06-04  0:26   ` Jay Vosburgh
2011-06-10 20:27     ` Jiri Bohac
2011-06-10 22:25       ` Jay Vosburgh
2011-06-11 23:13       ` David Miller
2011-06-05 21:28 ` David Miller [this message]
2011-06-07 15:17   ` [PATCH 1/2] vlan: only create special VLAN 0 once Patrick McHardy
2011-06-07 16:41     ` Jiri Bohac
2011-06-07 22:50       ` Patrick McHardy
2011-06-07 16:18   ` Jiri Bohac
2011-06-08  1:25     ` Jesse Gross
2011-06-09  0:01       ` David Miller

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=20110605.142823.1727360496050285755.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=jbohac@suse.cz \
    --cc=kaber@trash.net \
    --cc=netdev@vger.kernel.org \
    --cc=pedro.netdev@dondevamos.com \
    /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).