svn commit: r227791 - head/sys/netinet
Qing Li
qingli at freebsd.org
Wed Nov 23 14:53:07 UTC 2011
>
> 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
More information about the svn-src-all
mailing list