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>

next in thread | previous in thread | raw e-mail | index | archive | help
>
> =A0first I'd like to notice that we are speaking about obsoleted interfac=
es.
>

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:
>
> =A0 =A0 =A0 =A0struct ifreq ifr;
> =A0 =A0 =A0 =A0int s;
>
> =A0 =A0 =A0 =A0bzero(&ifr, sizeof(struct ifreq));
>
> =A0 =A0 =A0 =A0strncpy(ifr.ifr_name, "igb1", sizeof ifr.ifr_name);
> =A0 =A0 =A0 =A0ifr.ifr_addr.sa_family =3D AF_INET;
> =A0 =A0 =A0 =A0ifr.ifr_addr.sa_len =3D sizeof(struct sockaddr_in);
> =A0 =A0 =A0 =A0((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr =3D=
 inet_addr("10.0.0.1");
>
> =A0 =A0 =A0 =A0s =3D socket(AF_INET, SOCK_DGRAM, 0);
>
> =A0 =A0 =A0 =A0for (;;)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ioctl(s, SIOCSIFADDR, &ifr);
>
> And this script:
>
> =A0 =A0 =A0 =A0while (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:
>
> =A0 =A0 =A0 =A0if (ioctl(foo) < 0) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* fatal error: can't configure address! *=
/
> =A0 =A0 =A0 =A0}
>
> And this is correct way. Look into this from viewpoint of say quagga deve=
loper.
> One doesn't need to know about this tricks in FreeBSD kernel.
>

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

--Qing



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