netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: netdev@vger.kernel.org, davem@davemloft.net,
	Sven Eckelmann <sven@narfation.org>
Subject: [PATCH 3/7] batman-adv: Don't always delete softif when last slave was removed
Date: Sat, 24 Nov 2012 01:02:08 +0100	[thread overview]
Message-ID: <1353715332-4284-3-git-send-email-sven@narfation.org> (raw)
In-Reply-To: <1353715332-4284-1-git-send-email-sven@narfation.org>

batman-adv has an unusual way to manage softinterfaces. These will be created
automatically when a user writes to the batman-adv/mesh_iface file in sysfs and
removed when no slave device exists anymore.

This behaviour cannot be changed without breaking compatibility with existing
code. Instead other interfaces should be able to slightly reduce this behaviour
and provide a more common reaction to a removal of a slave interface.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 net/batman-adv/hard-interface.c |    8 +++++---
 net/batman-adv/hard-interface.h |   13 ++++++++++++-
 net/batman-adv/sysfs.c          |    6 ++++--
 3 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index 50f4a5c..daeb632 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -407,7 +407,8 @@ err:
 	return ret;
 }
 
-void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface)
+void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface,
+				     enum batadv_hard_if_cleanup autodel)
 {
 	struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
 	struct batadv_hard_iface *primary_if = NULL;
@@ -445,7 +446,7 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface)
 	dev_put(hard_iface->soft_iface);
 
 	/* nobody uses this interface anymore */
-	if (!bat_priv->num_ifaces)
+	if (!bat_priv->num_ifaces && autodel == BATADV_IF_CLEANUP_AUTO)
 		batadv_softif_destroy(hard_iface->soft_iface);
 
 	hard_iface->soft_iface = NULL;
@@ -511,7 +512,8 @@ static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface)
 
 	/* first deactivate interface */
 	if (hard_iface->if_status != BATADV_IF_NOT_IN_USE)
-		batadv_hardif_disable_interface(hard_iface);
+		batadv_hardif_disable_interface(hard_iface,
+						BATADV_IF_CLEANUP_AUTO);
 
 	if (hard_iface->if_status != BATADV_IF_NOT_IN_USE)
 		return;
diff --git a/net/batman-adv/hard-interface.h b/net/batman-adv/hard-interface.h
index 3732366..34cf367 100644
--- a/net/batman-adv/hard-interface.h
+++ b/net/batman-adv/hard-interface.h
@@ -29,13 +29,24 @@ enum batadv_hard_if_state {
 	BATADV_IF_I_WANT_YOU,
 };
 
+/**
+ * enum batadv_hard_if_cleanup - Cleanup modi for soft_iface after slave removal
+ * @BATADV_IF_CLEANUP_KEEP: Don't automatically delete soft-interface
+ * @BATADV_IF_CLEANUP_AUTO: Delete soft-interface after last slave was removed
+ */
+enum batadv_hard_if_cleanup {
+	BATADV_IF_CLEANUP_KEEP,
+	BATADV_IF_CLEANUP_AUTO,
+};
+
 extern struct notifier_block batadv_hard_if_notifier;
 
 struct batadv_hard_iface*
 batadv_hardif_get_by_netdev(const struct net_device *net_dev);
 int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
 				   const char *iface_name);
-void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface);
+void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface,
+				     enum batadv_hard_if_cleanup autodel);
 void batadv_hardif_remove_interfaces(void);
 int batadv_hardif_min_mtu(struct net_device *soft_iface);
 void batadv_update_min_mtu(struct net_device *soft_iface);
diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c
index 84a55cb..5d868d3 100644
--- a/net/batman-adv/sysfs.c
+++ b/net/batman-adv/sysfs.c
@@ -582,13 +582,15 @@ static ssize_t batadv_store_mesh_iface(struct kobject *kobj,
 	}
 
 	if (status_tmp == BATADV_IF_NOT_IN_USE) {
-		batadv_hardif_disable_interface(hard_iface);
+		batadv_hardif_disable_interface(hard_iface,
+						BATADV_IF_CLEANUP_AUTO);
 		goto unlock;
 	}
 
 	/* if the interface already is in use */
 	if (hard_iface->if_status != BATADV_IF_NOT_IN_USE)
-		batadv_hardif_disable_interface(hard_iface);
+		batadv_hardif_disable_interface(hard_iface,
+						BATADV_IF_CLEANUP_AUTO);
 
 	ret = batadv_hardif_enable_interface(hard_iface, buff);
 
-- 
1.7.10.4

  parent reply	other threads:[~2012-11-24  0:02 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-24  0:02 [PATCH 1/7] batman-adv: Move soft-interface initialization to ndo_init Sven Eckelmann
2012-11-24  0:02 ` [PATCH 2/7] batman-adv: Move deinitialization of soft-interface to destructor Sven Eckelmann
2012-11-24  0:02 ` Sven Eckelmann [this message]
2012-11-24  0:02 ` [PATCH 4/7] batman-adv: Remove slave interfaces before removing master interface Sven Eckelmann
2012-11-24  0:02 ` [PATCH 5/7] batman-adv: Allow to postpone softif unregistration Sven Eckelmann
2012-11-24  0:02 ` [PATCH 6/7] batman-adv: Allow to use rntl_link for device creation/deletion Sven Eckelmann
     [not found]   ` <20121201131108.GL24115@ritirata.org>
     [not found]     ` <20121201131108.GL24115-E/2OGukznS5g9hUCZPvPmw@public.gmane.org>
2012-12-01 13:16       ` Sven Eckelmann
2012-12-01 13:28         ` Re: [B.A.T.M.A.N.] " Antonio Quartulli
     [not found]           ` <20121201132802.GM24115-E/2OGukznS5g9hUCZPvPmw@public.gmane.org>
2012-12-01 13:39             ` Sven Eckelmann
2012-12-01 14:54               ` Re: Re: [B.A.T.M.A.N.] " Antonio Quartulli
2012-11-24  0:02 ` [PATCH 7/7] batman-adv: Allow to modify slaves of soft-interfaces through rntl_link Sven Eckelmann
2012-11-24 20:59 ` [PATCH 1/7] batman-adv: Move soft-interface initialization to ndo_init David Miller
     [not found]   ` <20121124.155902.1261596975089040930.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-11-24 21:23     ` Sven Eckelmann
2012-12-24 14:22 ` Pau Koning
     [not found]   ` <CANiGF9_=svx+W4Rhx8BL1NBv0H1aULeh71sX9YkMeR66OmmimA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-12-24 14:37     ` Marek Lindner
     [not found]       ` <201212242237.07208.lindner_marek-LWAfsSFWpa4@public.gmane.org>
2012-12-24 15:36         ` Pau Koning
2012-12-24 19:37           ` [B.A.T.M.A.N.] " Marek Lindner
2012-12-24 23:18             ` Pau Koning
     [not found]               ` <CANiGF9_4QP0ts2kV9Bruk_8L7h1870LMcrRhtsYu35q=COF0hQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-12-25  8:19                 ` Marek Lindner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1353715332-4284-3-git-send-email-sven@narfation.org \
    --to=sven@narfation.org \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).