From patchwork Tue Nov 27 11:11:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 1003776 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="oXg8RKp6"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4341MR11kCz9s4s for ; Tue, 27 Nov 2018 22:12:02 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729391AbeK0WJd (ORCPT ); Tue, 27 Nov 2018 17:09:33 -0500 Received: from mail-pf1-f181.google.com ([209.85.210.181]:34408 "EHLO mail-pf1-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726561AbeK0WJd (ORCPT ); Tue, 27 Nov 2018 17:09:33 -0500 Received: by mail-pf1-f181.google.com with SMTP id h3so8202560pfg.1; Tue, 27 Nov 2018 03:11:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=f8oypM1ZGQQFi6BM4xDYMRrrRGXYreRC9YIbhoNf8JQ=; b=oXg8RKp6bKSsexdQspoFMdQIy1ZJIkV4p+2jAX/7sKns9iqKzH0/zVGYpRvzdzUhgt E8qXALWm4TFtyMIeWWwQl1qyksIfERHBFBn3ISkQBgspKHVi2yR0+2uUa0Xkd6t3anRw ul6lpgUj5UhAKsoYo/3NlhG9S24V8o2tdVGr2etkDPXXyhnxwL0Bpf2YWUA3DPLSGpxC bUnNL8wj4FJarpX3GQBtIYIUFf+7ZiDQnjulJOckoN33rFwHIVpHPoheCT19cYBp9a72 QBkIt5g8jRCgZmW/3RkfzXbh7FQQeyZSeZYZSVdh9PywUvi8pSKDBqOAyceR2S2LAOL6 LzYA== 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; bh=f8oypM1ZGQQFi6BM4xDYMRrrRGXYreRC9YIbhoNf8JQ=; b=RX+ZdHbzAI+/4uAlbUMdPPLjSsNiBQQvDp8xPkAYF7CXXTagS5wrp9NeW73dUC5IdW OLjKAXta0mtc/9AWfPz600JNZzURYQjupJ9dSv+lIwApBL23H3yYS6a6nDM2ETFagTZj aKF7IVO8TsdkJSE0FRJlda7RgcJJajEIJiCMag31CyFJdqzjr6SJydFMyEUZgio8I+5m tJ28br+7lKHR10Mqwhp5wUX14q65tW4Su4SEq4oJvW1C1bvoshuykXlYtcnhiM0U879I +0e9MJU1u9kQF1ybZ1b1WnZql8AGAEkYStKGgAfFpf2A6jNPkKAOJ9a9WaVjtxuKcd1Z Ch3A== X-Gm-Message-State: AGRZ1gKwNxxM5KoyO9sZMnL5OLndtiNffJJqrmn1upd9GU5w1Hw2T/g9 qXlNueYUa9NNUL5QUP52j1gqFcwEYHk= X-Google-Smtp-Source: AFSGD/XMFLHnx6WWh5RTkg1Fq1cpRXduSUNtd2OzhHo8zprd6y68ZBOwYV5gLhfnOD8dGtO8Hhvj3g== X-Received: by 2002:a63:4815:: with SMTP id v21mr28544749pga.308.1543317118428; Tue, 27 Nov 2018 03:11:58 -0800 (PST) Received: from localhost ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id i4sm4505627pfj.82.2018.11.27.03.11.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Nov 2018 03:11:57 -0800 (PST) From: Xin Long To: network dev , linux-sctp@vger.kernel.org Cc: davem@davemloft.net, Marcelo Ricardo Leitner , Neil Horman , Jakub Audykowicz Subject: [PATCHv2 net] sctp: update frag_point when stream_interleave is set Date: Tue, 27 Nov 2018 19:11:50 +0800 Message-Id: <507afa887be8d5be9cc3030f6f21bc40719615e2.1543317110.git.lucien.xin@gmail.com> X-Mailer: git-send-email 2.1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org sctp_assoc_update_frag_point() should be called whenever asoc->pathmtu changes, but we missed one place in sctp_association_init(). It would cause frag_point is zero when sending data. As says in Jakub's reproducer, if sp->pathmtu is set by socketopt, the new asoc->pathmtu inherits it in sctp_association_init(). Later when transports are added and their pmtu >= asoc->pathmtu, it will never call sctp_assoc_update_frag_point() to set frag_point. This patch is to fix it by updating frag_point after asoc->pathmtu is set as sp->pathmtu in sctp_association_init(). Note that it moved them after sctp_stream_init(), as stream->si needs to be set first. Frag_point's calculation is also related with datachunk's type, so it needs to update frag_point when stream->si may be changed in sctp_process_init(). v1->v2: - call sctp_assoc_update_frag_point() separately in sctp_process_init and sctp_association_init, per Marcelo's suggestion. Fixes: 2f5e3c9df693 ("sctp: introduce sctp_assoc_update_frag_point") Reported-by: Jakub Audykowicz Signed-off-by: Xin Long Acked-by: Marcelo Ricardo Leitner Acked-by: Neil Horman --- net/sctp/associola.c | 7 ++++--- net/sctp/sm_make_chunk.c | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/net/sctp/associola.c b/net/sctp/associola.c index 6a28b96..dd77ec3 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c @@ -118,9 +118,6 @@ static struct sctp_association *sctp_association_init( asoc->flowlabel = sp->flowlabel; asoc->dscp = sp->dscp; - /* Initialize default path MTU. */ - asoc->pathmtu = sp->pathmtu; - /* Set association default SACK delay */ asoc->sackdelay = msecs_to_jiffies(sp->sackdelay); asoc->sackfreq = sp->sackfreq; @@ -252,6 +249,10 @@ static struct sctp_association *sctp_association_init( 0, gfp)) goto fail_init; + /* Initialize default path MTU. */ + asoc->pathmtu = sp->pathmtu; + sctp_assoc_update_frag_point(asoc); + /* Assume that peer would support both address types unless we are * told otherwise. */ diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index 4a4fd19..f4ac6c5 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c @@ -2462,6 +2462,9 @@ int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk, asoc->c.sinit_max_instreams, gfp)) goto clean_up; + /* Update frag_point when stream_interleave may get changed. */ + sctp_assoc_update_frag_point(asoc); + if (!asoc->temp && sctp_assoc_set_id(asoc, gfp)) goto clean_up;