From patchwork Mon May 14 17:34:38 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: 913162 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="HvGCoe7k"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40l7D63gkPz9s0W for ; Tue, 15 May 2018 03:36:38 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753071AbeENRgf (ORCPT ); Mon, 14 May 2018 13:36:35 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:45249 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752189AbeENRfA (ORCPT ); Mon, 14 May 2018 13:35:00 -0400 Received: by mail-qt0-f194.google.com with SMTP id j42-v6so17168633qtj.12; Mon, 14 May 2018 10:35:00 -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=SF5UE5TjoNgJ5CSp9ABBA6rBYTSMXBVkRrW/Os1DLq8=; b=HvGCoe7kPmWxxsRK+r6mUPpRjIcxmm1eixHSoNl4KysIQY7bw46JApFJDHvoU+eRIq EqzDO8JSQxDEABnqagE9XutuKXLY7w3KghBaIjb9nZiGWCwKM/yCY3LMC6SbmZvM97Of vQsys+FguR394DJjBNOJGD2BfEgoJhjk+Dad7z4DXtsKYpTG3bwKNQmmHkt9fPFdTiXU 8+AYJoUv+u0Pne3p+FQn8zqbaUBTcO9x3jMxUGcDxuGEx7RXvqOBD/LasxTuQcFbeKvI xBmWvPu4hJw2VU6Yfvv7mNjn/A59hc+T/gmp8IVdPkTOSLi1WWZKpSjAcGHgafQH5UrX z3rw== 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=SF5UE5TjoNgJ5CSp9ABBA6rBYTSMXBVkRrW/Os1DLq8=; b=E8vfUIrYm3jNJ3+p4eVNXQZhoVF5S7mtjZVEVOhZUZJ71+Ty3mS7ZNWkeHkfy3tm0e itelw5+KyilVpVujTUZ/bTXLN/YUByt44jzPUGYwIAG0P8CmH9kmbaL3q8AfSdDvL5Hg zAfePyxoawJ5o2WJzzX+RO+2JeXfklzXU69sWCPE32E098aVigsFQFg1GVO1sbKi0c1M D89DWayF9wza3AsGCK2pQdfZ0kqPXgHNpZTSZ7Ns2H2UfrCRfXrzIvg37PeZ1F2HfBBj AwX/FwdKA6+/CrYxIK3JjcBLHInPMEbCB5kIC1gLUMixKc/u6RzvtcqdiRqQrExjV602 SLpA== X-Gm-Message-State: ALKqPwdsBVzUG+BI+0UTSGc0RP8lTb4icqGkSscuf8jm6Kx0CbuAptVk xvF+9ElK5822wWgXCEitm0SPbuG+LFs= X-Google-Smtp-Source: AB8JxZpFuNmH5ZZ5Myw+WA17fMtLt1zZQf/TxJIwR/yexqJoIp3fmcTNTx3j4rXaOT/b1Ndp9vzTng== X-Received: by 2002:ac8:2d11:: with SMTP id n17-v6mr10357575qta.378.1526319299810; Mon, 14 May 2018 10:34:59 -0700 (PDT) Received: from localhost.localdomain ([45.4.239.227]) by smtp.gmail.com with ESMTPSA id u188-v6sm7337068qkd.45.2018.05.14.10.34.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 10:34:57 -0700 (PDT) Received: by localhost.localdomain (Postfix, from userid 1000) id 9683618147E; Mon, 14 May 2018 14:34:53 -0300 (-03) From: Marcelo Ricardo Leitner To: netdev@vger.kernel.org Cc: linux-sctp@vger.kernel.org, Neil Horman , Xin Long , Vlad Yasevich Subject: [PATCH net-next v3 3/8] sctp: move the flush of ctrl chunks into its own function Date: Mon, 14 May 2018 14:34:38 -0300 Message-Id: <75b70a6e6dea50ae3562519a370bdad191ab7df8.1526318522.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 Named sctp_outq_flush_ctrl and, with that, keep the contexts contained. One small fix embedded is the reset of one_packet at every iteration. This allows bundling of some control chunks in case they were preceeded by another control chunk that cannot be bundled. Other than this, it has the same behavior. Changes since v2: - Fixed panic reported by kbuild test robot if building with only up to this patch applied, due to bad parameter to sctp_outq_select_transport and by not initializing packet after calling sctp_outq_flush_ctrl. Signed-off-by: Marcelo Ricardo Leitner --- net/sctp/outqueue.c | 92 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 56 insertions(+), 36 deletions(-) -- 2.14.3 diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c index bda50596d4bfebeac03966c5a161473df1c1986a..92f14f51edf28cf596c76b98854a10c0fd28bb22 100644 --- a/net/sctp/outqueue.c +++ b/net/sctp/outqueue.c @@ -875,45 +875,21 @@ static bool sctp_outq_select_transport(struct sctp_chunk *chunk, return changed; } -/* - * Try to flush an outqueue. - * - * Description: Send everything in q which we legally can, subject to - * congestion limitations. - * * Note: This function can be called from multiple contexts so appropriate - * locking concerns must be made. Today we use the sock lock to protect - * this function. - */ -static void sctp_outq_flush(struct sctp_outq *q, int rtx_timeout, gfp_t gfp) +static void sctp_outq_flush_ctrl(struct sctp_outq *q, + struct sctp_transport **_transport, + struct list_head *transport_list, + gfp_t gfp) { - struct sctp_packet *packet; + struct sctp_transport *transport = *_transport; struct sctp_association *asoc = q->asoc; - __u32 vtag = asoc->peer.i.init_tag; - struct sctp_transport *transport = NULL; + struct sctp_packet *packet = NULL; struct sctp_chunk *chunk, *tmp; enum sctp_xmit status; - int error = 0; - int start_timer = 0; - int one_packet = 0; - - /* These transports have chunks to send. */ - struct list_head transport_list; - struct list_head *ltransport; - - INIT_LIST_HEAD(&transport_list); - packet = NULL; - - /* - * 6.10 Bundling - * ... - * When bundling control chunks with DATA chunks, an - * endpoint MUST place control chunks first in the outbound - * SCTP packet. The transmitter MUST transmit DATA chunks - * within a SCTP packet in increasing order of TSN. - * ... - */ + int one_packet, error; list_for_each_entry_safe(chunk, tmp, &q->control_chunk_list, list) { + one_packet = 0; + /* RFC 5061, 5.3 * F1) This means that until such time as the ASCONF * containing the add is acknowledged, the sender MUST @@ -929,9 +905,11 @@ static void sctp_outq_flush(struct sctp_outq *q, int rtx_timeout, gfp_t gfp) /* Pick the right transport to use. Should always be true for * the first chunk as we don't have a transport by then. */ - if (sctp_outq_select_transport(chunk, asoc, &transport, - &transport_list)) + if (sctp_outq_select_transport(chunk, asoc, _transport, + transport_list)) { + transport = *_transport; packet = &transport->packet; + } switch (chunk->chunk_hdr->type) { /* @@ -954,6 +932,7 @@ static void sctp_outq_flush(struct sctp_outq *q, int rtx_timeout, gfp_t gfp) if (sctp_test_T_bit(chunk)) packet->vtag = asoc->c.my_vtag; /* fallthru */ + /* The following chunks are "response" chunks, i.e. * they are generated in response to something we * received. If we are sending these, then we can @@ -979,7 +958,7 @@ static void sctp_outq_flush(struct sctp_outq *q, int rtx_timeout, gfp_t gfp) case SCTP_CID_RECONF: status = sctp_packet_transmit_chunk(packet, chunk, one_packet, gfp); - if (status != SCTP_XMIT_OK) { + if (status != SCTP_XMIT_OK) { /* put the chunk back */ list_add(&chunk->list, &q->control_chunk_list); break; @@ -1006,6 +985,47 @@ static void sctp_outq_flush(struct sctp_outq *q, int rtx_timeout, gfp_t gfp) BUG(); } } +} + +/* + * Try to flush an outqueue. + * + * Description: Send everything in q which we legally can, subject to + * congestion limitations. + * * Note: This function can be called from multiple contexts so appropriate + * locking concerns must be made. Today we use the sock lock to protect + * this function. + */ +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; + struct list_head *ltransport; + + INIT_LIST_HEAD(&transport_list); + packet = NULL; + + /* + * 6.10 Bundling + * ... + * When bundling control chunks with DATA chunks, an + * endpoint MUST place control chunks first in the outbound + * SCTP packet. The transmitter MUST transmit DATA chunks + * within a SCTP packet in increasing order of TSN. + * ... + */ + + sctp_outq_flush_ctrl(q, &transport, &transport_list, gfp); + packet = &transport->packet; if (q->asoc->src_out_of_asoc_ok) goto sctp_flush_out;