Bug 756439

Summary: ping Record Route report incorrect (same route)
Product: [Fedora] Fedora Reporter: Enrique V. Bonet Esteban <enrique.bonet>
Component: iputilsAssignee: Jiri Skala <jskala>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: unspecified    
Version: 15CC: aglotov, jskala
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-11-24 13:58:32 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Enrique V. Bonet Esteban 2011-11-23 15:23:32 UTC
Description of problem:

The ping -R command report (same route) although the route are different. The
problem turns up when before reaching the different section route (A or B),
there is a 0 value in a component of the IP address of a node. In the
following example, which we use in our university lessons, the routers
balanced the network traffic one to one:

Route A:
10.0.0.2 <- Fedora 15
10.0.4.5
10.0.3.1
10.0.2.2 <- Fedora 15
10.0.2.2
10.0.4.2
10.0.0.1
10.0.0.2

Route B:
10.0.0.2 <- Fedora 15
10.0.4.1
10.0.2.1
10.0.2.2 <- Fedora 15
10.0.2.2
10.0.4.2
10.0.0.1
10.0.0.2

Executing the command ping -R 10.0.2.2 in the 10.0.0.2 host, the ping reports
the first route A (or the first route B) and after always the (same route),
instead of reporting the A route, B route, A route, B route...

Version-Release number of selected component (if applicable):

iputils-20071127 and subsequent iputils packages, including Fedora 14, Fedora 
15, Fedora 16 and rawhide iputils packages.

How reproducible:

Execute ping -R in a network with two routes and, for example, Fedora node
with IP 10.0.X.X.

Steps to Reproduce:
1. Install the iputils package in a Fedora 14 or later version.
2. Execute ping -R in a network as describe above.
3. The ping -R report (same route).
4. Modify the code as after the bug is solved.
  
Actual results:

ping -R report (same route)

Expected results:

ping -R report route A, route B, route A, route B, ...

Additional info:

The error is caused by the use of the strncmp() function in the code that
replaces the obsolete bcmp() function:

if (i == old_rrlen
    && !strncmp((char *)cp, old_rr, i)
    && !(options & F_FLOOD)) {
        printf("\t(same route)");
        i = ((i + 3) / 4) * 4;
        cp += i;
        break;
}

The bug solution is to replace the strncmp() function for the memcmp() function 
as follows:

if (i == old_rrlen
    && !memcmp(cp, (unsigned char *)old_rr, i)
    && !(options & F_FLOOD)) {
        printf("\t(same route)");
        i = ((i + 3) / 4) * 4;
        cp += i;
        break;
}