Skip to contentSkip to conversation

use RFC addresses for testing

PATCH Superseded Stephen Hemminger 4 participants 32 messages Jun 18, 2018 – Apr 21, 2019

lore
Share & tools
lore
#0 lore raw

v3 cover use RFC addresses for testing

These patches get rid of the custom addresses used in testpmd and l3fwd, and instead uses values that are in the existing RFC's.

Stephen Hemminger (3):
testpmd: add ability to set tx IP and UDP parameters examples/l3fwd: use reserved IPv4/IPv6 addresses examples/l3fwd: format the IP addresses for printing

 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 +++++
 examples/l3fwd/l3fwd_lpm.c            | 49 +++++++++++++++------------
 5 files changed, 102 insertions(+), 29 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH v3 1/3 testpmd: add ability to set tx IP and UDP parameters

Use RFC standard values for Tx only test as defaults. But let the user override those values on command line.

---
 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(-)
app/test-pmd/parameters.c +49 -0
index 75807623c719..6d666e088fd9 100644
@@ -19,6 +19,7 @@
 #include <stdint.h>
 #include <unistd.h>
 #include <inttypes.h>
+#include <arpa/inet.h>
 
 #include <rte_common.h>
 #include <rte_byteorder.h>
@@ -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)
app/test-pmd/testpmd.h +6 -0
index f51cd9dd9bbd..48f7b364e9b3 100644
@@ -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;
app/test-pmd/txonly.c +10 -8
index 1f08b6ed37a2..689c53eb73f8 100644
@@ -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.
doc/guides/testpmd_app_ug/run_app.rst +9 -0
index f301c2b6f709..ae9eb712e209 100644
@@ -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``.
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH v3 1/3] testpmd: add ability to set tx IP and UDP parameters

Hi Stephen,

Quoted 13 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Monday, June 18, 2018 10:36 PM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>
Subject: [dpdk-dev] [PATCH v3 1/3] testpmd: add ability to set tx IP and UDP parameters

Use RFC standard values for Tx only test as defaults. But let the user override those values on command line.

---

<snip>

doc/guides/testpmd_app_ug/run_app.rst The commandline options are: · line 253

Quoted 12 lines
 app/test-pmd/parameters.c             | 49 +++++++++++++++++++++++++++
doc/guides/testpmd_app_ug/run_app.rst +2 -0
index f301c2b6f709..ae9eb712e209 100644
@@ -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``

A newline should be inserted after the above line to maintain the existing format of the output HTML file.

doc/guides/testpmd_app_ug/run_app.rst The commandline options are: · line 257

Quoted 4 lines
doc/guides/testpmd_app_ug/run_app.rst +4 -0
+    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]``

A newline should be inserted after the above line to maintain the existing format of the output HTML file.

Quoted 9 lines
doc/guides/testpmd_app_ug/run_app.rst +3 -0
+    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``.
--
2.17.1

dpdk/devtools/check-git-log.sh -1
Wrong headline label:
testpmd: add ability to set tx IP and UDP parameters
Wrong headline lowercase:
testpmd: add ability to set tx IP and UDP parameters

The headline label should be "app/testpmd:"
"tx" should "Tx"

I commented on this previously.

Regards,

Bernard.

#3 lore raw

Re: [PATCH v3 1/3] testpmd: add ability to set tx IP and UDP parameters

Hi Stephen,

Please would you like to send a v4?

22/06/2018 11:12, Iremonger, Bernard:

Quoted 66 lines

Hi Stephen,

Quoted 13 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Monday, June 18, 2018 10:36 PM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>
Subject: [dpdk-dev] [PATCH v3 1/3] testpmd: add ability to set tx IP and UDP parameters

Use RFC standard values for Tx only test as defaults. But let the user override those values on command line.

---

<snip>

doc/guides/testpmd_app_ug/run_app.rst The commandline options are: · line 253

Quoted 12 lines
 app/test-pmd/parameters.c             | 49 +++++++++++++++++++++++++++
doc/guides/testpmd_app_ug/run_app.rst +2 -0
index f301c2b6f709..ae9eb712e209 100644
@@ -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``

A newline should be inserted after the above line to maintain the existing format of the output HTML file.

doc/guides/testpmd_app_ug/run_app.rst The commandline options are: · line 257

Quoted 4 lines
doc/guides/testpmd_app_ug/run_app.rst +4 -0
+    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]``

A newline should be inserted after the above line to maintain the existing format of the output HTML file.

Quoted 9 lines
doc/guides/testpmd_app_ug/run_app.rst +3 -0
+    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``.
--
2.17.1

dpdk/devtools/check-git-log.sh -1
Wrong headline label:
testpmd: add ability to set tx IP and UDP parameters
Wrong headline lowercase:
testpmd: add ability to set tx IP and UDP parameters

The headline label should be "app/testpmd:"
"tx" should "Tx"

I commented on this previously.

Regards,

Bernard.

#4 lore raw

Re: [PATCH v3 1/3] testpmd: add ability to set tx IP and UDP parameters

In reply to Stephen Hemminger

Tuesday, June 19, 2018 12:36 AM

Quoted 194 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Tuesday, June 19, 2018 12:36 AM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>
Subject: [dpdk-dev] [PATCH v3 1/3] testpmd: add ability to set tx IP and UDP parameters

Use RFC standard values for Tx only test as defaults. But let the user override those values on command line.

---
 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(-)
app/test-pmd/parameters.c index renamed from app/test-pmd/parameters.c +0 -0

75807623c719..6d666e088fd9 100644

app/test-pmd/parameters.c +23 -0
@@ -19,6 +19,7 @@
 #include <stdint.h>
 #include <unistd.h>
 #include <inttypes.h>
+#include <arpa/inet.h>
 
 #include <rte_common.h>
 #include <rte_byteorder.h>
@@ -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);

app/test-pmd/parameters.c +7 -0
+			}
+			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 ||

