From owner-svn-src-all@FreeBSD.ORG Wed Nov 23 14:53:07 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B7727106564A; Wed, 23 Nov 2011 14:53:07 +0000 (UTC) (envelope-from tomelite82@gmail.com) Received: from mail-bw0-f54.google.com (mail-bw0-f54.google.com [209.85.214.54]) by mx1.freebsd.org (Postfix) with ESMTP id A542F8FC17; Wed, 23 Nov 2011 14:53:06 +0000 (UTC) Received: by bkbzs8 with SMTP id zs8so2191272bkb.13 for ; Wed, 23 Nov 2011 06:53:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=A0QhvCU/fLyR/lBZtRL5oX9vDjN5t1VzH9gKf9sTv9c=; b=okvTOpFO0HfLMhuUf7J+Zf9JlraDNcS1s2SFOU1SLRbFdZeFyyJkQbBZtOu40TBaQv SpPBh392QFIhtep3SN9AmF9XQlIXMpAbCjodj4I+qVsUNx0ONRn1i4xZM2ZLvEtJv5K2 dYnw0VK5csd4LTo9PEyExcSWqVjlLS1Ez/nk4= MIME-Version: 1.0 Received: by 10.204.199.132 with SMTP id es4mr10179172bkb.4.1322059985442; Wed, 23 Nov 2011 06:53:05 -0800 (PST) Sender: tomelite82@gmail.com Received: by 10.223.93.132 with HTTP; Wed, 23 Nov 2011 06:53:05 -0800 (PST) In-Reply-To: <20111122154312.GL96616@FreeBSD.org> References: <201111211410.pALEAD9B046139@svn.freebsd.org> <20111121195439.GE96616@FreeBSD.org> <20111122154312.GL96616@FreeBSD.org> Date: Wed, 23 Nov 2011 06:53:05 -0800 X-Google-Sender-Auth: s7xX4j0gFeBjinH3sla4nZumO8s Message-ID: From: Qing Li To: Gleb Smirnoff Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r227791 - head/sys/netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Nov 2011 14:53:07 -0000 > > =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 ? > > 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. > > 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