From patchwork Wed Jul 13 15:30:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 16511 X-Patchwork-Delegate: mareklindner@neomailbox.ch Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [IPv6:::1]) by open-mesh.org (Postfix) with ESMTP id 57FCF82696; Wed, 13 Jul 2016 17:31:36 +0200 (CEST) Authentication-Results: open-mesh.org; dmarc=none header.from=narfation.org Authentication-Results: open-mesh.org; dkim=fail reason="verification failed; unprotected key" header.d=narfation.org header.i=@narfation.org header.b=FjhlWo8U; dkim-adsp=fail (unprotected policy); dkim-atps=neutral Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=79.140.41.39; helo=v3-1039.vlinux.de; envelope-from=sven@narfation.org; receiver=b.a.t.m.a.n@lists.open-mesh.org Authentication-Results: open-mesh.org; dmarc=pass header.from=narfation.org Received: from v3-1039.vlinux.de (narfation.org [79.140.41.39]) by open-mesh.org (Postfix) with ESMTPS id 9EC9282692 for ; Wed, 13 Jul 2016 17:30:37 +0200 (CEST) Received: from sven-desktop.home.narfation.org (p2003007C6F04E6FED85BF65F15063EF0.dip0.t-ipconnect.de [IPv6:2003:7c:6f04:e6fe:d85b:f65f:1506:3ef0]) by v3-1039.vlinux.de (Postfix) with ESMTPSA id E9FBB1100F1; Wed, 13 Jul 2016 17:30:36 +0200 (CEST) Authentication-Results: v3-1039.vlinux.de; dmarc=none header.from=narfation.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=narfation.org; s=20121; t=1468423837; bh=xGqueWJAFnkumabMAZSzqKWOAo3pg0M/v1wdB+Wj2jI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FjhlWo8UaO6ShuH3U6A+yqtrFauPBQRJGrT5mx8WzqXXt1xdYdXi4U7283oFTgnBp Exn9rwPXTLU5T0cr69AA/FqfSiC11TQM4Nagdw5NmPE4U3TzOEmNDPYHts6ZkfA08m j472uEHH1AiOnF5Kj9x85gGSt7YHaIDXSLHs4NuE= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Wed, 13 Jul 2016 17:30:20 +0200 Message-Id: <1468423822-28324-5-git-send-email-sven@narfation.org> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1468423822-28324-1-git-send-email-sven@narfation.org> References: <35819279.yt4EnXKmx6@bentobox> <1468423822-28324-1-git-send-email-sven@narfation.org> Subject: [B.A.T.M.A.N.] [PATCH 5/7] batctl: Allow to disable automatic interface new/destroy X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" Users may not want to lose their configured batman-adv soft-interface when they remove a single interface from it. The default configuration may not working well enough in the network setup of the user and thus it should be possible to avoid that it gets reset to it when a new interface is added after the last one was removed. This can be done by avoiding automatic creation of an interface when the command "add" is used together with the option "-M". The add would fail when the soft-interface disappeared for some reason and thus the soft-interface would not be created again with the default configuration. But more importantly, the "del" command can be informed with the option "-M" to not try to remove the soft-interface in the first place. Signed-off-by: Sven Eckelmann --- man/batctl.8 | 4 +++- sys.c | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/man/batctl.8 b/man/batctl.8 index 8dcf18a..0d77546 100644 --- a/man/batctl.8 +++ b/man/batctl.8 @@ -52,10 +52,12 @@ performances, is also included. .br .TP .I \fBcommands: -.IP "\fBinterface\fP|\fBif\fP [\fBadd\fP|\fBdel iface(s)\fP]" +.IP "\fBinterface\fP|\fBif\fP [\fB-M\fP] [\fBadd\fP|\fBdel iface(s)\fP]" If no parameter is given or the first parameter is neither "add" nor "del" the current interface settings are displayed. In order to add or delete interfaces specify "add" or "del" as first argument and append the interface names you wish to add or delete. Multiple interfaces can be specified. +The "\-M" option tells batctl to not automatically create the batman-adv interface on "add" or to destroy it when "del" +removed all interfaces which belonged to it. .IP "\fBinterface\fP|\fBif\fP [\fBnew\fP|\fBdestroy\fP]" A batman-adv interface without attached interfaces can be created using "new". The parameter "destroy" can be used to free all attached interfaces and remove batman-adv interface. diff --git a/sys.c b/sys.c index 7cd2690..88dd39f 100644 --- a/sys.c +++ b/sys.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -122,6 +123,7 @@ static void interface_usage(void) fprintf(stderr, "Usage: batctl [options] interface [parameters] [add|del iface(s)]\n"); fprintf(stderr, " batctl [options] interface [parameters] [new|destroy]\n"); fprintf(stderr, "parameters:\n"); + fprintf(stderr, " \t -M disable automatic creation/removal of batman-adv interface\n"); fprintf(stderr, " \t -h print this help\n"); } @@ -385,12 +387,16 @@ int interface(char *mesh_iface, int argc, char **argv) unsigned int cnt; int rest_argc; char **rest_argv; + bool manual_mode = false; - while ((optchar = getopt(argc, argv, "h")) != -1) { + while ((optchar = getopt(argc, argv, "hM")) != -1) { switch (optchar) { case 'h': interface_usage(); return EXIT_SUCCESS; + case 'M': + manual_mode = true; + break; default: interface_usage(); return EXIT_FAILURE; @@ -465,7 +471,7 @@ int interface(char *mesh_iface, int argc, char **argv) /* get index of batman-adv interface - or try to create it */ ifmaster = if_nametoindex(mesh_iface); - if (!ifmaster && rest_argv[0][0] == 'a') { + if (!manual_mode && !ifmaster && rest_argv[0][0] == 'a') { ret = new_interface(mesh_iface); if (ret < 0) { fprintf(stderr, @@ -518,7 +524,7 @@ int interface(char *mesh_iface, int argc, char **argv) } /* check if there is no interface left and then destroy mesh_iface */ - if (rest_argv[0][0] == 'd') { + if (!manual_mode && rest_argv[0][0] == 'd') { cnt = count_interfaces(mesh_iface); if (cnt == 0) destroy_interface(mesh_iface);