app/test-pmd/parameters.c +3 -0
+				    !(*end == '\0' || *end == ','))
+					rte_exit(EXIT_FAILURE,
+						 "Invalid UDP port: %s\n",

optarg);

app/test-pmd/parameters.c +9 -0
+				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",

app/test-pmd/parameters.c +7 -0
+							 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)
app/test-pmd/testpmd.h index renamed from app/test-pmd/testpmd.h +0 -0

f51cd9dd9bbd..48f7b364e9b3 100644

app/test-pmd/testpmd.h +6 -0
@@ -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

app/test-pmd/txonly.c +10 -7
@@ -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.
doc/guides/testpmd_app_ug/run_app.rst +0 -0
index f301c2b6f709..ae9eb712e209 100644
@@ -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.

doc/guides/testpmd_app_ug/run_app.rst +3 -0
+
+*   ``--tx-ip=SRC,DST``
+    Set the source and destination IP address used when doing transmit only

test.

doc/guides/testpmd_app_ug/run_app.rst +4 -0
+    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.

doc/guides/testpmd_app_ug/run_app.rst +2 -0
+    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``.
--
2.17.1

#5 lore raw

Re: [PATCH v3 1/3] testpmd: add ability to set tx IP and UDP parameters

In reply to Stephen Hemminger

Hi Stephan,

Tuesday, June 19, 2018 12:36 AM, Stephen Hemminger:

Quoted 5 lines

Subject: [dpdk-dev] [PATCH v3 1/3] testpmd: add ability to set tx IP and UDP parameters

Use RFC standard values for Tx only test as defaults. But let the user override those values on command line.

I think it is a good flexibility to add to testpmd for testing purposes.

Wondering if we can expend this one a bit more for the user to configure a range of udp/tcp ports and ip src/dst addresses which will be transmitted in a round robin fashion by the application. We don't need testpmd to be full blown packet generator, but sending range of 5 tuple can much help when testing RSS/single core performance.

Quoted 183 lines
---
 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(-)
app/test-pmd/parameters.c index renamed from app/test-pmd/parameters.c +0 -0

75807623c719..6d666e088fd9 100644

app/test-pmd/parameters.c +23 -0
@@ -19,6 +19,7 @@
 #include <stdint.h>
 #include <unistd.h>
 #include <inttypes.h>
+#include <arpa/inet.h>
 
 #include <rte_common.h>
 #include <rte_byteorder.h>
@@ -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);

app/test-pmd/parameters.c +7 -0
+			}
+			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 ||

app/test-pmd/parameters.c +3 -0
+				    !(*end == '\0' || *end == ','))
+					rte_exit(EXIT_FAILURE,
+						 "Invalid UDP port: %s\n",

optarg);

app/test-pmd/parameters.c +9 -0
+				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",

app/test-pmd/parameters.c +7 -0
+							 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)
app/test-pmd/testpmd.h index renamed from app/test-pmd/testpmd.h +0 -0

f51cd9dd9bbd..48f7b364e9b3 100644

app/test-pmd/testpmd.h +6 -0
@@ -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

app/test-pmd/txonly.c +10 -7
@@ -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.
doc/guides/testpmd_app_ug/run_app.rst +0 -0
index f301c2b6f709..ae9eb712e209 100644
@@ -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.

doc/guides/testpmd_app_ug/run_app.rst +3 -0
+
+*   ``--tx-ip=SRC,DST``
+    Set the source and destination IP address used when doing transmit only

test.

doc/guides/testpmd_app_ug/run_app.rst +4 -0
+    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.

doc/guides/testpmd_app_ug/run_app.rst +2 -0
+    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``.
--
2.17.1

#6 lore raw

v4 cover use RFC addresses in test applications

In reply to Stephen Hemminger

These patches get rid of the custom addresses used in testpmd and l3fwd, and instead uses values that are in the existing RFC's.

Stephen Hemminger (3):
app/testpmd: add ability to set Tx IP and UDP parameters examples/l3fwd: use reserved IPv4/IPv6 addresses examples/l3fwd: format the IP addresses for printing

 app/test-pmd/parameters.c             | 49 +++++++++++++++++++++++++++
 app/test-pmd/testpmd.h                |  6 ++++
 app/test-pmd/txonly.c                 | 22 +++++++-----
 doc/guides/testpmd_app_ug/run_app.rst | 12 ++++++-
 examples/l3fwd/l3fwd_lpm.c            | 49 +++++++++++++++------------
 5 files changed, 107 insertions(+), 31 deletions(-)
Signature · 1 line
2.17.1
#7 lore raw

PATCH v4 1/3 app/testpmd: add ability to set Tx IP and UDP parameters

Use RFC 2544 standard values for Tx only test as default IP address and port. But let the user override those values on command line.

---
v4 - update documentation to be more precise
support new tx-multi-flow addresses

 app/test-pmd/parameters.c             | 49 +++++++++++++++++++++++++++
 app/test-pmd/testpmd.h                |  6 ++++
 app/test-pmd/txonly.c                 | 22 +++++++-----
 doc/guides/testpmd_app_ug/run_app.rst | 12 ++++++-
 4 files changed, 79 insertions(+), 10 deletions(-)
app/test-pmd/parameters.c +49 -0
index 7b6b60905dce..8b523a5c66ed 100644
@@ -19,6 +19,7 @@
 #include <stdint.h>
 #include <unistd.h>
 #include <inttypes.h>
+#include <arpa/inet.h>
 
 #include <rte_common.h>
 #include <rte_byteorder.h>
@@ -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 | "
@@ -645,6 +647,8 @@ launch_args_parse(int argc, char** argv)
 		{ "mlockall",			0, 0, 0 },
 		{ "no-mlockall",		0, 0, 0 },
 		{ "mp-alloc",			1, 0, 0 },
+		{ "tx-ip",			1, 0, 0 },
+		{ "tx-udp",			1, 0, 0 },
 		{ "noisy-tx-sw-buffer-size",	1, 0, 0 },
 		{ "noisy-tx-sw-buffer-flushtime", 1, 0, 0 },
 		{ "noisy-lkup-memory",		1, 0, 0 },
@@ -743,6 +747,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)
app/test-pmd/testpmd.h +6 -0
index a45988ebc524..18d2c1ef1eaf 100644
@@ -443,6 +443,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;
app/test-pmd/txonly.c +13 -9
index def52a0487ea..ed5e715ea648 100644
@@ -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
@@ -105,8 +107,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. */
 
@@ -121,8 +123,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.
@@ -253,7 +255,9 @@ pkt_burst_transmit(struct fwd_stream *fs)
 			 * packet generator for developer's quick performance
 			 * regression test.
 			 */
-			addr = (IP_DST_ADDR | (ip_var++ << 8)) + rte_lcore_id();
+			addr = (tx_ip_dst_addr | (ip_var++ << 8))
+				+ rte_lcore_id();
+
 			ip_hdr->src_addr = rte_cpu_to_be_32(addr);
 		}
 		copy_buf_to_pkt(&pkt_udp_hdr, sizeof(pkt_udp_hdr), pkt,
doc/guides/testpmd_app_ug/run_app.rst +11 -1
index b717b8c7b742..a72f94923210 100644
@@ -121,12 +121,22 @@ The commandline options are:
        XX:XX:XX:XX:XX:02
        ...
 
-
 *   ``--eth-peer=N,XX:XX:XX:XX:XX:XX``
 
     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 address values are source 192.18.0.1 and
+    destination 192.18.0.2. These are special purpose addresses
+    reserved for benchmakring (RFC 2544).
+
+*   ``--tx-udp=SRC[,DST]``
+    Set the source and destination UDP port number for transmit test only test.
+    The default port is the port 9 which is defined for the discard protocol
+    (RFC 863).
+
 *   ``--pkt-filter-mode=mode``
 
     Set Flow Director mode where mode is either ``none`` (the default), ``signature`` or ``perfect``.
Signature · 1 line
2.17.1
#8 lore raw

Re: [dpdk-dev] [PATCH v4 1/3] app/testpmd: add ability to set Tx IP and UDP parameters

Hi Stephen,

Quoted 207 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Tuesday, April 2, 2019 9:39 PM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>
Subject: [dpdk-dev] [PATCH v4 1/3] app/testpmd: add ability to set Tx IP and UDP parameters

Use RFC 2544 standard values for Tx only test as default IP address and port. But let the user override those values on command line.

---
v4 - update documentation to be more precise
support new tx-multi-flow addresses

 app/test-pmd/parameters.c             | 49 +++++++++++++++++++++++++++
 app/test-pmd/testpmd.h                |  6 ++++
 app/test-pmd/txonly.c                 | 22 +++++++-----
 doc/guides/testpmd_app_ug/run_app.rst | 12 ++++++-
 4 files changed, 79 insertions(+), 10 deletions(-)
app/test-pmd/parameters.c index renamed from app/test-pmd/parameters.c +0 -0

7b6b60905dce..8b523a5c66ed 100644

app/test-pmd/parameters.c +30 -0
@@ -19,6 +19,7 @@
 #include <stdint.h>
 #include <unistd.h>
 #include <inttypes.h>
+#include <arpa/inet.h>
 
 #include <rte_common.h>
 #include <rte_byteorder.h>
@@ -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 | "
@@ -645,6 +647,8 @@ launch_args_parse(int argc, char** argv)
 		{ "mlockall",			0, 0, 0 },
 		{ "no-mlockall",		0, 0, 0 },
 		{ "mp-alloc",			1, 0, 0 },
+		{ "tx-ip",			1, 0, 0 },
+		{ "tx-udp",			1, 0, 0 },
 		{ "noisy-tx-sw-buffer-size",	1, 0, 0 },
 		{ "noisy-tx-sw-buffer-flushtime", 1, 0, 0 },
 		{ "noisy-lkup-memory",		1, 0, 0 },
@@ -743,6 +747,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 ||

app/test-pmd/parameters.c +3 -0
+				    !(*end == '\0' || *end == ','))
+					rte_exit(EXIT_FAILURE,
+						 "Invalid UDP port: %s\n",

optarg);

app/test-pmd/parameters.c +9 -0
+				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",

app/test-pmd/parameters.c +7 -0
+							 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)
app/test-pmd/testpmd.h index renamed from app/test-pmd/testpmd.h +0 -0

a45988ebc524..18d2c1ef1eaf 100644

app/test-pmd/testpmd.h +6 -0
@@ -443,6 +443,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 def52a0487ea..ed5e715ea648 100644

app/test-pmd/txonly.c +13 -9
@@ -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
@@ -105,8 +107,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. */
 
@@ -121,8 +123,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.
@@ -253,7 +255,9 @@ pkt_burst_transmit(struct fwd_stream *fs)
 			 * packet generator for developer's quick performance
 			 * regression test.
 			 */
-			addr = (IP_DST_ADDR | (ip_var++ << 8)) + rte_lcore_id();
+			addr = (tx_ip_dst_addr | (ip_var++ << 8))
+				+ rte_lcore_id();
+
 			ip_hdr->src_addr = rte_cpu_to_be_32(addr);
 		}
 		copy_buf_to_pkt(&pkt_udp_hdr, sizeof(pkt_udp_hdr), pkt, diff -
-git a/doc/guides/testpmd_app_ug/run_app.rst

b/doc/guides/testpmd_app_ug/run_app.rst
index b717b8c7b742..a72f94923210 100644

doc/guides/testpmd_app_ug/run_app.rst +11 -1
@@ -121,12 +121,22 @@ The commandline options are:
        XX:XX:XX:XX:XX:02
...
 
-
 *   ``--eth-peer=N,XX:XX:XX:XX:XX:XX``
 
     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 address values are source 192.18.0.1 and
+    destination 192.18.0.2. These are special purpose addresses
+    reserved for benchmakring (RFC 2544).
+
+*   ``--tx-udp=SRC[,DST]``
+    Set the source and destination UDP port number for transmit test only test.
+    The default port is the port 9 which is defined for the discard protocol
+    (RFC 863).
+
 *   ``--pkt-filter-mode=mode``
 
     Set Flow Director mode where mode is either ``none`` (the default),
Quoted 3 lines

``signature`` or ``perfect``.
--
2.17.1

This patch fails to apply to DPDK 19.05.rc1.
It probably needs to be rebased.

Regards,

Bernard.

#9 lore raw

PATCH v4 2/3 examples/l3fwd: use reserved IPv4/IPv6 addresses

In reply to Stephen Hemminger

The l3fwd 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.

---
v4 - fix IPv6 /48 entries

 examples/l3fwd/l3fwd_lpm.c | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)
examples/l3fwd/l3fwd_lpm.c +18 -16
index b1dc195ad8cb..3191fc4c2639 100644
@@ -39,26 +39,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 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}, 48, 0},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0}, 48, 1},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0}, 48, 2},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0}, 48, 3},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0}, 48, 4},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0}, 48, 5},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0}, 48, 6},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0}, 48, 7},
 };
 
 #define IPV4_L3FWD_LPM_NUM_ROUTES \
Signature · 1 line
2.17.1
#10 lore raw

Re: [dpdk-dev] [PATCH v4 2/3] examples/l3fwd: use reserved IPv4/IPv6 addresses

Hi Stephen,

Quoted 11 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Tuesday, April 2, 2019 9:39 PM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>
Subject: [dpdk-dev] [PATCH v4 2/3] examples/l3fwd: use reserved IPv4/IPv6 addresses

The l3fwd 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.

There should probably be a fixes line.
Also the commit line should have the "fix" keyword.

Quoted 59 lines

---
v4 - fix IPv6 /48 entries

 examples/l3fwd/l3fwd_lpm.c | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)
examples/l3fwd/l3fwd_lpm.c index renamed from examples/l3fwd/l3fwd_lpm.c +0 -0

b1dc195ad8cb..3191fc4c2639 100644

examples/l3fwd/l3fwd_lpm.c +19 -17
@@ -39,26 +39,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 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}, 48, 0},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0}, 48, 1},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0}, 48, 2},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0}, 48, 3},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0}, 48, 4},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0}, 48, 5},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0}, 48, 6},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0}, 48, 7},
 };
 
 #define IPV4_L3FWD_LPM_NUM_ROUTES \
--
Quoted 1 line

2.17.1

Regards,

Bernard.

#11 lore raw

Re: [dpdk-dev] [PATCH v4 2/3] examples/l3fwd: use reserved IPv4/IPv6 addresses

Quoted 10 lines · Bernard

Hi Stephen,

Quoted 8 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Tuesday, April 2, 2019 9:39 PM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>
Subject: [dpdk-dev] [PATCH v4 2/3] examples/l3fwd: use reserved IPv4/IPv6 addresses

Quoted 6 lines
Quoted 3 lines

The l3fwd 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.

There should probably be a fixes line.
Also the commit line should have the "fix" keyword.

The original behavior was not a bug. It was just a poor design choice. Therefore the lack of fixes tag is intentional.
Also didn't want this patch to make it into stable release and risk breaking some existing test bed.

#12 lore raw

PATCH v4 3/3 examples/l3fwd: format the IP addresses for printing

In reply to Stephen Hemminger

The IP addresses should be formatted using standard routines rather than dumpin in raw hex.

---
v4 - remove fixes, the original output was raw but not a bug

 examples/l3fwd/l3fwd_lpm.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
examples/l3fwd/l3fwd_lpm.c +10 -5
index 3191fc4c2639..172a036b2707 100644
@@ -13,6 +13,7 @@
 #include <errno.h>
 #include <getopt.h>
 #include <stdbool.h>
+#include <arpa/inet.h>
 
 #include <rte_debug.h>
 #include <rte_ether.h>
@@ -260,6 +261,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;
@@ -275,6 +277,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 &
@@ -292,8 +295,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);
 	}
@@ -331,9 +335,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);
 	}
 }
 
Signature · 1 line
2.17.1
Acked-by on v4 3/3
#13 lore raw

Re: [dpdk-dev] [PATCH v4 3/3] examples/l3fwd: format the IP addresses for printing

Hi Stephen,

Quoted 10 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Tuesday, April 2, 2019 9:39 PM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>
Subject: [dpdk-dev] [PATCH v4 3/3] examples/l3fwd: format the IP addresses for printing

The IP addresses should be formatted using standard routines rather than dumpin in raw hex.

Typo: "dumpin" should be "dumping"

Quoted 2 lines

Otherwise

#14 lore raw

v5 cover use RFC addresses in test applications

In reply to Stephen Hemminger

These patches get rid of the custom addresses used in testpmd and l3fwd, and instead uses values that are in the existing RFC's.

v5 -- rebase to 19.05-rc1 and fix reword commit message

Stephen Hemminger (3):
app/testpmd: add ability to set Tx IP and UDP parameters examples/l3fwd: use reserved IPv4/IPv6 addresses examples/l3fwd: format the IP addresses for printing

 app/test-pmd/parameters.c             | 49 +++++++++++++++++++++++++++
 app/test-pmd/testpmd.h                |  6 ++++
 app/test-pmd/txonly.c                 | 20 ++++++-----
 doc/guides/testpmd_app_ug/run_app.rst | 12 ++++++-
 examples/l3fwd/l3fwd_lpm.c            | 49 +++++++++++++++------------
 5 files changed, 105 insertions(+), 31 deletions(-)
Signature · 1 line
2.17.1
#15 lore raw

PATCH v5 1/3 app/testpmd: add ability to set Tx IP and UDP parameters

This patch changes what testpmd uses as IP addresses when run in transmit only mode. The old code was using 192.168.0.1 -> 192.168.0.2
but these addresses are reserved for private Internet by RFC 1918.

The new code uses 192.18.0.1 and 192.18.0.2 which are on the subnet reserved for performance testing by RFC 2544.

New command line option allows the user to pick any other src/dst address desired.

Notice: this changes the default IP address for transmit only. It may cause some user who has hardcoded network addresses to report a regression.

---
v5 -- rebase to 19.05-rc1 and fix reword commit message

 app/test-pmd/parameters.c             | 49 +++++++++++++++++++++++++++
 app/test-pmd/testpmd.h                |  6 ++++
 app/test-pmd/txonly.c                 | 20 ++++++-----
 doc/guides/testpmd_app_ug/run_app.rst | 12 ++++++-
 4 files changed, 77 insertions(+), 10 deletions(-)
app/test-pmd/parameters.c +49 -0
index 7b6b60905dce..8b523a5c66ed 100644
@@ -19,6 +19,7 @@
 #include <stdint.h>
 #include <unistd.h>
 #include <inttypes.h>
+#include <arpa/inet.h>
 
 #include <rte_common.h>
 #include <rte_byteorder.h>
@@ -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 | "
@@ -645,6 +647,8 @@ launch_args_parse(int argc, char** argv)
 		{ "mlockall",			0, 0, 0 },
 		{ "no-mlockall",		0, 0, 0 },
 		{ "mp-alloc",			1, 0, 0 },
+		{ "tx-ip",			1, 0, 0 },
+		{ "tx-udp",			1, 0, 0 },
 		{ "noisy-tx-sw-buffer-size",	1, 0, 0 },
 		{ "noisy-tx-sw-buffer-flushtime", 1, 0, 0 },
 		{ "noisy-lkup-memory",		1, 0, 0 },
@@ -743,6 +747,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)
app/test-pmd/testpmd.h +6 -0
index a45988ebc524..18d2c1ef1eaf 100644
@@ -443,6 +443,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;
app/test-pmd/txonly.c +11 -9
index 66e63788a25e..632d655235f0 100644
@@ -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
@@ -105,8 +107,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. */
 
@@ -121,8 +123,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.
@@ -206,7 +208,7 @@ pkt_burst_prepare(struct rte_mbuf *pkt, struct rte_mempool *mbp,
 		 * packet generator for developer's quick performance
 		 * regression test.
 		 */
-		addr = (IP_DST_ADDR | (ip_var++ << 8)) + rte_lcore_id();
+		addr = (tx_ip_dst_addr | (ip_var++ << 8)) + rte_lcore_id();
 		ip_hdr->src_addr = rte_cpu_to_be_32(addr);
 	}
 	copy_buf_to_pkt(&pkt_udp_hdr, sizeof(pkt_udp_hdr), pkt,
doc/guides/testpmd_app_ug/run_app.rst +11 -1
index b717b8c7b742..a72f94923210 100644
@@ -121,12 +121,22 @@ The commandline options are:
        XX:XX:XX:XX:XX:02
        ...
 
-
 *   ``--eth-peer=N,XX:XX:XX:XX:XX:XX``
 
     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 address values are source 192.18.0.1 and
+    destination 192.18.0.2. These are special purpose addresses
+    reserved for benchmakring (RFC 2544).
+
+*   ``--tx-udp=SRC[,DST]``
+    Set the source and destination UDP port number for transmit test only test.
+    The default port is the port 9 which is defined for the discard protocol
+    (RFC 863).
+
 *   ``--pkt-filter-mode=mode``
 
     Set Flow Director mode where mode is either ``none`` (the default), ``signature`` or ``perfect``.
Signature · 1 line
2.17.1
#16 lore raw

Re: [dpdk-dev] [PATCH v5 1/3] app/testpmd: add ability to set Tx IP and UDP parameters

Hi Stephen,

Quoted 207 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Tuesday, April 9, 2019 7:20 PM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>
Subject: [dpdk-dev] [PATCH v5 1/3] app/testpmd: add ability to set Tx IP and UDP parameters

This patch changes what testpmd uses as IP addresses when run in transmit only mode. The old code was using
192.168.0.1 -> 192.168.0.2
but these addresses are reserved for private Internet by RFC 1918.

The new code uses 192.18.0.1 and 192.18.0.2 which are on the subnet reserved for performance testing by RFC 2544.

New command line option allows the user to pick any other src/dst address desired.

Notice: this changes the default IP address for transmit only. It may cause some user who has hardcoded network addresses to report a regression.

---
v5 -- rebase to 19.05-rc1 and fix reword commit message

 app/test-pmd/parameters.c             | 49 +++++++++++++++++++++++++++
 app/test-pmd/testpmd.h                |  6 ++++
 app/test-pmd/txonly.c                 | 20 ++++++-----
 doc/guides/testpmd_app_ug/run_app.rst | 12 ++++++-
 4 files changed, 77 insertions(+), 10 deletions(-)
app/test-pmd/parameters.c index renamed from app/test-pmd/parameters.c +0 -0

7b6b60905dce..8b523a5c66ed 100644

app/test-pmd/parameters.c +23 -0
@@ -19,6 +19,7 @@
 #include <stdint.h>
 #include <unistd.h>
 #include <inttypes.h>
+#include <arpa/inet.h>
 
 #include <rte_common.h>
 #include <rte_byteorder.h>
@@ -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 | "
@@ -645,6 +647,8 @@ launch_args_parse(int argc, char** argv)
 		{ "mlockall",			0, 0, 0 },
 		{ "no-mlockall",		0, 0, 0 },
 		{ "mp-alloc",			1, 0, 0 },
+		{ "tx-ip",			1, 0, 0 },
+		{ "tx-udp",			1, 0, 0 },
 		{ "noisy-tx-sw-buffer-size",	1, 0, 0 },
 		{ "noisy-tx-sw-buffer-flushtime", 1, 0, 0 },
 		{ "noisy-lkup-memory",		1, 0, 0 },
@@ -743,6 +747,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);

app/test-pmd/parameters.c +7 -0
+			}
+			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 ||

app/test-pmd/parameters.c +3 -0
+				    !(*end == '\0' || *end == ','))
+					rte_exit(EXIT_FAILURE,
+						 "Invalid UDP port: %s\n",

optarg);

