Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2716727imm; Wed, 3 Oct 2018 08:08:55 -0700 (PDT) X-Google-Smtp-Source: ACcGV62keCjExB2QSRyIQu5xe+5/mCVDmdDS4m8dbuPsULvVZnXMivktLtqu/GuE3ldHVKturS2q X-Received: by 2002:a63:fa09:: with SMTP id y9-v6mr1752447pgh.177.1538579335041; Wed, 03 Oct 2018 08:08:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538579335; cv=none; d=google.com; s=arc-20160816; b=HUrQQVpnqupQRgDL06TaJf4OTOk8hOCzqZCg+NUY6DP7NWbmij7RR+pIYtDu1xYJcC I4ahDQ8H3H5TkFiPZmhsARQhS5cFv41/Z4BUltxDkoyyVGF9JTFSfw4+vAgZqe25olFy emw2b0UdrcFRO1PgLlA/RQWa5MRtLOl9rFjeBSZHNo54gllY5nrLwUoWJnLWc39vrYEV tawaPzx6f+Zda+8PSqMZpvCMpqroTcZ/QclvDHEYU1guGFGWr8NJLzH8jw+NP9BVksky InQuwoQm7jrNggZr2UqGOz+ZH3teKrLv0Om0iLGnHc7ITGp0ZXEmplxgtm+27OpcmHuP SlJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=jEgLo7rrfCPW5l3ealQfMoc5waYiy2TEwp+xxtoiWyQ=; b=AvaEeAWuMtfRO7FHRQxsNZcnVhYxEHh8aUNg1WLROK9NaqZVccaa/Q13Og+/3RtQQc P5/aInRK35/kiZuc8dhYOTHHS6mE9tawohb4H6kKoELJs+RRnr6GDpAE1gXSJVV3F+ih ZhXs2AoAy7UNtKnEBIwthDrg9ZNTzJvJYo9AGDau6HhbAQGIpG+HIfDwXKwgo3SxCpr2 CEy08t09IcwFeyzTeBQwfpMcFC4yxCgkk6Fi9Wu/DTGQnpgzTXeAyT41qUWeDZd3Fcyj TTxSi8112iQHl90AEPQZ55bKdxNpOSrgCur9lmBklBSivTAj6c+VC6VPxN4ITAEYNOEt luuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eMK1chv5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z10-v6si1457055pgv.487.2018.10.03.08.08.38; Wed, 03 Oct 2018 08:08:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eMK1chv5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727065AbeJCV5L (ORCPT + 99 others); Wed, 3 Oct 2018 17:57:11 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:45829 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726797AbeJCV5L (ORCPT ); Wed, 3 Oct 2018 17:57:11 -0400 Received: by mail-pf1-f193.google.com with SMTP id a23-v6so1813178pfi.12; Wed, 03 Oct 2018 08:08:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=jEgLo7rrfCPW5l3ealQfMoc5waYiy2TEwp+xxtoiWyQ=; b=eMK1chv5JUQSiUClntInrjlfc7WQ/4iclz5yNGVUtyMVJJK6HzSRkwtuJmtxuIbowf /PAu5Jqpgh2WGcayTzO8BjALtTAa2FjRj7bnqn8osZSiFTDQM+eZWQStlmtLgyoKmJYq LShhA4+GlQSwfVfw4rCg15YSVhA0/70bhW2Q7aAjaqAgPusS2KtGzo0eni13m199JFab ZnmY2fDe9Q2aS+w660wQhbfhggoHmecb3EN+6GxBX6CP5TBoPHvuX2aFuBaQOREfocUC H0JjYSerH91CxZ2eiq24+uHzCPE2bi9hsgiQzJlAdxYkvMnyU78bqTYB3qbVK7+yamdf Av4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=jEgLo7rrfCPW5l3ealQfMoc5waYiy2TEwp+xxtoiWyQ=; b=mYzrQ+Y0O2Z1bNfL8fDcHmJfKYdpMHV7eZeZLOCKopp+p00RaLxAI4vR++dWGr3uVH ec3K7ebtBpHHP0/W6Ciqgsjml0ahR4g9Th41HIALWIwXh+N77lVMan5VijR8kNBGSpQp bapCA1zdGjK2FSM2PHFbZTpb7D23H5cZ/mwMk3MenJ4AhRbGH8j0OSNqGlMVCxmrAuhl 1fyD55zxSnmMnkGEjJFEW2glZ237ogsL5RwFmqQ5o/GwUfC8pQb5RZEdkcz6EfrXSDDC 09QYI5ixeBpVkCxalDKKJbELLVsDNhymj8CW4SlTKR8R1HSdzI1hDjOazuxi5v2P7Ko+ r7Dw== X-Gm-Message-State: ABuFfogt1+t3OuHvVz+lpwUEyXNd1PHZdVJPuqws8Q8hEseDuwfSQSYu bPaYq2z7+6qkfMTdLaMxPLc= X-Received: by 2002:a63:5059:: with SMTP id q25-v6mr1736911pgl.171.1538579303679; Wed, 03 Oct 2018 08:08:23 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id 19-v6sm4426606pft.97.2018.10.03.08.08.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 08:08:22 -0700 (PDT) From: Yafang Shao To: edumazet@google.com, davem@davemloft.net Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yafang Shao Subject: [PATCH net-next] inet: do not set backlog if listen fails Date: Wed, 3 Oct 2018 23:07:59 +0800 Message-Id: <1538579279-11614-1-git-send-email-laoar.shao@gmail.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org These two backlog members are not necessary set in inet_csk_listen_start(). Regarding sk_max_ack_backlog, it will be set in the caller inet_listen and dccp_listen_start. Regraing sk_ack_backlog, it is better to put it together with sk_max_ack_backlog in the same function and only set on success. Signed-off-by: Yafang Shao --- net/dccp/proto.c | 1 + net/ipv4/af_inet.c | 1 + net/ipv4/inet_connection_sock.c | 3 --- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/net/dccp/proto.c b/net/dccp/proto.c index 875858c..34d48cd 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c @@ -959,6 +959,7 @@ int inet_dccp_listen(struct socket *sock, int backlog) err = dccp_listen_start(sk, backlog); if (err) goto out; + sk->sk_ack_backlog = 0; } sk->sk_max_ack_backlog = backlog; err = 0; diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 1fbe2f8..9690e0d 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -230,6 +230,7 @@ int inet_listen(struct socket *sock, int backlog) if (err) goto out; tcp_call_bpf(sk, BPF_SOCK_OPS_TCP_LISTEN_CB, 0, NULL); + sk->sk_ack_backlog = 0; } sk->sk_max_ack_backlog = backlog; err = 0; diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index dfd5009..c25d0b3 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -870,9 +870,6 @@ int inet_csk_listen_start(struct sock *sk, int backlog) int err = -EADDRINUSE; reqsk_queue_alloc(&icsk->icsk_accept_queue); - - sk->sk_max_ack_backlog = backlog; - sk->sk_ack_backlog = 0; inet_csk_delack_init(sk); /* There is race window here: we announce ourselves listening, -- 1.8.3.1