From 16321c0bb7263952a20a98ac7eca67e55baeaaae Mon Sep 17 00:00:00 2001 From: Sridhar Samudrala Date: Tue, 2 Sep 2003 21:06:16 -0700 Subject: [PATCH] [SCTP] draft 07 API changes: Disable listening when backlog is 0. --- net/sctp/socket.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 63befdba6de25..624ea882f1b19 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -3346,9 +3346,19 @@ SCTP_STATIC int sctp_seqpacket_listen(struct sock *sk, int backlog) if (!sctp_style(sk, UDP)) return -EINVAL; + /* If backlog is zero, disable listening. */ + if (!backlog) { + if (sctp_sstate(sk, CLOSED)) + return 0; + + sctp_unhash_endpoint(ep); + sk->sk_state = SCTP_SS_CLOSED; + } + + /* Return if we are already listening. */ if (sctp_sstate(sk, LISTENING)) return 0; - + /* * If a bind() or sctp_bindx() is not called prior to a listen() * call that allows new associations to be accepted, the system @@ -3379,6 +3389,15 @@ SCTP_STATIC int sctp_stream_listen(struct sock *sk, int backlog) struct sctp_opt *sp = sctp_sk(sk); struct sctp_endpoint *ep = sp->ep; + /* If backlog is zero, disable listening. */ + if (!backlog) { + if (sctp_sstate(sk, CLOSED)) + return 0; + + sctp_unhash_endpoint(ep); + sk->sk_state = SCTP_SS_CLOSED; + } + if (sctp_sstate(sk, LISTENING)) return 0; -- 2.53.0