app/test-pmd/parameters.c +9 -0
+				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",

app/test-pmd/parameters.c +7 -0
+							 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)
app/test-pmd/testpmd.h index renamed from app/test-pmd/testpmd.h +0 -0

a45988ebc524..18d2c1ef1eaf 100644

app/test-pmd/testpmd.h +6 -0
@@ -443,6 +443,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 66e63788a25e..632d655235f0 100644

app/test-pmd/txonly.c +11 -8
@@ -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
@@ -105,8 +107,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. */
 
@@ -121,8 +123,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.
@@ -206,7 +208,7 @@ pkt_burst_prepare(struct rte_mbuf *pkt, struct
 rte_mempool *mbp,
 		 * packet generator for developer's quick performance
 		 * regression test.
 		 */
-		addr = (IP_DST_ADDR | (ip_var++ << 8)) + rte_lcore_id();
+		addr = (tx_ip_dst_addr | (ip_var++ << 8)) + rte_lcore_id();
 		ip_hdr->src_addr = rte_cpu_to_be_32(addr);
 	}

copy_buf_to_pkt(&pkt_udp_hdr, sizeof(pkt_udp_hdr), pkt, diff --git
a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst
index b717b8c7b742..a72f94923210 100644

doc/guides/testpmd_app_ug/run_app.rst +0 -1
@@ -121,12 +121,22 @@ The commandline options are:
        XX:XX:XX:XX:XX:02
...
 
-
 *   ``--eth-peer=N,XX:XX:XX:XX:XX:XX``
 
     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.

Quoted 1 line

+* ``--tx-ip=SRC,DST``

An extra blank line is needed here for correct formatting in the output HTML

doc/guides/testpmd_app_ug/run_app.rst The commandline options are: · line 135

Quoted 7 lines

+ Set the source and destination IP address used when doing transmit only
test.

doc/guides/testpmd_app_ug/run_app.rst +5 -0
+    The defaults address values are source 192.18.0.1 and
+    destination 192.18.0.2. These are special purpose addresses
+    reserved for benchmakring (RFC 2544).
+
+*   ``--tx-udp=SRC[,DST]``

An extra blank line is needed here for correct formatting in the output HTML

Quoted 11 lines

+ Set the source and destination UDP port number for transmit test only
test.

doc/guides/testpmd_app_ug/run_app.rst +3 -0
+    The default port is the port 9 which is defined for the discard protocol
+    (RFC 863).
+
 *   ``--pkt-filter-mode=mode``
 
     Set Flow Director mode where mode is either ``none`` (the default),

``signature`` or ``perfect``.
--
2.17.1

./dpdk/devtools/checkpatches.sh is showing some lines over 80 characters in parameters.c

### [dpdk-dev] [PATCH v5 1/3] app/testpmd: add ability to set Tx IP and UDP parameters

WARNING:LONG_LINE: line over 80 characters
#88: FILE: app/test-pmd/parameters.c:762:
+ "Invalid source IP address: %s\n", optarg);

WARNING:LONG_LINE: line over 80 characters
#93: FILE: app/test-pmd/parameters.c:767:
+ "Invalid destination IP address: %s\n", optarg);

WARNING:LONG_LINE: line over 80 characters
#101: FILE: app/test-pmd/parameters.c:775:
+ if (errno != 0 || end == optarg || n > UINT16_MAX ||

WARNING:LONG_LINE: line over 80 characters
#104: FILE: app/test-pmd/parameters.c:778:
+ "Invalid UDP port: %s\n", optarg);

total: 0 errors, 4 warnings, 153 lines checked

Regards,

Bernard.

#17 lore raw

PATCH v5 2/3 examples/l3fwd: use reserved IPv4/IPv6 addresses

In reply to Stephen Hemminger

The l3fwd 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.

---
 examples/l3fwd/l3fwd_lpm.c | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)
examples/l3fwd/l3fwd_lpm.c +18 -16
index b1dc195ad8cb..3191fc4c2639 100644
@@ -39,26 +39,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 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}, 48, 0},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0}, 48, 1},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0}, 48, 2},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0}, 48, 3},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0}, 48, 4},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0}, 48, 5},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0}, 48, 6},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0}, 48, 7},
 };
 
 #define IPV4_L3FWD_LPM_NUM_ROUTES \
Signature · 1 line
2.17.1
Acked-by on v5 2/3
#18 lore raw

Re: [dpdk-dev] [PATCH v5 2/3] examples/l3fwd: use reserved IPv4/IPv6 addresses

Quoted 9 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Tuesday, April 9, 2019 7:20 PM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>
Subject: [dpdk-dev] [PATCH v5 2/3] examples/l3fwd: use reserved IPv4/IPv6 addresses

Quoted 5 lines

The l3fwd 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.

#19 lore raw

PATCH v5 3/3 examples/l3fwd: format the IP addresses for printing

In reply to Stephen Hemminger

The IP addresses should be formatted using standard routines rather than outputing in raw hex.

---

 examples/l3fwd/l3fwd_lpm.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
examples/l3fwd/l3fwd_lpm.c +10 -5
index 3191fc4c2639..172a036b2707 100644
@@ -13,6 +13,7 @@
 #include <errno.h>
 #include <getopt.h>
 #include <stdbool.h>
+#include <arpa/inet.h>
 
 #include <rte_debug.h>
 #include <rte_ether.h>
@@ -260,6 +261,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;
@@ -275,6 +277,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 &
@@ -292,8 +295,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);
 	}
@@ -331,9 +335,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);
 	}
 }
 
Signature · 1 line
2.17.1
#20 lore raw

v6 cover use IPv4 addresses reserved for testing

In reply to Stephen Hemminger

These patches get rid of the custom addresses used in testpmd and l3fwd, and instead uses values that are reserved for testing in the relevant RFC 2544.

This version fixes some formatting and long lines.

