From owner-freebsd-questions Thu Mar 9 11:32:21 1995 Return-Path: questions-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id LAA19364 for questions-outgoing; Thu, 9 Mar 1995 11:32:21 -0800 Received: from irbs.com ([199.182.75.129]) by freefall.cdrom.com (8.6.10/8.6.6) with ESMTP id LAA19356 for ; Thu, 9 Mar 1995 11:32:18 -0800 Received: (from jc@localhost) by irbs.com (8.6.10/8.6.6) id OAA16039; Thu, 9 Mar 1995 14:31:06 -0500 From: John Capo Message-Id: <199503091931.OAA16039@irbs.com> Subject: Re: [FreeBSD-2.0-RELEASE] general kernel config file questions To: marques@vax.ox.ac.uk (Jose Marques) Date: Thu, 9 Mar 1995 14:31:05 -0500 (EST) Cc: freebsd-questions@FreeBSD.org In-Reply-To: from "Jose Marques" at Mar 9, 95 03:59:37 pm X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Length: 2965 Sender: questions-owner@FreeBSD.org Precedence: bulk Jose Marques writes: > > The messsage to which I am replying originally appeared on December 4th of > last year on the FreeBSD-questions mailing list. > > >>FYI: I had, at one point, tried to include the 'proxyarp' option on the > >>command line of 'pppd'. This seemed to cause pppd to consume 98-95% > >>of CPU!! I don't use that option anymore -- if you need it, good luck ;) > >> > >The fix for this is: > > > >in sys-bsd.c > > > >line 690 said: > >mask = ((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr.s_addr; > > > >it should say: > >mask = ((struct sockaddr_in *) &ifreq->ifr_addr)->sin_addr.s_addr; > > ^^ > > I am using FreeBSD 1.1.5.1R and found the same problem with the proxyarp > option. However I found that the above fix did not work for me. After > a little experimentation I found that by changing line 480 from: > > mask = ((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr.s_addr; > > to: > > mask = ((struct sockaddr_in *) &(ifreq.ifr_addr))->sin_addr.s_addr; > > did the trick. I suspect this is of academic interest only. > > > > >Mark > > -- > Jose Marques > I posted this a while back but it did not raise any interest. >From get_ether_addr() in sys-bsd.c, line 666. The for loop terminates when ifr >= ifend. ifr is pointed to the next structure at the bottom of the for loop at line 696. The loop does not terminate due to the continues. Also, the mask obtained in line 690 is not the netmask. It is the interface address. On my system, all three sockaddr structs in the ifreq struct had the same address, the interface address. Am I missing something here? 666:/* * Scan through looking for an interface with an Internet * address on the same subnet as `ipaddr'. */ ifend = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len); for (ifr = ifc.ifc_req; ifr < ifend; ) { 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)); /* * Check that the interface is up, and not point-to-point * or loopback. */ if (ioctl(s, SIOCGIFFLAGS, &ifreq) < 0) continue; if ((ifreq.ifr_flags & (IFF_UP|IFF_BROADCAST|IFF_POINTOPOINT|IFF_LOOPBACK|IFF_NOARP)) != (IFF_UP|IFF_BROADCAST)) continue; /* * Get its netmask and check that it's on the right subnet. */ if (ioctl(s, SIOCGIFNETMASK, &ifreq) < 0) continue; 690: mask = ((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr.s_addr; if ((ipaddr & mask) != (ina & mask)) continue; break; } 696: ifr = (struct ifreq *) ((char *)&ifr->ifr_addr + ifr->ifr_addr.sa_len); } --- John Capo