From patchwork Sat Jan 7 09:43:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 712246 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3twc2n1DrSz9srY for ; Sat, 7 Jan 2017 20:44:49 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="N5FWZNfg"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941345AbdAGJor (ORCPT ); Sat, 7 Jan 2017 04:44:47 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:33129 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S941323AbdAGJnv (ORCPT ); Sat, 7 Jan 2017 04:43:51 -0500 Received: by mail-pg0-f66.google.com with SMTP id 194so1959052pgd.0; Sat, 07 Jan 2017 01:43:51 -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:in-reply-to:references :in-reply-to:references; bh=W1OZqv5EOTzIKP3T6Z15LLaYGbeClt/mxLPnzj79Cv4=; b=N5FWZNfge3bVJj0k5stvplNmi0yKg5Jr6ZH5Z4FuDZKzccBV8InOoO7bkLq4Ti7RdC 7pWI04c0seyAx9bQbmJqs1/K4HLRcRPs2vdoqnKXsub4P9IxFtv82cYBTrViRLB4wmR3 8mONfr8rNdD3vrJzkWvMdiHKfaRWj7rSbSUt23ZEdR+eMGOzp88Tt1Uyt4aKjCLvkxDZ 02QOkxBUwgIB20Gzj3TSfUWbVygWH5uOENGIiiLheMyoxBcpLvTd7WbEzGIpxpI5AI9r 8CUMozVXWqHpmERBQGpSzSDJ1buyKRGyGt0HVFiLHJK1oD+GwMOiva9POzLdsJvei2nA e1UQ== 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:in-reply-to:references; bh=W1OZqv5EOTzIKP3T6Z15LLaYGbeClt/mxLPnzj79Cv4=; b=LGOlwKAPCFIFahOVfJbHFKq6F6f5SY9kj4EbI47m1+hFd/8hOFj8LF9m7OPAgmdXxt 9EVqxddxVV5aXBe6nKQl5wFQGZXy6X73tQR95rSyZtICZJefRzAft/dVTNbbSLDQL2fx MoO6WoQJ0CL5vd0m1qCS1+CiH3b7c/F3zLxV7yRpPH6afRkKkylq/BbJZ531f9++dxpv OISi9bee7GDJzvFIYlx1+e4rxGyCwIWrHVMGabtvgG3Pv4MfKTdVi+7x/6eMLFcPW+8P aAy5dl/8R166lvafzSi6R3WDDEYoKfjhz1odpCaZ/O1PXh8JdGkgcDYPCUPHX/u1IXYs EIxA== X-Gm-Message-State: AIkVDXKbtZ7ZmooRtQAYov1J8GbSHHsza81Z85xc5bq5s+B1/RSKxKbjW0rQ3zVfPey5hw== X-Received: by 10.84.208.102 with SMTP id f35mr175728675plh.137.1483782230593; Sat, 07 Jan 2017 01:43:50 -0800 (PST) Received: from localhost ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id r68sm155668874pfk.85.2017.01.07.01.43.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Jan 2017 01:43:49 -0800 (PST) From: Xin Long To: network dev , linux-sctp@vger.kernel.org Cc: Marcelo Ricardo Leitner , Neil Horman , Vlad Yasevich , davem@davemloft.net Subject: [PATCHv2 net-next 5/5] sctp: add support for generating stream reconf add streams request chunk Date: Sat, 7 Jan 2017 17:43:02 +0800 Message-Id: <10e93a2d60d92fdda0357ba4f958c1c8b4e6f5fb.1483781759.git.lucien.xin@gmail.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: References: <01d610742b62da93ccd79581e407b0aec7bc488c.1483781759.git.lucien.xin@gmail.com> In-Reply-To: References: Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch is to define Add Incoming/Outgoing Streams Request Parameter described in rfc6525 section 4.5 and 4.6. They can be in one same chunk trunk as rfc6525 section 3.1-7 describes, so make them in one function. Signed-off-by: Xin Long --- include/linux/sctp.h | 7 +++++++ include/net/sctp/sm.h | 3 +++ net/sctp/sm_make_chunk.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/include/linux/sctp.h b/include/linux/sctp.h index c4fcc7d..3a9f234 100644 --- a/include/linux/sctp.h +++ b/include/linux/sctp.h @@ -771,4 +771,11 @@ struct sctp_strreset_resptsn { __u32 receivers_next_tsn; } __packed; +struct sctp_strreset_addstrm { + sctp_paramhdr_t param_hdr; + __u32 request_seq; + __u16 number_of_streams; + __u16 reserved; +} __packed; + #endif /* __LINUX_SCTP_H__ */ diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h index 013d69f..35986d0 100644 --- a/include/net/sctp/sm.h +++ b/include/net/sctp/sm.h @@ -272,6 +272,9 @@ struct sctp_chunk *sctp_make_strreset_tsnresp( struct sctp_association *asoc, __u32 result, __u32 sn, __u32 sender_tsn, __u32 receiver_tsn); +struct sctp_chunk *sctp_make_strreset_addstrm( + const struct sctp_association *asoc, + __u16 out, __u16 in); void sctp_chunk_assign_tsn(struct sctp_chunk *); void sctp_chunk_assign_ssn(struct sctp_chunk *); diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index 34edb30..e6a5530 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c @@ -3750,3 +3750,49 @@ struct sctp_chunk *sctp_make_strreset_tsnresp( return retval; } + +/* RE-CONFIG 4.5/4.6 (ADD STREAM) + * 0 1 2 3 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Parameter Type = 17 | Parameter Length = 12 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Re-configuration Request Sequence Number | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Number of new streams | Reserved | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +struct sctp_chunk *sctp_make_strreset_addstrm( + const struct sctp_association *asoc, + __u16 out, __u16 in) +{ + struct sctp_strreset_addstrm addstrm; + __u16 length = sizeof(addstrm); + struct sctp_chunk *retval; + + retval = sctp_make_reconf(asoc, (!!out + !!in) * length); + if (!retval) + return NULL; + + if (out) { + addstrm.param_hdr.type = SCTP_PARAM_RESET_ADD_OUT_STREAMS; + addstrm.param_hdr.length = htons(length); + addstrm.number_of_streams = htons(out); + addstrm.request_seq = htonl(asoc->strreset_outseq); + addstrm.reserved = 0; + + sctp_addto_chunk(retval, length, &addstrm); + } + + if (in) { + addstrm.param_hdr.type = SCTP_PARAM_RESET_ADD_IN_STREAMS; + addstrm.param_hdr.length = htons(length); + addstrm.number_of_streams = htons(in); + addstrm.request_seq = htonl(asoc->strreset_outseq + !!out); + addstrm.reserved = 0; + + sctp_addto_chunk(retval, length, &addstrm); + } + + return retval; +}