Stephen Hemminger (3):
app/testpmd: add ability to set Tx IP and UDP parameters examples/l3fwd: use reserved IPv4/IPv6 addresses examples/l3fwd: format the IP addresses for printing

 app/test-pmd/parameters.c             | 53 +++++++++++++++++++++++++++
 app/test-pmd/testpmd.h                |  6 +++
 app/test-pmd/txonly.c                 | 20 +++++-----
 doc/guides/testpmd_app_ug/run_app.rst | 14 ++++++-
 examples/l3fwd/l3fwd_lpm.c            | 49 ++++++++++++++-----------
 5 files changed, 111 insertions(+), 31 deletions(-)
Signature · 1 line
2.17.1
#21 lore raw

PATCH v6 1/3 app/testpmd: add ability to set Tx IP and UDP parameters

This patch changes what testpmd uses as IP addresses when run in transmit only mode. The old code was using 192.168.0.1 -> 192.168.0.2
but these addresses are reserved for private Internet by RFC 1918.

The new code uses 192.18.0.1 and 192.18.0.2 which are on the subnet reserved for performance testing by RFC 2544.

New command line option allows the user to pick any other src/dst address desired.

Notice: this changes the default IP address for transmit only. It may cause some user who has hardcoded network addresses to report a regression.

---
v6 - fix formatting of document and break long lines

 app/test-pmd/parameters.c             | 53 +++++++++++++++++++++++++++
 app/test-pmd/testpmd.h                |  6 +++
 app/test-pmd/txonly.c                 | 20 +++++-----
 doc/guides/testpmd_app_ug/run_app.rst | 14 ++++++-
 4 files changed, 83 insertions(+), 10 deletions(-)
app/test-pmd/parameters.c +53 -0
index 7b6b60905dce..d358cda2451f 100644
@@ -19,6 +19,7 @@
 #include <stdint.h>
 #include <unistd.h>
 #include <inttypes.h>
+#include <arpa/inet.h>
 
 #include <rte_common.h>
 #include <rte_byteorder.h>
@@ -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 | "
@@ -645,6 +647,8 @@ launch_args_parse(int argc, char** argv)
 		{ "mlockall",			0, 0, 0 },
 		{ "no-mlockall",		0, 0, 0 },
 		{ "mp-alloc",			1, 0, 0 },
+		{ "tx-ip",			1, 0, 0 },
+		{ "tx-udp",			1, 0, 0 },
 		{ "noisy-tx-sw-buffer-size",	1, 0, 0 },
 		{ "noisy-tx-sw-buffer-flushtime", 1, 0, 0 },
 		{ "noisy-lkup-memory",		1, 0, 0 },
@@ -743,6 +747,55 @@ 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)
app/test-pmd/testpmd.h +6 -0
index a45988ebc524..18d2c1ef1eaf 100644
@@ -443,6 +443,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;
app/test-pmd/txonly.c +11 -9
index 66e63788a25e..632d655235f0 100644
@@ -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
@@ -105,8 +107,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. */
 
@@ -121,8 +123,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.
@@ -206,7 +208,7 @@ pkt_burst_prepare(struct rte_mbuf *pkt, struct rte_mempool *mbp,
 		 * packet generator for developer's quick performance
 		 * regression test.
 		 */
-		addr = (IP_DST_ADDR | (ip_var++ << 8)) + rte_lcore_id();
+		addr = (tx_ip_dst_addr | (ip_var++ << 8)) + rte_lcore_id();
 		ip_hdr->src_addr = rte_cpu_to_be_32(addr);
 	}
 	copy_buf_to_pkt(&pkt_udp_hdr, sizeof(pkt_udp_hdr), pkt,
doc/guides/testpmd_app_ug/run_app.rst +13 -1
index b717b8c7b742..a3e8e9bf2de2 100644
@@ -121,12 +121,24 @@ The commandline options are:
        XX:XX:XX:XX:XX:02
        ...
 
-
 *   ``--eth-peer=N,XX:XX:XX:XX:XX:XX``
 
     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 address values are source 192.18.0.1 and
+    destination 192.18.0.2. These are special purpose addresses
+    reserved for benchmarking (RFC 2544).
+
+*   ``--tx-udp=SRC[,DST]``
+
+    Set the source and destination UDP port number for transmit test only test.
+    The default port is the port 9 which is defined for the discard protocol
+    (RFC 863).
+
 *   ``--pkt-filter-mode=mode``
 
     Set Flow Director mode where mode is either ``none`` (the default), ``signature`` or ``perfect``.
Signature · 1 line
2.17.1
Acked-by on v6 1/3
#22 lore raw

Re: [dpdk-dev] [PATCH v6 1/3] app/testpmd: add ability to set Tx IP and UDP parameters

Quoted 17 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Wednesday, April 10, 2019 6:42 PM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>
Subject: [dpdk-dev] [PATCH v6 1/3] app/testpmd: add ability to set Tx IP and UDP parameters

This patch changes what testpmd uses as IP addresses when run in transmit only mode. The old code was using
192.168.0.1 -> 192.168.0.2
but these addresses are reserved for private Internet by RFC 1918.

The new code uses 192.18.0.1 and 192.18.0.2 which are on the subnet reserved for performance testing by RFC 2544.

Quoted 8 lines

New command line option allows the user to pick any other src/dst address desired.

Notice: this changes the default IP address for transmit only. It may cause some user who has hardcoded network addresses to report a regression.

#23 lore raw

PATCH v6 2/3 examples/l3fwd: use reserved IPv4/IPv6 addresses

In reply to Stephen Hemminger

The l3fwd 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.

---
 examples/l3fwd/l3fwd_lpm.c | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)
examples/l3fwd/l3fwd_lpm.c +18 -16
index b1dc195ad8cb..3191fc4c2639 100644
@@ -39,26 +39,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 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}, 48, 0},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0}, 48, 1},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0}, 48, 2},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0}, 48, 3},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0}, 48, 4},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0}, 48, 5},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0}, 48, 6},
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0}, 48, 7},
 };
 
 #define IPV4_L3FWD_LPM_NUM_ROUTES \
