Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Nov 2011 06:53:05 -0800
From:      Qing Li <qingli@freebsd.org>
To:        Gleb Smirnoff <glebius@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r227791 - head/sys/netinet
Message-ID:  <CAGnGRdKsKMT%2BDsuj5aXbso8VCpkPiEJz-H8qsheJtPNpK13tvA@mail.gmail.com>
In-Reply-To: <20111122154312.GL96616@FreeBSD.org>
References:  <201111211410.pALEAD9B046139@svn.freebsd.org> <CAGnGRdLpWwTkfjirBYe7x-1TVOMtHiRJNX4dM-iQXwQgP3mCVQ@mail.gmail.com> <20111121195439.GE96616@FreeBSD.org> <CAGnGRdL%2BTBG7O55FnfgTmLBE8=cdZPy%2BcOdJZNgbB9P=BCdMww@mail.gmail.com> <20111122154312.GL96616@FreeBSD.org>

index | next in thread | previous in thread | raw e-mail

>
>  first I'd like to notice that we are speaking about obsoleted interfaces.
>

Yup, that's why you don't see me commenting on your other commits around
ia_netmask stuff, do you ?

<snip>

>
> Back to your comments:
>
> I have made a test case that proves, that usage of deleted address isn't
> prevented when it is removed, but loopback route still exists.
>
> The test is the following run a race between this program:
>
>        struct ifreq ifr;
>        int s;
>
>        bzero(&ifr, sizeof(struct ifreq));
>
>        strncpy(ifr.ifr_name, "igb1", sizeof ifr.ifr_name);
>        ifr.ifr_addr.sa_family = AF_INET;
>        ifr.ifr_addr.sa_len = sizeof(struct sockaddr_in);
>        ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr = inet_addr("10.0.0.1");
>
>        s = socket(AF_INET, SOCK_DGRAM, 0);
>
>        for (;;)
>                ioctl(s, SIOCSIFADDR, &ifr);
>
> And this script:
>
>        while (true); do nc -z 10.0.0.1 22 || echo Fail; done
>

I am not sure if this test scenario is valid.

The loopback route is wiped at line #853 and then quickly inserted back at
line #936 because you are SIOCSIFADDR the same address over and over again.

<snip>

>
> Application writers don't know this in-kernel things. They usually write code
> this way:
>
>        if (ioctl(foo) < 0) {
>                /* fatal error: can't configure address! */
>        }
>
> And this is correct way. Look into this from viewpoint of say quagga developer.
> One doesn't need to know about this tricks in FreeBSD kernel.
>

Yes, you have a good point there and I agree completely.

--Qing


help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGnGRdKsKMT%2BDsuj5aXbso8VCpkPiEJz-H8qsheJtPNpK13tvA>