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

Nikunj A Dadhania nikunj at linux.vnet.ibm.com
Fri Apr 22 15:23:04 AEST 2016


Thomas Huth <thuth at redhat.com> writes:

> 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?

Ping currently only supports IPv4. Case here was that subnet mask is not
provided and we are trying to guess the subnet mask. Dont think this
will be accurate always, but will work.

> If you need automatic netmask calculation, shouldn't
> that rather be done by the type of IP address that has been specified?

Here its only IPv4. We still dont have ipv6 support here. I have that in
my list though.

> (or maybe via an "/xx" suffix of the specified IP address string?)

I am not sure about this, can you please elaborate?

Regards
Nikunj



More information about the SLOF mailing list