Signature · 1 line
2.17.1
Acked-by on v6 2/3
#24 lore raw

Re: [dpdk-dev] [PATCH v6 2/3] examples/l3fwd: use reserved IPv4/IPv6 addresses

Quoted 9 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Wednesday, April 10, 2019 6:42 PM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>
Subject: [dpdk-dev] [PATCH v6 2/3] examples/l3fwd: use reserved IPv4/IPv6 addresses

Quoted 5 lines

The l3fwd 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.

#25 lore raw

PATCH v6 3/3 examples/l3fwd: format the IP addresses for printing

In reply to Stephen Hemminger

The IP addresses should be formatted using standard routines rather than outputing in raw hex.

---
 examples/l3fwd/l3fwd_lpm.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
examples/l3fwd/l3fwd_lpm.c +10 -5
index 3191fc4c2639..172a036b2707 100644
@@ -13,6 +13,7 @@
 #include <errno.h>
 #include <getopt.h>
 #include <stdbool.h>
+#include <arpa/inet.h>
 
 #include <rte_debug.h>
 #include <rte_ether.h>
@@ -260,6 +261,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;
@@ -275,6 +277,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 &
@@ -292,8 +295,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);
 	}
@@ -331,9 +335,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);
 	}
 }
 
Signature · 1 line
2.17.1
#26 lore raw

Re: [dpdk-dev] [PATCH v6 0/3] use IPv4 addresses reserved for testing

In reply to Stephen Hemminger

10/04/2019 19:41, Stephen Hemminger:

Quoted 4 lines

Stephen Hemminger (3):
app/testpmd: add ability to set Tx IP and UDP parameters examples/l3fwd: use reserved IPv4/IPv6 addresses examples/l3fwd: format the IP addresses for printing

Applied, thanks

#27 lore raw

PATCH v3 2/3 examples/l3fwd: use reserved IPv4/IPv6 addresses

In reply to Stephen Hemminger

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")
---
 examples/l3fwd/l3fwd_lpm.c | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)
examples/l3fwd/l3fwd_lpm.c +18 -16
index a747126a2404..3724f79c1924 100644
@@ -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 \
Signature · 1 line
2.17.1
#28 lore raw

Re: [PATCH v3 2/3] examples/l3fwd: use reserved IPv4/IPv6 addresses

Hi Stephen,

Quoted 15 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Monday, June 18, 2018 10:36 PM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>
Subject: [dpdk-dev] [PATCH v3 2/3] examples/l3fwd: use reserved IPv4/IPv6 addresses

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")

---

<snip>

Quoted 10 lines
 examples/l3fwd/l3fwd_lpm.c | 34 ++++++++++++++++++----------------
examples/l3fwd/l3fwd_lpm.c +2 -5
+/* 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},

examples/l3fwd/l3fwd_lpm.c struct ipv6_l3fwd_lpm_route { · line 63

Quoted 10 lines
examples/l3fwd/l3fwd_lpm.c +7 -3
-	{{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},

Should the depth value of 48 be used instead of 64 in the lines above?

examples/l3fwd/l3fwd_lpm.c struct ipv6_l3fwd_lpm_route { · line 64

Quoted 1 line
examples/l3fwd/l3fwd_lpm.c +1 -0
+	{{32, 1, 2, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0}, 48, 0},

Should 20 be used instead of 32 in the lines above ?

Quoted 5 lines

};

#define IPV4_L3FWD_LPM_NUM_ROUTES \
--
2.17.1

#29 lore raw

PATCH v3 3/3 examples/l3fwd: format the IP addresses for printing

In reply to Stephen Hemminger

It is better user experience to print standard format for addresses rather than raw hex.

---
 examples/l3fwd/l3fwd_lpm.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
examples/l3fwd/l3fwd_lpm.c +10 -5
index 3724f79c1924..3edc82aa2c62 100644
@@ -13,6 +13,7 @@
 #include <errno.h>
 #include <getopt.h>
 #include <stdbool.h>
+#include <arpa/inet.h>
 
 #include <rte_debug.h>
 #include <rte_ether.h>
@@ -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);
 	}
 }
 
Signature · 1 line
2.17.1
#30 lore raw

Re: [PATCH v3 3/3] examples/l3fwd: format the IP addresses for printing

Hi Stephen,

Quoted 8 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Monday, June 18, 2018 10:36 PM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>
Subject: [dpdk-dev] [PATCH v3 3/3] examples/l3fwd: format the IP addresses for printing

Quoted 6 lines

It is better user experience to print standard format for addresses rather than raw hex.

---
 examples/l3fwd/l3fwd_lpm.c | 15 ++++++++++-----

<snip>

dpdk/devtools/check-git-log.sh -1
Wrong beginning of commit message:
It is better user experience to print standard format for addresses

It is complaining about "It" in the commit message, not sure why.

Hi Thomas,

Could this be a bug in the check-git-log script.

Regards,

Bernard.

#31 lore raw

Re: [PATCH v3 3/3] examples/l3fwd: format the IP addresses for printing

22/06/2018 12:23, Iremonger, Bernard:

Quoted 23 lines

Hi Stephen,

Quoted 8 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Monday, June 18, 2018 10:36 PM
To: [email protected]
Cc: Stephen Hemminger <[email protected]>
Subject: [dpdk-dev] [PATCH v3 3/3] examples/l3fwd: format the IP addresses for printing

Quoted 6 lines

It is better user experience to print standard format for addresses rather than raw hex.

---
 examples/l3fwd/l3fwd_lpm.c | 15 ++++++++++-----

<snip>

dpdk/devtools/check-git-log.sh -1
Wrong beginning of commit message:
It is better user experience to print standard format for addresses

Quoted 5 lines

It is complaining about "It" in the commit message, not sure why.

Hi Thomas,

Could this be a bug in the check-git-log script.

No it is not a bug, just a pedantic warning :)
Look at this commit for the explanation:

	http://git.dpdk.org/dpdk/commit/?id=9c24780f0d5efd