diff mbox

[v3,1/3] ping: report success on localhost ping

Message ID 1462248067-15346-1-git-send-email-nikunj@linux.vnet.ibm.com
State Superseded
Headers show

Commit Message

Nikunj A Dadhania May 3, 2016, 4:01 a.m. UTC
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
---
 clients/net-snk/app/netapps/ping.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Thomas Huth May 3, 2016, 6:42 a.m. UTC | #1
On 03.05.2016 06:01, Nikunj A Dadhania wrote:
> Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
> ---
>  clients/net-snk/app/netapps/ping.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/clients/net-snk/app/netapps/ping.c b/clients/net-snk/app/netapps/ping.c
> index 2c7dadb..4facf06 100644
> --- a/clients/net-snk/app/netapps/ping.c
> +++ b/clients/net-snk/app/netapps/ping.c
> @@ -180,6 +180,12 @@ ping(int argc, char *argv[])
>  	       ((fn_ip.server_ip >> 8) & 0xFF), (fn_ip.server_ip & 0xFF));
>  
>  
> +	// Report success on localhost ping
> +	if (memcmp(&fn_ip.server_ip, &fn_ip.own_ip, 4) == 0) {
> +		printf("success\n");
> +		return 0;
> +	}
> +
>  	ping_ipv4(fd_device, fn_ip.server_ip);
>  
>  	set_timer(TICKS_SEC / 10 * ping_args.timeout);

Nice cheating ;-)

Reviewed-by: Thomas Huth <thuth@redhat.com>
diff mbox

Patch

diff --git a/clients/net-snk/app/netapps/ping.c b/clients/net-snk/app/netapps/ping.c
index 2c7dadb..4facf06 100644
--- a/clients/net-snk/app/netapps/ping.c
+++ b/clients/net-snk/app/netapps/ping.c
@@ -180,6 +180,12 @@  ping(int argc, char *argv[])
 	       ((fn_ip.server_ip >> 8) & 0xFF), (fn_ip.server_ip & 0xFF));
 
 
+	// Report success on localhost ping
+	if (memcmp(&fn_ip.server_ip, &fn_ip.own_ip, 4) == 0) {
+		printf("success\n");
+		return 0;
+	}
+
 	ping_ipv4(fd_device, fn_ip.server_ip);
 
 	set_timer(TICKS_SEC / 10 * ping_args.timeout);