From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 64ED0A0032; Mon, 12 Sep 2022 21:03:35 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EBD8A40151; Mon, 12 Sep 2022 21:03:34 +0200 (CEST) Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by mails.dpdk.org (Postfix) with ESMTP id 5EC89400D5 for ; Mon, 12 Sep 2022 21:03:34 +0200 (CEST) Received: by mail-pl1-f170.google.com with SMTP id iw17so9515398plb.0 for ; Mon, 12 Sep 2022 12:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=3DMCwEIOo0AGEAww/R6nljq+5JWsxkTj/yHZCfniD6s=; b=JSHo3f8+fsqJMpWdp1tz00ZPHojLyt4yyHZ1R9OzLs1EnH50Q3Cp8ZDTQ31sMP2BFq aOhpeJpEFf69Slfw+9pCVhUpEdyY7Ay5UvwFQRuI1T7HAjCpFIAoPb1rbzJaihjt1xJq SBACwI8AHz+EwCkyY6o53nlQa2j7NICY/aVSasw+vFQbUjthqOMWVcJh5PuGBO7/6xBy zxqaN1bkptEoarB2x6sUmKG5JqMB5ltwWidzi6ixBk7bv+LTgwVO0xWS81nWVME3f26k t4lQW7DFua33PsdnGcSmSvsaNN80Xe0TYBT6jQHdbu76ndHaxGblskkhptrpFOdijCJq JZ0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=3DMCwEIOo0AGEAww/R6nljq+5JWsxkTj/yHZCfniD6s=; b=Y8kjj46+2yUoXfK3PWCUZiaBR7eQRY4b22oHs2mON8BIfDlnKOUZDJOBcdQMGReVyZ mjm4ecJZggO/RgJp5Jh56oyBBgMDnBs/r8jaVHkoTkmVGHq9EeNA3GCz71yBnO8R0ayN u4uoFMggG7ssFjhxSXMNlRoPadUvrhEnsr6yqX+ROT63IG0vEToLVnnc8pMsUq3UP1Aq t+beDaJyziMhK2usfRtqmukc//CwWdBsIFT84Ss79wfh3ZULNeJ1mPKRA/vShH3dd3EC 5P54g6rEg7Vae+Ozd45WOeCNh9yIBHrRJmH8RaV58BwGr/ctioZ16r9PTKQH9NIAb3+B 6UEg== X-Gm-Message-State: ACgBeo1w79XR7OMSur+3TYaHMMHvnPFNN82WsYBkmj7sno0ZO8Kd3uLx sNaH4JZbyEnSDhW0/UtCzvLdqYs/+0/LAQ== X-Google-Smtp-Source: AA6agR4JuKvkq4dOCrMgt9Yp3n/BCVujvv9oblCsQvnc7b7jq5CuXyzmtKdqdhEMkp5WGjyGG+d90A== X-Received: by 2002:a17:902:d490:b0:177:fc1d:6b0c with SMTP id c16-20020a170902d49000b00177fc1d6b0cmr20032306plg.28.1663009413180; Mon, 12 Sep 2022 12:03:33 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id l5-20020a170903244500b00177f32b1a32sm6348242pls.271.2022.09.12.12.03.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 12:03:32 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Arshdeep Kaur Subject: [RFT] dumpcap: add file-prefix option Date: Mon, 12 Sep 2022 12:03:30 -0700 Message-Id: <20220912190330.73159-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220912124309.233363-1-arshdeep.kaur@intel.com> References: <20220912124309.233363-1-arshdeep.kaur@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org When using dumpcap in container environment or with multiple DPDK processes, it is useful to be able to specify file prefix. This version only accepts the long format option used by other commands. If no prefix is specified then the default is used. Suggested-by: Arshdeep Kaur Signed-off-by: Stephen Hemminger --- Did basic command line test, but still needs testing with a prefix being used (ie multiple apps). app/dumpcap/main.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c index a6041d4ff495..bdeef96d9c0b 100644 --- a/app/dumpcap/main.c +++ b/app/dumpcap/main.c @@ -61,6 +61,7 @@ static char *output_name; static const char *filter_str; static unsigned int ring_size = 2048; static const char *capture_comment; +static const char *file_prefix; static uint32_t snaplen = RTE_MBUF_DEFAULT_BUF_SIZE; static bool dump_bpf; static struct { @@ -122,6 +123,7 @@ static void usage(void) " add a capture comment to the output file\n" "\n" "Miscellaneous:\n" + " --file-prefix= prefix to use for multi-process\n" " -q don't report packet capture counts\n" " -v, --version print version information and exit\n" " -h, --help display this help and exit\n" @@ -310,6 +312,7 @@ static void parse_opts(int argc, char **argv) static const struct option long_options[] = { { "autostop", required_argument, NULL, 'a' }, { "capture-comment", required_argument, NULL, 0 }, + { "file-prefix", required_argument, NULL, 0 }, { "help", no_argument, NULL, 'h' }, { "interface", required_argument, NULL, 'i' }, { "list-interfaces", no_argument, NULL, 'D' }, @@ -330,11 +333,13 @@ static void parse_opts(int argc, char **argv) switch (c) { case 0: - switch (option_index) { - case 0: + if (!strcmp(long_options[option_index].name, + "capture-comment")) { capture_comment = optarg; - break; - default: + } else if (!strcmp(long_options[option_index].name, + "file-prefix")) { + file_prefix = optarg; + } else { usage(); exit(1); } @@ -512,12 +517,14 @@ static void dpdk_init(void) static const char * const args[] = { "dumpcap", "--proc-type", "secondary", "--log-level", "notice" - }; - const int eal_argc = RTE_DIM(args); + int eal_argc = RTE_DIM(args); char **eal_argv; unsigned int i; + if (file_prefix != NULL) + eal_argc += 2; + /* DPDK API requires mutable versions of command line arguments. */ eal_argv = calloc(eal_argc + 1, sizeof(char *)); if (eal_argv == NULL) @@ -527,6 +534,11 @@ static void dpdk_init(void) for (i = 1; i < RTE_DIM(args); i++) eal_argv[i] = strdup(args[i]); + if (file_prefix != NULL) { + eal_argv[i++] = strdup("--file-prefix"); + eal_argv[i++] = strdup(file_prefix); + } + if (rte_eal_init(eal_argc, eal_argv) < 0) rte_exit(EXIT_FAILURE, "EAL init failed: is primary process running?\n"); -- 2.35.1