diff mbox

[iproute] ipl2tp: Print help even on systems without l2tp support

Message ID 1456301567-32474-1-git-send-email-phil@nwl.cc
State Accepted, archived
Delegated to: stephen hemminger
Headers show

Commit Message

Phil Sutter Feb. 24, 2016, 8:12 a.m. UTC
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 ip/ipl2tp.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

stephen hemminger March 2, 2016, 5:33 p.m. UTC | #1
On Wed, 24 Feb 2016 09:12:47 +0100
Phil Sutter <phil@nwl.cc> wrote:

> Signed-off-by: Phil Sutter <phil@nwl.cc>

Applied
diff mbox

Patch

diff --git a/ip/ipl2tp.c b/ip/ipl2tp.c
index f050880eef02a..3e3b21ddfb7fe 100644
--- a/ip/ipl2tp.c
+++ b/ip/ipl2tp.c
@@ -720,6 +720,9 @@  static int do_show(int argc, char **argv)
 
 int do_ipl2tp(int argc, char **argv)
 {
+	if (argc < 1 || !matches(*argv, "help"))
+		usage();
+
 	if (genl_family < 0) {
 		if (rtnl_open_byproto(&genl_rth, 0, NETLINK_GENERIC) < 0) {
 			fprintf(stderr, "Cannot open generic netlink socket\n");
@@ -731,9 +734,6 @@  int do_ipl2tp(int argc, char **argv)
 			exit(1);
 	}
 
-	if (argc < 1)
-		usage();
-
 	if (matches(*argv, "add") == 0)
 		return do_add(argc-1, argv+1);
 	if (matches(*argv, "delete") == 0)
@@ -742,8 +742,6 @@  int do_ipl2tp(int argc, char **argv)
 	    matches(*argv, "lst") == 0 ||
 	    matches(*argv, "list") == 0)
 		return do_show(argc-1, argv+1);
-	if (matches(*argv, "help") == 0)
-		usage();
 
 	fprintf(stderr, "Command \"%s\" is unknown, try \"ip l2tp help\".\n", *argv);
 	exit(-1);