From patchwork Sun Jan 13 09:51:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 2706 Return-Path: Received: from nm19.bullet.mail.sg3.yahoo.com (nm19.bullet.mail.sg3.yahoo.com [106.10.148.70]) by open-mesh.org (Postfix) with ESMTPS id A992F601AFF for ; Sun, 13 Jan 2013 10:51:30 +0100 (CET) Received: from [106.10.166.118] by nm19.bullet.mail.sg3.yahoo.com with NNFMP; 13 Jan 2013 09:51:25 -0000 Received: from [106.10.167.225] by tm7.bullet.mail.sg3.yahoo.com with NNFMP; 13 Jan 2013 09:51:25 -0000 Received: from [127.0.0.1] by smtp198.mail.sg3.yahoo.com with NNFMP; 13 Jan 2013 09:51:25 -0000 X-Yahoo-Newman-Id: 780815.46002.bm@smtp198.mail.sg3.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: Ul9R.XYVM1kt6gKVhMb9nuzZFVID7vdvnpF94R0iSCjnfVn 8MSqxku1glgLq3UvmVKslR09f2Xjp.AYB9khIfULlD4Y56IQXSpdSQS4y5b8 zvqBMBAjFhwUa93Aa3_zquKLa2DTVsGs_ZX.cBd2jVgruH2p9RV.LINtdUHf 6uLIBhBQOTi2XNpnyiFZhf7dh9M8Pw0VmTn38jwQPwopaOQy0pAVK1F_IWpu eLMTsW7aG57Ka2hBAVoZPhpih2ZaJ4ZyqjMEzft709yH9JVEO4wLGTD0pfe4 goOwCxXQeiYK5TZrI7DYfvmzBtXFdbPYBy3sdRO25gxUCZj9dmvOJsMDZ3nv yJ6F3PfuDFb0uFPkdnhYuCaM5qIiXhwkSJdrfQb5Fl3ybHVBDuEeg1NcSk1y L2yA9P4lCBLrKUbbYYoKwPxmR1fKnOR6bBS99LDs8FIyc X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- Received: from localhost (lindner_marek@1.36.145.67 with plain) by smtp198.mail.sg3.yahoo.com with SMTP; 13 Jan 2013 01:51:25 -0800 PST From: Marek Lindner To: b.a.t.m.a.n@lists.open-mesh.org Date: Sun, 13 Jan 2013 17:51:00 +0800 Message-Id: <1358070663-8226-3-git-send-email-lindner_marek@yahoo.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1358070663-8226-1-git-send-email-lindner_marek@yahoo.de> References: <201301131750.39338.lindner_marek@yahoo.de> <1358070663-8226-1-git-send-email-lindner_marek@yahoo.de> Cc: Sven Eckelmann Subject: [B.A.T.M.A.N.] [PATCHv2 3/6] batman-adv: Don't always delete softif when last slave was removed X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Jan 2013 09:51:32 -0000 From: Sven Eckelmann 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 --- hard-interface.c | 8 +++++--- hard-interface.h | 13 ++++++++++++- sysfs.c | 6 ++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/hard-interface.c b/hard-interface.c index da000e9..74e3ec2 100644 --- a/hard-interface.c +++ b/hard-interface.c @@ -408,7 +408,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; @@ -446,7 +447,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; @@ -533,7 +534,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/hard-interface.h b/hard-interface.h index 308437d..4989288 100644 --- a/hard-interface.h +++ b/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/sysfs.c b/sysfs.c index afbba31..c507fbb 100644 --- a/sysfs.c +++ b/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);