From patchwork Mon May 14 17:34:36 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: 913150 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="s+XqRQ6v"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40l7BL2Hm3z9s0q for ; Tue, 15 May 2018 03:35:06 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753121AbeENRfC (ORCPT ); Mon, 14 May 2018 13:35:02 -0400 Received: from mail-qk0-f194.google.com ([209.85.220.194]:37667 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752057AbeENRe7 (ORCPT ); Mon, 14 May 2018 13:34:59 -0400 Received: by mail-qk0-f194.google.com with SMTP id 11-v6so10681910qkk.4; Mon, 14 May 2018 10:34:59 -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=YyTtGWVy0MEFTb/349RlJa2wplQBDbZzqD+E0Pe00WY=; b=s+XqRQ6vm94JbNvnodvm2MkRucQKUtyHq6OGui+aYB9CtoZKfj71G2Rh5I9lqRfDpG u/C41TL0qWbVocYSQP7tYnvykk3ffe9/0KkJJyE1DZm2GB+rH2bzJtF98NcAcgmSMiZM qxdmtF0vNpR9y3R+11THI7sYzf3Qu1Pw9b5HAqo1Oo/GpklmMpBQgEJKfSVksrQqXmRv aYUJDOAHKmCYGjsD3rXb1OgGkwwaeQlVtEXw4PxUUvXQOuf4iFUWG4CzKlEpX0YVNQGI GdaoF+iheBzxOC0Fxdqq7TUyAhnqJP3rOfwF9yAev+sPW6OiweKrL/YLyHQDnwSDz+Gg eUjg== 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=YyTtGWVy0MEFTb/349RlJa2wplQBDbZzqD+E0Pe00WY=; b=J5v2Zs83r7c6QJQ0GCzshC2B/fZyy9nIOu1m0dOpoXIJCMZwG6NV0UOWFRpT8pRVOY PEac8O00F3nCAV8vVJwpVKkRDoIBW97XwgzvxAkzgG8udTzXVFFHTwbL/jJ8HiTLoxGJ jAh3l2QA/hI5QOjZMVu726WVTco/LnysmgVXvIWsbwFmBbHL+AsYwqCkRbMfSkauyThQ RpJPwMCnV79ZUtleIGSZApUCulbH0fDg5i6pXylSdE8knj+ypbNKkYHhRnRbY6lNNpEJ 9Z3IdNXcYur1ZhsCKn/Mv6F5jVB5i+gQJcDTGkgG4qzr8Mmua+fZgnpzZP3SkoMAqLpD P0Ew== X-Gm-Message-State: ALKqPwcTOQH9QPvX9uvQef3+7mFVYkd7UxpDJaZi8/WrXNl1SaiWV1PX Yb5Et3F4CQN3zhN4QLv3KBk= X-Google-Smtp-Source: AB8JxZo+LLjw6fQEZUYj2oo3rE/FZ39nC6hFyAkGQ+02+ZRwxU2I4ODxWF/VJi4uX1CZ/+HrbHM7yg== X-Received: by 2002:a37:8687:: with SMTP id i129-v6mr9068563qkd.42.1526319299076; Mon, 14 May 2018 10:34:59 -0700 (PDT) Received: from localhost.localdomain ([45.4.239.227]) by smtp.gmail.com with ESMTPSA id z64-v6sm6360802qke.66.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 84D941808CE; 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 1/8] sctp: add sctp_packet_singleton Date: Mon, 14 May 2018 14:34:36 -0300 Message-Id: <5c6e1ac9cc236d6c9bff13212986e4cd23ea387f.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 Factor out the code for generating singletons. It's used only once, but helps to keep the context contained. The const variables are to ease the reading of subsequent calls in there. Signed-off-by: Marcelo Ricardo Leitner --- net/sctp/outqueue.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c index dee7cbd5483149024f2f3195db2fe4d473b1a00a..300bd0dfc7c14c9df579dbe2f9e78dd8356ae1a3 100644 --- a/net/sctp/outqueue.c +++ b/net/sctp/outqueue.c @@ -776,6 +776,20 @@ void sctp_outq_uncork(struct sctp_outq *q, gfp_t gfp) sctp_outq_flush(q, 0, gfp); } +static int sctp_packet_singleton(struct sctp_transport *transport, + struct sctp_chunk *chunk, gfp_t gfp) +{ + const struct sctp_association *asoc = transport->asoc; + const __u16 sport = asoc->base.bind_addr.port; + const __u16 dport = asoc->peer.port; + const __u32 vtag = asoc->peer.i.init_tag; + struct sctp_packet singleton; + + sctp_packet_init(&singleton, transport, sport, dport); + sctp_packet_config(&singleton, vtag, 0); + sctp_packet_append_chunk(&singleton, chunk); + return sctp_packet_transmit(&singleton, gfp); +} /* * Try to flush an outqueue. @@ -789,10 +803,7 @@ void sctp_outq_uncork(struct sctp_outq *q, gfp_t gfp) static void sctp_outq_flush(struct sctp_outq *q, int rtx_timeout, gfp_t gfp) { struct sctp_packet *packet; - struct sctp_packet singleton; struct sctp_association *asoc = q->asoc; - __u16 sport = asoc->base.bind_addr.port; - __u16 dport = asoc->peer.port; __u32 vtag = asoc->peer.i.init_tag; struct sctp_transport *transport = NULL; struct sctp_transport *new_transport; @@ -905,10 +916,7 @@ static void sctp_outq_flush(struct sctp_outq *q, int rtx_timeout, gfp_t gfp) case SCTP_CID_INIT: case SCTP_CID_INIT_ACK: case SCTP_CID_SHUTDOWN_COMPLETE: - sctp_packet_init(&singleton, transport, sport, dport); - sctp_packet_config(&singleton, vtag, 0); - sctp_packet_append_chunk(&singleton, chunk); - error = sctp_packet_transmit(&singleton, gfp); + error = sctp_packet_singleton(transport, chunk, gfp); if (error < 0) { asoc->base.sk->sk_err = -error; return; From patchwork Mon May 14 17:34:37 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: 913160 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="J7HHKPw0"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40l7CL18kfz9s0W for ; Tue, 15 May 2018 03:35:58 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753330AbeENRfz (ORCPT ); Mon, 14 May 2018 13:35:55 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:44071 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752347AbeENRfB (ORCPT ); Mon, 14 May 2018 13:35:01 -0400 Received: by mail-qt0-f194.google.com with SMTP id d3-v6so17174886qtp.11; 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=sFOD0cQFU2cnz5cZR1JwX9xAY4oRei+bCn2rR2n1I7U=; b=J7HHKPw0fdmNDNW9sB5sBqJ9pP29yAgZwyhcIOGdYZDqptTEMomsJLX2A0hqGr4kSY tV+z2M//1+blbZZKS35sgLDdIPUnFNstTeMuA+P0q6XsOyiKAiLdSwQ0wiet//bP0Sj2 pbLb8yze8weu89sL38vubRrjiYAVDT+zd6E9BXcMrFCGBT/WlRP6e45FVye/jXGuujrA axFjyqRX3hxcEpc8GFtzkEql41PoLeCCS6CsX9Vv2DvVf5GET+M7MFqYMdeRS5u/Y8GM t1+4Eqg2n2MIi1xoy/4lvXXbOfEa8GQqQ9GAUKaCEO8Aj2XPxXraZKTYpRL4Yu9CRqHQ PWBw== 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=sFOD0cQFU2cnz5cZR1JwX9xAY4oRei+bCn2rR2n1I7U=; b=fsaSUZfV4JItnaoH1sslcxNn5jtAcTKmbvbPuFSFjtL4fx9f4iAsgrUVmsYRUMku/e +OwST6jhPn3NoNivL6SeHaimwtd5ghwPY7tvO/4e/3TsORToV82MZtMII9dtKm28A43S sSfPYagyX+CVVxqLxZlyzH1T/FLuqmPGxEBQ/oPNPYaDIP+lBeeBCyPBCe9jYaz1x/TZ QMhvEv5EC78Cr+dGtogbJIzzWhPjsJg6qKoMEt7ARCYBt/oZPQHGJhN3N8O9RTLyYsMd 94YrqHEZTkVrES946M+KFu6OclXNuOv3khptg5ctUbgqK+ztMJ79DbMn4k43GqgUiI4Q aVRw== X-Gm-Message-State: ALKqPwe0bt6FOAzhMPNdMLmh5JRuUGo4g7d0+UeBRDdDBeopVtKvBb7d kPOd904IeBnfoEkQmiKFiSc= X-Google-Smtp-Source: AB8JxZpGLkzBY0a/IQoVO8owAeFRwpQnl5rVCI6OQ278FatnL0lf7k4iinuVnoWs6sAjm31N+FnmlA== X-Received: by 2002:a0c:f88e:: with SMTP id u14-v6mr9815418qvn.61.1526319300282; Mon, 14 May 2018 10:35:00 -0700 (PDT) Received: from localhost.localdomain ([45.4.239.227]) by smtp.gmail.com with ESMTPSA id t184-v6sm7493212qkc.6.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 892071812C5; 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 2/8] sctp: factor out sctp_outq_select_transport Date: Mon, 14 May 2018 14:34:37 -0300 Message-Id: <85c608b7d56ccd73e218268a499e636ca16dbd35.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 We had two spots doing such complex operation and they were very close to each other, a bit more tailored to here or there. This patch unifies these under the same function, sctp_outq_select_transport, which knows how to handle control chunks and original transmissions (but not retransmissions). Signed-off-by: Marcelo Ricardo Leitner --- net/sctp/outqueue.c | 187 +++++++++++++++++++++++++--------------------------- 1 file changed, 90 insertions(+), 97 deletions(-) diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c index 300bd0dfc7c14c9df579dbe2f9e78dd8356ae1a3..bda50596d4bfebeac03966c5a161473df1c1986a 100644 --- a/net/sctp/outqueue.c +++ b/net/sctp/outqueue.c @@ -791,6 +791,90 @@ static int sctp_packet_singleton(struct sctp_transport *transport, return sctp_packet_transmit(&singleton, gfp); } +static bool sctp_outq_select_transport(struct sctp_chunk *chunk, + struct sctp_association *asoc, + struct sctp_transport **transport, + struct list_head *transport_list) +{ + struct sctp_transport *new_transport = chunk->transport; + struct sctp_transport *curr = *transport; + bool changed = false; + + if (!new_transport) { + if (!sctp_chunk_is_data(chunk)) { + /* + * If we have a prior transport pointer, see if + * the destination address of the chunk + * matches the destination address of the + * current transport. If not a match, then + * try to look up the transport with a given + * destination address. We do this because + * after processing ASCONFs, we may have new + * transports created. + */ + if (curr && sctp_cmp_addr_exact(&chunk->dest, + &curr->ipaddr)) + new_transport = curr; + else + new_transport = sctp_assoc_lookup_paddr(asoc, + &chunk->dest); + } + + /* if we still don't have a new transport, then + * use the current active path. + */ + if (!new_transport) + new_transport = asoc->peer.active_path; + } else { + __u8 type; + + switch (new_transport->state) { + case SCTP_INACTIVE: + case SCTP_UNCONFIRMED: + case SCTP_PF: + /* If the chunk is Heartbeat or Heartbeat Ack, + * send it to chunk->transport, even if it's + * inactive. + * + * 3.3.6 Heartbeat Acknowledgement: + * ... + * A HEARTBEAT ACK is always sent to the source IP + * address of the IP datagram containing the + * HEARTBEAT chunk to which this ack is responding. + * ... + * + * ASCONF_ACKs also must be sent to the source. + */ + type = chunk->chunk_hdr->type; + if (type != SCTP_CID_HEARTBEAT && + type != SCTP_CID_HEARTBEAT_ACK && + type != SCTP_CID_ASCONF_ACK) + new_transport = asoc->peer.active_path; + break; + default: + break; + } + } + + /* Are we switching transports? Take care of transport locks. */ + if (new_transport != curr) { + changed = true; + curr = new_transport; + *transport = curr; + if (list_empty(&curr->send_ready)) + list_add_tail(&curr->send_ready, transport_list); + + sctp_packet_config(&curr->packet, asoc->peer.i.init_tag, + asoc->peer.ecn_capable); + /* We've switched transports, so apply the + * Burst limit to the new transport. + */ + sctp_transport_burst_limited(curr); + } + + return changed; +} + /* * Try to flush an outqueue. * @@ -806,7 +890,6 @@ static void sctp_outq_flush(struct sctp_outq *q, int rtx_timeout, gfp_t gfp) struct sctp_association *asoc = q->asoc; __u32 vtag = asoc->peer.i.init_tag; struct sctp_transport *transport = NULL; - struct sctp_transport *new_transport; struct sctp_chunk *chunk, *tmp; enum sctp_xmit status; int error = 0; @@ -843,68 +926,12 @@ static void sctp_outq_flush(struct sctp_outq *q, int rtx_timeout, gfp_t gfp) list_del_init(&chunk->list); - /* Pick the right transport to use. */ - new_transport = chunk->transport; - - if (!new_transport) { - /* - * If we have a prior transport pointer, see if - * the destination address of the chunk - * matches the destination address of the - * current transport. If not a match, then - * try to look up the transport with a given - * destination address. We do this because - * after processing ASCONFs, we may have new - * transports created. - */ - if (transport && - sctp_cmp_addr_exact(&chunk->dest, - &transport->ipaddr)) - new_transport = transport; - else - new_transport = sctp_assoc_lookup_paddr(asoc, - &chunk->dest); - - /* if we still don't have a new transport, then - * use the current active path. - */ - if (!new_transport) - new_transport = asoc->peer.active_path; - } else if ((new_transport->state == SCTP_INACTIVE) || - (new_transport->state == SCTP_UNCONFIRMED) || - (new_transport->state == SCTP_PF)) { - /* If the chunk is Heartbeat or Heartbeat Ack, - * send it to chunk->transport, even if it's - * inactive. - * - * 3.3.6 Heartbeat Acknowledgement: - * ... - * A HEARTBEAT ACK is always sent to the source IP - * address of the IP datagram containing the - * HEARTBEAT chunk to which this ack is responding. - * ... - * - * ASCONF_ACKs also must be sent to the source. - */ - if (chunk->chunk_hdr->type != SCTP_CID_HEARTBEAT && - chunk->chunk_hdr->type != SCTP_CID_HEARTBEAT_ACK && - chunk->chunk_hdr->type != SCTP_CID_ASCONF_ACK) - new_transport = asoc->peer.active_path; - } - - /* Are we switching transports? - * Take care of transport locks. + /* Pick the right transport to use. Should always be true for + * the first chunk as we don't have a transport by then. */ - if (new_transport != transport) { - transport = new_transport; - if (list_empty(&transport->send_ready)) { - list_add_tail(&transport->send_ready, - &transport_list); - } + if (sctp_outq_select_transport(chunk, asoc, &transport, + &transport_list)) packet = &transport->packet; - sctp_packet_config(packet, vtag, - asoc->peer.ecn_capable); - } switch (chunk->chunk_hdr->type) { /* @@ -1072,43 +1099,9 @@ static void sctp_outq_flush(struct sctp_outq *q, int rtx_timeout, gfp_t gfp) goto sctp_flush_out; } - /* If there is a specified transport, use it. - * Otherwise, we want to use the active path. - */ - new_transport = chunk->transport; - if (!new_transport || - ((new_transport->state == SCTP_INACTIVE) || - (new_transport->state == SCTP_UNCONFIRMED) || - (new_transport->state == SCTP_PF))) - new_transport = asoc->peer.active_path; - if (new_transport->state == SCTP_UNCONFIRMED) { - WARN_ONCE(1, "Attempt to send packet on unconfirmed path."); - sctp_sched_dequeue_done(q, chunk); - sctp_chunk_fail(chunk, 0); - sctp_chunk_free(chunk); - continue; - } - - /* Change packets if necessary. */ - if (new_transport != transport) { - transport = new_transport; - - /* Schedule to have this transport's - * packet flushed. - */ - if (list_empty(&transport->send_ready)) { - list_add_tail(&transport->send_ready, - &transport_list); - } - + if (sctp_outq_select_transport(chunk, asoc, &transport, + &transport_list)) packet = &transport->packet; - sctp_packet_config(packet, vtag, - asoc->peer.ecn_capable); - /* We've switched transports, so apply the - * Burst limit to the new transport. - */ - sctp_transport_burst_limited(transport); - } pr_debug("%s: outq:%p, chunk:%p[%s], tx-tsn:0x%x skb->head:%p " "skb->users:%d\n", 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; From patchwork Mon May 14 17:34:39 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: 913161 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="QWFUMIEq"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40l7CS1dYnz9s0W for ; Tue, 15 May 2018 03:36:04 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753316AbeENRfy (ORCPT ); Mon, 14 May 2018 13:35:54 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:34277 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751884AbeENRfC (ORCPT ); Mon, 14 May 2018 13:35:02 -0400 Received: by mail-qt0-f195.google.com with SMTP id m5-v6so17213905qti.1; Mon, 14 May 2018 10:35:01 -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=pdzjhy7K/gJyL0s0IMjzZTjZJiqcvNo8OChcDX60ftg=; b=QWFUMIEq2ZxBgxEubfsziki9cRxi25MNUDn74wrBLdfVamynu7HIsju69w704Yr12v URtpgMtSMfG2A12Iraqdg+0EvY6zIitCyifaURiCbwfo0BY1AASs186VMOEENQ/OQXHK 6C4plFnqozAM19gO4yRsKMQDop0KinNJqSasWHZiP57sY4xV8SY9LeE2Zgwk39AgXeJv v9cKrPsfvtkpIZwYtkJoeTyDtv0ZAHcyp7YbST8lm3J3RU/Ppl6OlrtwuokY+2NFa3B6 cwwD1KycVyhPUNgLN8f3cVhwsnkX4ZZV189BSK30A+BxYvK4URA/Tvxk+Iqh2nwRw7rT N3nQ== 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=pdzjhy7K/gJyL0s0IMjzZTjZJiqcvNo8OChcDX60ftg=; b=OkHbQzKCc9L0S7LRcfdLfGKwkKtwpkVTpBEUGLgZZ89SBSKzp09KBrk9NsruyhcXY0 2wGLueyeLPvtft/BX4dahlsvq/qdNH+yeoy8mRAojcM+phBXO+ASOvYJPhf6nmlV0Uk7 KkoSH5vMmrzMXgT0bEC7Dr97gCLu98GgHpnPT9/BvT1XRDSjxARd6XIMw0gR8y9zGgn5 ZsKt21gqiRyeaMehRIa47hQs5ylzOrDHxTCP9hRg45FO/3Nzz+ryi3JWSFYLwnpdz2em 8Wm2usJPfgsfwkW9mzHWfNGcvDnIMmh8MXMxpjT+JMPZmWj7CHTl8tJtbVJee2FtPkd7 8raw== X-Gm-Message-State: ALKqPwdNkL6vNsgzHxtxe+bEzm4RaoNpGjb1Z+aFZDP98FGV3S8AUm7C 9q0vTiRInD07fvwjYoYsCnisQTQ6EGE= X-Google-Smtp-Source: AB8JxZrrEZ07EyQZdsimiH4zGpb5x9oiOuypXjstX4Fb5IfuTuES2A9QJAT77IFP51S0yMEWnM3asQ== X-Received: by 2002:ac8:73cc:: with SMTP id v12-v6mr6553926qtp.208.1526319301028; Mon, 14 May 2018 10:35:01 -0700 (PDT) Received: from localhost.localdomain ([45.4.239.227]) by smtp.gmail.com with ESMTPSA id c20-v6sm6880723qkm.59.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 9E82918140F; 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 4/8] sctp: move outq data rtx code out of sctp_outq_flush Date: Mon, 14 May 2018 14:34:39 -0300 Message-Id: <84221eeeec444593bfe297330452e3be3a91b5e3.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 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 92f14f51edf28cf596c76b98854a10c0fd28bb22..49e80bf2ade73914f3be275016df0a6e7f06f606 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; @@ -1053,45 +1102,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 From patchwork Mon May 14 17:34:40 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: 913154 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="dkkP8fDS"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40l7Bc2LnWz9s0W for ; Tue, 15 May 2018 03:35:20 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753208AbeENRfS (ORCPT ); Mon, 14 May 2018 13:35:18 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:41225 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753129AbeENRfF (ORCPT ); Mon, 14 May 2018 13:35:05 -0400 Received: by mail-qt0-f193.google.com with SMTP id g13-v6so17192449qth.8; Mon, 14 May 2018 10:35:04 -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=0bCgFFTulZkSKzSdvKkcuKc8seTPu+H+kYknzdU9QLw=; b=dkkP8fDS4XIE/WGt5o22lnCwJwSKwPvUklT0j9imDu10Jn0mqbnnntYU8a1Id3eFm/ i0+WfVQwVgjsiQjtBg3j7RiS0hkte3wka912evuiR2U4leBA3L/FFjB6iT26gST2RPyt rofPq6B5NajMl43mWGTH7ZDeuAnFIXIlMCV38CavNG/6agpV/MJ+2erXMK2/QvpsfoEo dxKvvFGxm7MsW3QJP39aCKvj7HSjr4LH/tfF9X9d4zUeCRx+R3jWhPkAO2Gf/6QKuHkI /fNNpQDf1O9Hu60U73pOap/uFyk7tsiBDkhl5xQEduPBXwo1+LYh0W5xWqjcxHQowLzV luYw== 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=0bCgFFTulZkSKzSdvKkcuKc8seTPu+H+kYknzdU9QLw=; b=f4B6xymyPTU7I4EEoKRlcjIcuOG99DD/sCtBbIrUNRRmfxXbI4OkRayuLSYiAeFPu9 /eB+ymqsOTQgC042AjKdPuA2xzy3hQL5bBqQGCEBESYju4WieFXD9UmwfmK1l0kTp587 k2sH6pn5YUxfa1sx2IMHvir2GFJ9hIFMQoguZt0RxFnp8zOJ9pCINpEN696dkSDdbyb2 wW0cVts1ejqQu/fvanLNoDv92n7BYf/RIFKRbBmwJDtk735GJgY6UnAR0ZPdOATw1KiK NXNS9Zdkgd8YD0b3z0h0GQ+uMZbNSWVXNu0YL4O/T3OVvutSYTnrFhiiHRycRWiWgmbQ WHmQ== X-Gm-Message-State: ALKqPwfuyMceKzh9QSDXQ/RbMgWkO5UeeXiobuOP3yhkgXyskGSYJPYd BI1qwPqPjQrk86IfZa0I8PRqEpW4Uek= X-Google-Smtp-Source: AB8JxZpdzFVMVSgW1p8e0OFHSeNmV/wta6U321YcjIx4xdwVozbUTk4llRvy2/RmRz35t9pIm7d0wg== X-Received: by 2002:aed:2374:: with SMTP id i49-v6mr9893697qtc.412.1526319303958; Mon, 14 May 2018 10:35:03 -0700 (PDT) Received: from localhost.localdomain ([45.4.239.227]) by smtp.gmail.com with ESMTPSA id 41-v6sm8345104qtz.37.2018.05.14.10.35.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 10:35:01 -0700 (PDT) Received: by localhost.localdomain (Postfix, from userid 1000) id A5D8D1814A9; 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 5/8] sctp: move flushing of data chunks out of sctp_outq_flush Date: Mon, 14 May 2018 14:34:40 -0300 Message-Id: <816d58dbcf25ec79372bb215d78b8d2b2194424e.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 To the new sctp_outq_flush_data. Again, smaller functions and with well defined objectives. Signed-off-by: Marcelo Ricardo Leitner --- net/sctp/outqueue.c | 149 ++++++++++++++++++++++++++-------------------------- 1 file changed, 75 insertions(+), 74 deletions(-) diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c index 49e80bf2ade73914f3be275016df0a6e7f06f606..bfa2e43dfd31d115862b65d1650858fcaa6f203b 100644 --- a/net/sctp/outqueue.c +++ b/net/sctp/outqueue.c @@ -1038,46 +1038,17 @@ static bool sctp_outq_flush_rtx(struct sctp_outq *q, return true; } -/* - * 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_data(struct sctp_outq *q, + struct sctp_transport **_transport, + struct list_head *transport_list, + int rtx_timeout, gfp_t gfp) { - struct sctp_packet *packet; + struct sctp_transport *transport = *_transport; + struct sctp_packet *packet = transport ? &transport->packet : NULL; struct sctp_association *asoc = q->asoc; - struct sctp_transport *transport = NULL; struct sctp_chunk *chunk; enum sctp_xmit status; - int error = 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; /* Is it OK to send data chunks? */ switch (asoc->state) { @@ -1102,10 +1073,11 @@ static void sctp_outq_flush(struct sctp_outq *q, int rtx_timeout, gfp_t gfp) * current cwnd). */ if (!list_empty(&q->retransmit)) { - if (!sctp_outq_flush_rtx(q, &transport, &transport_list, + if (!sctp_outq_flush_rtx(q, _transport, transport_list, rtx_timeout)) break; /* We may have switched current transport */ + transport = *_transport; packet = &transport->packet; } @@ -1131,12 +1103,14 @@ static void sctp_outq_flush(struct sctp_outq *q, int rtx_timeout, gfp_t gfp) if (asoc->stream.out[sid].state == SCTP_STREAM_CLOSED) { sctp_outq_head_data(q, chunk); - goto sctp_flush_out; + break; } - 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; + } pr_debug("%s: outq:%p, chunk:%p[%s], tx-tsn:0x%x skb->head:%p " "skb->users:%d\n", @@ -1148,8 +1122,10 @@ static void sctp_outq_flush(struct sctp_outq *q, int rtx_timeout, gfp_t gfp) /* Add the chunk to the packet. */ status = sctp_packet_transmit_chunk(packet, chunk, 0, gfp); - switch (status) { + case SCTP_XMIT_OK: + break; + case SCTP_XMIT_PMTU_FULL: case SCTP_XMIT_RWND_FULL: case SCTP_XMIT_DELAY: @@ -1161,41 +1137,25 @@ static void sctp_outq_flush(struct sctp_outq *q, int rtx_timeout, gfp_t gfp) status); sctp_outq_head_data(q, chunk); - goto sctp_flush_out; - - case SCTP_XMIT_OK: - /* The sender is in the SHUTDOWN-PENDING state, - * The sender MAY set the I-bit in the DATA - * chunk header. - */ - if (asoc->state == SCTP_STATE_SHUTDOWN_PENDING) - chunk->chunk_hdr->flags |= SCTP_DATA_SACK_IMM; - if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED) - asoc->stats.ouodchunks++; - else - asoc->stats.oodchunks++; - - /* Only now it's safe to consider this - * chunk as sent, sched-wise. - */ - sctp_sched_dequeue_done(q, chunk); - - break; - - default: - BUG(); + return; } - /* BUG: We assume that the sctp_packet_transmit() - * call below will succeed all the time and add the - * chunk to the transmitted list and restart the - * timers. - * It is possible that the call can fail under OOM - * conditions. - * - * Is this really a problem? Won't this behave - * like a lost TSN? + /* The sender is in the SHUTDOWN-PENDING state, + * The sender MAY set the I-bit in the DATA + * chunk header. */ + if (asoc->state == SCTP_STATE_SHUTDOWN_PENDING) + chunk->chunk_hdr->flags |= SCTP_DATA_SACK_IMM; + if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED) + asoc->stats.ouodchunks++; + else + asoc->stats.oodchunks++; + + /* Only now it's safe to consider this + * chunk as sent, sched-wise. + */ + sctp_sched_dequeue_done(q, chunk); + list_add_tail(&chunk->transmitted_list, &transport->transmitted); @@ -1206,7 +1166,7 @@ static void sctp_outq_flush(struct sctp_outq *q, int rtx_timeout, gfp_t gfp) * COOKIE-ECHO chunk. */ if (packet->has_cookie_echo) - goto sctp_flush_out; + break; } break; @@ -1214,6 +1174,47 @@ static void sctp_outq_flush(struct sctp_outq *q, int rtx_timeout, gfp_t gfp) /* Do nothing. */ break; } +} + +/* + * 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; + struct sctp_transport *transport = NULL; + int error = 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; + + sctp_outq_flush_data(q, &transport, &transport_list, rtx_timeout, gfp); sctp_flush_out: From patchwork Mon May 14 17:34:41 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: 913152 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="qAjH2CYA"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40l7BV4Lt0z9s0W for ; Tue, 15 May 2018 03:35:14 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753150AbeENRfG (ORCPT ); Mon, 14 May 2018 13:35:06 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:38802 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753125AbeENRfD (ORCPT ); Mon, 14 May 2018 13:35:03 -0400 Received: by mail-qk0-f196.google.com with SMTP id b39-v6so10670772qkb.5; Mon, 14 May 2018 10:35:03 -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=iBwTW5wNJeHmdNp2f2XMlJoZmjgLfE1yug17NbODGXE=; b=qAjH2CYAQkSSRWhgygamfhNTSN43lj5JFQBa5irNsgf7X+1bJt5Dxkp1V9osBu6hlE NslfTcab59RRITOxlKIVLx+cbb+C2Kk4Jhb+JAzuPlF0iMymA5erC9vR+MOyFrA33dto tOVgupURrpZqHP8k72Xp7fZmwLRG3mYv/vq/hC0gU/UPl0+AlTk/Rmo/TWqR5kxKtx/+ 3mLm31fRoudsB0EipE6u+l9fD31DknfGtuSbeR5+xWhQjoN5ztC79FdA64IimqrNkG2E KC/WJlTVD770wqKRSqSBQri/HCNccl2+DOo/NiVcoOry70PO+TkTPJi75gIuj1IpGHGQ uIaw== 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=iBwTW5wNJeHmdNp2f2XMlJoZmjgLfE1yug17NbODGXE=; b=L9NVKcGwB2T3QC3yd7FUvNDoylrao2PR1wTFePMYjIsgzpiVIIHaAEN7TwVzfpWXVT Ba3BkyjByWYRuHQfbHDk8qA6QG2xLRKnSNWUC5JYCe6tHbteBBnuHjd5cVvEPBURafvL 4/qzCK31bW2hYoY2BVZR0w/gbXm1TVSm9IPV1eTYNMTCA8M4NBLZN44Xx+9H6gBS3HVg v3TLuySMMOaJLud6aUTuK5vxIeJ649U3ao3UaVlVe77iWGXwB9NvwoYekTvnLVyl73Mo w6PslLDIq46K3g1o3sIZfKstQf7w+6ScCAlqccCLRG2aHZnRfgyYMGjztAxvB6j2M3EZ XZfQ== X-Gm-Message-State: ALKqPwf4ZrQJooRF5I51BKoDchMZdlAVSlrlV4EC1SknMhkH59Ba3lmR lEWjJFZQ0ge431IGIl7xAs0= X-Google-Smtp-Source: AB8JxZr4Fo/H7Bm0DsY7RHlOMwlG0JF1d35qYEq3PWTg493X7+rm0sUoCedXzXHQIufsZ+DAn/QBNA== X-Received: by 2002:a37:c0c5:: with SMTP id v66-v6mr9302778qkv.343.1526319302706; Mon, 14 May 2018 10:35:02 -0700 (PDT) Received: from localhost.localdomain ([45.4.239.227]) by smtp.gmail.com with ESMTPSA id b52-v6sm8277053qta.58.2018.05.14.10.35.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 10:35:01 -0700 (PDT) Received: by localhost.localdomain (Postfix, from userid 1000) id A9D111814CC; 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 6/8] sctp: move transport flush code out of sctp_outq_flush Date: Mon, 14 May 2018 14:34:41 -0300 Message-Id: <875fc90196a94e4353966cd3e1d3afd91b81e151.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 To the new sctp_outq_flush_transports. Comment on Nagle is outdated and removed. Nagle is performed earlier, while checking if the chunk fits the packet: if the outq length is not enough to fill the packet, it returns SCTP_XMIT_DELAY. So by when it gets to sctp_outq_flush_transports, it has to go through all enlisted transports. Signed-off-by: Marcelo Ricardo Leitner --- net/sctp/outqueue.c | 56 +++++++++++++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c index bfa2e43dfd31d115862b65d1650858fcaa6f203b..44465e64857b79636a78917a12776402ccb8f990 100644 --- a/net/sctp/outqueue.c +++ b/net/sctp/outqueue.c @@ -1176,6 +1176,29 @@ static void sctp_outq_flush_data(struct sctp_outq *q, } } +static void sctp_outq_flush_transports(struct sctp_outq *q, + struct list_head *transport_list, + gfp_t gfp) +{ + struct list_head *ltransport; + struct sctp_packet *packet; + struct sctp_transport *t; + int error = 0; + + while ((ltransport = sctp_list_dequeue(transport_list)) != NULL) { + t = list_entry(ltransport, struct sctp_transport, send_ready); + packet = &t->packet; + if (!sctp_packet_empty(packet)) { + error = sctp_packet_transmit(packet, gfp); + if (error < 0) + q->asoc->base.sk->sk_err = -error; + } + + /* Clear the burst limited state, if any */ + sctp_transport_burst_reset(t); + } +} + /* * Try to flush an outqueue. * @@ -1187,17 +1210,10 @@ static void sctp_outq_flush_data(struct sctp_outq *q, */ 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; + /* Current transport being used. It's NOT the same as curr active one */ struct sctp_transport *transport = NULL; - int error = 0; - /* These transports have chunks to send. */ - struct list_head transport_list; - struct list_head *ltransport; - - INIT_LIST_HEAD(&transport_list); - packet = NULL; + LIST_HEAD(transport_list); /* * 6.10 Bundling @@ -1218,27 +1234,7 @@ static void sctp_outq_flush(struct sctp_outq *q, int rtx_timeout, gfp_t gfp) sctp_flush_out: - /* Before returning, examine all the transports touched in - * this call. Right now, we bluntly force clear all the - * transports. Things might change after we implement Nagle. - * But such an examination is still required. - * - * --xguo - */ - while ((ltransport = sctp_list_dequeue(&transport_list)) != NULL) { - struct sctp_transport *t = list_entry(ltransport, - struct sctp_transport, - send_ready); - packet = &t->packet; - if (!sctp_packet_empty(packet)) { - error = sctp_packet_transmit(packet, gfp); - if (error < 0) - asoc->base.sk->sk_err = -error; - } - - /* Clear the burst limited state, if any */ - sctp_transport_burst_reset(t); - } + sctp_outq_flush_transports(q, &transport_list, gfp); } /* Update unack_data based on the incoming SACK chunk */ From patchwork Mon May 14 17:34:42 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: 913151 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="plXCu2k4"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40l7BP4HHpz9s0q for ; Tue, 15 May 2018 03:35:09 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753169AbeENRfH (ORCPT ); Mon, 14 May 2018 13:35:07 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:42048 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752057AbeENRfD (ORCPT ); Mon, 14 May 2018 13:35:03 -0400 Received: by mail-qt0-f194.google.com with SMTP id c2-v6so17196134qtn.9; Mon, 14 May 2018 10:35:02 -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=TuLKFzKtTD2NvUO1Mc+PbfF6O292cHXE7rdDA7LaT9Y=; b=plXCu2k49CGQgMImnb9IueEjA7/HZp8IB37CxeLrQrm4yJNdpc/876HGh9tj9SC/jn NN5In9ymWjmRBEIj1D/dLV89LwQ7c5MZadcXvWDRqtGHCyo0QSXy7xO+KTy1JcP0Ahhr CbBLdYXQLhaE1lF0korim6pvIEM//ESdrnnPD6lnK6Zgjj9PdTxCTdAboSLpNlNfqBMj 0WIScuW0g7gwDYbD/XEuluw4vE/OW9LSbdcqP9P3W83+Mr+SUt3Qqz1a9hl25UYQ1WYD 4I1BAcAM5VFATvVJDaCE9TT7X6gc9BqInDLa39mRSm6Z2ykZciZvIKQGu39CLIa7tC6F KucA== 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=TuLKFzKtTD2NvUO1Mc+PbfF6O292cHXE7rdDA7LaT9Y=; b=O+sCWH9t4e2tIznLqD/OZHxc0M5fhQCBD9m7bAb4XfdNIgKnpJCU1fBZeIQz8jk6dq bjYIzy8liZGSIu4Hl+/g+ReSkFP5iw2Rh3HypljvtkmwlwE1x44QmXXRvWQbkYFnLWOE /DXJOjlKJPi2+Pfj5M6TlZ1sMIKGfUgsopWvi9RllkY/R0JUgkm9u4iTQnsJnsEzAMCM KiL9uFUUxyVSqCxtPSLQSyTRjMoUrxzQ1pAQ8TyLpzknQEapCw3nF/YvWixsHR6ZOxOX BJlv5hTdW2VQX3m0WGKUFNUyHMex3BXG9EyF1lMXwuAEGG7RM4CX0FVx9dtGduH/L2qQ vt3g== X-Gm-Message-State: ALKqPwevD9VF0WfcGQKFO2Tf/VCf/HsuSB/TkGsj0p220KTmDoDCjwU0 GrOvNShT3vhFa0H76UoZZ0E= X-Google-Smtp-Source: AB8JxZp0OYV4ZxHrXxWpZwonZBR1YMOMq/wJwDL2Rm69UjIx11Ys7Ky++IJdh+/4Q8M9H9LRbF3/RA== X-Received: by 2002:a0c:8abc:: with SMTP id 57-v6mr9855663qvv.147.1526319302233; Mon, 14 May 2018 10:35:02 -0700 (PDT) Received: from localhost.localdomain ([45.4.239.227]) by smtp.gmail.com with ESMTPSA id l1-v6sm7856334qki.32.2018.05.14.10.35.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 10:35:01 -0700 (PDT) Received: by localhost.localdomain (Postfix, from userid 1000) id B4B86181503; 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 7/8] sctp: make use of gfp on retransmissions Date: Mon, 14 May 2018 14:34:42 -0300 Message-Id: <9e20ebbda02e4b81bd97fce0a095e2d55125f713.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 Retransmissions may be triggered when in user context, so lets make use of gfp. Signed-off-by: Marcelo Ricardo Leitner --- net/sctp/outqueue.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c index 44465e64857b79636a78917a12776402ccb8f990..e1632b8e2900f88070aebc82bbe4eca61f424e87 100644 --- a/net/sctp/outqueue.c +++ b/net/sctp/outqueue.c @@ -608,7 +608,7 @@ void sctp_retransmit(struct sctp_outq *q, struct sctp_transport *transport, * 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) + int rtx_timeout, int *start_timer, gfp_t gfp) { struct sctp_transport *transport = pkt->transport; struct sctp_chunk *chunk, *chunk1; @@ -684,12 +684,12 @@ static int __sctp_outq_flush_rtx(struct sctp_outq *q, struct sctp_packet *pkt, * control chunks are already freed so there * is nothing we can do. */ - sctp_packet_transmit(pkt, GFP_ATOMIC); + sctp_packet_transmit(pkt, gfp); goto redo; } /* Send this packet. */ - error = sctp_packet_transmit(pkt, GFP_ATOMIC); + error = sctp_packet_transmit(pkt, gfp); /* If we are retransmitting, we should only * send a single packet. @@ -705,7 +705,7 @@ static int __sctp_outq_flush_rtx(struct sctp_outq *q, struct sctp_packet *pkt, case SCTP_XMIT_RWND_FULL: /* Send this packet. */ - error = sctp_packet_transmit(pkt, GFP_ATOMIC); + error = sctp_packet_transmit(pkt, gfp); /* Stop sending DATA as there is no more room * at the receiver. @@ -715,7 +715,7 @@ static int __sctp_outq_flush_rtx(struct sctp_outq *q, struct sctp_packet *pkt, case SCTP_XMIT_DELAY: /* Send this packet. */ - error = sctp_packet_transmit(pkt, GFP_ATOMIC); + error = sctp_packet_transmit(pkt, gfp); /* Stop sending DATA because of nagle delay. */ done = 1; @@ -991,7 +991,7 @@ static void sctp_outq_flush_ctrl(struct sctp_outq *q, static bool sctp_outq_flush_rtx(struct sctp_outq *q, struct sctp_transport **_transport, struct list_head *transport_list, - int rtx_timeout) + int rtx_timeout, gfp_t gfp) { struct sctp_transport *transport = *_transport; struct sctp_packet *packet = transport ? &transport->packet : NULL; @@ -1015,7 +1015,8 @@ static bool sctp_outq_flush_rtx(struct sctp_outq *q, asoc->peer.ecn_capable); } - error = __sctp_outq_flush_rtx(q, packet, rtx_timeout, &start_timer); + error = __sctp_outq_flush_rtx(q, packet, rtx_timeout, &start_timer, + gfp); if (error < 0) asoc->base.sk->sk_err = -error; @@ -1074,7 +1075,7 @@ static void sctp_outq_flush_data(struct sctp_outq *q, */ if (!list_empty(&q->retransmit)) { if (!sctp_outq_flush_rtx(q, _transport, transport_list, - rtx_timeout)) + rtx_timeout, gfp)) break; /* We may have switched current transport */ transport = *_transport; From patchwork Mon May 14 17:34:43 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: 913153 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="JOrHVoTL"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40l7BZ717Wz9s0W for ; Tue, 15 May 2018 03:35:18 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753196AbeENRfR (ORCPT ); Mon, 14 May 2018 13:35:17 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:39892 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753134AbeENRfF (ORCPT ); Mon, 14 May 2018 13:35:05 -0400 Received: by mail-qt0-f194.google.com with SMTP id f1-v6so17213744qtj.6; Mon, 14 May 2018 10:35:05 -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=eMYawa8APSS7T8JPovnC43gZZPj8MebfU5gzVaUyEp0=; b=JOrHVoTLPrhTHBVjyfSHYT9Pz4UrH5bRUNIZhdgNDdbUsSY9VERLq+mVY5PJguyq+L a1yeOdi1FVB2rsHvwaV9ut/pfYR/7Z2sd0TtqYO5y/wk7xA/OYtmo1d9xFjVfuyhtY/T hJf6iJ1crmZkcMIp7w8YANpu2l1M+kYsfewRxjMIv7GIzXvcbvjZ2YY39OA4FFXNbO37 Nw0VcHpFcGIE5eCZv45fCN30EulhJpmj5mIT1hf5Cl95djUNsTFXOzdsGzSEIPaUXXuN P0PnSv8WH42AOfaLU+pLPKqO4+bZY/DnuPUZ8Y/qjAh4k330fw7Go3huU6m78kG02r0M 16Ag== 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=eMYawa8APSS7T8JPovnC43gZZPj8MebfU5gzVaUyEp0=; b=nuDt36Bsz2Vffs0F78EpwZLNPncWPx/shtSclrSA5HpkAp5f9fq1O4VHvh6BJmZ+vy GfKuN7dqiuxFil69TtKdmRmkLuEjGfZ0gg1JRm1+j7TwkjrJLEdD3IUz5Hj8zaq4wsPO PoRauDlclLr43IAx8DOlFrnmmYRdX2xlLg8EFmljgjMNE6QcD2+VR+CJCF60XN2HlU1R BkOr6ry9vvA7AjgCj788QamrL8vNXtB2ehHf8jY1Dn+csX/tfpFp2hD/2IgD8OLCNvlh dtTzrYTgrzJiY6hiZJ1u+5nNMa+sc03Yi1l/EvEdmvms8qcsfiY932d5zIpUL1vzqsas 2upA== X-Gm-Message-State: ALKqPwcSQ6lLRhymrzJZl2x98gBl+ikIakEHQVO8x1pZrWlysnMlKr0Z Q9t0+EWSdrwZs7bp3C+7WxT855eMOfM= X-Google-Smtp-Source: AB8JxZrmhZogWRe7v5R2hjWDOy9ttJJatg+IYB7A3mVCSdJo4vswjQ0+iu6u1D1qywMQ04MITiRENA== X-Received: by 2002:ac8:745:: with SMTP id k5-v6mr10226830qth.133.1526319304448; Mon, 14 May 2018 10:35:04 -0700 (PDT) Received: from localhost.localdomain ([45.4.239.227]) by smtp.gmail.com with ESMTPSA id z16-v6sm8362323qta.34.2018.05.14.10.35.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 10:35:01 -0700 (PDT) Received: by localhost.localdomain (Postfix, from userid 1000) id BC282181504; 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 8/8] sctp: rework switch cases in sctp_outq_flush_data Date: Mon, 14 May 2018 14:34:43 -0300 Message-Id: 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 Remove an inner one, which tended to be error prone due to the cascading and it can be replaced by a simple if (). Rework the outer one so that the actual flush code is not inside it. Now we first validate if we can or cannot send data, return if not, and then the flush code. Suggested-by: Xin Long Signed-off-by: Marcelo Ricardo Leitner --- net/sctp/outqueue.c | 191 +++++++++++++++++++++++++--------------------------- 1 file changed, 93 insertions(+), 98 deletions(-) diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c index e1632b8e2900f88070aebc82bbe4eca61f424e87..e9c22b3db11cd702afc52f8233fb7f39d917698a 100644 --- a/net/sctp/outqueue.c +++ b/net/sctp/outqueue.c @@ -1058,122 +1058,117 @@ static void sctp_outq_flush_data(struct sctp_outq *q, * chunk. */ if (!packet || !packet->has_cookie_echo) - break; + return; /* fallthru */ case SCTP_STATE_ESTABLISHED: case SCTP_STATE_SHUTDOWN_PENDING: case SCTP_STATE_SHUTDOWN_RECEIVED: - /* - * RFC 2960 6.1 Transmission of DATA Chunks - * - * C) When the time comes for the sender to transmit, - * before sending new DATA chunks, the sender MUST - * first transmit any outstanding DATA chunks which - * are marked for retransmission (limited by the - * current cwnd). - */ - if (!list_empty(&q->retransmit)) { - if (!sctp_outq_flush_rtx(q, _transport, transport_list, - rtx_timeout, gfp)) - break; - /* We may have switched current transport */ - transport = *_transport; - packet = &transport->packet; - } + break; - /* Apply Max.Burst limitation to the current transport in - * case it will be used for new data. We are going to - * rest it before we return, but we want to apply the limit - * to the currently queued data. - */ - if (transport) - sctp_transport_burst_limited(transport); - - /* Finally, transmit new packets. */ - while ((chunk = sctp_outq_dequeue_data(q)) != NULL) { - __u32 sid = ntohs(chunk->subh.data_hdr->stream); - - /* Has this chunk expired? */ - if (sctp_chunk_abandoned(chunk)) { - sctp_sched_dequeue_done(q, chunk); - sctp_chunk_fail(chunk, 0); - sctp_chunk_free(chunk); - continue; - } + default: + /* Do nothing. */ + return; + } - if (asoc->stream.out[sid].state == SCTP_STREAM_CLOSED) { - sctp_outq_head_data(q, chunk); - break; - } + /* + * RFC 2960 6.1 Transmission of DATA Chunks + * + * C) When the time comes for the sender to transmit, + * before sending new DATA chunks, the sender MUST + * first transmit any outstanding DATA chunks which + * are marked for retransmission (limited by the + * current cwnd). + */ + if (!list_empty(&q->retransmit)) { + if (!sctp_outq_flush_rtx(q, _transport, transport_list, + rtx_timeout, gfp)) + return; + /* We may have switched current transport */ + transport = *_transport; + packet = &transport->packet; + } - if (sctp_outq_select_transport(chunk, asoc, _transport, - transport_list)) { - transport = *_transport; - packet = &transport->packet; - } + /* Apply Max.Burst limitation to the current transport in + * case it will be used for new data. We are going to + * rest it before we return, but we want to apply the limit + * to the currently queued data. + */ + if (transport) + sctp_transport_burst_limited(transport); - pr_debug("%s: outq:%p, chunk:%p[%s], tx-tsn:0x%x skb->head:%p " - "skb->users:%d\n", - __func__, q, chunk, chunk && chunk->chunk_hdr ? - sctp_cname(SCTP_ST_CHUNK(chunk->chunk_hdr->type)) : - "illegal chunk", ntohl(chunk->subh.data_hdr->tsn), - chunk->skb ? chunk->skb->head : NULL, chunk->skb ? - refcount_read(&chunk->skb->users) : -1); - - /* Add the chunk to the packet. */ - status = sctp_packet_transmit_chunk(packet, chunk, 0, gfp); - switch (status) { - case SCTP_XMIT_OK: - break; + /* Finally, transmit new packets. */ + while ((chunk = sctp_outq_dequeue_data(q)) != NULL) { + __u32 sid = ntohs(chunk->subh.data_hdr->stream); - case SCTP_XMIT_PMTU_FULL: - case SCTP_XMIT_RWND_FULL: - case SCTP_XMIT_DELAY: - /* We could not append this chunk, so put - * the chunk back on the output queue. - */ - pr_debug("%s: could not transmit tsn:0x%x, status:%d\n", - __func__, ntohl(chunk->subh.data_hdr->tsn), - status); + /* Has this chunk expired? */ + if (sctp_chunk_abandoned(chunk)) { + sctp_sched_dequeue_done(q, chunk); + sctp_chunk_fail(chunk, 0); + sctp_chunk_free(chunk); + continue; + } - sctp_outq_head_data(q, chunk); - return; - } + if (asoc->stream.out[sid].state == SCTP_STREAM_CLOSED) { + sctp_outq_head_data(q, chunk); + break; + } - /* The sender is in the SHUTDOWN-PENDING state, - * The sender MAY set the I-bit in the DATA - * chunk header. - */ - if (asoc->state == SCTP_STATE_SHUTDOWN_PENDING) - chunk->chunk_hdr->flags |= SCTP_DATA_SACK_IMM; - if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED) - asoc->stats.ouodchunks++; - else - asoc->stats.oodchunks++; + if (sctp_outq_select_transport(chunk, asoc, _transport, + transport_list)) { + transport = *_transport; + packet = &transport->packet; + } - /* Only now it's safe to consider this - * chunk as sent, sched-wise. + pr_debug("%s: outq:%p, chunk:%p[%s], tx-tsn:0x%x skb->head:%p " + "skb->users:%d\n", + __func__, q, chunk, chunk && chunk->chunk_hdr ? + sctp_cname(SCTP_ST_CHUNK(chunk->chunk_hdr->type)) : + "illegal chunk", ntohl(chunk->subh.data_hdr->tsn), + chunk->skb ? chunk->skb->head : NULL, chunk->skb ? + refcount_read(&chunk->skb->users) : -1); + + /* Add the chunk to the packet. */ + status = sctp_packet_transmit_chunk(packet, chunk, 0, gfp); + if (status != SCTP_XMIT_OK) { + /* We could not append this chunk, so put + * the chunk back on the output queue. */ - sctp_sched_dequeue_done(q, chunk); + pr_debug("%s: could not transmit tsn:0x%x, status:%d\n", + __func__, ntohl(chunk->subh.data_hdr->tsn), + status); - list_add_tail(&chunk->transmitted_list, - &transport->transmitted); + sctp_outq_head_data(q, chunk); + break; + } - sctp_transport_reset_t3_rtx(transport); - transport->last_time_sent = jiffies; + /* The sender is in the SHUTDOWN-PENDING state, + * The sender MAY set the I-bit in the DATA + * chunk header. + */ + if (asoc->state == SCTP_STATE_SHUTDOWN_PENDING) + chunk->chunk_hdr->flags |= SCTP_DATA_SACK_IMM; + if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED) + asoc->stats.ouodchunks++; + else + asoc->stats.oodchunks++; - /* Only let one DATA chunk get bundled with a - * COOKIE-ECHO chunk. - */ - if (packet->has_cookie_echo) - break; - } - break; + /* Only now it's safe to consider this + * chunk as sent, sched-wise. + */ + sctp_sched_dequeue_done(q, chunk); - default: - /* Do nothing. */ - break; + list_add_tail(&chunk->transmitted_list, + &transport->transmitted); + + sctp_transport_reset_t3_rtx(transport); + transport->last_time_sent = jiffies; + + /* Only let one DATA chunk get bundled with a + * COOKIE-ECHO chunk. + */ + if (packet->has_cookie_echo) + break; } }