All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] sctp: return a one-to-one type socket when doing peeloff
@ 2020-03-02  6:57 ` Xin Long
  0 siblings, 0 replies; 23+ messages in thread
From: Xin Long @ 2020-03-02  6:57 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: davem, Marcelo Ricardo Leitner, Neil Horman, jere.leppanen,
	michael.tuexen

As it says in rfc6458#section-9.2:

  The application uses the sctp_peeloff() call to branch off an
  association into a separate socket.  (Note that the semantics are
  somewhat changed from the traditional one-to-one style accept()
  call.)  Note also that the new socket is a one-to-one style socket.
  Thus, it will be confined to operations allowed for a one-to-one
  style socket.

Prior to this patch, sctp_peeloff() returned a one-to-many type socket,
on which some operations are not allowed, like shutdown, as Jere
reported.

This patch is to change it to return a one-to-one type socket instead.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reported-by: Leppanen, Jere (Nokia - FI/Espoo) <jere.leppanen@nokia.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/sctp/socket.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 1b56fc4..2b55beb 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -88,8 +88,7 @@ static int sctp_send_asconf(struct sctp_association *asoc,
 static int sctp_do_bind(struct sock *, union sctp_addr *, int);
 static int sctp_autobind(struct sock *sk);
 static int sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
-			     struct sctp_association *assoc,
-			     enum sctp_socket_type type);
+			     struct sctp_association *assoc);
 
 static unsigned long sctp_memory_pressure;
 static atomic_long_t sctp_memory_allocated;
@@ -4965,7 +4964,7 @@ static struct sock *sctp_accept(struct sock *sk, int flags, int *err, bool kern)
 	/* Populate the fields of the newsk from the oldsk and migrate the
 	 * asoc to the newsk.
 	 */
-	error = sctp_sock_migrate(sk, newsk, asoc, SCTP_SOCKET_TCP);
+	error = sctp_sock_migrate(sk, newsk, asoc);
 	if (error) {
 		sk_common_release(newsk);
 		newsk = NULL;
@@ -5711,7 +5710,7 @@ int sctp_do_peeloff(struct sock *sk, sctp_assoc_t id, struct socket **sockp)
 		return -EINVAL;
 
 	/* Create a new socket.  */
-	err = sock_create(sk->sk_family, SOCK_SEQPACKET, IPPROTO_SCTP, &sock);
+	err = sock_create(sk->sk_family, SOCK_STREAM, IPPROTO_SCTP, &sock);
 	if (err < 0)
 		return err;
 
@@ -5727,8 +5726,7 @@ int sctp_do_peeloff(struct sock *sk, sctp_assoc_t id, struct socket **sockp)
 	/* Populate the fields of the newsk from the oldsk and migrate the
 	 * asoc to the newsk.
 	 */
-	err = sctp_sock_migrate(sk, sock->sk, asoc,
-				SCTP_SOCKET_UDP_HIGH_BANDWIDTH);
+	err = sctp_sock_migrate(sk, sock->sk, asoc);
 	if (err) {
 		sock_release(sock);
 		sock = NULL;
@@ -9453,8 +9451,7 @@ static inline void sctp_copy_descendant(struct sock *sk_to,
  * and its messages to the newsk.
  */
 static int sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
-			     struct sctp_association *assoc,
-			     enum sctp_socket_type type)
+			     struct sctp_association *assoc)
 {
 	struct sctp_sock *oldsp = sctp_sk(oldsk);
 	struct sctp_sock *newsp = sctp_sk(newsk);
@@ -9562,7 +9559,7 @@ static int sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
 	 * original UDP-style socket or created with the accept() call on a
 	 * TCP-style socket..
 	 */
-	newsp->type = type;
+	newsp->type = SCTP_SOCKET_TCP;
 
 	/* Mark the new socket "in-use" by the user so that any packets
 	 * that may arrive on the association after we've moved it are
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2020-03-13  0:27 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-02  6:57 [PATCH net] sctp: return a one-to-one type socket when doing peeloff Xin Long
2020-03-02  6:57 ` Xin Long
2020-03-03 18:38 ` Leppanen, Jere (Nokia - FI/Espoo)
2020-03-03 18:38   ` Leppanen, Jere (Nokia - FI/Espoo)
2020-03-04  9:38   ` Xin Long
2020-03-04  9:38     ` Xin Long
2020-03-04 17:13     ` Jere Leppanen
2020-03-04 17:13       ` Jere Leppanen
2020-03-05 14:01       ` David Laight
2020-03-05 14:01         ` David Laight
2020-03-05 17:31         ` Jere Leppanen
2020-03-05 17:31           ` Jere Leppanen
2020-03-11  3:34       ` Marcelo Ricardo Leitner
2020-03-11  3:34         ` Marcelo Ricardo Leitner
2020-03-11 18:41         ` Jere Leppanen
2020-03-11 18:41           ` Jere Leppanen
2020-03-10  1:09 ` David Miller
2020-03-10  1:09   ` David Miller
2020-03-11  3:35   ` Marcelo Ricardo Leitner
2020-03-11  3:35     ` Marcelo Ricardo Leitner
2020-03-13  0:27 ` [sctp] 38ec705901: ltp.test_peeloff.fail kernel test robot
2020-03-13  0:27   ` kernel test robot
2020-03-13  0:27   ` [LTP] " kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.