From owner-svn-src-all@freebsd.org Tue Aug 16 13:01:59 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6149EBBBCEC for ; Tue, 16 Aug 2016 13:01:59 +0000 (UTC) (envelope-from rrs@netflix.com) Received: from mail-pf0-x236.google.com (mail-pf0-x236.google.com [IPv6:2607:f8b0:400e:c00::236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3303B12D0 for ; Tue, 16 Aug 2016 13:01:59 +0000 (UTC) (envelope-from rrs@netflix.com) Received: by mail-pf0-x236.google.com with SMTP id y134so27575567pfg.0 for ; Tue, 16 Aug 2016 06:01:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netflix.com; s=google; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=xAHEblL8eUsmHnnowv72BymcS7UGih1pp+NaTqJkMH0=; b=Cxp/KMkH5KAgt2Wi1KZCi/rQmjDvXuRfuhT9W22UBCqUZmAptACD5nL8y1kdsdiCs/ dkLSavJrPB9toMOT4dXhgOQ13mtBDlODylKbayXBRGnTr8vFxn2IPGkGxL/7xyXv+LgO z12fe+aOfJHg10TOnb8QTjv+fUiWZ+weSIoF8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=xAHEblL8eUsmHnnowv72BymcS7UGih1pp+NaTqJkMH0=; b=eSMod/Jyl7IcJfRf10XHrrRL7xk4C1HSeDE2YvReCZnlW9RMJ2YGHcFOVuVQIAee1O 03HZdmM/tV/akgiPGIcIzRSi1Wr5WtX3LQvcO4NmH+WBs7ztozIgnUtY8FZ6TPFqhE85 zznTEQm0ehDoKIX6AJBeOaOvv/ZLHv3G26FoY1ioY9wnHr68rSqGjScrflPSEvBzq3by ooZmxWQA4Fzi4Sg011jeD/bWRqMvhfeOJmXR1NaAuJ+QnqCmT9Bv2vFmESEaB4LwXYbR vQ24Ejipmb3+JJv+NRH5f3NZnMfFcGmJk4i/DQJpjoDmSs/RJp5VeNBgxjrLl2GKIi1D 0D7A== X-Gm-Message-State: AEkooutnePPKK6NiiduzX8+MOmi2Qf2/QuFDjqFI/Hhtvp2Tl+8SEOvxx2TO4sUjWBrC7se2 X-Received: by 10.98.35.145 with SMTP id q17mr64087317pfj.42.1471352518665; Tue, 16 Aug 2016 06:01:58 -0700 (PDT) Received: from [100.127.65.50] ([69.53.245.200]) by smtp.gmail.com with ESMTPSA id g13sm39322491pfb.7.2016.08.16.06.01.57 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Aug 2016 06:01:58 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: svn commit: r304218 - head/sys/netinet From: Randall Stewart In-Reply-To: <92a3cfc1-56bc-813f-dd12-ac19c66fd716@selasky.org> Date: Tue, 16 Aug 2016 06:01:57 -0700 Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <272AD783-2988-4EE7-89A5-EC6FA1313122@netflix.com> References: <201608161240.u7GCeuWS082118@repo.freebsd.org> <92a3cfc1-56bc-813f-dd12-ac19c66fd716@selasky.org> To: Hans Petter Selasky X-Mailer: Apple Mail (2.3124) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 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: Tue, 16 Aug 2016 13:01:59 -0000 Sure Let me add some comments for you. The idea her is that you pick-up a = reference to the PCB.. so it can=E2=80=99t be removed. Thus when you re-lock the = INP you check the dropped flag (just in case someone did get in). Let me get that in comments.. (note thats also why when using this = function you have to use its companion function to drop the reference). > On Aug 16, 2016, at 5:58 AM, Hans Petter Selasky = wrote: >=20 > On 08/16/16 14:40, Randall Stewart wrote: >> +int >> +tcp_inpinfo_lock_add(struct inpcb *inp) >> +{ >> + in_pcbref(inp); >> + INP_WUNLOCK(inp); >> + INP_INFO_RLOCK(&V_tcbinfo); >> + INP_WLOCK(inp); >> + if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { >> + return(1); >> + } >> + return(0); >> + >> +} >=20 > Hi, >=20 > Could you add some comments describing how it is considered safe to = drop the INP write-lock and then pick it up again? >=20 > My first impression is that because you are dropping the inp lock, = multiple threads can enter the code in question, leaving the window open = to races? >=20 > --HPS -------- Randall Stewart rrs@netflix.com 803-317-4952