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

Message ID 20180618213557.15209-4-stephen@networkplumber.org
State Superseded, archived
Delegated to: Thomas Monjalon
Headers show
Series
  • use RFC addresses for testing
Related show

Checks

Context Check Description
ci/Intel-compilation fail Compilation issues
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger June 18, 2018, 9:35 p.m.
It is better user experience to print standard format for addresses
rather than raw hex.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/l3fwd/l3fwd_lpm.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

Comments

Bernard Iremonger June 22, 2018, 10:23 a.m. | #1
Hi Stephen,

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Stephen Hemminger
> Sent: Monday, June 18, 2018 10:36 PM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>
> Subject: [dpdk-dev] [PATCH v3 3/3] examples/l3fwd: format the IP addresses for
> printing
> 
> It is better user experience to print standard format for addresses rather than
> raw hex.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  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.
Thomas Monjalon June 22, 2018, 1:44 p.m. | #2
22/06/2018 12:23, Iremonger, Bernard:
> Hi Stephen,
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Stephen Hemminger
> > Sent: Monday, June 18, 2018 10:36 PM
> > To: dev@dpdk.org
> > Cc: Stephen Hemminger <stephen@networkplumber.org>
> > Subject: [dpdk-dev] [PATCH v3 3/3] examples/l3fwd: format the IP addresses for
> > printing
> > 
> > It is better user experience to print standard format for addresses rather than
> > raw hex.
> > 
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > ---
> >  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. 

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

Patch

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 <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);
 	}
 }