Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3693715imm; Mon, 18 Jun 2018 02:26:03 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKN+x71EuVuzX1QodJ+X1mAo/IRIhcFLRDPplMcKmOSRKB/8mS7RtnnIrCc83sY6am0O2Km X-Received: by 2002:a65:4d4b:: with SMTP id j11-v6mr10311160pgt.430.1529313963183; Mon, 18 Jun 2018 02:26:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529313963; cv=none; d=google.com; s=arc-20160816; b=hb8KZI3h0+d6awhuTyANa8rx0TTT0kWfvdBnm+BE/0xyA1LDCsOWNovh4mJpUISDO8 QqJT+hObg4je+0fH46aciKa0ZatmvlfESFi1VpIuVH4Ya53kOtFHVgNcYvRBgnaldy5h 4UC1KKugjhCIPwXJNHYw8sAdOqfyk6eyYmKvoCKDd0Fur1nF/qFinLnFCWEWO/s0gT3G u6jiS0+s22kBiKxEVZOpCggtlRtm/PwU4LMUA0wS5X5Bxt5xjPWWvOZpDyVrfxu+SBgw 6R2L2GsYNuGic65NgNmyxe2rcnAALPeThljgqgS4Wal3N43F/8yefOJfIo2H4RgV40D4 fk4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=KHhhWoqISDvj3tVbhsdpNTYGPFRd567SeThEMGoc6aM=; b=tRbwGF++b2Fk0+Q+lGGtW/RCwhH8Q9Fc4eTtUvr7rhXE+2VjvkWs6JreyV0HaW0h+C g5hSD+PkTk2ChlkHK1YwFpx2kV3e6mf1oP+7+Rvclafs+NAXbVW5p/AmWIEbg5u3QNBn JP/ne6P8B3FxbVRgn4psqFHTCJuTCFX0JYAWEqoKgHebLPDB9B5RB9CEDXcqdzPjnS9I GBqibhhoVFSGu/K27Pr+3ovoxP83aDUDSgo2FzOFqcu1oGZk1hCk94URxQknD6WsnfxW GUOcyMp8LRBgMk/aJVxtiYjZAYcgs/HqYCqwtujr3NLjR/g0Kx4iY5egSHxT2GDNYr/q dc4A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 133-v6si15591333pfc.21.2018.06.18.02.25.49; Mon, 18 Jun 2018 02:26:03 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966308AbeFRI0z (ORCPT + 99 others); Mon, 18 Jun 2018 04:26:55 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:57444 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965815AbeFRI0t (ORCPT ); Mon, 18 Jun 2018 04:26:49 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 1F2DEBAD; Mon, 18 Jun 2018 08:26:47 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Dionne , David Howells , Sasha Levin Subject: [PATCH 4.16 216/279] rxrpc: Fix missing start of call timeout Date: Mon, 18 Jun 2018 10:13:21 +0200 Message-Id: <20180618080617.795845373@linuxfoundation.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618080608.851973560@linuxfoundation.org> References: <20180618080608.851973560@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Howells [ Upstream commit c54e43d752c7187595c8c62a231e0b0d53c7fded ] The expect_rx_by call timeout is supposed to be set when a call is started to indicate that we need to receive a packet by that point. This is currently put back every time we receive a packet, but it isn't started when we first send a packet. Without this, the call may wait forever if the server doesn't deign to reply. Fix this by setting the timeout upon a successful UDP sendmsg call for the first DATA packet. The timeout is initiated only for initial transmission and not for subsequent retries as we don't want the retry mechanism to extend the timeout indefinitely. Fixes: a158bdd3247b ("rxrpc: Fix call timeouts") Reported-by: Marc Dionne Signed-off-by: David Howells Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- net/rxrpc/ar-internal.h | 1 + net/rxrpc/input.c | 2 +- net/rxrpc/output.c | 11 +++++++++++ net/rxrpc/sendmsg.c | 10 ++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) --- a/net/rxrpc/ar-internal.h +++ b/net/rxrpc/ar-internal.h @@ -464,6 +464,7 @@ enum rxrpc_call_flag { RXRPC_CALL_SEND_PING, /* A ping will need to be sent */ RXRPC_CALL_PINGING, /* Ping in process */ RXRPC_CALL_RETRANS_TIMEOUT, /* Retransmission due to timeout occurred */ + RXRPC_CALL_BEGAN_RX_TIMER, /* We began the expect_rx_by timer */ }; /* --- a/net/rxrpc/input.c +++ b/net/rxrpc/input.c @@ -971,7 +971,7 @@ static void rxrpc_input_call_packet(stru if (timo) { unsigned long now = jiffies, expect_rx_by; - expect_rx_by = jiffies + timo; + expect_rx_by = now + timo; WRITE_ONCE(call->expect_rx_by, expect_rx_by); rxrpc_reduce_call_timer(call, expect_rx_by, now, rxrpc_timer_set_for_normal); --- a/net/rxrpc/output.c +++ b/net/rxrpc/output.c @@ -407,6 +407,17 @@ done: rxrpc_timer_set_for_lost_ack); } } + + if (sp->hdr.seq == 1 && + !test_and_set_bit(RXRPC_CALL_BEGAN_RX_TIMER, + &call->flags)) { + unsigned long nowj = jiffies, expect_rx_by; + + expect_rx_by = nowj + call->next_rx_timo; + WRITE_ONCE(call->expect_rx_by, expect_rx_by); + rxrpc_reduce_call_timer(call, expect_rx_by, nowj, + rxrpc_timer_set_for_normal); + } } rxrpc_set_keepalive(call); --- a/net/rxrpc/sendmsg.c +++ b/net/rxrpc/sendmsg.c @@ -223,6 +223,15 @@ static void rxrpc_queue_packet(struct rx ret = rxrpc_send_data_packet(call, skb, false); if (ret < 0) { + switch (ret) { + case -ENETUNREACH: + case -EHOSTUNREACH: + case -ECONNREFUSED: + rxrpc_set_call_completion(call, + RXRPC_CALL_LOCAL_ERROR, + 0, ret); + goto out; + } _debug("need instant resend %d", ret); rxrpc_instant_resend(call, ix); } else { @@ -241,6 +250,7 @@ static void rxrpc_queue_packet(struct rx rxrpc_timer_set_for_send); } +out: rxrpc_free_skb(skb, rxrpc_skb_tx_freed); _leave(""); }