From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) by dpdk.org (Postfix) with ESMTP id DDCC816E for ; Tue, 12 Dec 2017 00:13:03 +0100 (CET) Received: by mail-pf0-f196.google.com with SMTP id u25so12721742pfg.5 for ; Mon, 11 Dec 2017 15:13:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=z+cqobotINWDuTjrJWL2gWHhKQDVqXwBd+vozTyaSB0=; b=ku0cVMPfoFpT8nhpWVLQFJUhi22dg4p37obY9RUg7lpraK0Owu20e1iG91OhimIbbL b/TtWYcJAPqHWxysH2FQ40JfxuwOBRsdtf0DzIiA76vpZU+qvmzlCjHyv8H4n85/GsFS YFxl3HUJEdD4BnmHrC1Lh61Z1E46+aAC6NDDlGnvMvmTZjRDqenoINLpNRhqyM80Eviz a8WkQAWgSWcJPZGdwAifzJL0eAlpxIMRFN5mWIDQBdCU3UKbQpuExPgsJtoOZNBQkRwb BmOtiZcXPXsgeAAxdfVE/XTcNqlRTs7gvyQ8+OQM1pwKxRXq3Wo1o9vYQnJx1oSbIOFX lzaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=z+cqobotINWDuTjrJWL2gWHhKQDVqXwBd+vozTyaSB0=; b=SlgLyIjVrNPLsUDMUQ0K6pyYg66xrXi2WRPhRVpWiuueUuvwX3J2LZKYoyPMGnFO/x rhYN0+BV+XU/X06MaHQjGuDueosiZmF/rj8lotN7UprFbYpL3y2/aZ7KLl42Hyg15fSd k5zYyuD6c69e2MhCVJwTIYjoSJj+rm8PQGZFDqBgJkerwn0CEbxFOA2oZ0m7BGp4+9CM NezFzEIpGrdQXjINqG+aTKIYOadKJj3UR94ejKRVCF/jk6OZwUH7kE0O3QYmm1d3qP9b 9MbzVAbsyVrwbI4PgdV0keRCu6sPVf1TvYNs3J21i4Xv7DdYw2SB7jTWKRb3pp7bcjCh ivoQ== X-Gm-Message-State: AKGB3mJCyeKDPw1Jwct2XcgsoACbMxsFsSXZgzSIV7GDutYreVa4SqbE Qr/3vFehKsAtlPFWtAbUK+883eHojL4= X-Google-Smtp-Source: ACJfBovahD6iKGji7RtJDtwBf+He5sQJVUX8Yavzc4ATCisNzLqk77b/XDrndCQi++AimI22YYQOfw== X-Received: by 10.98.74.19 with SMTP id x19mr182637pfa.43.1513033982580; Mon, 11 Dec 2017 15:13:02 -0800 (PST) Received: from localhost.localdomain (76-14-207-240.or.wavecable.com. [76.14.207.240]) by smtp.gmail.com with ESMTPSA id k23sm28984752pfj.22.2017.12.11.15.13.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Dec 2017 15:13:01 -0800 (PST) From: Stephen Hemminger X-Google-Original-From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Mon, 11 Dec 2017 15:12:58 -0800 Message-Id: <20171211231258.16494-1-sthemmin@microsoft.com> X-Mailer: git-send-email 2.11.0 Subject: [dpdk-dev] [PATCH] l3fwd: set cli back to unix style X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Dec 2017 23:13:04 -0000 The l3fwd program became chatty, and the code looks cluttered in recent versions. DPDK programs should try for Unix (not VMS) style and not print messages for the options user selected. Also, errors should be printed on stderr. To make it easier to find code matching error messages; error strings should be placed in situ rather than saved as string vaiables. Fixes: 268888b5b020 ("examples/l3fwd: modularize") Signed-off-by: Stephen Hemminger --- examples/l3fwd/main.c | 45 +++++++++++---------------------------------- 1 file changed, 11 insertions(+), 34 deletions(-) diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c index 6229568f2f19..501e18c8989d 100644 --- a/examples/l3fwd/main.c +++ b/examples/l3fwd/main.c @@ -307,7 +307,7 @@ init_lcore_rx_queues(void) static void print_usage(const char *prgname) { - printf("%s [EAL options] --" + fprintf(stderr, "%s [EAL options] --" " -p PORTMASK" " [-P]" " [-E]" @@ -537,22 +537,6 @@ parse_args(int argc, char **argv) argvopt = argv; /* Error or normal output strings. */ - const char *str1 = "L3FWD: Invalid portmask"; - const char *str2 = "L3FWD: Promiscuous mode selected"; - const char *str3 = "L3FWD: Exact match selected"; - const char *str4 = "L3FWD: Longest-prefix match selected"; - const char *str5 = "L3FWD: Invalid config"; - const char *str6 = "L3FWD: NUMA is disabled"; - const char *str7 = "L3FWD: IPV6 is specified"; - const char *str8 = - "L3FWD: Jumbo frame is enabled - disabling simple TX path"; - const char *str9 = "L3FWD: Invalid packet length"; - const char *str10 = "L3FWD: Set jumbo frame max packet len to "; - const char *str11 = "L3FWD: Invalid hash entry number"; - const char *str12 = - "L3FWD: LPM and EM are mutually exclusive, select only one"; - const char *str13 = "L3FWD: LPM or EM none selected, default LPM on"; - while ((opt = getopt_long(argc, argvopt, short_options, lgopts, &option_index)) != EOF) { @@ -561,24 +545,21 @@ parse_args(int argc, char **argv) case 'p': enabled_port_mask = parse_portmask(optarg); if (enabled_port_mask == 0) { - printf("%s\n", str1); + fprintf(stderr, "Invalid portmask\n"); print_usage(prgname); return -1; } break; case 'P': - printf("%s\n", str2); promiscuous_on = 1; break; case 'E': - printf("%s\n", str3); l3fwd_em_on = 1; break; case 'L': - printf("%s\n", str4); l3fwd_lpm_on = 1; break; @@ -586,7 +567,7 @@ parse_args(int argc, char **argv) case CMD_LINE_OPT_CONFIG_NUM: ret = parse_config(optarg); if (ret) { - printf("%s\n", str5); + fprintf(stderr, "Invalid config\n"); print_usage(prgname); return -1; } @@ -597,21 +578,19 @@ parse_args(int argc, char **argv) break; case CMD_LINE_OPT_NO_NUMA_NUM: - printf("%s\n", str6); numa_on = 0; break; case CMD_LINE_OPT_IPV6_NUM: - printf("%sn", str7); ipv6 = 1; break; case CMD_LINE_OPT_ENABLE_JUMBO_NUM: { - struct option lenopts = { + const struct option lenopts = { "max-pkt-len", required_argument, 0, 0 }; - printf("%s\n", str8); + port_conf.rxmode.jumbo_frame = 1; /* @@ -621,16 +600,14 @@ parse_args(int argc, char **argv) if (getopt_long(argc, argvopt, "", &lenopts, &option_index) == 0) { ret = parse_max_pkt_len(optarg); - if ((ret < 64) || - (ret > MAX_JUMBO_PKT_LEN)) { - printf("%s\n", str9); + if (ret < 64 || ret > MAX_JUMBO_PKT_LEN) { + fprintf(stderr, + "invalid maximum packet length\n"); print_usage(prgname); return -1; } port_conf.rxmode.max_rx_pkt_len = ret; } - printf("%s %u\n", str10, - (unsigned int)port_conf.rxmode.max_rx_pkt_len); break; } @@ -639,7 +616,7 @@ parse_args(int argc, char **argv) if ((ret > 0) && (ret <= L3FWD_HASH_ENTRIES)) { hash_entry_number = ret; } else { - printf("%s\n", str11); + fprintf(stderr, "invalid hash entry number\n"); print_usage(prgname); return -1; } @@ -658,7 +635,7 @@ parse_args(int argc, char **argv) /* If both LPM and EM are selected, return error. */ if (l3fwd_lpm_on && l3fwd_em_on) { - printf("%s\n", str12); + fprintf(stderr, "LPM and EM are mutually exclusive, select only one\n"); return -1; } @@ -667,8 +644,8 @@ parse_args(int argc, char **argv) * as default match. */ if (!l3fwd_lpm_on && !l3fwd_em_on) { + fprintf(stderr, "LPM or EM none selected, default LPM on\n"); l3fwd_lpm_on = 1; - printf("%s\n", str13); } /* -- 2.11.0