Commit b8cbd81d0944cd2dc097b2b4ae8adaf639c5b4df

Authored by Antonio Quartulli
Committed by Antonio Quartulli
1 parent 90f4435da4

batman-adv: make the AP isolation attribute VLAN specific

AP isolation has to be enabled on one VLAN interface only.
This patch moves the AP isolation attribute to the per-vlan
interface attribute set, enabling it to have a different
value depending on the selected vlan.

Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>

Showing 6 changed files with 33 additions and 16 deletions Side-by-side Diff

Documentation/ABI/testing/sysfs-class-net-mesh
... ... @@ -6,13 +6,14 @@
6 6 Indicates whether the batman protocol messages of the
7 7 mesh <mesh_iface> shall be aggregated or not.
8 8  
9   -What: /sys/class/net/<mesh_iface>/mesh/ap_isolation
  9 +What: /sys/class/net/<mesh_iface>/mesh/<vlan_subdir>/ap_isolation
10 10 Date: May 2011
11 11 Contact: Antonio Quartulli <antonio@meshcoding.com>
12 12 Description:
13 13 Indicates whether the data traffic going from a
14 14 wireless client to another wireless client will be
15   - silently dropped.
  15 + silently dropped. <vlan_subdir> is empty when referring
  16 + to the untagged lan.
16 17  
17 18 What: /sys/class/net/<mesh_iface>/mesh/bonding
18 19 Date: June 2010
net/batman-adv/soft-interface.c
... ... @@ -381,7 +381,8 @@
381 381 batadv_tt_add_temporary_global_entry(bat_priv, orig_node,
382 382 ethhdr->h_source, vid);
383 383  
384   - 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,
  385 + vid))
385 386 goto dropped;
386 387  
387 388 netif_rx(skb);
... ... @@ -458,6 +459,8 @@
458 459 vlan->vid = vid;
459 460 atomic_set(&vlan->refcount, 1);
460 461  
  462 + atomic_set(&vlan->ap_isolation, 0);
  463 +
461 464 err = batadv_sysfs_add_vlan(bat_priv->soft_iface, vlan);
462 465 if (err) {
463 466 kfree(vlan);
... ... @@ -657,7 +660,6 @@
657 660 #ifdef CONFIG_BATMAN_ADV_DAT
658 661 atomic_set(&bat_priv->distributed_arp_table, 1);
659 662 #endif
660   - atomic_set(&bat_priv->ap_isolation, 0);
661 663 atomic_set(&bat_priv->gw_mode, BATADV_GW_MODE_OFF);
662 664 atomic_set(&bat_priv->gw_sel_class, 20);
663 665 atomic_set(&bat_priv->gw.bandwidth_down, 100);
net/batman-adv/sysfs.c
... ... @@ -453,7 +453,6 @@
453 453 batadv_dat_status_update);
454 454 #endif
455 455 BATADV_ATTR_SIF_BOOL(fragmentation, S_IRUGO | S_IWUSR, batadv_update_min_mtu);
456   -BATADV_ATTR_SIF_BOOL(ap_isolation, S_IRUGO | S_IWUSR, NULL);
457 456 static BATADV_ATTR(routing_algo, S_IRUGO, batadv_show_bat_algo, NULL);
458 457 static BATADV_ATTR(gw_mode, S_IRUGO | S_IWUSR, batadv_show_gw_mode,
459 458 batadv_store_gw_mode);
... ... @@ -483,7 +482,6 @@
483 482 &batadv_attr_distributed_arp_table,
484 483 #endif
485 484 &batadv_attr_fragmentation,
486   - &batadv_attr_ap_isolation,
487 485 &batadv_attr_routing_algo,
488 486 &batadv_attr_gw_mode,
489 487 &batadv_attr_orig_interval,
490 488  
... ... @@ -499,10 +497,13 @@
499 497 NULL,
500 498 };
501 499  
  500 +BATADV_ATTR_VLAN_BOOL(ap_isolation, S_IRUGO | S_IWUSR, NULL);
  501 +
502 502 /**
503 503 * batadv_vlan_attrs - array of vlan specific sysfs attributes
504 504 */
505 505 static struct batadv_attribute *batadv_vlan_attrs[] = {
  506 + &batadv_attr_vlan_ap_isolation,
506 507 NULL,
507 508 };
508 509  
net/batman-adv/translation-table.c
... ... @@ -1482,8 +1482,19 @@
1482 1482 struct batadv_tt_global_entry *tt_global_entry = NULL;
1483 1483 struct batadv_orig_node *orig_node = NULL;
1484 1484 struct batadv_tt_orig_list_entry *best_entry;
  1485 + bool ap_isolation_enabled = false;
  1486 + struct batadv_softif_vlan *vlan;
