[SLOF] [PATCH 1/2] ping: use gateway address for routing

Nikunj A Dadhania nikunj at linux.vnet.ibm.com
Wed Apr 13 17:03:51 AEST 2016


ping was failing for machine across the subnet with
statically assinged IP address. The parsed gateway address
was ignored in the stack because the router variable was not
set.

Currently, ping does not take a netmask parameter, set netmask parameter
with the common top order bits of client IP and gateway IP.

Signed-off-by: Nikunj A Dadhania <nikunj at 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..1522792 100644
--- a/clients/net-snk/app/netapps/ping.c
+++ b/clients/net-snk/app/netapps/ping.c
@@ -163,6 +163,12 @@ ping(int argc, char *argv[])
 
 	} else {
 		memcpy(&fn_ip.own_ip, &ping_args.client_ip.integer, 4);
+		if (ping_args.gateway_ip.integer) {
+			uint32_t netmask;
+			netmask = ping_args.gateway_ip.integer & ping_args.client_ip.integer;
+			set_ipv4_netmask(netmask & 0xFFFFFF00);
+			set_ipv4_router(ping_args.gateway_ip.integer);
+		}
 		arp_failed = 1;
 		printf("  Own IP address: ");
 	}
-- 
2.5.5



More information about the SLOF mailing list