Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Mar 1995 14:31:05 -0500 (EST)
From:      John Capo <jc@irbs.com>
To:        marques@vax.ox.ac.uk (Jose Marques)
Cc:        freebsd-questions@FreeBSD.org
Subject:   Re: [FreeBSD-2.0-RELEASE] general kernel config file questions
Message-ID:  <199503091931.OAA16039@irbs.com>
In-Reply-To: <v01510100ab84d5008083@[163.1.67.21]> from "Jose Marques" at Mar 9, 95 03:59:37 pm

next in thread | previous in thread | raw e-mail | index | archive | help
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 <jose.marques@las.ox.ac.uk>
> 

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199503091931.OAA16039>