*BSD News Article 54046


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!simtel!chi-news.cic.net!newsfeed.internetmci.com!EU.net!Germany.EU.net!zib-berlin.de!irz401!uriah.heep!not-for-mail
From: j@uriah.heep.sax.de (J Wunsch)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: IP Forwarding under FreeBSD
Date: 5 Nov 1995 22:41:00 +0100
Organization: Private FreeBSD site, Dresden.
Lines: 89
Message-ID: <47jb1c$kol@uriah.heep.sax.de>
References: <46ngrd$5hq@bilbo.nask.org.pl> <470e8d$1m8@uriah.heep.sax.de> <47ai2i$is1@bilbo.nask.org.pl>
NNTP-Posting-Host: uriah.heep.sax.de
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

Jaroslaw Bazydlo <jarekb@ire.pw.edu.pl> wrote:
>beta: {11} more options
>-detach
>38400
>silent
>proxyarp

That's it.  Proxyarp was known to be broken in 2.0.5.

Actually, in 99 % of all cases, you don't really need it.

Just in case, here's the fix (not by me, but reported to work):

Index: sys-bsd.c
===================================================================
RCS file: /home/cvs/src/usr.sbin/pppd/sys-bsd.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- sys-bsd.c	1995/05/30 03:51:16	1.3
+++ sys-bsd.c	1995/10/03 10:50:42	1.4
@@ -19,7 +19,7 @@
  */
 
 #ifndef lint
-static char rcsid[] = "$Id: sys-bsd.c,v 1.3 1995/05/30 03:51:16 rgrimes Exp $";
+static char rcsid[] = "$Id: sys-bsd.c,v 1.4 1995/10/03 10:50:42 joerg Exp $";
 #endif
 
 /*
@@ -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;
-- 
cheers, J"org

joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)