aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/soft-interface.c
diff options
context:
space:
mode:
authorAntonio Quartulli <antonio@open-mesh.com>2013-06-04 06:11:39 -0400
committerAntonio Quartulli <antonio@meshcoding.com>2013-10-19 09:11:21 -0400
commitc018ad3de61a1dc4194879a53e5559e094aa7b1a (patch)
tree4edb9c156b618dae46d38249a5c817e0d1f1e2b0 /net/batman-adv/soft-interface.c
parentbc58eeef744df93e141678ef44452f0869cd563d (diff)
batman-adv: add the VLAN ID attribute to the TT entry
To make the translation table code VLAN-aware, each entry must carry the VLAN ID which it belongs to. This patch adds such attribute to the related TT structures. Signed-off-by: Antonio Quartulli <antonio@open-mesh.com> Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Diffstat (limited to 'net/batman-adv/soft-interface.c')
-rw-r--r--net/batman-adv/soft-interface.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index e8a2bd699d40..279e91d570a7 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -118,9 +118,10 @@ static int batadv_interface_set_mac_addr(struct net_device *dev, void *p)
118 118
119 /* only modify transtable if it has been initialized before */ 119 /* only modify transtable if it has been initialized before */
120 if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_ACTIVE) { 120 if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_ACTIVE) {
121 batadv_tt_local_remove(bat_priv, old_addr, 121 batadv_tt_local_remove(bat_priv, old_addr, BATADV_NO_FLAGS,
122 "mac address changed", false); 122 "mac address changed", false);
123 batadv_tt_local_add(dev, addr->sa_data, BATADV_NULL_IFINDEX); 123 batadv_tt_local_add(dev, addr->sa_data, BATADV_NO_FLAGS,
124 BATADV_NULL_IFINDEX);
124 } 125 }
125 126
126 return 0; 127 return 0;
@@ -152,33 +153,33 @@ static void batadv_interface_set_rx_mode(struct net_device *dev)
152static int batadv_interface_tx(struct sk_buff *skb, 153static int batadv_interface_tx(struct sk_buff *skb,
153 struct net_device *soft_iface) 154 struct net_device *soft_iface)
154{ 155{
155 struct ethhdr *ethhdr = (struct ethhdr *)skb->data; 156 struct ethhdr *ethhdr;
156 struct batadv_priv *bat_priv = netdev_priv(soft_iface); 157 struct batadv_priv *bat_priv = netdev_priv(soft_iface);
157 struct batadv_hard_iface *primary_if = NULL; 158 struct batadv_hard_iface *primary_if = NULL;
158 struct batadv_bcast_packet *bcast_packet; 159 struct batadv_bcast_packet *bcast_packet;
159 struct vlan_ethhdr *vhdr;
160 __be16 ethertype = htons(ETH_P_BATMAN); 160 __be16 ethertype = htons(ETH_P_BATMAN);
161 static const uint8_t stp_addr[ETH_ALEN] = {0x01, 0x80, 0xC2, 0x00, 161 static const uint8_t stp_addr[ETH_ALEN] = {0x01, 0x80, 0xC2, 0x00,
162 0x00, 0x00}; 162 0x00, 0x00};
163 static const uint8_t ectp_addr[ETH_ALEN] = {0xCF, 0x00, 0x00, 0x00, 163 static const uint8_t ectp_addr[ETH_ALEN] = {0xCF, 0x00, 0x00, 0x00,
164 0x00, 0x00}; 164 0x00, 0x00};
165 struct vlan_ethhdr *vhdr;
165 unsigned int header_len = 0; 166 unsigned int header_len = 0;
166 int data_len = skb->len, ret; 167 int data_len = skb->len, ret;
167 unsigned short vid __maybe_unused = BATADV_NO_FLAGS; 168 unsigned long brd_delay = 1;
168 bool do_bcast = false; 169 bool do_bcast = false;
170 unsigned short vid;
169 uint32_t seqno; 171 uint32_t seqno;
170 unsigned long brd_delay = 1;
171 172
172 if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE) 173 if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE)
173 goto dropped; 174 goto dropped;
174 175
175 soft_iface->trans_start = jiffies; 176 soft_iface->trans_start = jiffies;
177 vid = batadv_get_vid(skb, 0);
178 ethhdr = (struct ethhdr *)skb->data;
176 179
177 switch (ntohs(ethhdr->h_proto)) { 180 switch (ntohs(ethhdr->h_proto)) {
178 case ETH_P_8021Q: 181 case ETH_P_8021Q:
179 vhdr = (struct vlan_ethhdr *)skb->data; 182 vhdr = (struct vlan_ethhdr *)skb->data;
180 vid = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK;
181 vid |= BATADV_VLAN_HAS_TAG;
182 183
183 if (vhdr->h_vlan_encapsulated_proto != ethertype) 184 if (vhdr->h_vlan_encapsulated_proto != ethertype)
184 break; 185 break;
@@ -196,7 +197,8 @@ static int batadv_interface_tx(struct sk_buff *skb,
196 197
197 /* Register the client MAC in the transtable */ 198 /* Register the client MAC in the transtable */
198 if (!is_multicast_ether_addr(ethhdr->h_source)) 199 if (!is_multicast_ether_addr(ethhdr->h_source))
199 batadv_tt_local_add(soft_iface, ethhdr->h_source, skb->skb_iif); 200 batadv_tt_local_add(soft_iface, ethhdr->h_source, vid,
201 skb->skb_iif);
200 202
201 /* don't accept stp packets. STP does not help in meshes. 203 /* don't accept stp packets. STP does not help in meshes.
202 * better use the bridge loop avoidance ... 204 * better use the bridge loop avoidance ...
@@ -296,7 +298,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
296 298
297 batadv_dat_snoop_outgoing_arp_reply(bat_priv, skb); 299 batadv_dat_snoop_outgoing_arp_reply(bat_priv, skb);
298 300
299 ret = batadv_send_skb_unicast(bat_priv, skb); 301 ret = batadv_send_skb_unicast(bat_priv, skb, vid);
300 if (ret != 0) 302 if (ret != 0)
301 goto dropped_freed; 303 goto dropped_freed;
302 } 304 }
@@ -319,12 +321,12 @@ void batadv_interface_rx(struct net_device *soft_iface,
319 struct sk_buff *skb, struct batadv_hard_iface *recv_if, 321 struct sk_buff *skb, struct batadv_hard_iface *recv_if,
320 int hdr_size, struct batadv_orig_node *orig_node) 322 int hdr_size, struct batadv_orig_node *orig_node)
321{ 323{
322 struct batadv_priv *bat_priv = netdev_priv(soft_iface);
323 struct ethhdr *ethhdr;
324 struct vlan_ethhdr *vhdr;
325 struct batadv_header *batadv_header = (struct batadv_header *)skb->data; 324 struct batadv_header *batadv_header = (struct batadv_header *)skb->data;
326 unsigned short vid __maybe_unused = BATADV_NO_FLAGS; 325 struct batadv_priv *bat_priv = netdev_priv(soft_iface);
327 __be16 ethertype = htons(ETH_P_BATMAN); 326 __be16 ethertype = htons(ETH_P_BATMAN);
327 struct vlan_ethhdr *vhdr;
328 struct ethhdr *ethhdr;
329 unsigned short vid;
328 bool is_bcast; 330 bool is_bcast;
329 331
330 is_bcast = (batadv_header->packet_type == BATADV_BCAST); 332 is_bcast = (batadv_header->packet_type == BATADV_BCAST);
@@ -336,13 +338,12 @@ void batadv_interface_rx(struct net_device *soft_iface,
336 skb_pull_rcsum(skb, hdr_size); 338 skb_pull_rcsum(skb, hdr_size);
337 skb_reset_mac_header(skb); 339 skb_reset_mac_header(skb);
338 340
341 vid = batadv_get_vid(skb, hdr_size);
339 ethhdr = eth_hdr(skb); 342 ethhdr = eth_hdr(skb);
340 343
341 switch (ntohs(ethhdr->h_proto)) { 344 switch (ntohs(ethhdr->h_proto)) {
342 case ETH_P_8021Q: 345 case ETH_P_8021Q:
343 vhdr = (struct vlan_ethhdr *)skb->data; 346 vhdr = (struct vlan_ethhdr *)skb->data;
344 vid = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK;
345 vid |= BATADV_VLAN_HAS_TAG;
346 347
347 if (vhdr->h_vlan_encapsulated_proto != ethertype) 348 if (vhdr->h_vlan_encapsulated_proto != ethertype)
348 break; 349 break;
@@ -378,7 +379,7 @@ void batadv_interface_rx(struct net_device *soft_iface,
378 379
379 if (orig_node) 380 if (orig_node)
380 batadv_tt_add_temporary_global_entry(bat_priv, orig_node, 381 batadv_tt_add_temporary_global_entry(bat_priv, orig_node,
381 ethhdr->h_source); 382 ethhdr->h_source, vid);
382 383
383 if (batadv_is_ap_isolated(bat_priv, ethhdr->h_source, ethhdr->h_dest)) 384 if (batadv_is_ap_isolated(bat_priv, ethhdr->h_source, ethhdr->h_dest))
384 goto dropped; 385 goto dropped;