From syssgm@devetir.qld.gov.au  Mon Aug 21 03:59:26 1995
Received: from bunyip.cc.uq.oz.au (bunyip.cc.uq.oz.au [130.102.2.1])
          by freefall.FreeBSD.org (8.6.11/8.6.6) with SMTP id DAA12154
          for <FreeBSD-gnats-submit@freebsd.org>; Mon, 21 Aug 1995 03:59:22 -0700
Received: from cc.uq.oz.au by bunyip.cc.uq.oz.au 
          id <01058-0@bunyip.cc.uq.oz.au>; Mon, 21 Aug 1995 20:59:14 +1000
Received: from sieve.devetir.qld.gov.au 
          by pandora.devetir.qld.gov.au (8.6.10/DEVETIR-E0.3a) with ESMTP 
          id VAA16683 for <FreeBSD-gnats-submit@freebsd.org>;
          Mon, 21 Aug 1995 21:03:50 +1000
Received: (from syssgm@localhost) by sieve.devetir.qld.gov.au (8.6.11/8.6.9) 
          id UAA05980; Mon, 21 Aug 1995 20:56:37 +1000
Message-Id: <199508211056.UAA05980@sieve.devetir.qld.gov.au>
Date: Mon, 21 Aug 1995 20:56:37 +1000
From: Stephen McKay <syssgm@devetir.qld.gov.au>
Sender: syssgm@devetir.qld.gov.au
To: FreeBSD-gnats-submit@freebsd.org
Subject: pppd fails with proxyarp
X-Send-Pr-Version: 3.2

>Number:         701
>Category:       bin
>Synopsis:       pppd fails to set proxy arp when requested
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Aug 21 04:00:02 PDT 1995
>Closed-Date:    Tue Oct 3 11:50:51 MET 1995
>Last-Modified:  Tue Oct  3 11:52:04 MET 1995
>Originator:     Stephen McKay
>Release:        FreeBSD 2.0-BUILT-19950603 i386
>Organization:
DEVETIR, State Government, Queensland, Australia.
>Environment:

	FreeBSD 2.0.5, generic 486DX hardware.

>Description:

	get_ether_addr() fails to find an ethernet address to proxy with,
	and, at least on my machine, spins forever looking for one.

>How-To-Repeat:

	Add 'proxyarp' to /etc/ppp/options, and connect with 'pppd'.  Watch
	the load average increase, and note that 'arp -a' shows no proxy.

>Fix:

	This patch gives me a warm inner glow, and a working pppd.

diff -ru pppd.old/sys-bsd.c pppd/sys-bsd.c
--- pppd.old/sys-bsd.c	Mon May 29 23:51:16 1995
+++ pppd/sys-bsd.c	Mon Aug 21 20:34:29 1995
@@ -639,6 +639,12 @@
 
 
 /*
+ * How to find the next ifreq structure in the stuff returned by SIOCGIFCONF.
+ */
+#define next_ifreq(ifr)	\
+    ((struct ifreq *) ((char *)&(ifr)->ifr_addr + (ifr)->ifr_addr.sa_len))
+
+/*
  * get_ether_addr - get the hardware address of an interface on the
  * the same subnet as ipaddr.
  */
@@ -668,7 +674,7 @@
      * address on the same subnet as `ipaddr'.
      */
     ifend = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len);
-    for (ifr = ifc.ifc_req; ifr < ifend; ) {
+    for (ifr = ifc.ifc_req; ifr < ifend; ifr = next_ifreq(ifr)) {
 	if (ifr->ifr_addr.sa_family == AF_INET) {
 	    ina = ((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr.s_addr;
 	    strncpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name));
@@ -687,13 +693,12 @@
 	     */
 	    if (ioctl(s, SIOCGIFNETMASK, &ifreq) < 0)
 		continue;
-	    mask = ((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr.s_addr;
+	    mask = ((struct sockaddr_in *) &ifreq.ifr_addr)->sin_addr.s_addr;
 	    if ((ipaddr & mask) != (ina & mask))
 		continue;
 
 	    break;
 	}
-	ifr = (struct ifreq *) ((char *)&ifr->ifr_addr + ifr->ifr_addr.sa_len);
     }
 
     if (ifr >= ifend)
@@ -705,7 +710,7 @@
      * for this interface.
      */
     ifp = ifr;
-    for (ifr = ifc.ifc_req; ifr < ifend; ) {
+    for (ifr = ifc.ifc_req; ifr < ifend; ifr = next_ifreq(ifr)) {
 	if (strcmp(ifp->ifr_name, ifr->ifr_name) == 0
 	    && ifr->ifr_addr.sa_family == AF_LINK) {
 	    /*
@@ -715,7 +720,6 @@
 	    BCOPY(dla, hwaddr, dla->sdl_len);
 	    return 1;
 	}
-	ifr = (struct ifreq *) ((char *)&ifr->ifr_addr + ifr->ifr_addr.sa_len);
     }
 
     return 0;
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: joerg 
State-Changed-When: Tue Oct 3 11:50:51 MET 1995 
State-Changed-Why:  
Suggested fix applied in rev 1.4 of sys-bsd.c. 
Thanks && sorry for the delay! 

>Unformatted:
 >Gratuitous whinge:
 
 	Am I the only one that finds iijppp mysterious and basically
 	impossible to set up as a dedicated ppp server?  pppd is explained
 	so much better.
 
