From patchwork Sat May 12 22:21:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Ricardo Leitner X-Patchwork-Id: 912474 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="iB4mq4zD"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40k1dS3J1Cz9s1w for ; Sun, 13 May 2018 08:21:16 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751816AbeELWVL (ORCPT ); Sat, 12 May 2018 18:21:11 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:34321 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751110AbeELWVI (ORCPT ); Sat, 12 May 2018 18:21:08 -0400 Received: by mail-qt0-f194.google.com with SMTP id m5-v6so11702019qti.1; Sat, 12 May 2018 15:21:07 -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:in-reply-to:references; bh=ZOYqMlKXBHntbkPw0WRMHtHTQt4KFPs+S4ZocWHGa0A=; b=iB4mq4zDJAQ2SKOXcI3G5+nehant4G/1BhdERPVy35AUq6HJEX/jXmqPj0RBaudHwy eYkZRHYXqDXLLF+2EO0H8s8BuyNW7t+cICYDVT8Q/Av0U1WpP09/n8Ys72smCFDrobPi PoryMRlA1NMaKOXvh8UiwaNzsgaT6J5NN9MIwSmB1tF7lMzIs/jtyCDA338wk39ZqWZU 1o2bOz1VaBKK2B+VwQ3q56eD6ZWDKz/fkRGZdGyPdNw+7bVVfOddYkOK+O1U+rqluFnm CEJ3+2A0D0zqTMEJWQptiuLG7SnGE5994fkQMwZU5T8ux5Qdxm9+YXuh8uaRgY8MlL6e Q6Wg== 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:in-reply-to :references; bh=ZOYqMlKXBHntbkPw0WRMHtHTQt4KFPs+S4ZocWHGa0A=; b=s7namqt2hblektMyBtjneRjP7cfn04bNAwOs0AJwQuGZCHyHFRALFX5lnlt4yqti3w AZQxJ6NuPv4xn46DyE3GFgrKrj2Dxxs39S9v/y5YgXnUEx0QjcsSJCMg3bwLwYLKp2RW fG7c8UVZyx5pUT3HRiY6nrBzXR88082xJKNhlrEV1oxEqWLwpzkv3Hqp9o9mRE32PZq3 JvWE2hcRa3BvmF3XCuxazH2uiHYyrGEzC23/Hu+oHgV+TP4f3pmvjZuBCBnej5QUtnDx Q4nmoJa251OLkcyrEwVRtYyrm2Ft/Fn/PbDVCmbF1BX7Gbfrkvcgzvc7y+ftPPvMwkTT N2OQ== X-Gm-Message-State: ALKqPwcPqv7+Yd6orgAu6RDo1ifMw19e+CVPI2A2t/H35UV51w++p8oc bsMThEybZk1WFiXmp9UmAIQ= X-Google-Smtp-Source: AB8JxZqvA0DW2zyUoAzWHrac2EYB//JuEhJnI77FE3nrGTC5laViI9h9oeV1NLIBpM3h5WBqMnuHRA== X-Received: by 2002:a0c:fac2:: with SMTP id p2-v6mr3724182qvo.59.1526163667358; Sat, 12 May 2018 15:21:07 -0700 (PDT) Received: from localhost.localdomain ([45.4.239.227]) by smtp.gmail.com with ESMTPSA id q67-v6sm5077386qki.97.2018.05.12.15.21.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 12 May 2018 15:21:06 -0700 (PDT) Received: by localhost.localdomain (Postfix, from userid 1000) id 9CA69180C66; Sat, 12 May 2018 19:21:04 -0300 (-03) From: Marcelo Ricardo Leitner To: netdev@vger.kernel.org Cc: linux-sctp@vger.kernel.org, Neil Horman , Vlad Yasevich , Xin Long Subject: [PATCH net-next v2 4/8] sctp: move outq data rtx code out of sctp_outq_flush Date: Sat, 12 May 2018 19:21:04 -0300 Message-Id: <5ca419bb19f4c6a821ba2b159f7624af6a472215.1526142784.git.marcelo.leitner@gmail.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: References: Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch renames current sctp_outq_flush_rtx to __sctp_outq_flush_rtx and create a new sctp_outq_flush_rtx, with the code that was on sctp_outq_flush. Again, the idea is to have functions with small and defined objectives. Yes, there is an open-coded path selection in the now sctp_outq_flush_rtx. That is kept as is for now because it may be very different when we implement retransmission path selection algorithms for CMT-SCTP. Signed-off-by: Marcelo Ricardo Leitner --- net/sctp/outqueue.c | 101 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 58 insertions(+), 43 deletions(-) diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c index 800202c68cb89f1086ee7d3a4493dc752c8bf6ac..6d7ee372a9d6b8e68a759277830d5334ec992d47 100644 --- a/net/sctp/outqueue.c +++ b/net/sctp/outqueue.c @@ -601,14 +601,14 @@ void sctp_retransmit(struct sctp_outq *q, struct sctp_transport *transport, /* * Transmit DATA chunks on the retransmit queue. Upon return from - * sctp_outq_flush_rtx() the packet 'pkt' may contain chunks which + * __sctp_outq_flush_rtx() the packet 'pkt' may contain chunks which * need to be transmitted by the caller. * We assume that pkt->transport has already been set. * * The return value is a normal kernel error return value. */ -static int sctp_outq_flush_rtx(struct sctp_outq *q, struct sctp_packet *pkt, - int rtx_timeout, int *start_timer) +static int __sctp_outq_flush_rtx(struct sctp_outq *q, struct sctp_packet *pkt, + int rtx_timeout, int *start_timer) { struct sctp_transport *transport = pkt->transport; struct sctp_chunk *chunk, *chunk1; @@ -987,6 +987,57 @@ static void sctp_outq_flush_ctrl(struct sctp_outq *q, } } +/* Returns false if new data shouldn't be sent */ +static bool sctp_outq_flush_rtx(struct sctp_outq *q, + struct sctp_transport **_transport, + struct list_head *transport_list, + int rtx_timeout) +{ + struct sctp_transport *transport = *_transport; + struct sctp_packet *packet = transport ? &transport->packet : NULL; + struct sctp_association *asoc = q->asoc; + int error, start_timer = 0; + + if (asoc->peer.retran_path->state == SCTP_UNCONFIRMED) + return false; + + if (transport != asoc->peer.retran_path) { + /* Switch transports & prepare the packet. */ + transport = asoc->peer.retran_path; + *_transport = transport; + + if (list_empty(&transport->send_ready)) + list_add_tail(&transport->send_ready, + transport_list); + + packet = &transport->packet; + sctp_packet_config(packet, asoc->peer.i.init_tag, + asoc->peer.ecn_capable); + } + + error = __sctp_outq_flush_rtx(q, packet, rtx_timeout, &start_timer); + if (error < 0) + asoc->base.sk->sk_err = -error; + + if (start_timer) { + sctp_transport_reset_t3_rtx(transport); + transport->last_time_sent = jiffies; + } + + /* This can happen on COOKIE-ECHO resend. Only + * one chunk can get bundled with a COOKIE-ECHO. + */ + if (packet->has_cookie_echo) + return false; + + /* Don't send new data if there is still data + * waiting to retransmit. + */ + if (!list_empty(&q->retransmit)) + return false; + + return true; +} /* * Try to flush an outqueue. * @@ -1000,12 +1051,10 @@ static void sctp_outq_flush(struct sctp_outq *q, int rtx_timeout, gfp_t gfp) { struct sctp_packet *packet; struct sctp_association *asoc = q->asoc; - __u32 vtag = asoc->peer.i.init_tag; struct sctp_transport *transport = NULL; struct sctp_chunk *chunk; enum sctp_xmit status; int error = 0; - int start_timer = 0; /* These transports have chunks to send. */ struct list_head transport_list; @@ -1052,45 +1101,11 @@ static void sctp_outq_flush(struct sctp_outq *q, int rtx_timeout, gfp_t gfp) * current cwnd). */ if (!list_empty(&q->retransmit)) { - if (asoc->peer.retran_path->state == SCTP_UNCONFIRMED) - goto sctp_flush_out; - if (transport == asoc->peer.retran_path) - goto retran; - - /* Switch transports & prepare the packet. */ - - transport = asoc->peer.retran_path; - - if (list_empty(&transport->send_ready)) { - list_add_tail(&transport->send_ready, - &transport_list); - } - + if (!sctp_outq_flush_rtx(q, &transport, &transport_list, + rtx_timeout)) + break; + /* We may have switched current transport */ packet = &transport->packet; - sctp_packet_config(packet, vtag, - asoc->peer.ecn_capable); - retran: - error = sctp_outq_flush_rtx(q, packet, - rtx_timeout, &start_timer); - if (error < 0) - asoc->base.sk->sk_err = -error; - - if (start_timer) { - sctp_transport_reset_t3_rtx(transport); - transport->last_time_sent = jiffies; - } - - /* This can happen on COOKIE-ECHO resend. Only - * one chunk can get bundled with a COOKIE-ECHO. - */ - if (packet->has_cookie_echo) - goto sctp_flush_out; - - /* Don't send new data if there is still data - * waiting to retransmit. - */ - if (!list_empty(&q->retransmit)) - goto sctp_flush_out; } /* Apply Max.Burst limitation to the current transport in