From patchwork Mon Jun 18 21:35:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 41235 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4A6563230; Mon, 18 Jun 2018 23:36:04 +0200 (CEST) Received: from mail-pl0-f47.google.com (mail-pl0-f47.google.com [209.85.160.47]) by dpdk.org (Postfix) with ESMTP id D7DF02C0C for ; Mon, 18 Jun 2018 23:36:01 +0200 (CEST) Received: by mail-pl0-f47.google.com with SMTP id g20-v6so9740870plq.1 for ; Mon, 18 Jun 2018 14:36:01 -0700 (PDT) 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:in-reply-to:references; bh=K/RbMRXH+tC2fmTJM9CxU2swZJtOBhzqhQDwvzIlVX0=; b=yejtO+ssA2LhEQ/kXRANGDRP/+/g5AzTGw7UKXZR65qVtfv6R6jOmiPjQ+U0tjc1sU WIpdwy8ORltqQ5ZCExMe1q48F6mbUjRNz+zIaAAnKmAf5u9plluaFOxEolc+YlUj5Jb7 i10+7SlHNm3Q5uZlomxRqGz1e3NMvNqHizCO5cDsTWwZFNVft2WMlU6BSSiAdFhioVbY nFLv6yUF65nufvmu7MjOkYggPYVYkv8i9BfMOXMXB0v5Y9ffJIYWQiTKxnKo3xJDj854 INsxV/7lOg6/uHTlpW0D91nk3wOr6degNZITwIPJuvZyf5Eq/auZcLsLnQj0MOPuiTKf j9Qw== 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:in-reply-to :references; bh=K/RbMRXH+tC2fmTJM9CxU2swZJtOBhzqhQDwvzIlVX0=; b=j58q6/eYQKSiny75S21wdWi2w/8ngo2HdEZWa7eSQdErELMUVgtnSls1PCrIlfa4nh oX3cvHv0KILKtxl2Dn1iu/Df2jc68zCm0sL1S3Z+9OvDubQAEFPDjt/yjykDen0sHlGa twD4CY0dKe01JK126G/nfihDbOGU2Vlw4+Bl5s4nQn2UQNxNL5JaffEnw8Obtfi2lwvF SRlKsoDPBamwgs6XFcGTjT3QQCyYYjKdQ1INj/0Lr1oLCfO3vR4m+tuH2zTgIsRJ241+ L00rrbNOpoYSn08DZ5MoJan3frDTpGF8izJ7fNAJY1XV9kt1E0dl0DNXDS2w1vHuZVIJ 16yA== X-Gm-Message-State: APt69E0MSRo9Zv+r7eZ7CQVNXF7LPLuhmRv5npxabr64VfgFvhqndwF/ sOR+zpIJNUOPvGOkTI13/bHzWrtbvAQ= X-Google-Smtp-Source: ADUXVKL8nUtXdl7DB6lNlAYSKZNALVRB3uCbAlCq/jDxEor6laPWN4J9wWWeTSMr/pZZJHycfL0m7g== X-Received: by 2002:a17:902:2884:: with SMTP id f4-v6mr15864704plb.204.1529357760749; Mon, 18 Jun 2018 14:36:00 -0700 (PDT) Received: from xeon-e3.lan (204-195-35-107.wavecable.com. [204.195.35.107]) by smtp.gmail.com with ESMTPSA id n70-v6sm34246969pfh.140.2018.06.18.14.35.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jun 2018 14:35:59 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Mon, 18 Jun 2018 14:35:55 -0700 Message-Id: <20180618213557.15209-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618213557.15209-1-stephen@networkplumber.org> References: <20180618213557.15209-1-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH v3 1/3] testpmd: add ability to set tx IP and UDP parameters 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Use RFC standard values for Tx only test as defaults. But let the user override those values on command line. Signed-off-by: Stephen Hemminger --- app/test-pmd/parameters.c | 49 +++++++++++++++++++++++++++ app/test-pmd/testpmd.h | 6 ++++ app/test-pmd/txonly.c | 18 +++++----- doc/guides/testpmd_app_ug/run_app.rst | 9 +++++ 4 files changed, 74 insertions(+), 8 deletions(-) diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 75807623c719..6d666e088fd9 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -65,6 +66,7 @@ usage(char* progname) #ifdef RTE_LIBRTE_CMDLINE "--eth-peers-configfile= | " "--eth-peer=X,M:M:M:M:M:M | " + "--tx-ip=SRC,DST | --tx-udp=PORT | " #endif "--pkt-filter-mode= |" "--rss-ip | --rss-udp | " @@ -625,6 +627,8 @@ launch_args_parse(int argc, char** argv) { "vxlan-gpe-port", 1, 0, 0 }, { "mlockall", 0, 0, 0 }, { "no-mlockall", 0, 0, 0 }, + { "tx-ip", 1, 0, 0 }, + { "tx-udp", 1, 0, 0 }, { 0, 0, 0, 0 }, }; @@ -717,6 +721,51 @@ launch_args_parse(int argc, char** argv) nb_peer_eth_addrs++; } #endif + if (!strcmp(lgopts[opt_idx].name, "tx-ip")) { + struct in_addr in; + char *end; + + end = strchr(optarg, ','); + if (end == optarg || !end) + rte_exit(EXIT_FAILURE, + "Invalid tx-ip: %s", optarg); + + *end++ = 0; + if (inet_aton(optarg, &in) == 0) + rte_exit(EXIT_FAILURE, + "Invalid source IP address: %s\n", optarg); + tx_ip_src_addr = rte_be_to_cpu_32(in.s_addr); + + if (inet_aton(end, &in) == 0) + rte_exit(EXIT_FAILURE, + "Invalid destination IP address: %s\n", optarg); + tx_ip_dst_addr = rte_be_to_cpu_32(in.s_addr); + } + if (!strcmp(lgopts[opt_idx].name, "tx-udp")) { + char *end = NULL; + + errno = 0; + n = strtoul(optarg, &end, 10); + if (errno != 0 || end == optarg || n > UINT16_MAX || + !(*end == '\0' || *end == ',')) + rte_exit(EXIT_FAILURE, + "Invalid UDP port: %s\n", optarg); + tx_udp_src_port = n; + if (*end == ',') { + char *dst = end + 1; + + n = strtoul(dst, &end, 10); + if (errno != 0 || end == dst || + n > UINT16_MAX || *end) + rte_exit(EXIT_FAILURE, + "Invalid destination UDP port: %s\n", + dst); + tx_udp_dst_port = n; + } else { + tx_udp_dst_port = n; + } + + } if (!strcmp(lgopts[opt_idx].name, "nb-ports")) { n = atoi(optarg); if (n > 0 && n <= nb_ports) diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index f51cd9dd9bbd..48f7b364e9b3 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -444,6 +444,12 @@ extern int8_t tx_pthresh; extern int8_t tx_hthresh; extern int8_t tx_wthresh; +extern uint16_t tx_udp_src_port; +extern uint16_t tx_udp_dst_port; + +extern uint32_t tx_ip_src_addr; +extern uint32_t tx_ip_dst_addr; + extern struct fwd_config cur_fwd_config; extern struct fwd_engine *cur_fwd_eng; extern uint32_t retry_enabled; diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c index 1f08b6ed37a2..689c53eb73f8 100644 --- a/app/test-pmd/txonly.c +++ b/app/test-pmd/txonly.c @@ -40,11 +40,13 @@ #include "testpmd.h" -#define UDP_SRC_PORT 1024 -#define UDP_DST_PORT 1024 +/* use RFC863 Discard Protocol */ +uint16_t tx_udp_src_port = 9; +uint16_t tx_udp_dst_port = 9; -#define IP_SRC_ADDR ((192U << 24) | (168 << 16) | (0 << 8) | 1) -#define IP_DST_ADDR ((192U << 24) | (168 << 16) | (0 << 8) | 2) +/* use RFC5735 / RFC2544 reserved network test addresses */ +uint32_t tx_ip_src_addr = (192U << 24) | (18 << 16) | (0 << 8) | 1; +uint32_t tx_ip_dst_addr = (192U << 24) | (18 << 16) | (0 << 8) | 2; #define IP_DEFTTL 64 /* from RFC 1340. */ #define IP_VERSION 0x40 @@ -104,8 +106,8 @@ setup_pkt_udp_ip_headers(struct ipv4_hdr *ip_hdr, * Initialize UDP header. */ pkt_len = (uint16_t) (pkt_data_len + sizeof(struct udp_hdr)); - udp_hdr->src_port = rte_cpu_to_be_16(UDP_SRC_PORT); - udp_hdr->dst_port = rte_cpu_to_be_16(UDP_DST_PORT); + udp_hdr->src_port = rte_cpu_to_be_16(tx_udp_src_port); + udp_hdr->dst_port = rte_cpu_to_be_16(tx_udp_dst_port); udp_hdr->dgram_len = RTE_CPU_TO_BE_16(pkt_len); udp_hdr->dgram_cksum = 0; /* No UDP checksum. */ @@ -120,8 +122,8 @@ setup_pkt_udp_ip_headers(struct ipv4_hdr *ip_hdr, ip_hdr->next_proto_id = IPPROTO_UDP; ip_hdr->packet_id = 0; ip_hdr->total_length = RTE_CPU_TO_BE_16(pkt_len); - ip_hdr->src_addr = rte_cpu_to_be_32(IP_SRC_ADDR); - ip_hdr->dst_addr = rte_cpu_to_be_32(IP_DST_ADDR); + ip_hdr->src_addr = rte_cpu_to_be_32(tx_ip_src_addr); + ip_hdr->dst_addr = rte_cpu_to_be_32(tx_ip_dst_addr); /* * Compute IP header checksum. diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst index f301c2b6f709..ae9eb712e209 100644 --- a/doc/guides/testpmd_app_ug/run_app.rst +++ b/doc/guides/testpmd_app_ug/run_app.rst @@ -249,6 +249,15 @@ The commandline options are: Set the MAC address ``XX:XX:XX:XX:XX:XX`` of the peer port N, where 0 <= N < ``CONFIG_RTE_MAX_ETHPORTS`` from the configuration file. + +* ``--tx-ip=SRC,DST`` + Set the source and destination IP address used when doing transmit only test. + The defaults are source 192.18.0.1 and destination 192.18.0.2. + +* ``--tx-udp=SRC[,DST]`` + Set the source and destination UDP port number for transmit test only test. + The default port is the 9 (discard). + * ``--pkt-filter-mode=mode`` Set Flow Director mode where mode is either ``none`` (the default), ``signature`` or ``perfect``. From patchwork Mon Jun 18 21:35:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 41236 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6FF23378E; Mon, 18 Jun 2018 23:36:06 +0200 (CEST) Received: from mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) by dpdk.org (Postfix) with ESMTP id 907E93195 for ; Mon, 18 Jun 2018 23:36:03 +0200 (CEST) Received: by mail-pf0-f196.google.com with SMTP id z24-v6so8816012pfe.7 for ; Mon, 18 Jun 2018 14:36:03 -0700 (PDT) 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:in-reply-to:references; bh=sqy0tZXrPh0RsZiVNskwIYihTDxgsS7NQctgkjqrIx4=; b=wJVy32CL1MJaZneGlSqq05Sheo4iJceCOV4U5BLH3asxjxw/DIksDp15WB70NahcZQ 46igB/nXwRPOLq0b0lUgredCMUkR1/bIKu5NU/DLi2ah2P7Yo0zoPPdnAVvLjSSdc7hk baaCzoORrWVvcIjt7/QOPFHtT5tv6KdAQnoLkZeQ8L21it74wYLR3OM7+/WzADiWannp 4OrL9eVhhQUdBPAN0mstjyh3PqJx8WhKTa8lmDvHqc+C4dz+wmNMYqmFCLTjoBO504jo bGfo8UI2f05TR1dazRs+rE+OdzRfb08iX50Ekv1v/A31yXpcfYyJXyF+n+VZXYsR6AGy pGcA== 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:in-reply-to :references; bh=sqy0tZXrPh0RsZiVNskwIYihTDxgsS7NQctgkjqrIx4=; b=nn7qcTw8BO7biEi9L3whWlJ8yRutraJ/ZHKOQO70QI1pp9jF41ahC5utlddeV4cb7u AMYTQ7fTl7smzuUFRASkCSQbbXHckzVnc0AS34BoRxQ0zQ1hHwnv4sZ7PDj/F+OdzkpP oxFHzgCBgjVkj44FkPDwFfAa9FJRG6QTaoS+xBWvEhdF9nfedDv9iKK8v+nPQspHQXlG vVIROLqt+oAQVkMRPBlfzYhYEwjfwDndExgLzMI1qwafQZL5UoTgF/nQA5QvKSIMpKSG lb3Q+u+04jEgd472pW8JQhp1udr3J0oK3+Drrb22eAngEKF37hIO7KE695kwoT1hX3t4 z06A== X-Gm-Message-State: APt69E1he0evtYDyHedRzb76HB2x7VZz0Q/kfRQkaaZLnojElFJ6We67 nr9brYNe57E0gDABi7dk8G3st93WC+o= X-Google-Smtp-Source: ADUXVKIMq9DfBhS+fYd3HkmIY/66v2FPdhurHSX5Gx/76qcnCEALKo2Xqr++r7Jc4izN8l7n42difQ== X-Received: by 2002:a62:f615:: with SMTP id x21-v6mr15151648pfh.43.1529357762239; Mon, 18 Jun 2018 14:36:02 -0700 (PDT) Received: from xeon-e3.lan (204-195-35-107.wavecable.com. [204.195.35.107]) by smtp.gmail.com with ESMTPSA id n70-v6sm34246969pfh.140.2018.06.18.14.36.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jun 2018 14:36:01 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Mon, 18 Jun 2018 14:35:56 -0700 Message-Id: <20180618213557.15209-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618213557.15209-1-stephen@networkplumber.org> References: <20180618213557.15209-1-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH v3 2/3] examples/l3fwd: use reserved IPv4/IPv6 addresses 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The example should use the IPv4 addresses defined in RFC5735 and the IPv6 addresses defined in RFC5180 for the L3 forwarding example Longest Prefix Match table. Fixes: 268888b5b020 ("examples/l3fwd: modularize") Signed-off-by: Stephen Hemminger --- examples/l3fwd/l3fwd_lpm.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c index a747126a2404..3724f79c1924 100644 --- a/examples/l3fwd/l3fwd_lpm.c +++ b/examples/l3fwd/l3fwd_lpm.c @@ -40,26 +40,28 @@ struct ipv6_l3fwd_lpm_route { uint8_t if_out; }; +/* 192.18.0.0/16 are set aside for RFC2544 benchmarking. */ static struct ipv4_l3fwd_lpm_route ipv4_l3fwd_lpm_route_array[] = { - {IPv4(1, 1, 1, 0), 24, 0}, - {IPv4(2, 1, 1, 0), 24, 1}, - {IPv4(3, 1, 1, 0), 24, 2}, - {IPv4(4, 1, 1, 0), 24, 3}, - {IPv4(5, 1, 1, 0), 24, 4}, - {IPv4(6, 1, 1, 0), 24, 5}, - {IPv4(7, 1, 1, 0), 24, 6}, - {IPv4(8, 1, 1, 0), 24, 7}, + {IPv4(192, 18, 0, 0), 24, 0}, + {IPv4(192, 18, 1, 0), 24, 1}, + {IPv4(192, 18, 2, 0), 24, 2}, + {IPv4(192, 18, 3, 0), 24, 3}, + {IPv4(192, 18, 4, 0), 24, 4}, + {IPv4(192, 18, 5, 0), 24, 5}, + {IPv4(192, 18, 6, 0), 24, 6}, + {IPv4(192, 18, 7, 0), 24, 7}, }; +/* 2001:0200::/48 is IANA reserved address range for IPv6 benchmarking (RFC5180) */ static struct ipv6_l3fwd_lpm_route ipv6_l3fwd_lpm_route_array[] = { - {{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 48, 0}, - {{2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 48, 1}, - {{3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 48, 2}, - {{4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 48, 3}, - {{5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 48, 4}, - {{6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 48, 5}, - {{7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 48, 6}, - {{8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 48, 7}, + {{32, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 64, 0}, + {{32, 1, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0}, 64, 0}, + {{32, 1, 2, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0}, 64, 0}, + {{32, 1, 2, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0}, 64, 0}, + {{32, 1, 2, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0}, 64, 0}, + {{32, 1, 2, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0}, 64, 0}, + {{32, 1, 2, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0}, 64, 0}, + {{32, 1, 2, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0}, 48, 0}, }; #define IPV4_L3FWD_LPM_NUM_ROUTES \ From patchwork Mon Jun 18 21:35:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 41237 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B924F44BE; Mon, 18 Jun 2018 23:36:07 +0200 (CEST) Received: from mail-pf0-f182.google.com (mail-pf0-f182.google.com [209.85.192.182]) by dpdk.org (Postfix) with ESMTP id 430D22C6D for ; Mon, 18 Jun 2018 23:36:04 +0200 (CEST) Received: by mail-pf0-f182.google.com with SMTP id h12-v6so8814237pfk.11 for ; Mon, 18 Jun 2018 14:36:04 -0700 (PDT) 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:in-reply-to:references; bh=hXVLGhNXkLh9gKlTFB/wMPtEhRAlYxP4FIdty6zp6Qk=; b=UFOncGlil+Z2YW5L4yH7bZdzLVksYWYZN5sEqCRUvuhIxAl00U2izVeEcqvlIba3AV 7jmysZ/YRFH8KZ6mdCD2DtFTzx8c7D0gAM0h9l2eOoN1hAHF5BG9jtgdc2hQ5jjoVOzZ l6N4TjuQZGPhCYNq7b5UnlYzeXEndGsI6/JL7ugKJAqzBL0njiV4jBjXnEqvwYmAa1i+ nhVqvLAEI6UlvKrbNFbCY6YMMlTz9iu92GszskJzfmpK/9BUI1AJ7rnFirBo9YeZmQ/+ RRlU7TyR0FNnsuEaLFDnSbEHPHpI6Dt/pYMjYXf0cG7mykn268tdtJvVOoj1T47Sb/u2 Zbog== 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:in-reply-to :references; bh=hXVLGhNXkLh9gKlTFB/wMPtEhRAlYxP4FIdty6zp6Qk=; b=mSY6gPQv82wpL5mGpF8MzHSGOX4iIoX8ac46K8FlXaBNdI7Sr1cSSKE80q5bEIXnw+ pGra/HPyYSe26T/MOwfe9IBwmCqNUSmiAPzLOOXDIHRFf76Wzc2axwYqZX6ZyWRHTDiJ eZf03U4B12+MR6qhUPs3KFzNDWJO5KawGifFmN/eQPypAoJ7EcxSNYTvkZh4pnbGrDQB SD52kH3yMHj3/mBP+STejBk4D8UnUh8Uc4ONi3q+jz8CwZi+JCxeqfkf1f0qV1k1dsO/ wzBBHxHTu6FR8jMbFD8Cu5GYioM+3ur9l8Wj4qqVAGfZOuMoP+VZHeOuJpZm7kmr1XS8 P5nA== X-Gm-Message-State: APt69E3a52hukM85Jrk57heOhH7EJ28IRonTBVlq+KlWFTHLWdWxcV5c 2ud90uSPXrN5PtNROU4z/Q4amHapjGA= X-Google-Smtp-Source: ADUXVKLNbkyGoXMJ8xaoJH4z7xSHI/ZsruQBrNnIF9alDtP2c/qiKJDor8T54qRFtfkhc5pjv7GWRA== X-Received: by 2002:a62:dc1c:: with SMTP id t28-v6mr15167041pfg.137.1529357763174; Mon, 18 Jun 2018 14:36:03 -0700 (PDT) Received: from xeon-e3.lan (204-195-35-107.wavecable.com. [204.195.35.107]) by smtp.gmail.com with ESMTPSA id n70-v6sm34246969pfh.140.2018.06.18.14.36.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jun 2018 14:36:02 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Mon, 18 Jun 2018 14:35:57 -0700 Message-Id: <20180618213557.15209-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618213557.15209-1-stephen@networkplumber.org> References: <20180618213557.15209-1-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH v3 3/3] examples/l3fwd: format the IP addresses for printing 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" It is better user experience to print standard format for addresses rather than raw hex. Signed-off-by: Stephen Hemminger --- examples/l3fwd/l3fwd_lpm.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c index 3724f79c1924..3edc82aa2c62 100644 --- a/examples/l3fwd/l3fwd_lpm.c +++ b/examples/l3fwd/l3fwd_lpm.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -261,6 +262,7 @@ setup_lpm(const int socketid) unsigned i; int ret; char s[64]; + char abuf[INET6_ADDRSTRLEN]; /* create the LPM table */ config_ipv4.max_rules = IPV4_L3FWD_LPM_MAX_RULES; @@ -276,6 +278,7 @@ setup_lpm(const int socketid) /* populate the LPM table */ for (i = 0; i < IPV4_L3FWD_LPM_NUM_ROUTES; i++) { + struct in_addr in; /* skip unused ports */ if ((1 << ipv4_l3fwd_lpm_route_array[i].if_out & @@ -293,8 +296,9 @@ setup_lpm(const int socketid) i, socketid); } - printf("LPM: Adding route 0x%08x / %d (%d)\n", - (unsigned)ipv4_l3fwd_lpm_route_array[i].ip, + in.s_addr = htonl(ipv4_l3fwd_lpm_route_array[i].ip); + printf("LPM: Adding route %s / %d (%d)\n", + inet_ntop(AF_INET, &in, abuf, sizeof(abuf)), ipv4_l3fwd_lpm_route_array[i].depth, ipv4_l3fwd_lpm_route_array[i].if_out); } @@ -332,9 +336,10 @@ setup_lpm(const int socketid) } printf("LPM: Adding route %s / %d (%d)\n", - "IPV6", - ipv6_l3fwd_lpm_route_array[i].depth, - ipv6_l3fwd_lpm_route_array[i].if_out); + inet_ntop(AF_INET6, ipv6_l3fwd_lpm_route_array[i].ip, + abuf, sizeof(abuf)), + ipv6_l3fwd_lpm_route_array[i].depth, + ipv6_l3fwd_lpm_route_array[i].if_out); } }