Subject: pkg/17759: choparp does not work on NetBSD/sparc64 (patch included)
To: None <gnats-bugs@gnats.netbsd.org>
From: None <wizard@sik.oulu.fi>
List: netbsd-bugs
Date: 07/29/2002 12:44:10
>Number:         17759
>Category:       pkg
>Synopsis:       choparp does not work on NetBSD/sparc64 (patch included)
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 29 12:45:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Tomi Nylund
>Release:        NetBSD 1.6_BETA4
>Organization:
University of Oulu, Finland
>Environment:
NetBSD 1.6_BETA4
>Description:
Choparp uses u_long structure in checkarp function, where it ANDs
received inet address against known netmask, seeing if it turns out
to be the network number for the network being proxyed. Problem is,
the datatype used for holding the ipv4 address is of u_long, which
in sparc64, is 64 bits long, not 32. Since U-SPARC is big endian,
the returned IP address is all zeros.

In function:

    }
    target_ip = ntohl(*(u_long *)(arp->arp_tpa));
    if ((target_ip & target_mask) == target_net)
        return(-1);             /* OK */
    return(0);
}

you can see the u_long that causes the problems.

>How-To-Repeat:
On NetBSD/sparc64:

cd pkgsrc/net/choparp; make; make install. Try to use it, it does not
reply to arp requests.
>Fix:
Change the datatype from u_long to for example u_int32_t. Patch follows:
--- choparp.c.orig      Mon Jul 29 22:18:21 2002
+++ choparp.c   Mon Jul 29 22:15:42 2002
@@ -184,7 +184,7 @@
        fprintf(stderr,"checkarp: WARNING: received unknown type ARPrequest.\n");
        return(0);
     }
-    target_ip = ntohl(*(u_long *)(arp->arp_tpa));
+    target_ip = ntohl(*(u_int32_t *)(arp->arp_tpa));
     if ((target_ip & target_mask) == target_net)
        return(-1);             /* OK */
     return(0);

>Release-Note:
>Audit-Trail:
>Unformatted: