Skip to content

Commit e4b420d

Browse files
committed
batman-adv: avoid adding unused VLAN IDs
This ports the following, (mostly) pending patches to batman-adv v2024.3: ef7304a25220 batman-adv: avoid adding bridge VLAN IDs through ndo_vlan_rx_add_vid() eaa064600666 batman-adv: add dynamic, bridged-in TT VID detection support 6f166f584737 batman-adv: Map VID 0 to untagged TT VLAN This should reduce (half?) the OGM overhead. Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
1 parent 017dd23 commit e4b420d

3 files changed

Lines changed: 675 additions & 0 deletions
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
From 6f166f5847375d3e50f6e0b4161f890fe9ef408d Mon Sep 17 00:00:00 2001
2+
From: Sven Eckelmann <sven@narfation.org>
3+
Date: Mon, 16 Dec 2024 19:37:12 +0100
4+
Subject: [PATCH 1/3] batman-adv: Map VID 0 to untagged TT VLAN
5+
MIME-Version: 1.0
6+
Content-Type: text/plain; charset=UTF-8
7+
Content-Transfer-Encoding: 8bit
8+
9+
VID 0 is not a valid VLAN according to "802.1Q-2011" "Table 9-2—Reserved
10+
VID values". It is only used to indicate "priority tag" frames which only
11+
contain priority information and no VID.
12+
13+
The 8021q is also redirecting the priority tagged frames to the underlying
14+
interface since commit ad1afb003939 ("vlan_dev: VLAN 0 should be treated as
15+
"no vlan tag" (802.1p packet)"). But at the same time, it automatically
16+
adds the VID 0 to all devices to ensure that VID 0 is in the allowed list
17+
of the HW filter. This resulted in a VLAN 0 which was always announced in
18+
OGM messages.
19+
20+
batman-adv should therefore not create a new batadv_softif_vlan for VID 0
21+
and handle all VID 0 related frames using the "untagged" global/local
22+
translation tables.
23+
24+
Acked-by: Antonio Quartulli <antonio@mandelbit.com>
25+
Signed-off-by: Sven Eckelmann <sven@narfation.org>
26+
---
27+
net/batman-adv/main.c | 7 +++++++
28+
net/batman-adv/soft-interface.c | 14 ++++++++++++++
29+
2 files changed, 21 insertions(+)
30+
31+
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
32+
index 8acbf33234b6..bbb6ed5869de 100644
33+
--- a/net/batman-adv/main.c
34+
+++ b/net/batman-adv/main.c
35+
@@ -637,6 +637,13 @@ unsigned short batadv_get_vid(struct sk_buff *skb, size_t header_len)
36+
37+
vhdr = (struct vlan_ethhdr *)(skb->data + header_len);
38+
vid = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK;
39+
+
40+
+ /* VID 0 is only used to indicate "priority tag" frames which only
41+
+ * contain priority information and no VID.
42+
+ */
43+
+ if (vid == 0)
44+
+ return BATADV_NO_FLAGS;
45+
+
46+
vid |= BATADV_VLAN_HAS_TAG;
47+
48+
return vid;
49+
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
50+
index 5f4b13a593fd..bdc64be545ff 100644
51+
--- a/net/batman-adv/soft-interface.c
52+
+++ b/net/batman-adv/soft-interface.c
53+
@@ -677,6 +677,14 @@ static int batadv_interface_add_vid(struct net_device *dev, __be16 proto,
54+
if (proto != htons(ETH_P_8021Q))
55+
return -EINVAL;
56+
57+
+ /* VID 0 is only used to indicate "priority tag" frames which only
58+
+ * contain priority information and no VID. No management structures
59+
+ * should be created for this VID and it should be handled like an
60+
+ * untagged frame.
61+
+ */
62+
+ if (vid == 0)
63+
+ return 0;
64+
+
65+
vid |= BATADV_VLAN_HAS_TAG;
66+
67+
/* if a new vlan is getting created and it already exists, it means that
68+
@@ -724,6 +732,12 @@ static int batadv_interface_kill_vid(struct net_device *dev, __be16 proto,
69+
if (proto != htons(ETH_P_8021Q))
70+
return -EINVAL;
71+
72+
+ /* "priority tag" frames are handled like "untagged" frames
73+
+ * and no softif_vlan needs to be destroyed
74+
+ */
75+
+ if (vid == 0)
76+
+ return 0;
77+
+
78+
vlan = batadv_softif_vlan_get(bat_priv, vid | BATADV_VLAN_HAS_TAG);
79+
if (!vlan)
80+
return -ENOENT;
81+
--
82+
2.47.2
83+

0 commit comments

Comments
 (0)