From patchwork Mon Feb 11 09:10:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 2780 Return-Path: Received: from nm17-vm3.bullet.mail.sg3.yahoo.com (nm17-vm3.bullet.mail.sg3.yahoo.com [106.10.149.82]) by open-mesh.org (Postfix) with ESMTPS id 3B46E6013E6 for ; Mon, 11 Feb 2013 10:10:55 +0100 (CET) Received: from [106.10.166.114] by nm17.bullet.mail.sg3.yahoo.com with NNFMP; 11 Feb 2013 09:10:53 -0000 Received: from [106.10.167.173] by tm3.bullet.mail.sg3.yahoo.com with NNFMP; 11 Feb 2013 09:10:52 -0000 Received: from [127.0.0.1] by smtp146.mail.sg3.yahoo.com with NNFMP; 11 Feb 2013 09:10:52 -0000 X-Yahoo-Newman-Id: 708144.47489.bm@smtp146.mail.sg3.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: GGwiKRwVM1lWLWaJVRvI_kvbtmPwqqWPGth3Bh1hvXbZ63Y 06YM7.yyOh1WXnz14qniKUzDs8vyohX02GVwJMilr18aNX44uS4GUEALlx8y YMuC3WlWQQxsOFAnZuSLKJ2d9IPpm8kwGXR65tGGTFz9h_AK4FP5tFf3BOa0 gfab7J7Nh0HgNyUEjxZTushF2tPidcrjkYk3ChIDY52IgNyKiB74PvQ8fM4_ fHm6V8e9O_2zMFjVmHEqpyKWAzYFzYFYX07OWfHp3tUIVq7er_VVIgjfJSVk J.3ZRxKQXB7dN1XZpljGTK9Sst3y1ssN1dJ6Wo1C_tP1T5zHM6kWfNPepJor yvEKuY1GLjUjPYUfA8bs9LYuCIy55loyauotj5mg6c.NY2UOjjq.BCkDcF5u Tndo2oQHHFs83dlx0OiBsEjH6JLgmU8.SRNbTUnPiyEFh X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- Received: from localhost (lindner_marek@1.36.145.66 with plain) by smtp146.mail.sg3.yahoo.com with SMTP; 11 Feb 2013 01:10:52 -0800 PST From: Marek Lindner To: b.a.t.m.a.n@lists.open-mesh.org Date: Mon, 11 Feb 2013 17:10:24 +0800 Message-Id: <1360573828-24399-3-git-send-email-lindner_marek@yahoo.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1360573828-24399-1-git-send-email-lindner_marek@yahoo.de> References: <201302111710.04911.lindner_marek@yahoo.de> <1360573828-24399-1-git-send-email-lindner_marek@yahoo.de> Cc: Sven Eckelmann Subject: [B.A.T.M.A.N.] [PATCHv3 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: Mon, 11 Feb 2013 09:10:57 -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 ce39f62..15a22ef 100644 --- a/sysfs.c +++ b/sysfs.c @@ -588,13 +588,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);