ping prints ip address octets backwards on host redirect

Bug #1892108 reported by Åge Strand
62
This bug affects 13 people
Affects Status Importance Assigned to Milestone
iputils (Ubuntu)
Undecided
Unassigned

Bug Description

Description: Ubuntu 20.04.1 LTS
Release: 20.04

Just noticed a weird thing with ping on Ubuntu 20.04, which I recently updated to.

This is what I get when pinging a host on my network:

user@ubuntu2004:~$ ping 10.156.0.63
PING 10.156.0.63 (10.156.0.63) 56(84) bytes of data.
From 10.15.0.1 icmp_seq=2 Redirect Host(New nexthop: 2.0.15.10)

The ubuntu2004 machine is located in the 10.15.0.x network.
10.15.0.1 is a DSL router.
10.15.0.2 is a firewall between multiple networks.
10.156.0.63 is a machine on a different local network.

All traffic not destined for the internet is routed from 10.15.0.1 to 10.15.0.2, so I would expect the printout to read "New nexthop: 10.15.0.2".

However, as you can see this is not the case. Instead the octets are printed in reverse order.

To verify this I tried the same on another machine in the same network, running Ubuntu 18.04:

user@ubuntu1804:~$ ping 10.156.0.63
PING 10.156.0.63 (10.156.0.63) 56(84) bytes of data.
From 10.15.0.1: icmp_seq=2 Redirect Host(New nexthop: 10.15.0.2)

As you can see, the printout is correct here: "New nexthop: 10.15.0.2"

I further verified the discrepancy by using tcpdump to interpret the ICMP packets on the ubuntu2004 machine, and there seems to be no problem for tcpdump to display the correct IP address.

My assumption is that there is something wrong in the print function which displays the IP address for a host redirect.

Revision history for this message
Åge Strand (aagestrand) wrote :

Possible culprit might be the pr_icmph function in ping.c, lines 1250 - 1259:

  {
   struct sockaddr_in sin = {
    .sin_family = AF_INET,
    .sin_addr = {
     icp ? icp->un.gateway : info
    }
   };

   printf(_("(New nexthop: %s)\n"), pr_addr(&sin, sizeof sin));
  }

Are you sure the variables used for .sin_addr input are guaranteed to be in network byte order?

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in iputils (Ubuntu):
status: New → Confirmed
Revision history for this message
Mike Bergeron (clandestiny) wrote :

I'm afraid it likely runs a bit deeper than just being "printed in reverse order". I had a Redirect Host of 192.168.107.65 print backwards and actually name resolve w192.z065107168.sea-wa.dsl.cnc.net (65.107.168.192) and thereafter ping returns ceased, ostensibly because it tried to route my private addresses through some dsl client in Seattle. It's now November, and a fresh install of Focal 20.04.1 still has this problem, reported in August. It might be obscure, but it's not trivial.

I hope someone is working on this.

Thanks,
-MikeB

Revision history for this message
Silvan Diem (linuxfighter) wrote :

Please fix it asap.
We have the same issue. We have migrated our Nagios to Ubuntu 20.04. Now we have flapping hosts, because of this issue!

Is there a timeline when you will able to fix it ?

Thanks

Silvan

Revision history for this message
Richard Laager (rlaager) wrote :

I was able to verify this is fixed in iputils-ping 20210202-1. That is, I saw this same problem, grabbed those sources from Debian, built them, and tested again. Accordingly, this should already be fixed in Ubuntu impish.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers