[haiku-commits] Re: r34642 - haiku/trunk/src/servers/net

  • From: "Axel Dörfler" <axeld@xxxxxxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 12 Dec 2009 19:53:58 +0100

Jérôme Duval <korli@xxxxxxxxxxxxxxxx> wrote:
> 2009/12/12 Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>:
> > Why even bother to test if it exists before?
> Sure, we can let the network stack fail on a non configured
> interface.
> I was trying to avoid this case, not needed though.

If you really wanted to do that, you could also just check if the
interface exists:

        ifreq request;
        strlcpy(request.ifr_name, name, IF_NAMESIZE);
        if (ioctl(socket.FD(), SIOCGIFINDEX, &request, sizeof(struct ifreq))
< 0)
                return 0;

In any case, just deleting a possibly non existing interface is much
cheaper than having to copy the interface list to userland, and then
searching for that interface in that list; since there is a big race
condition between retrieving the list and deleting the interface, you
can't even know if not someone else removed that interface in the mean


Other related posts: