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

Thomas Huth thuth at redhat.com
Thu Apr 21 21:35:38 AEST 2016


On 13.04.2016 09:03, Nikunj A Dadhania wrote:
> 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);

That netmask calculation looks somewhat strange to me ... what's the
rationale here? If you need automatic netmask calculation, shouldn't
that rather be done by the type of IP address that has been specified?
(or maybe via an "/xx" suffix of the specified IP address string?)

 Thomas

> +			set_ipv4_router(ping_args.gateway_ip.integer);
> +		}
>  		arp_failed = 1;
>  		printf("  Own IP address: ");
>  	}
> 



More information about the SLOF mailing list