aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/soft-interface.c
diff options
context:
space:
mode:
authorAntonio Quartulli <antonio@open-mesh.com>2013-07-02 05:04:35 -0400
committerAntonio Quartulli <antonio@meshcoding.com>2013-10-19 11:28:42 -0400
commit90f4435da43191025712fdcf6b0dc09c018456e9 (patch)
tree6c74c3ad0053e06e3488282f1c39a2af38e88876 /net/batman-adv/soft-interface.c
parent5d2c05b213377694a2aa8ce1ed9b23f7c39b0569 (diff)
batman-adv: add sysfs framework for VLAN
Each VLAN can now have its own set of attributes which are exported through a new subfolder in the sysfs tree. Each VLAN created on top of a soft_iface will have its own subfolder. The subfolder is named "vlan%VID" and it is created inside the "mesh" sysfs folder belonging to batman-adv. Attributes corresponding to the untagged LAN are stored in the root sysfs folder as before. This patch also creates all the needed macros and data structures to easily handle new VLAN spacific attributes. 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.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 936b83bb02de..f74200c7e553 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -398,7 +398,7 @@ out:
398 * possibly free it 398 * possibly free it
399 * @softif_vlan: the vlan object to release 399 * @softif_vlan: the vlan object to release
400 */ 400 */
401static void batadv_softif_vlan_free_ref(struct batadv_softif_vlan *softif_vlan) 401void batadv_softif_vlan_free_ref(struct batadv_softif_vlan *softif_vlan)
402{ 402{
403 if (atomic_dec_and_test(&softif_vlan->refcount)) 403 if (atomic_dec_and_test(&softif_vlan->refcount))
404 kfree_rcu(softif_vlan, rcu); 404 kfree_rcu(softif_vlan, rcu);
@@ -412,8 +412,8 @@ static void batadv_softif_vlan_free_ref(struct batadv_softif_vlan *softif_vlan)
412 * Returns the private data of the vlan matching the vid passed as argument or 412 * Returns the private data of the vlan matching the vid passed as argument or
413 * NULL otherwise. The refcounter of the returned object is incremented by 1. 413 * NULL otherwise. The refcounter of the returned object is incremented by 1.
414 */ 414 */
415static struct batadv_softif_vlan * 415struct batadv_softif_vlan *batadv_softif_vlan_get(struct batadv_priv *bat_priv,
416batadv_softif_vlan_get(struct batadv_priv *bat_priv, unsigned short vid) 416 unsigned short vid)
417{ 417{
418 struct batadv_softif_vlan *vlan_tmp, *vlan = NULL; 418 struct batadv_softif_vlan *vlan_tmp, *vlan = NULL;
419 419
@@ -443,6 +443,7 @@ batadv_softif_vlan_get(struct batadv_priv *bat_priv, unsigned short vid)
443int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid) 443int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid)
444{ 444{
445 struct batadv_softif_vlan *vlan; 445 struct batadv_softif_vlan *vlan;
446 int err;
446 447
447 vlan = batadv_softif_vlan_get(bat_priv, vid); 448 vlan = batadv_softif_vlan_get(bat_priv, vid);
448 if (vlan) { 449 if (vlan) {
@@ -457,6 +458,12 @@ int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid)
457 vlan->vid = vid; 458 vlan->vid = vid;
458 atomic_set(&vlan->refcount, 1); 459 atomic_set(&vlan->refcount, 1);
459 460
461 err = batadv_sysfs_add_vlan(bat_priv->soft_iface, vlan);
462 if (err) {
463 kfree(vlan);
464 return err;
465 }
466
460 /* add a new TT local entry. This one will be marked with the NOPURGE 467 /* add a new TT local entry. This one will be marked with the NOPURGE
461 * flag 468 * flag
462 */ 469 */
@@ -483,6 +490,8 @@ static void batadv_softif_destroy_vlan(struct batadv_priv *bat_priv,
483 hlist_del_rcu(&vlan->list); 490 hlist_del_rcu(&vlan->list);
484 spin_unlock_bh(&bat_priv->softif_vlan_list_lock); 491 spin_unlock_bh(&bat_priv->softif_vlan_list_lock);
485 492
493 batadv_sysfs_del_vlan(bat_priv, vlan);
494
486 /* explicitly remove the associated TT local entry because it is marked 495 /* explicitly remove the associated TT local entry because it is marked
487 * with the NOPURGE flag 496 * with the NOPURGE flag
488 */ 497 */