aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAntonio Quartulli <antonio@open-mesh.com>2013-04-19 12:07:00 -0400
committerAntonio Quartulli <ordex@autistici.org>2013-05-28 20:44:55 -0400
commiteb2deb6b39b1597577c1635e9ebf319f1ae02213 (patch)
tree94cea78183fa4e5da3245d8ac07ce8020f08ccc8 /net
parentaa27c31265f111ff73d948a5846a3f193376491e (diff)
batman-adv: change VID semantic in the BLA code
In order to make batman-adv fully vlan aware later, the semantic used for variables storing the VLAN ID values has to be changed in order to be adapted to the new one which will be used batman-adv wide. In particular, the VID has to be an "_unsigned_ short int" and its 4 MSB will be used as a flag bitfield, while the remaining 12 bits are used to store the real VID value Signed-off-by: Antonio Quartulli <antonio@open-mesh.com> Signed-off-by: Marek Lindner <lindner_marek@yahoo.de> Acked-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Diffstat (limited to 'net')
-rw-r--r--net/batman-adv/bridge_loop_avoidance.c51
-rw-r--r--net/batman-adv/bridge_loop_avoidance.h12
-rw-r--r--net/batman-adv/main.h11
-rw-r--r--net/batman-adv/soft-interface.c4
-rw-r--r--net/batman-adv/types.h4
5 files changed, 49 insertions, 33 deletions
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index 082189e2e40d..7354063567bd 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -180,7 +180,7 @@ static struct batadv_bla_claim
180 */ 180 */
181static struct batadv_bla_backbone_gw * 181static struct batadv_bla_backbone_gw *
182batadv_backbone_hash_find(struct batadv_priv *bat_priv, 182batadv_backbone_hash_find(struct batadv_priv *bat_priv,
183 uint8_t *addr, short vid) 183 uint8_t *addr, unsigned short vid)
184{ 184{
185 struct batadv_hashtable *hash = bat_priv->bla.backbone_hash; 185 struct batadv_hashtable *hash = bat_priv->bla.backbone_hash;
186 struct hlist_head *head; 186 struct hlist_head *head;
@@ -257,7 +257,7 @@ batadv_bla_del_backbone_claims(struct batadv_bla_backbone_gw *backbone_gw)
257 * @claimtype: the type of the claim (CLAIM, UNCLAIM, ANNOUNCE, ...) 257 * @claimtype: the type of the claim (CLAIM, UNCLAIM, ANNOUNCE, ...)
258 */ 258 */
259static void batadv_bla_send_claim(struct batadv_priv *bat_priv, uint8_t *mac, 259static void batadv_bla_send_claim(struct batadv_priv *bat_priv, uint8_t *mac,
260 short vid, int claimtype) 260 unsigned short vid, int claimtype)
261{ 261{
262 struct sk_buff *skb; 262 struct sk_buff *skb;
263 struct ethhdr *ethhdr; 263 struct ethhdr *ethhdr;
@@ -335,13 +335,14 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, uint8_t *mac,
335 memcpy(hw_src, mac, ETH_ALEN); 335 memcpy(hw_src, mac, ETH_ALEN);
336 memcpy(ethhdr->h_dest, mac, ETH_ALEN); 336 memcpy(ethhdr->h_dest, mac, ETH_ALEN);
337 batadv_dbg(BATADV_DBG_BLA, bat_priv, 337 batadv_dbg(BATADV_DBG_BLA, bat_priv,
338 "bla_send_claim(): REQUEST of %pM to %pMon vid %d\n", 338 "bla_send_claim(): REQUEST of %pM to %pM on vid %d\n",
339 ethhdr->h_source, ethhdr->h_dest, vid); 339 ethhdr->h_source, ethhdr->h_dest, vid);
340 break; 340 break;
341 } 341 }
342 342
343 if (vid != -1) 343 if (vid & BATADV_VLAN_HAS_TAG)
344 skb = vlan_insert_tag(skb, htons(ETH_P_8021Q), vid); 344 skb = vlan_insert_tag(skb, htons(ETH_P_8021Q),
345 vid & VLAN_VID_MASK);
345 346
346 skb_reset_mac_header(skb); 347 skb_reset_mac_header(skb);
347 skb->protocol = eth_type_trans(skb, soft_iface); 348 skb->protocol = eth_type_trans(skb, soft_iface);
@@ -367,7 +368,7 @@ out:
367 */ 368 */
368static struct batadv_bla_backbone_gw * 369static struct batadv_bla_backbone_gw *
369batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, uint8_t *orig, 370batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, uint8_t *orig,
370 short vid, bool own_backbone) 371 unsigned short vid, bool own_backbone)
371{ 372{
372 struct batadv_bla_backbone_gw *entry; 373 struct batadv_bla_backbone_gw *entry;
373 struct batadv_orig_node *orig_node; 374 struct batadv_orig_node *orig_node;
@@ -434,7 +435,7 @@ batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, uint8_t *orig,
434static void 435static void
435batadv_bla_update_own_backbone_gw(struct batadv_priv *bat_priv, 436batadv_bla_update_own_backbone_gw(struct batadv_priv *bat_priv,
436 struct batadv_hard_iface *primary_if, 437 struct batadv_hard_iface *primary_if,
437 short vid) 438 unsigned short vid)
438{ 439{
439 struct batadv_bla_backbone_gw *backbone_gw; 440 struct batadv_bla_backbone_gw *backbone_gw;
440 441
@@ -456,7 +457,7 @@ batadv_bla_update_own_backbone_gw(struct batadv_priv *bat_priv,
456 */ 457 */
457static void batadv_bla_answer_request(struct batadv_priv *bat_priv, 458static void batadv_bla_answer_request(struct batadv_priv *bat_priv,
458 struct batadv_hard_iface *primary_if, 459 struct batadv_hard_iface *primary_if,
459 short vid) 460 unsigned short vid)
460{ 461{
461 struct hlist_head *head; 462 struct hlist_head *head;
462 struct batadv_hashtable *hash; 463 struct batadv_hashtable *hash;
@@ -547,7 +548,7 @@ static void batadv_bla_send_announce(struct batadv_priv *bat_priv,
547 * @backbone_gw: the backbone gateway which claims it 548 * @backbone_gw: the backbone gateway which claims it
548 */ 549 */
549static void batadv_bla_add_claim(struct batadv_priv *bat_priv, 550static void batadv_bla_add_claim(struct batadv_priv *bat_priv,
550 const uint8_t *mac, const short vid, 551 const uint8_t *mac, const unsigned short vid,
551 struct batadv_bla_backbone_gw *backbone_gw) 552 struct batadv_bla_backbone_gw *backbone_gw)
552{ 553{
553 struct batadv_bla_claim *claim; 554 struct batadv_bla_claim *claim;
@@ -611,7 +612,7 @@ claim_free_ref:
611 * given mac address and vid. 612 * given mac address and vid.
612 */ 613 */
613static void batadv_bla_del_claim(struct batadv_priv *bat_priv, 614static void batadv_bla_del_claim(struct batadv_priv *bat_priv,
614 const uint8_t *mac, const short vid) 615 const uint8_t *mac, const unsigned short vid)
615{ 616{
616 struct batadv_bla_claim search_claim, *claim; 617 struct batadv_bla_claim search_claim, *claim;
617 618
@@ -637,7 +638,7 @@ static void batadv_bla_del_claim(struct batadv_priv *bat_priv,
637/* check for ANNOUNCE frame, return 1 if handled */ 638/* check for ANNOUNCE frame, return 1 if handled */
638static int batadv_handle_announce(struct batadv_priv *bat_priv, 639static int batadv_handle_announce(struct batadv_priv *bat_priv,
639 uint8_t *an_addr, uint8_t *backbone_addr, 640 uint8_t *an_addr, uint8_t *backbone_addr,
640 short vid) 641 unsigned short vid)
641{ 642{
642 struct batadv_bla_backbone_gw *backbone_gw; 643 struct batadv_bla_backbone_gw *backbone_gw;
643 uint16_t crc; 644 uint16_t crc;
@@ -685,7 +686,7 @@ static int batadv_handle_announce(struct batadv_priv *bat_priv,
685static int batadv_handle_request(struct batadv_priv *bat_priv, 686static int batadv_handle_request(struct batadv_priv *bat_priv,
686 struct batadv_hard_iface *primary_if, 687 struct batadv_hard_iface *primary_if,
687 uint8_t *backbone_addr, 688 uint8_t *backbone_addr,
688 struct ethhdr *ethhdr, short vid) 689 struct ethhdr *ethhdr, unsigned short vid)
689{ 690{
690 /* check for REQUEST frame */ 691 /* check for REQUEST frame */
691 if (!batadv_compare_eth(backbone_addr, ethhdr->h_dest)) 692 if (!batadv_compare_eth(backbone_addr, ethhdr->h_dest))
@@ -709,7 +710,7 @@ static int batadv_handle_request(struct batadv_priv *bat_priv,
709static int batadv_handle_unclaim(struct batadv_priv *bat_priv, 710static int batadv_handle_unclaim(struct batadv_priv *bat_priv,
710 struct batadv_hard_iface *primary_if, 711 struct batadv_hard_iface *primary_if,
711 uint8_t *backbone_addr, 712 uint8_t *backbone_addr,
712 uint8_t *claim_addr, short vid) 713 uint8_t *claim_addr, unsigned short vid)
713{ 714{
714 struct batadv_bla_backbone_gw *backbone_gw; 715 struct batadv_bla_backbone_gw *backbone_gw;
715 716
@@ -738,7 +739,7 @@ static int batadv_handle_unclaim(struct batadv_priv *bat_priv,
738static int batadv_handle_claim(struct batadv_priv *bat_priv, 739static int batadv_handle_claim(struct batadv_priv *bat_priv,
739 struct batadv_hard_iface *primary_if, 740 struct batadv_hard_iface *primary_if,
740 uint8_t *backbone_addr, uint8_t *claim_addr, 741 uint8_t *backbone_addr, uint8_t *claim_addr,
741 short vid) 742 unsigned short vid)
742{ 743{
743 struct batadv_bla_backbone_gw *backbone_gw; 744 struct batadv_bla_backbone_gw *backbone_gw;
744 745
@@ -861,7 +862,7 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv,
861 struct batadv_bla_claim_dst *bla_dst; 862 struct batadv_bla_claim_dst *bla_dst;
862 uint16_t proto; 863 uint16_t proto;
863 int headlen; 864 int headlen;
864 short vid = -1; 865 unsigned short vid = BATADV_NO_FLAGS;
865 int ret; 866 int ret;
866 867
867 ethhdr = eth_hdr(skb); 868 ethhdr = eth_hdr(skb);
@@ -869,6 +870,7 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv,
869 if (ntohs(ethhdr->h_proto) == ETH_P_8021Q) { 870 if (ntohs(ethhdr->h_proto) == ETH_P_8021Q) {
870 vhdr = (struct vlan_ethhdr *)ethhdr; 871 vhdr = (struct vlan_ethhdr *)ethhdr;
871 vid = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK; 872 vid = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK;
873 vid |= BATADV_VLAN_HAS_TAG;
872 proto = ntohs(vhdr->h_vlan_encapsulated_proto); 874 proto = ntohs(vhdr->h_vlan_encapsulated_proto);
873 headlen = sizeof(*vhdr); 875 headlen = sizeof(*vhdr);
874 } else { 876 } else {
@@ -1358,7 +1360,7 @@ int batadv_bla_is_backbone_gw(struct sk_buff *skb,
1358 struct ethhdr *ethhdr; 1360 struct ethhdr *ethhdr;
1359 struct vlan_ethhdr *vhdr; 1361 struct vlan_ethhdr *vhdr;
1360 struct batadv_bla_backbone_gw *backbone_gw; 1362 struct batadv_bla_backbone_gw *backbone_gw;
1361 short vid = -1; 1363 unsigned short vid = BATADV_NO_FLAGS;
1362 1364
1363 if (!atomic_read(&orig_node->bat_priv->bridge_loop_avoidance)) 1365 if (!atomic_read(&orig_node->bat_priv->bridge_loop_avoidance))
1364 return 0; 1366 return 0;
@@ -1375,6 +1377,7 @@ int batadv_bla_is_backbone_gw(struct sk_buff *skb,
1375 1377
1376 vhdr = (struct vlan_ethhdr *)(skb->data + hdr_size); 1378 vhdr = (struct vlan_ethhdr *)(skb->data + hdr_size);
1377 vid = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK; 1379 vid = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK;
1380 vid |= BATADV_VLAN_HAS_TAG;
1378 } 1381 }
1379 1382
1380 /* see if this originator is a backbone gw for this VLAN */ 1383 /* see if this originator is a backbone gw for this VLAN */
@@ -1424,8 +1427,8 @@ void batadv_bla_free(struct batadv_priv *bat_priv)
1424 * returns 1, otherwise it returns 0 and the caller shall further 1427 * returns 1, otherwise it returns 0 and the caller shall further
1425 * process the skb. 1428 * process the skb.
1426 */ 1429 */
1427int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid, 1430int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
1428 bool is_bcast) 1431 unsigned short vid, bool is_bcast)
1429{ 1432{
1430 struct ethhdr *ethhdr; 1433 struct ethhdr *ethhdr;
1431 struct batadv_bla_claim search_claim, *claim = NULL; 1434 struct batadv_bla_claim search_claim, *claim = NULL;
@@ -1519,7 +1522,8 @@ out:
1519 * returns 1, otherwise it returns 0 and the caller shall further 1522 * returns 1, otherwise it returns 0 and the caller shall further
1520 * process the skb. 1523 * process the skb.
1521 */ 1524 */
1522int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid) 1525int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
1526 unsigned short vid)
1523{ 1527{
1524 struct ethhdr *ethhdr; 1528 struct ethhdr *ethhdr;
1525 struct batadv_bla_claim search_claim, *claim = NULL; 1529 struct batadv_bla_claim search_claim, *claim = NULL;
@@ -1623,7 +1627,7 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
1623 hlist_for_each_entry_rcu(claim, head, hash_entry) { 1627 hlist_for_each_entry_rcu(claim, head, hash_entry) {
1624 is_own = batadv_compare_eth(claim->backbone_gw->orig, 1628 is_own = batadv_compare_eth(claim->backbone_gw->orig,
1625 primary_addr); 1629 primary_addr);
1626 seq_printf(seq, " * %pM on % 5d by %pM [%c] (%#.4x)\n", 1630 seq_printf(seq, " * %pM on %5d by %pM [%c] (%#.4x)\n",
1627 claim->addr, claim->vid, 1631 claim->addr, claim->vid,
1628 claim->backbone_gw->orig, 1632 claim->backbone_gw->orig,
1629 (is_own ? 'x' : ' '), 1633 (is_own ? 'x' : ' '),
@@ -1676,10 +1680,9 @@ int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, void *offset)
1676 if (is_own) 1680 if (is_own)
1677 continue; 1681 continue;
1678 1682
1679 seq_printf(seq, 1683 seq_printf(seq, " * %pM on %5d %4i.%03is (%#.4x)\n",
1680 " * %pM on % 5d % 4i.%03is (%#.4x)\n", 1684 backbone_gw->orig, backbone_gw->vid, secs,
1681 backbone_gw->orig, backbone_gw->vid, 1685 msecs, backbone_gw->crc);
1682 secs, msecs, backbone_gw->crc);
1683 } 1686 }
1684 rcu_read_unlock(); 1687 rcu_read_unlock();
1685 } 1688 }
diff --git a/net/batman-adv/bridge_loop_avoidance.h b/net/batman-adv/bridge_loop_avoidance.h
index dea2fbc5d98d..4b102e71e5bd 100644
--- a/net/batman-adv/bridge_loop_avoidance.h
+++ b/net/batman-adv/bridge_loop_avoidance.h
@@ -21,9 +21,10 @@
21#define _NET_BATMAN_ADV_BLA_H_ 21#define _NET_BATMAN_ADV_BLA_H_
22 22
23#ifdef CONFIG_BATMAN_ADV_BLA 23#ifdef CONFIG_BATMAN_ADV_BLA
24int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid, 24int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
25 bool is_bcast); 25 unsigned short vid, bool is_bcast);
26int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid); 26int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
27 unsigned short vid);
27int batadv_bla_is_backbone_gw(struct sk_buff *skb, 28int batadv_bla_is_backbone_gw(struct sk_buff *skb,
28 struct batadv_orig_node *orig_node, int hdr_size); 29 struct batadv_orig_node *orig_node, int hdr_size);
29int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset); 30int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset);
@@ -42,13 +43,14 @@ void batadv_bla_free(struct batadv_priv *bat_priv);
42#else /* ifdef CONFIG_BATMAN_ADV_BLA */ 43#else /* ifdef CONFIG_BATMAN_ADV_BLA */
43 44
44static inline int batadv_bla_rx(struct batadv_priv *bat_priv, 45static inline int batadv_bla_rx(struct batadv_priv *bat_priv,
45 struct sk_buff *skb, short vid, bool is_bcast) 46 struct sk_buff *skb, unsigned short vid,
47 bool is_bcast)
46{ 48{
47 return 0; 49 return 0;
48} 50}
49 51
50static inline int batadv_bla_tx(struct batadv_priv *bat_priv, 52static inline int batadv_bla_tx(struct batadv_priv *bat_priv,
51 struct sk_buff *skb, short vid) 53 struct sk_buff *skb, unsigned short vid)
52{ 54{
53 return 0; 55 return 0;
54} 56}
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index ea1a3bafe9c3..6f25ef29f305 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -162,6 +162,17 @@ enum batadv_uev_type {
162#include <linux/seq_file.h> 162#include <linux/seq_file.h>
163#include "types.h" 163#include "types.h"
164 164
165/**
166 * batadv_vlan_flags - flags for the four MSB of any vlan ID field
167 * @BATADV_VLAN_HAS_TAG: whether the field contains a valid vlan tag or not
168 */
169enum batadv_vlan_flags {
170 BATADV_VLAN_HAS_TAG = BIT(15),
171};
172
173#define BATADV_PRINT_VID(vid) (vid & BATADV_VLAN_HAS_TAG ? \
174 (int)(vid & VLAN_VID_MASK) : -1)
175
165extern char batadv_routing_algo[]; 176extern char batadv_routing_algo[];
166extern struct list_head batadv_hardif_list; 177extern struct list_head batadv_hardif_list;
167 178
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index b26a6cdb934c..700d0b49742d 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -154,7 +154,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
154 0x00, 0x00}; 154 0x00, 0x00};
155 unsigned int header_len = 0; 155 unsigned int header_len = 0;
156 int data_len = skb->len, ret; 156 int data_len = skb->len, ret;
157 short vid __maybe_unused = -1; 157 unsigned short vid __maybe_unused = BATADV_NO_FLAGS;
158 bool do_bcast = false; 158 bool do_bcast = false;
159 uint32_t seqno; 159 uint32_t seqno;
160 unsigned long brd_delay = 1; 160 unsigned long brd_delay = 1;
@@ -303,7 +303,7 @@ void batadv_interface_rx(struct net_device *soft_iface,
303 struct ethhdr *ethhdr; 303 struct ethhdr *ethhdr;
304 struct vlan_ethhdr *vhdr; 304 struct vlan_ethhdr *vhdr;
305 struct batadv_header *batadv_header = (struct batadv_header *)skb->data; 305 struct batadv_header *batadv_header = (struct batadv_header *)skb->data;
306 short vid __maybe_unused = -1; 306 unsigned short vid __maybe_unused = BATADV_NO_FLAGS;
307 __be16 ethertype = __constant_htons(ETH_P_BATMAN); 307 __be16 ethertype = __constant_htons(ETH_P_BATMAN);
308 bool is_bcast; 308 bool is_bcast;
309 309
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 5f542bdd9a4d..b2c94e139319 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -642,7 +642,7 @@ struct batadv_socket_packet {
642#ifdef CONFIG_BATMAN_ADV_BLA 642#ifdef CONFIG_BATMAN_ADV_BLA
643struct batadv_bla_backbone_gw { 643struct batadv_bla_backbone_gw {
644 uint8_t orig[ETH_ALEN]; 644 uint8_t orig[ETH_ALEN];
645 short vid; 645 unsigned short vid;
646 struct hlist_node hash_entry; 646 struct hlist_node hash_entry;
647 struct batadv_priv *bat_priv; 647 struct batadv_priv *bat_priv;
648 unsigned long lasttime; 648 unsigned long lasttime;
@@ -665,7 +665,7 @@ struct batadv_bla_backbone_gw {
665 */ 665 */
666struct batadv_bla_claim { 666struct batadv_bla_claim {
667 uint8_t addr[ETH_ALEN]; 667 uint8_t addr[ETH_ALEN];
668 short vid; 668 unsigned short vid;
669 struct batadv_bla_backbone_gw *backbone_gw; 669 struct batadv_bla_backbone_gw *backbone_gw;
670 unsigned long lasttime; 670 unsigned long lasttime;
671 struct hlist_node hash_entry; 671 struct hlist_node hash_entry;