From 90f4435da43191025712fdcf6b0dc09c018456e9 Mon Sep 17 00:00:00 2001 From: Antonio Quartulli Date: Tue, 2 Jul 2013 11:04:35 +0200 Subject: 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 Signed-off-by: Marek Lindner --- net/batman-adv/soft-interface.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'net/batman-adv/soft-interface.c') 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: * possibly free it * @softif_vlan: the vlan object to release */ -static void batadv_softif_vlan_free_ref(struct batadv_softif_vlan *softif_vlan) +void batadv_softif_vlan_free_ref(struct batadv_softif_vlan *softif_vlan) { if (atomic_dec_and_test(&softif_vlan->refcount)) kfree_rcu(softif_vlan, rcu); @@ -412,8 +412,8 @@ static void batadv_softif_vlan_free_ref(struct batadv_softif_vlan *softif_vlan) * Returns the private data of the vlan matching the vid passed as argument or * NULL otherwise. The refcounter of the returned object is incremented by 1. */ -static struct batadv_softif_vlan * -batadv_softif_vlan_get(struct batadv_priv *bat_priv, unsigned short vid) +struct batadv_softif_vlan *batadv_softif_vlan_get(struct batadv_priv *bat_priv, + unsigned short vid) { struct batadv_softif_vlan *vlan_tmp, *vlan = NULL; @@ -443,6 +443,7 @@ batadv_softif_vlan_get(struct batadv_priv *bat_priv, unsigned short vid) int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid) { struct batadv_softif_vlan *vlan; + int err; vlan = batadv_softif_vlan_get(bat_priv, vid); if (vlan) { @@ -457,6 +458,12 @@ int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid) vlan->vid = vid; atomic_set(&vlan->refcount, 1); + err = batadv_sysfs_add_vlan(bat_priv->soft_iface, vlan); + if (err) { + kfree(vlan); + return err; + } + /* add a new TT local entry. This one will be marked with the NOPURGE * flag */ @@ -483,6 +490,8 @@ static void batadv_softif_destroy_vlan(struct batadv_priv *bat_priv, hlist_del_rcu(&vlan->list); spin_unlock_bh(&bat_priv->softif_vlan_list_lock); + batadv_sysfs_del_vlan(bat_priv, vlan); + /* explicitly remove the associated TT local entry because it is marked * with the NOPURGE flag */ -- cgit v1.2.3-59-g8ed1b