Commit 78f4b6b8 authored by Sridhar Samudrala's avatar Sridhar Samudrala

[SCTP] Minor changes for tcp-style socket support.

parent 7cd48512
...@@ -210,14 +210,19 @@ typedef enum { ...@@ -210,14 +210,19 @@ typedef enum {
/* These are values for sk->state. /* These are values for sk->state.
* For a UDP-style SCTP socket, the states are defined as follows * For a UDP-style SCTP socket, the states are defined as follows
* (at this point of time, may change later after more discussions: FIXME) * - A socket in SCTP_SS_CLOSED state indicates that it is not willing to
* A socket in SCTP_SS_UNCONNECTED state indicates that it is not willing * accept new associations, but it can initiate the creation of new ones.
* to accept new associations, but it can initiate the creation of new * - A socket in SCTP_SS_LISTENING state indicates that it is willing to
* ones. * accept new associations and can initiate the creation of new ones.
* A socket in SCTP_SS_LISTENING state indicates that it is willing to * - A socket in SCTP_SS_ESTABLISHED state indicates that it is a peeled off
* accept new associations and can initiate the creation of new ones. * socket with one association.
* A socket in SCTP_SS_ESTABLISHED state indicates that it is a peeled off * For a TCP-style SCTP socket, the states are defined as follows
* socket with one association. * - A socket in SCTP_SS_CLOSED state indicates that it is not willing to
* accept new associations, but it can initiate the creation of new ones.
* - A socket in SCTP_SS_LISTENING state indicates that it is willing to
* accept new associations, but cannot initiate the creation of new ones.
* - A socket in SCTP_SS_ESTABLISHED state indicates that it has a single
* association in ESTABLISHED state.
*/ */
typedef enum { typedef enum {
SCTP_SS_CLOSED = TCP_CLOSE, SCTP_SS_CLOSED = TCP_CLOSE,
......
...@@ -105,8 +105,7 @@ static void sctp_cmd_new_state(sctp_cmd_seq_t *, sctp_association_t *, ...@@ -105,8 +105,7 @@ static void sctp_cmd_new_state(sctp_cmd_seq_t *, sctp_association_t *,
#define DEBUG_POST_SFX \ #define DEBUG_POST_SFX \
SCTP_DEBUG_PRINTK("sctp_do_sm post sfx: error %d, asoc %p[%s]\n", \ SCTP_DEBUG_PRINTK("sctp_do_sm post sfx: error %d, asoc %p[%s]\n", \
error, asoc, \ error, asoc, \
sctp_state_tbl[sctp_id2assoc(ep->base.sk, \ sctp_state_tbl[asoc?asoc->state:SCTP_STATE_CLOSED])
sctp_assoc2id(asoc))?asoc->state:SCTP_STATE_CLOSED])
/* /*
* This is the master state machine processing function. * This is the master state machine processing function.
...@@ -1239,12 +1238,19 @@ static void sctp_cmd_new_state(sctp_cmd_seq_t *cmds, sctp_association_t *asoc, ...@@ -1239,12 +1238,19 @@ static void sctp_cmd_new_state(sctp_cmd_seq_t *cmds, sctp_association_t *asoc,
wake_up_interruptible(&asoc->wait); wake_up_interruptible(&asoc->wait);
/* Wake up any processes waiting in the sk's sleep queue of /* Wake up any processes waiting in the sk's sleep queue of
* a tcp-style or udp-style peeled-off socket in * a TCP-style or UDP-style peeled-off socket in
* sctp_wait_for_accept() or sctp_wait_for_packet(). * sctp_wait_for_accept() or sctp_wait_for_packet().
* For a udp-style socket, the waiters are woken up by the * For a UDP-style socket, the waiters are woken up by the
* notifications. * notifications.
*/ */
if (sp->type != SCTP_SOCKET_UDP) if (SCTP_SOCKET_UDP != sp->type)
sk->state_change(sk); sk->state_change(sk);
} }
/* Change the sk->state of a TCP-style socket that has sucessfully
* completed a connect() call.
*/
if ((SCTP_STATE_ESTABLISHED == asoc->state) &&
(SCTP_SOCKET_TCP == sp->type) && (SCTP_SS_CLOSED == sk->state))
sk->state = SCTP_SS_ESTABLISHED;
} }
...@@ -1563,8 +1563,14 @@ SCTP_STATIC int sctp_connect(struct sock *sk, struct sockaddr *uaddr, ...@@ -1563,8 +1563,14 @@ SCTP_STATIC int sctp_connect(struct sock *sk, struct sockaddr *uaddr,
sp = sctp_sk(sk); sp = sctp_sk(sk);
ep = sp->ep; ep = sp->ep;
/* connect() cannot be done on a peeled-off socket. */ /* connect() cannot be done on a socket that is already in ESTABLISHED
if (SCTP_SOCKET_UDP_HIGH_BANDWIDTH == sp->type) { * state - UDP-style peeled off socket or a TCP-style socket that
* is already connected.
* It cannot be done even on a TCP-style listening socket.
*/
if ((SCTP_SS_ESTABLISHED == sk->state) ||
((SCTP_SOCKET_TCP == sp->type) &&
(SCTP_SS_LISTENING == sk->state))) {
err = -EISCONN; err = -EISCONN;
goto out_unlock; goto out_unlock;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment