[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <c9d33e1e1779cb9808346e8f3073b49cff7c2707.1471356460.git.sd@queasysnail.net>
Date: Tue, 16 Aug 2016 16:26:58 +0200
From: Sabrina Dubroca <sd@...asysnail.net>
To: netdev@...r.kernel.org
Cc: Phil Sutter <phil@....cc>,
Stephen Hemminger <stephen@...workplumber.org>,
Sabrina Dubroca <sd@...asysnail.net>
Subject: [PATCH iproute2 4/4] ila: show usage even if the module is not available
Currently, the `ip ila` command tries to initialize a genl context
even when we just want to see the help for the command, which doesn't
require to talk to the kernel at all.
Delay genl initialization, which can fail if the module isn't loaded,
until the point where we will actually need it.
Fixes: ec71cae0bb7b ("ila: Support for configuring ila to use netfilter hook")
Signed-off-by: Sabrina Dubroca <sd@...asysnail.net>
---
ip/ipila.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/ip/ipila.c b/ip/ipila.c
index 244245ca3c40..27f55e961a43 100644
--- a/ip/ipila.c
+++ b/ip/ipila.c
@@ -237,20 +237,21 @@ static int do_del(int argc, char **argv)
int do_ipila(int argc, char **argv)
{
- if (genl_init_handle(&genl_rth, ILA_GENL_NAME, &genl_family))
- exit(1);
-
if (argc < 1)
usage();
+ if (matches(*argv, "help") == 0)
+ usage();
+
+ if (genl_init_handle(&genl_rth, ILA_GENL_NAME, &genl_family))
+ exit(1);
+
if (matches(*argv, "add") == 0)
return do_add(argc-1, argv+1);
if (matches(*argv, "delete") == 0)
return do_del(argc-1, argv+1);
if (matches(*argv, "list") == 0)
return do_list(argc-1, argv+1);
- if (matches(*argv, "help") == 0)
- usage();
fprintf(stderr, "Command \"%s\" is unknown, try \"ip ila help\".\n",
*argv);
--
2.9.3
Powered by blists - more mailing lists