1485 1487  
1486   - if (src && atomic_read(&bat_priv->ap_isolation)) {
  1488 + /* if the AP isolation is requested on a VLAN, then check for its
  1489 + * setting in the proper VLAN private data structure
  1490 + */
  1491 + vlan = batadv_softif_vlan_get(bat_priv, vid);
  1492 + if (vlan) {
  1493 + ap_isolation_enabled = atomic_read(&vlan->ap_isolation);
  1494 + batadv_softif_vlan_free_ref(vlan);
  1495 + }
  1496 +
  1497 + if (src && ap_isolation_enabled) {
1487 1498 tt_local_entry = batadv_tt_local_hash_find(bat_priv, src, vid);
1488 1499 if (!tt_local_entry ||
1489 1500 (tt_local_entry->common.flags & BATADV_TT_CLIENT_PENDING))
1490 1501  
1491 1502  
1492 1503  
1493 1504  
... ... @@ -2547,22 +2558,22 @@
2547 2558 }
2548 2559  
2549 2560 bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, uint8_t *src,
2550   - uint8_t *dst)
  2561 + uint8_t *dst, unsigned short vid)
2551 2562 {
2552 2563 struct batadv_tt_local_entry *tt_local_entry = NULL;
2553 2564 struct batadv_tt_global_entry *tt_global_entry = NULL;
  2565 + struct batadv_softif_vlan *vlan;
2554 2566 bool ret = false;
2555 2567  
2556   - if (!atomic_read(&bat_priv->ap_isolation))
  2568 + vlan = batadv_softif_vlan_get(bat_priv, vid);
  2569 + if (!vlan || !atomic_read(&vlan->ap_isolation))
2557 2570 goto out;
2558 2571  
2559   - tt_local_entry = batadv_tt_local_hash_find(bat_priv, dst,
2560   - BATADV_NO_FLAGS);
  2572 + tt_local_entry = batadv_tt_local_hash_find(bat_priv, dst, vid);
2561 2573 if (!tt_local_entry)
2562 2574 goto out;
2563 2575  
2564   - tt_global_entry = batadv_tt_global_hash_find(bat_priv, src,
2565   - BATADV_NO_FLAGS);
  2576 + tt_global_entry = batadv_tt_global_hash_find(bat_priv, src, vid);
2566 2577 if (!tt_global_entry)
2567 2578 goto out;
2568 2579  
... ... @@ -2572,6 +2583,8 @@
2572 2583 ret = true;
2573 2584  
2574 2585 out:
  2586 + if (vlan)
  2587 + batadv_softif_vlan_free_ref(vlan);
2575 2588 if (tt_global_entry)
2576 2589 batadv_tt_global_entry_free_ref(tt_global_entry);
2577 2590 if (tt_local_entry)
net/batman-adv/translation-table.h
... ... @@ -39,7 +39,7 @@
39 39 bool batadv_is_my_client(struct batadv_priv *bat_priv, const uint8_t *addr,
40 40 unsigned short vid);
41 41 bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, uint8_t *src,
42   - uint8_t *dst);
  42 + uint8_t *dst, unsigned short vid);
43 43 void batadv_tt_local_commit_changes(struct batadv_priv *bat_priv);
44 44 bool batadv_tt_global_client_is_roaming(struct batadv_priv *bat_priv,
45 45 uint8_t *addr, unsigned short vid);
net/batman-adv/types.h
... ... @@ -534,6 +534,7 @@
534 534 * struct batadv_softif_vlan - per VLAN attributes set
535 535 * @vid: VLAN identifier
536 536 * @kobj: kobject for sysfs vlan subdirectory
  537 + * @ap_isolation: AP isolation state
537 538 * @list: list node for bat_priv::softif_vlan_list
538 539 * @refcount: number of context where this object is currently in use
539 540 * @rcu: struct used for freeing in a RCU-safe manner
... ... @@ -541,6 +542,7 @@
541 542 struct batadv_softif_vlan {
542 543 unsigned short vid;
543 544 struct kobject *kobj;
  545 + atomic_t ap_isolation; /* boolean */
544 546 struct hlist_node list;
545 547 atomic_t refcount;
546 548 struct rcu_head rcu;
... ... @@ -556,7 +558,6 @@
556 558 * @bonding: bool indicating whether traffic bonding is enabled
557 559 * @fragmentation: bool indicating whether traffic fragmentation is enabled
558 560 * @frag_seqno: incremental counter to identify chains of egress fragments
559   - * @ap_isolation: bool indicating whether ap isolation is enabled
560 561 * @bridge_loop_avoidance: bool indicating whether bridge loop avoidance is
561 562 * enabled
562 563 * @distributed_arp_table: bool indicating whether distributed ARP table is
... ... @@ -603,7 +604,6 @@
603 604 atomic_t bonding;
604 605 atomic_t fragmentation;
605 606 atomic_t frag_seqno;
606   - atomic_t ap_isolation;
607 607 #ifdef CONFIG_BATMAN_ADV_BLA
608 608 atomic_t bridge_loop_avoidance;
609 609 #endif