Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp4882468pjb; Mon, 27 Jul 2020 07:31:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyRHymoojZPpxTUS6Roh0JgW7pPpKjY8sqpSVWACb1EIZIIkew3Y1FvgHjq0X4LR+s1cnL X-Received: by 2002:aa7:c95a:: with SMTP id h26mr9097638edt.289.1595860285616; Mon, 27 Jul 2020 07:31:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595860285; cv=none; d=google.com; s=arc-20160816; b=0ZYLnhKFC4FbxH+HJs90F3rnPyU/vkKUdF0wklwtYO24qBqcTb/AwsQcgrX3xEqCrY x1taS6dbMPFOI/hXqAx3AOnkAKOVBAjvQpYsdSLWSO2ALKm3sdMoZviyRRX5VizBFAzg /3hRIZ9kDf9Va0oO7MMSLmJSHW3I80A0OvauzuEZ6VPUtRnQ+PWVqmsfa2NCiH2nm8od GPnTWTv3A6MNDXJw5K9TyYbg4yFz2Hdi+lDdQ8ylV6IxEOhBWKXRq+0iP6qmWzk4L0I8 17uyG6s4rGg3wM0J3rh/uRYX+/eWn4hL+bcSPgIEoH0m3bR/5QGheVzgvo+/a/s09Blf KrDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=s8EUKmr3vUNzcdOAuT/oHMPCyuSY8h8hClvH4pgovUg=; b=JOj7hiM9trR8ut3BGzN+FUd11yrhQ8MsIsxv4Oag3xvKfLWV9GlJ0z7tCLb9w2bRbQ zYwxcpQ7GcPfJ2/FqOJR3qPl87XG8a+6W6+tU5C62dYPGySkjhDk1bZp0hg8OF8OJ4X1 HjMGxqKw2aq7Ind8sGpj1lvopsq33XTcpGZna/L72y1zPMTzFtLdbeX15zse2KxcqRie PePPUfslqsREK3Xs4SJi82V7Jnnbos9+Q4OQ/6AMJDQq0golX2uuxm40bfv9Cm7SSZGi UuaKrJZ5a2a87R4jPPG1ijnEnwuFQT1dCsVTQ9BkGV8KOprUOdNT2u2b1WBCNPvvMTID c9bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wI0LSRtC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i9si5878613edb.144.2020.07.27.07.30.33; Mon, 27 Jul 2020 07:31:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wI0LSRtC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732461AbgG0O3T (ORCPT + 99 others); Mon, 27 Jul 2020 10:29:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:52674 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732078AbgG0OX0 (ORCPT ); Mon, 27 Jul 2020 10:23:26 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 39D7420775; Mon, 27 Jul 2020 14:23:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595859805; bh=R9n7i2d/2LiyirSf3VoJw7eQXDiACzZfwZCeutMFhUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wI0LSRtCdJHI04U5nIxqe3QcE1U9H3lr8nM0qoQ9bDriQlwx1Tu+FjCuNAOEbi9DF x1/g2FmdkOnIFuu7PSWBcjDx3KOy1mxkXf9iVN/7ntPcV3+1qJYUuOzWwVhirs/ejs ymUoORc+qkSWdiFKbxiz2IBIlj4QMhiAGjjmvGV8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, zhouxudong , guodeqing , Julian Anastasov , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.7 085/179] ipvs: fix the connection sync failed in some cases Date: Mon, 27 Jul 2020 16:04:20 +0200 Message-Id: <20200727134936.828153247@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200727134932.659499757@linuxfoundation.org> References: <20200727134932.659499757@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: guodeqing [ Upstream commit 8210e344ccb798c672ab237b1a4f241bda08909b ] The sync_thread_backup only checks sk_receive_queue is empty or not, there is a situation which cannot sync the connection entries when sk_receive_queue is empty and sk_rmem_alloc is larger than sk_rcvbuf, the sync packets are dropped in __udp_enqueue_schedule_skb, this is because the packets in reader_queue is not read, so the rmem is not reclaimed. Here I add the check of whether the reader_queue of the udp sock is empty or not to solve this problem. Fixes: 2276f58ac589 ("udp: use a separate rx queue for packet reception") Reported-by: zhouxudong Signed-off-by: guodeqing Acked-by: Julian Anastasov Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/ipvs/ip_vs_sync.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c index 605e0f68f8bd3..2b8abbfe018cf 100644 --- a/net/netfilter/ipvs/ip_vs_sync.c +++ b/net/netfilter/ipvs/ip_vs_sync.c @@ -1717,6 +1717,8 @@ static int sync_thread_backup(void *data) { struct ip_vs_sync_thread_data *tinfo = data; struct netns_ipvs *ipvs = tinfo->ipvs; + struct sock *sk = tinfo->sock->sk; + struct udp_sock *up = udp_sk(sk); int len; pr_info("sync thread started: state = BACKUP, mcast_ifn = %s, " @@ -1724,12 +1726,14 @@ static int sync_thread_backup(void *data) ipvs->bcfg.mcast_ifn, ipvs->bcfg.syncid, tinfo->id); while (!kthread_should_stop()) { - wait_event_interruptible(*sk_sleep(tinfo->sock->sk), - !skb_queue_empty(&tinfo->sock->sk->sk_receive_queue) - || kthread_should_stop()); + wait_event_interruptible(*sk_sleep(sk), + !skb_queue_empty_lockless(&sk->sk_receive_queue) || + !skb_queue_empty_lockless(&up->reader_queue) || + kthread_should_stop()); /* do we have data now? */ - while (!skb_queue_empty(&(tinfo->sock->sk->sk_receive_queue))) { + while (!skb_queue_empty_lockless(&sk->sk_receive_queue) || + !skb_queue_empty_lockless(&up->reader_queue)) { len = ip_vs_receive(tinfo->sock, tinfo->buf, ipvs->bcfg.sync_maxlen); if (len <= 0) { -- 2.25.1