[maintv2] batman-adv: replace WARN with rate limited output on non-existing VLAN

Message ID 1463071923-27298-1-git-send-email-sw@simonwunderlich.de (mailing list archive)
State Accepted, archived
Commit 04792115d24408a72bf8fccd5c4059478fc15eae
Delegated to: Marek Lindner
Headers

Commit Message

Simon Wunderlich May 12, 2016, 4:52 p.m. UTC
  If a VLAN tagged frame is received and the corresponding VLAN is not
configured on the soft interface, it will splat a WARN on every packet
received. This is a quite annoying behaviour for some scenarios, e.g. if
bat0 is bridged with eth0, and there are arbitrary VLAN tagged frames
from Ethernet coming in without having any VLAN configuration on bat0.

The code should probably create vlan objects on the fly and
transparently transport these VLAN-tagged Ethernet frames, but until
this is done, at least the WARN splat should be replaced by a rate
limited output.

Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
Changes to PATCH-maint:
 * added newline to output
---
 net/batman-adv/translation-table.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
  

Comments

Marek Lindner May 17, 2016, 9:12 a.m. UTC | #1
On Thursday, May 12, 2016 18:52:03 Simon Wunderlich wrote:
> If a VLAN tagged frame is received and the corresponding VLAN is not
> configured on the soft interface, it will splat a WARN on every packet
> received. This is a quite annoying behaviour for some scenarios, e.g. if
> bat0 is bridged with eth0, and there are arbitrary VLAN tagged frames
> from Ethernet coming in without having any VLAN configuration on bat0.
> 
> The code should probably create vlan objects on the fly and
> transparently transport these VLAN-tagged Ethernet frames, but until
> this is done, at least the WARN splat should be replaced by a rate
> limited output.
> 
> Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
> ---
> Changes to PATCH-maint:
>  * added newline to output
> ---
>  net/batman-adv/translation-table.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

Applied in revision 0479211.

Thanks,
Marek
  
Andreas Pape May 20, 2016, 10:05 a.m. UTC | #2
Hi,

this is a point I also stumbled across. In my use case the problem is a
little bit
more difficult.
I use a setup with bat interfaces bridged to ethernet interfaces and my
mesh nodes
shall forward layer2 transparently network traffic from the wired network
into the
mesh.

My problem now is that among the layer2 traffic there are also vlan tagged
frames
whereas the bat interface isn't member of the vlan to be forwarded itself.

More specific in my case the frames use vlan id 0 and are tagged mainly
due to the
reason to guarantee some QoS in the wired network.

Yes, I know one might argue what reason QoS priority tagging has in mesh
setups, but
these frames are not generated by my devices but I have to forward them
"as they are".

As far as I understood the code, these frames do not only lead to the WARN
messages
(and there I welcome Simon's patch) but also lead to a drop of the tagged
packets
(correct ?). If I understood this correctly I would prefer that batman
would handle
vlan tagged packets on layer 2 like an unmanaged switch does: still
forward such
packets according to the mac header.

What do you think?

Kind regards,
Andreas


..................................................................
PHOENIX CONTACT ELECTRONICS GmbH

Sitz der Gesellschaft / registered office of the company: 31812 Bad Pyrmont
USt-Id-Nr.: DE811742156
Amtsgericht Hannover HRB 100528 / district court Hannover HRB 100528
Geschäftsführer / Executive Board: Roland Bent, Dr. Martin Heubeck
  
Simon Wunderlich May 20, 2016, 10:34 a.m. UTC | #3
Hi Andreas,

On Friday 20 May 2016 12:05:35 Andreas Pape wrote:
> Hi,
> 
> this is a point I also stumbled across. In my use case the problem is a
> little bit
> more difficult.
> I use a setup with bat interfaces bridged to ethernet interfaces and my
> mesh nodes
> shall forward layer2 transparently network traffic from the wired network
> into the
> mesh.
> 
> My problem now is that among the layer2 traffic there are also vlan tagged
> frames
> whereas the bat interface isn't member of the vlan to be forwarded itself.
> 
> More specific in my case the frames use vlan id 0 and are tagged mainly
> due to the
> reason to guarantee some QoS in the wired network.
> 
> Yes, I know one might argue what reason QoS priority tagging has in mesh
> setups, but
> these frames are not generated by my devices but I have to forward them
> "as they are".
> 
> As far as I understood the code, these frames do not only lead to the WARN
> messages
> (and there I welcome Simon's patch) but also lead to a drop of the tagged
> packets
> (correct ?). If I understood this correctly I would prefer that batman
> would handle
> vlan tagged packets on layer 2 like an unmanaged switch does: still
> forward such
> packets according to the mac header.
> 
> What do you think?

I completely agree, this is what I'd expect from batman-adv to do. However, 
currently this isn't the case as you have noticed already.

As a workaround, you could create vlan interfaces like bat0.0 and eth0.0 and 
bridge those.

However in the long run, I think we should change the TT/VLAN code to create 
vlan objects on the fly when we get packets and remove those vlan objects when 
the corresponding TT local entries are gone (and no VLAN is actually 
configured). I've put this on my list of things I'll try to work on at some 
point, if anyone wants to prepare a patch before me please go ahead ... :)

Cheers,
      Simon
  

Patch

diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 9b4551a..48adb91 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -650,8 +650,10 @@  bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr,
 
 	/* increase the refcounter of the related vlan */
 	vlan = batadv_softif_vlan_get(bat_priv, vid);
-	if (WARN(!vlan, "adding TT local entry %pM to non-existent VLAN %d",
-		 addr, BATADV_PRINT_VID(vid))) {
+	if (!vlan) {
+		net_ratelimited_function(batadv_info, soft_iface,
+					 "adding TT local entry %pM to non-existent VLAN %d\n",
+					 addr, BATADV_PRINT_VID(vid));
 		kfree(tt_local);
 		tt_local = NULL;
 		goto out;