netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xin Long <lucien.xin@gmail.com>
To: network dev <netdev@vger.kernel.org>, linux-sctp@vger.kernel.org
Cc: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
	Neil Horman <nhorman@tuxdriver.com>,
	davem@davemloft.net
Subject: [PATCH net-next 5/5] sctp: add spt_pathcpthld in struct sctp_paddrthlds
Date: Mon,  9 Sep 2019 15:56:51 +0800	[thread overview]
Message-ID: <604e6ac718c29aa5b1a8c4b164a126b82bc42a2f.1568015756.git.lucien.xin@gmail.com> (raw)
In-Reply-To: <06a808c98b94e92b52276469e0257ef9f58923d0.1568015756.git.lucien.xin@gmail.com>
In-Reply-To: <cover.1568015756.git.lucien.xin@gmail.com>

Section 7.2 of rfc7829: "Peer Address Thresholds (SCTP_PEER_ADDR_THLDS)
Socket Option" extends 'struct sctp_paddrthlds' with 'spt_pathcpthld'
added to allow a user to change ps_retrans per sock/asoc/transport, as
other 2 paddrthlds: pf_retrans, pathmaxrxt.

Note that ps_retrans is not allowed to be greater than pf_retrans.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 include/uapi/linux/sctp.h |  1 +
 net/sctp/socket.c         | 10 ++++++++++
 2 files changed, 11 insertions(+)

diff --git a/include/uapi/linux/sctp.h b/include/uapi/linux/sctp.h
index a15cc28..dfd81e1 100644
--- a/include/uapi/linux/sctp.h
+++ b/include/uapi/linux/sctp.h
@@ -1069,6 +1069,7 @@ struct sctp_paddrthlds {
 	struct sockaddr_storage spt_address;
 	__u16 spt_pathmaxrxt;
 	__u16 spt_pathpfthld;
+	__u16 spt_pathcpthld;
 };
 
 /*
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 5e2098b..5b9774d 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -3954,6 +3954,9 @@ static int sctp_setsockopt_paddr_thresholds(struct sock *sk,
 			   sizeof(struct sctp_paddrthlds)))
 		return -EFAULT;
 
+	if (val.spt_pathpfthld > val.spt_pathcpthld)
+		return -EINVAL;
+
 	if (!sctp_is_any(sk, (const union sctp_addr *)&val.spt_address)) {
 		trans = sctp_addr_id2transport(sk, &val.spt_address,
 					       val.spt_assoc_id);
@@ -3963,6 +3966,7 @@ static int sctp_setsockopt_paddr_thresholds(struct sock *sk,
 		if (val.spt_pathmaxrxt)
 			trans->pathmaxrxt = val.spt_pathmaxrxt;
 		trans->pf_retrans = val.spt_pathpfthld;
+		trans->ps_retrans = val.spt_pathcpthld;
 
 		return 0;
 	}
@@ -3978,17 +3982,20 @@ static int sctp_setsockopt_paddr_thresholds(struct sock *sk,
 			if (val.spt_pathmaxrxt)
 				trans->pathmaxrxt = val.spt_pathmaxrxt;
 			trans->pf_retrans = val.spt_pathpfthld;
+			trans->ps_retrans = val.spt_pathcpthld;
 		}
 
 		if (val.spt_pathmaxrxt)
 			asoc->pathmaxrxt = val.spt_pathmaxrxt;
 		asoc->pf_retrans = val.spt_pathpfthld;
+		asoc->ps_retrans = val.spt_pathcpthld;
 	} else {
 		struct sctp_sock *sp = sctp_sk(sk);
 
 		if (val.spt_pathmaxrxt)
 			sp->pathmaxrxt = val.spt_pathmaxrxt;
 		sp->pf_retrans = val.spt_pathpfthld;
+		sp->ps_retrans = val.spt_pathcpthld;
 	}
 
 	return 0;
@@ -7232,6 +7239,7 @@ static int sctp_getsockopt_paddr_thresholds(struct sock *sk,
 		if (!trans)
 			return -ENOENT;
 
+		val.spt_pathcpthld = trans->ps_retrans;
 		val.spt_pathmaxrxt = trans->pathmaxrxt;
 		val.spt_pathpfthld = trans->pf_retrans;
 
@@ -7244,11 +7252,13 @@ static int sctp_getsockopt_paddr_thresholds(struct sock *sk,
 		return -EINVAL;
 
 	if (asoc) {
+		val.spt_pathcpthld = asoc->ps_retrans;
 		val.spt_pathpfthld = asoc->pf_retrans;
 		val.spt_pathmaxrxt = asoc->pathmaxrxt;
 	} else {
 		struct sctp_sock *sp = sctp_sk(sk);
 
+		val.spt_pathcpthld = sp->ps_retrans;
 		val.spt_pathpfthld = sp->pf_retrans;
 		val.spt_pathmaxrxt = sp->pathmaxrxt;
 	}
-- 
2.1.0


  reply	other threads:[~2019-09-09  7:57 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-09  7:56 [PATCH net-next 0/5] sctp: update from rfc7829 Xin Long
2019-09-09  7:56 ` [PATCH net-next 1/5] sctp: add SCTP_ADDR_POTENTIALLY_FAILED notification Xin Long
2019-09-09  7:56   ` [PATCH net-next 2/5] sctp: add pf_expose per netns and sock and asoc Xin Long
2019-09-09  7:56     ` [PATCH net-next 3/5] sctp: add SCTP_EXPOSE_POTENTIALLY_FAILED_STATE sockopt Xin Long
2019-09-09  7:56       ` [PATCH net-next 4/5] sctp: add support for Primary Path Switchover Xin Long
2019-09-09  7:56         ` Xin Long [this message]
2019-09-10 13:19           ` [PATCH net-next 5/5] sctp: add spt_pathcpthld in struct sctp_paddrthlds David Laight
2019-09-11  8:51             ` Xin Long
2019-09-11  9:03               ` David Laight
2019-09-11  9:21                 ` Xin Long
2019-09-11  9:38                   ` Xin Long
2019-09-11 12:56                     ` Marcelo Ricardo Leitner
2019-09-11 17:47                       ` Xin Long
2019-09-12 22:51                         ` Marcelo Ricardo Leitner
2019-09-13  8:36                           ` David Laight
2019-09-13 13:19                             ` 'Marcelo Ricardo Leitner'
2019-09-13 13:31                               ` David Laight
2019-09-13 13:40                                 ` 'Marcelo Ricardo Leitner'
2019-09-10 17:27           ` David Miller
2019-09-11  8:14             ` Xin Long

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=604e6ac718c29aa5b1a8c4b164a126b82bc42a2f.1568015756.git.lucien.xin@gmail.com \
    --to=lucien.xin@gmail.com \
    --cc=davem@davemloft.net \
    --cc=linux-sctp@vger.kernel.org \
    --cc=marcelo.leitner@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).