Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ping: print the gateway with the correct endianness
When receiving an ICMP redirect message, ping prints the nexthop,
but this is shown with the wrong endianness on x86:
$ ping 192.168.0.1
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=254 time=3.41 ms
From 192.168.85.1 icmp_seq=2 Redirect Host(New nexthop: 44.85.168.192)
64 bytes from 192.168.0.1: icmp_seq=2 ttl=254 time=3.75 ms
This only happens when using IPPROTO_ICMP sockets, with raw sockets the
issue doesn't happen:
$ sudo sysctl -w net.ipv4.ping_group_range='1 0'
net.ipv4.ping_group_range = 1 0
$ sudo ping 192.168.0.1
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=254 time=3.17 ms
From 192.168.85.1: icmp_seq=2 Redirect Host(New nexthop: 192.168.85.44)
64 bytes from 192.168.0.1: icmp_seq=2 ttl=254 time=3.79 ms
Signed-off-by: Matteo Croce <mcroce@redhat.com>- Loading branch information