Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2901937iog; Mon, 27 Jun 2022 05:25:04 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sBAoB+79Me6J8PUOls2aHIbZCfF3R9IgM0+DUGNXtmIAX5nUK3JCVQKNOw3qIyph9vyYb8 X-Received: by 2002:a63:8c47:0:b0:40d:2d4:e3a2 with SMTP id q7-20020a638c47000000b0040d02d4e3a2mr12858144pgn.2.1656332703942; Mon, 27 Jun 2022 05:25:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656332703; cv=none; d=google.com; s=arc-20160816; b=V9NLC8CDG4X6lx2zvVLpxaPX7Airx0lCLm97/Kjy2Oi8u79wghp+MJnaQF1WuRIeqB Go1tZQxaoG7YfkqUwB2cgvdMMpXuUyfWhfyNMhvvAHrlYWLcM2EPkkBg0Tl2k7m+UoVq 4HKibD39RJZszImjFxCQOUfOfywMb++Te7EzXwp1GrzXhZV5iCF8HonmxzIx/9eMunFl 8sYikL21r5UqKNRGd79qOsrYyv4QQo8E0ZMPLrgzlIVjTUd3jVQX9Mn22m/p9kBjmpXX KqGpmRAf1tf4ooPXur7n3MkPA+6uwexNMXcy6phJa9YfeTrBNTfdkWgihV9fmTFSZMe6 sHEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=sYQeWp+d/TDh1H/J2tAI+oPQ1oT8ub0d1dZxrLNepr0=; b=E1Dw1uSqR76cATPv3qjSQETzqyZQO57bxFigYEIXfFaMAEaU5A1Esf6+PeLNPS/+RX b9iKJ7X9c2ZLCwzi/FvO6Cp41jLdaY3fj9cLRQvzUkEOsS3894BDc2tWGcRMZ5SM4ag7 g5hdd3/bSDOua74uJ1DU6zaB+0chtQxKktJT4nJrnpxKA8TMaUUR6aOpjb4ULm2NxnA1 hZ7+GHZZNfnK5dp6oBx75F+XR4LEwv6gbw7UesbuKhHsJ0hAm1scLKhH6W8nK0ZuKqzC 9bLuSuKlcblH6Tkodv/lhmhPUoOEJo1DFhA2vRI14G0Ky9rq4KkDubeYac1mhHjFEcsW 9XQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=UPzvybY0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x10-20020a170902b40a00b00158e93cfafesi13568205plr.132.2022.06.27.05.24.52; Mon, 27 Jun 2022 05:25:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=UPzvybY0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239759AbiF0MBN (ORCPT + 99 others); Mon, 27 Jun 2022 08:01:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239046AbiF0LxH (ORCPT ); Mon, 27 Jun 2022 07:53:07 -0400 Received: from mail-yb1-xb30.google.com (mail-yb1-xb30.google.com [IPv6:2607:f8b0:4864:20::b30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4853EBC1F for ; Mon, 27 Jun 2022 04:47:38 -0700 (PDT) Received: by mail-yb1-xb30.google.com with SMTP id g4so4719265ybg.9 for ; Mon, 27 Jun 2022 04:47:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sYQeWp+d/TDh1H/J2tAI+oPQ1oT8ub0d1dZxrLNepr0=; b=UPzvybY0bUlTHioTVtlg1r6HIBbwwz/d3MemQOdMhEBUDWAYwzK9gjvr7nukp+W3om FPunTbjw+RmMAICaPiA5Qz57ge5thTtCBR/RXgKhGqFdnS2/dcRN0ignpFzzLSV/AYbv voKglgXJeOIrRcZiCHI7cZVJptRpIBYziO4rzpJD4BGPSBcZlIZhiMT7uq3SJQvODjld 4a3PRy8QlV22PLYG8eXjiirzDutcbu/Bf6vNTZSqIxn5aGdjig/3TzwSTy3s4pR3kXzS 4yynoJ1AQD6TUGL1mvfRnyeg7u0psa+mneEmhJIXHIUmP1R7B1bpKs6LitQkd07e5xUF qIfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sYQeWp+d/TDh1H/J2tAI+oPQ1oT8ub0d1dZxrLNepr0=; b=KTWnznIKGEMLKs9LZo/qC0UcS2zE1KAcByJkvXNN9+yLshpD690Pzi48ZrWmaDiTVr bl4lWQmUH0i3NX9eGQIbDWOMBwC17M3PdPmgiizn0Kzt0s6fGdxUMub4hcy73WZbBi9C RkfxOC4Gr/QMnTQ69NMF46ip7a1S8ZJLortMFZp+GITz8ZEtCQ+YyRoqxp+DvhN/kPk2 SC6O41Y9dew452SC+x/OEE8jRyGvF/QGIZuUuQOooJkydHUOVdpA8vLDY2jJeGHgp02D XzqMDUUUmB576r2PWPF8+jav2C45V9VKlMlrtsTQ/yB9zp066ULHMIXuGzHWzfF+B+AJ 1kLw== X-Gm-Message-State: AJIora9kHDb4IkjEX3N9bD3t+WD3lDI9ANTGJzALFQy/O37vHmEbzenF QzpmcpIuBkcvIFS5LaMYdwlu8Gjsbl7QpVZCNmSYoQ== X-Received: by 2002:a25:d957:0:b0:66c:9476:708f with SMTP id q84-20020a25d957000000b0066c9476708fmr9897744ybg.427.1656330457231; Mon, 27 Jun 2022 04:47:37 -0700 (PDT) MIME-Version: 1.0 References: <5099dc39-c6d9-115a-855b-6aa98d17eb4b@collabora.com> <8eb9b438-7018-4fe3-8be6-bb023df99594@collabora.com> <63316ba7-f612-af5a-3f33-125cf89de754@collabora.com> In-Reply-To: <63316ba7-f612-af5a-3f33-125cf89de754@collabora.com> From: Eric Dumazet Date: Mon, 27 Jun 2022 13:47:25 +0200 Message-ID: Subject: Re: [RFC] EADDRINUSE from bind() on application restart after killing To: Muhammad Usama Anjum Cc: "David S. Miller" , Hideaki YOSHIFUJI , David Ahern , Jakub Kicinski , Paolo Abeni , Gabriel Krisman Bertazi , open list , Collabora Kernel ML , Paul Gofman , "open list:NETWORKING [TCP]" , Sami Farin Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 27, 2022 at 12:20 PM Muhammad Usama Anjum wrote: > > Hi Eric, > > On 5/30/22 8:28 PM, Eric Dumazet wrote: > >> The following command and patch work for my use case. The socket in > >> TIME_WAIT_2 or TIME_WAIT state are closed when zapped. > >> > >> Can you please upstream this patch? > > Yes, I will when net-next reopens, thanks for testing it. > Have you tried upstreaming it? > > Tested-by: Muhammad Usama Anjum > I will do this today, thanks for the heads up. > > > >>> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c > >>> index 9984d23a7f3e1353d2e1fc9053d98c77268c577e..1b7bde889096aa800b2994c64a3a68edf3b62434 > >>> 100644 > >>> --- a/net/ipv4/tcp.c > >>> +++ b/net/ipv4/tcp.c > >>> @@ -4519,6 +4519,15 @@ int tcp_abort(struct sock *sk, int err) > >>> local_bh_enable(); > >>> return 0; > >>> } > >>> + if (sk->sk_state == TCP_TIME_WAIT) { > >>> + struct inet_timewait_sock *tw = inet_twsk(sk); > >>> + > >>> + refcount_inc(&tw->tw_refcnt); > >>> + local_bh_disable(); > >>> + inet_twsk_deschedule_put(tw); > >>> + local_bh_enable(); > >>> + return 0; > >>> + } > >>> return -EOPNOTSUPP; > >>> } > > -- > Muhammad Usama Anjum