]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ila: show usage even if the module is not available
authorSabrina Dubroca <sd@queasysnail.net>
Tue, 16 Aug 2016 14:26:58 +0000 (16:26 +0200)
committerStephen Hemminger <sthemmin@microsoft.com>
Wed, 17 Aug 2016 21:00:28 +0000 (14:00 -0700)
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@queasysnail.net>
ip/ipila.c

index d75c4629778bb80d07cea9fe8a81b458db1c8ea4..843cc1652589f1c668af836215d2ce4234bca199 100644 (file)
@@ -240,20 +240,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);