From patchwork Fri May 11 23:28:45 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: 912260 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="FIOM1Z+7"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40jRB25SfTz9s1b for ; Sat, 12 May 2018 09:28:58 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751764AbeEKX24 (ORCPT ); Fri, 11 May 2018 19:28:56 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:36603 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751620AbeEKX2w (ORCPT ); Fri, 11 May 2018 19:28:52 -0400 Received: by mail-qt0-f195.google.com with SMTP id q6-v6so9230799qtn.3; Fri, 11 May 2018 16:28:51 -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=Ll/RxMd6XnZZljsiCrltObZI6tARFOZ/8w2gDd9LGJg=; b=FIOM1Z+7YttI3OBDimZej8Tj5hN2gFLVu4AU4ubmLLo3qvmc6O3fPOZhE2mD+oc+q7 HbAOe683iwjNdAyRJ/Y3+Hpp/ikkO60zGya7Xh/NysZvVI4emvezPUVwbX8k+SwLgtm/ 1jCuf4mLFNpRStjm1OYaYrGiJ1GGf86oV8ETHK1RTsY3YIt6e6noKGMIswhR0iNwPOze OZo5I2gNsHhINz336p9txYDWjycXNuIn61wSo94VTGTLSJjtv3hW4G7hOrYNHRkFPSNa GSsMwwXPC01Xa+nAvZ/WkLc7abT0RgMvRiX1l9VN2aEvzRmEl5S17sSRLQrla3UVUsF1 TSSQ== 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=Ll/RxMd6XnZZljsiCrltObZI6tARFOZ/8w2gDd9LGJg=; b=tokjYWLqSKtxAZZnYT2YZDSXrYecjiu3yXuzC4oPSRTQkqiMxoEifijfiNIcliRUKN hYQlOI51OCcqvZ/tPNnINWxoGrpuc3O4ld5HQmQRX+ef+ddCuu8dzF94pZsm/999w44Q x9eSnaITA4Ma3wAyhoAM/7voxdKpf0hl4v6EPT9MmTJzVQ95P1gASkFgqPqy2M+jQN0/ GQ2pm/OapTi70Q98M/SbJqaCJUTelvw5Fv99p6f25BZmPzKi2/f9qf1bFR5OdB8os/W1 adzqnnL9Fx9IdpeEERSjIwfOAN7Xa+gIvKaAGs2/Jq+Jtm6miNImUfVOk9qWqxfg3ysw WboA== X-Gm-Message-State: ALKqPwfqiQtl/1WmLNcK4k4eBpGWNB1xhp1XLjps/Izkq/7tfb6/5FRk Z/M1GBGSXhDcIomK8wPZFpQ= X-Google-Smtp-Source: AB8JxZrT+MXZO6sgJ+6REr1cTaRwU3AFBfZOyFoCpFkCLyZ9iCu6Cgpi5IIVBWFUqPEIV/SoNkwHjg== X-Received: by 2002:ac8:2315:: with SMTP id a21-v6mr60797qta.73.1526081331177; Fri, 11 May 2018 16:28:51 -0700 (PDT) Received: from localhost.localdomain ([45.4.239.227]) by smtp.gmail.com with ESMTPSA id 193-v6sm1802810qkh.2.2018.05.11.16.28.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 May 2018 16:28:50 -0700 (PDT) Received: by localhost.localdomain (Postfix, from userid 1000) id 65F5A180C3B; Fri, 11 May 2018 20:28:48 -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 3/8] sctp: move the flush of ctrl chunks into its own function Date: Fri, 11 May 2018 20:28:45 -0300 Message-Id: <23e474529812a3e804b1a4311ec48f250b81bbc5.1526077476.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 preceded by another control chunk that cannot be bundled. Other than this, it has the same behavior. Signed-off-by: Marcelo Ricardo Leitner --- net/sctp/outqueue.c | 89 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 35 deletions(-) -- 2.14.3 diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c index bda50596d4bfebeac03966c5a161473df1c1986a..1081e1eea703be5d65d9828c3e4265fbb7a155f9 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 @@ -930,8 +906,10 @@ static void sctp_outq_flush(struct sctp_outq *q, int rtx_timeout, gfp_t gfp) * the first chunk as we don't have a transport by then. */ if (sctp_outq_select_transport(chunk, asoc, &transport, - &transport_list)) + &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,46 @@ 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); if (q->asoc->src_out_of_asoc_ok) goto sctp_flush_out;