From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2ED6DC43381 for ; Fri, 8 Mar 2019 22:40:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F2F5020643 for ; Fri, 8 Mar 2019 22:40:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726463AbfCHWk2 (ORCPT ); Fri, 8 Mar 2019 17:40:28 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:51297 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726422AbfCHWk2 (ORCPT ); Fri, 8 Mar 2019 17:40:28 -0500 Received: by mail-wm1-f66.google.com with SMTP id n19so13881984wmi.1 for ; Fri, 08 Mar 2019 14:40:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=9eH7Lq2mfxbR+EYSCCOPRyyy9BZaI3bXRVCUWL4to8o=; b=Vxp4GPejc+5zG/W8InRzJnLE10SsgAh/CzLRLTtftH7Yld49D1rBZP1GqDx9xCgGvr yYIxidoq1LsomJ3N0gqCiHEn9FvT3MEP0G1pAmJcKuu4vo7VTpW43+OR8xivteZeW3Zm fqREadmmdZOLBVIizyP4v1N2KebVFIVkqV75qhTDWqpl6ulYzmvSfc2YZ2Ssl69aWzdw nN/MUSXX8voElr7vhJF5ayKW/O9OgrcdZj4oXUx07FSalJ1WeK3QM2A0ERC3e8royg15 j+DBbja0KADHT8K9j4VrYmfm1s73OY/6IehT6odOpzH8dyMrv63TFWTeKUyQjc+CGt7S dknA== X-Gm-Message-State: APjAAAUSS4rIuWLHT4LAfb37/6zEeYDOc9nsoNBprAALv/HAxfkKtCDt 4Kk62dCb4zvBsdtS8iXQq56inMOTXpg= X-Google-Smtp-Source: APXvYqz98YDFzdZOmT9oSH7X3i5koT4CakTloMsYLsOiUMKds/iawCPEF8VI6v/ZbPdvfZWmBqY/Ng== X-Received: by 2002:a7b:c766:: with SMTP id x6mr10482412wmk.15.1552084826738; Fri, 08 Mar 2019 14:40:26 -0800 (PST) Received: from pc-2.home (2a01cb05850ddf00045dd60e6368f84b.ipv6.abo.wanadoo.fr. [2a01:cb05:850d:df00:45d:d60e:6368:f84b]) by smtp.gmail.com with ESMTPSA id p12sm11084941wrt.4.2019.03.08.14.40.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Mar 2019 14:40:26 -0800 (PST) Date: Fri, 8 Mar 2019 23:40:24 +0100 From: Guillaume Nault To: Eric Dumazet Cc: netdev@vger.kernel.org Subject: Re: [PATCH net] tcp: handle inet_csk_reqsk_queue_add() failures Message-ID: <20190308224023.GA26735@pc-2.home> References: <9b8502f9cec31c971e480ee2281f5cd7088b50df.1552077823.git.gnault@redhat.com> <20190308222231.GA26006@pc-2.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, Mar 08, 2019 at 02:34:07PM -0800, Eric Dumazet wrote: > > > On 03/08/2019 02:22 PM, Guillaume Nault wrote: > > On Fri, Mar 08, 2019 at 01:33:02PM -0800, Eric Dumazet wrote: > >> > >> > >> On 03/08/2019 01:09 PM, Guillaume Nault wrote: > >>> @@ -216,7 +216,12 @@ struct sock *tcp_get_cookie_sock(struct sock *sk, struct sk_buff *skb, > >>> refcount_set(&req->rsk_refcnt, 1); > >>> tcp_sk(child)->tsoffset = tsoff; > >>> sock_rps_save_rxhash(child, skb); > >>> - inet_csk_reqsk_queue_add(sk, req, child); > >>> + if (!inet_csk_reqsk_queue_add(sk, req, child)) { > >>> + bh_unlock_sock(child); > >>> + sock_put(child); > >>> + child = NULL; > >>> + reqsk_put(req); > >> > >> Since we use reqsk_free(req) in the same function, we can use reqsk_free(req) > >> here as well ? > >> > > That was my first approach, but reqsk_free() doesn't like it: > > > > static inline void reqsk_free(struct request_sock *req) > > { > > /* temporary debugging */ > > WARN_ON_ONCE(refcount_read(&req->rsk_refcnt) != 0); > > ... > > } > > Oh right, there is this refcount_set(&req->rsk_refcnt, 1) before the call > to inet_csk_reqsk_queue_add(sk, req, child); > > So just change the TFO case only :) > Well.. refcount is 1 in the TFO case too. Long term, do we want to keep the WARN_ON_ONCE()? If so, we should probably remove the comment.