From owner-freebsd-current@FreeBSD.ORG Fri Jun 13 18:20:11 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 153A037B404; Fri, 13 Jun 2003 18:20:11 -0700 (PDT) Received: from mail.cyberonic.com (mail.cyberonic.com [4.17.179.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id A3F9743F75; Fri, 13 Jun 2003 18:20:09 -0700 (PDT) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (node-40244c0a.sfo.onnet.us.uu.net [64.36.76.10]) by mail.cyberonic.com (8.12.8/8.12.5) with ESMTP id h5E1DLZM029371; Fri, 13 Jun 2003 21:13:22 -0400 Received: (from jmg@localhost) by hydrogen.funkthat.com (8.12.9/8.11.6) id h5E1Kbv9034295; Fri, 13 Jun 2003 18:20:37 -0700 (PDT) (envelope-from jmg) Date: Fri, 13 Jun 2003 18:20:37 -0700 From: John-Mark Gurney To: current@freebsd.org, sparc64@freebsd.org Message-ID: <20030614012037.GA32701@funkthat.com> Mail-Followup-To: current@freebsd.org, sparc64@freebsd.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="huq684BweRXVnRxX" Content-Disposition: inline User-Agent: Mutt/1.4.1i X-Operating-System: FreeBSD 4.2-RELEASE i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html Subject: rarpd broken on 64bit big endien machines (i.e. sparc64) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: John-Mark Gurney List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jun 2003 01:20:11 -0000 --huq684BweRXVnRxX Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Ok, I just tried to net boot an Ultra 2 from another sparc box, and rarpd is broken. It is still using u_long to represent the IPv4 addresses. Attached is a patch that switches from u_long to in_addr_t. I have confirmed that this works on both sparc64 (5.1-R) and x86 (4.7-R). Comments? -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not." --huq684BweRXVnRxX Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="rarpd.patch" ? rarpd ? rarpd.8.gz Index: rarpd.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/rarpd/rarpd.c,v retrieving revision 1.34 diff -u -r1.34 rarpd.c --- rarpd.c 2003/05/03 21:06:39 1.34 +++ rarpd.c 2003/06/14 01:02:48 @@ -114,8 +114,8 @@ struct if_info { struct if_info *ii_next; int ii_fd; /* BPF file descriptor */ - u_long ii_ipaddr; /* IP address of this interface */ - u_long ii_netmask; /* subnet or net mask */ + in_addr_t ii_ipaddr; /* IP address of this interface */ + in_addr_t ii_netmask; /* subnet or net mask */ u_char ii_eaddr[6]; /* Ethernet address of this interface */ char ii_ifname[sizeof(((struct ifreq *)0)->ifr_name) + 1]; }; @@ -136,22 +136,22 @@ static u_char zero[6]; static int bpf_open(void); -static u_long choose_ipaddr(u_long **, u_long, u_long); +static in_addr_t choose_ipaddr(in_addr_t **, in_addr_t, in_addr_t); static char *eatoa(u_char *); static int expand_syslog_m(const char *fmt, char **newfmt); static void init(char *); static void init_one(struct ifreq *, char *); -static char *intoa(u_long); -static u_long ipaddrtonetmask(u_long); +static char *intoa(in_addr_t); +static in_addr_t ipaddrtonetmask(in_addr_t); static void logmsg(int, const char *, ...) __printflike(2, 3); -static int rarp_bootable(u_long); +static int rarp_bootable(in_addr_t); static int rarp_check(u_char *, u_int); static void rarp_loop(void); static int rarp_open(char *); static void rarp_process(struct if_info *, u_char *, u_int); static void rarp_reply(struct if_info *, struct ether_header *, - u_long, u_int); -static void update_arptab(u_char *, u_long); + in_addr_t, u_int); +static void update_arptab(u_char *, in_addr_t); static void usage(void); int @@ -390,9 +390,9 @@ /* Verbose stuff */ if (verbose) for (ii = iflist; ii != NULL; ii = ii->ii_next) - logmsg(LOG_DEBUG, "%s %s 0x%08lx %s", + logmsg(LOG_DEBUG, "%s %s 0x%08x %s", ii->ii_ifname, intoa(ntohl(ii->ii_ipaddr)), - (u_long)ntohl(ii->ii_netmask), eatoa(ii->ii_eaddr)); + (in_addr_t)ntohl(ii->ii_netmask), eatoa(ii->ii_eaddr)); } void @@ -625,7 +625,7 @@ * configuration file. */ int -rarp_bootable(u_long addr) +rarp_bootable(in_addr_t addr) { #ifdef HAVE_DIRENT_H struct dirent *dent; @@ -636,7 +636,7 @@ char ipname[9]; static DIR *dd = NULL; - (void)sprintf(ipname, "%08lX", (u_long)ntohl(addr)); + (void)sprintf(ipname, "%08X", (in_addr_t)ntohl(addr)); /* * If directory is already open, rewind it. Otherwise, open it. @@ -666,8 +666,8 @@ * is on network 'net'; 'netmask' is a mask indicating the network portion * of the address. */ -u_long -choose_ipaddr(u_long **alist, u_long net, u_long netmask) +in_addr_t +choose_ipaddr(in_addr_t **alist, in_addr_t net, in_addr_t netmask) { for (; *alist; ++alist) if ((**alist & netmask) == net) @@ -684,7 +684,7 @@ { struct ether_header *ep; struct hostent *hp; - u_long target_ipaddr; + in_addr_t target_ipaddr; char ename[256]; ep = (struct ether_header *)pkt; @@ -708,7 +708,7 @@ ename); return; } - target_ipaddr = choose_ipaddr((u_long **)hp->h_addr_list, + target_ipaddr = choose_ipaddr((in_addr_t **)hp->h_addr_list, ii->ii_ipaddr & ii->ii_netmask, ii->ii_netmask); if (target_ipaddr == 0) { @@ -748,7 +748,7 @@ } rtmsg; void -update_arptab(u_char *ep, u_long ipaddr) +update_arptab(u_char *ep, in_addr_t ipaddr) { int cc; struct sockaddr_inarp *ar, *ar2; @@ -802,7 +802,7 @@ * directly connected network (the family is AF_INET in * this case). */ - logmsg(LOG_ERR, "bogus link family (%d) wrong net for %08lX?\n", + logmsg(LOG_ERR, "bogus link family (%d) wrong net for %08X?\n", ll2->sdl_family, ipaddr); close(r); return; @@ -845,7 +845,7 @@ } #else void -update_arptab(u_char *ep, u_long ipaddr) +update_arptab(u_char *ep, in_addr_t ipaddr) { struct arpreq request; struct sockaddr_in *sin; @@ -896,7 +896,7 @@ * ARP request. */ void -rarp_reply(struct if_info *ii, struct ether_header *ep, u_long ipaddr, +rarp_reply(struct if_info *ii, struct ether_header *ep, in_addr_t ipaddr, u_int len) { u_int n; @@ -936,8 +936,8 @@ * Get the netmask of an IP address. This routine is used if * SIOCGIFNETMASK doesn't work. */ -u_long -ipaddrtonetmask(u_long addr) +in_addr_t +ipaddrtonetmask(in_addr_t addr) { addr = ntohl(addr); if (IN_CLASSA(addr)) @@ -946,7 +946,7 @@ return htonl(IN_CLASSB_NET); if (IN_CLASSC(addr)) return htonl(IN_CLASSC_NET); - logmsg(LOG_DEBUG, "unknown IP address class: %08lX", addr); + logmsg(LOG_DEBUG, "unknown IP address class: %08X", addr); return htonl(0xffffffff); } @@ -954,7 +954,7 @@ * A faster replacement for inet_ntoa(). */ char * -intoa(u_long addr) +intoa(in_addr_t addr) { char *cp; u_int byte; --huq684BweRXVnRxX--