提交 a83f175c 编写于 作者: G guodeqing 提交者: Yang Yingliang

ipvs: fix the connection sync failed in some cases

stable inclusion
from linux-4.19.135
commit 8a330edef54f270c440034419f0694cee64c3075

--------------------------------

[ Upstream commit 8210e344 ]

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: 2276f58a ("udp: use a separate rx queue for packet reception")
Reported-by: Nzhouxudong <zhouxudong8@huawei.com>
Signed-off-by: Nguodeqing <geffrey.guo@huawei.com>
Acked-by: NJulian Anastasov <ja@ssi.bg>
Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NLi Aichun <liaichun@huawei.com>
Reviewed-by: Nguodeqing <geffrey.guo@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 5bc087a5
...@@ -1717,6 +1717,8 @@ static int sync_thread_backup(void *data) ...@@ -1717,6 +1717,8 @@ static int sync_thread_backup(void *data)
{ {
struct ip_vs_sync_thread_data *tinfo = data; struct ip_vs_sync_thread_data *tinfo = data;
struct netns_ipvs *ipvs = tinfo->ipvs; struct netns_ipvs *ipvs = tinfo->ipvs;
struct sock *sk = tinfo->sock->sk;
struct udp_sock *up = udp_sk(sk);
int len; int len;
pr_info("sync thread started: state = BACKUP, mcast_ifn = %s, " pr_info("sync thread started: state = BACKUP, mcast_ifn = %s, "
...@@ -1724,12 +1726,14 @@ static int sync_thread_backup(void *data) ...@@ -1724,12 +1726,14 @@ static int sync_thread_backup(void *data)
ipvs->bcfg.mcast_ifn, ipvs->bcfg.syncid, tinfo->id); ipvs->bcfg.mcast_ifn, ipvs->bcfg.syncid, tinfo->id);
while (!kthread_should_stop()) { while (!kthread_should_stop()) {
wait_event_interruptible(*sk_sleep(tinfo->sock->sk), wait_event_interruptible(*sk_sleep(sk),
!skb_queue_empty(&tinfo->sock->sk->sk_receive_queue) !skb_queue_empty_lockless(&sk->sk_receive_queue) ||
|| kthread_should_stop()); !skb_queue_empty_lockless(&up->reader_queue) ||
kthread_should_stop());
/* do we have data now? */ /* 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, len = ip_vs_receive(tinfo->sock, tinfo->buf,
ipvs->bcfg.sync_maxlen); ipvs->bcfg.sync_maxlen);
if (len <= 0) { if (len <= 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册