Skip to content

Commit 8210e34

Browse files
guodeqing-hwummakynes
authored andcommitted
ipvs: fix the connection sync failed in some cases
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: 2276f58 ("udp: use a separate rx queue for packet reception") Reported-by: zhouxudong <[email protected]> Signed-off-by: guodeqing <[email protected]> Acked-by: Julian Anastasov <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 1e9451c commit 8210e34

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

net/netfilter/ipvs/ip_vs_sync.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,19 +1717,23 @@ static int sync_thread_backup(void *data)
17171717
{
17181718
struct ip_vs_sync_thread_data *tinfo = data;
17191719
struct netns_ipvs *ipvs = tinfo->ipvs;
1720+
struct sock *sk = tinfo->sock->sk;
1721+
struct udp_sock *up = udp_sk(sk);
17201722
int len;
17211723

17221724
pr_info("sync thread started: state = BACKUP, mcast_ifn = %s, "
17231725
"syncid = %d, id = %d\n",
17241726
ipvs->bcfg.mcast_ifn, ipvs->bcfg.syncid, tinfo->id);
17251727

17261728
while (!kthread_should_stop()) {
1727-
wait_event_interruptible(*sk_sleep(tinfo->sock->sk),
1728-
!skb_queue_empty(&tinfo->sock->sk->sk_receive_queue)
1729-
|| kthread_should_stop());
1729+
wait_event_interruptible(*sk_sleep(sk),
1730+
!skb_queue_empty_lockless(&sk->sk_receive_queue) ||
1731+
!skb_queue_empty_lockless(&up->reader_queue) ||
1732+
kthread_should_stop());
17301733

17311734
/* do we have data now? */
1732-
while (!skb_queue_empty(&(tinfo->sock->sk->sk_receive_queue))) {
1735+
while (!skb_queue_empty_lockless(&sk->sk_receive_queue) ||
1736+
!skb_queue_empty_lockless(&up->reader_queue)) {
17331737
len = ip_vs_receive(tinfo->sock, tinfo->buf,
17341738
ipvs->bcfg.sync_maxlen);
17351739
if (len <= 0) {

0 commit comments

Comments
 (0)