|
@@ -139,13 +139,15 @@ static void reject_rx_queue(struct sock *sk)
|
|
|
*
|
|
*
|
|
|
* Returns 0 on success, errno otherwise
|
|
* Returns 0 on success, errno otherwise
|
|
|
*/
|
|
*/
|
|
|
-static int tipc_sk_create(struct net *net, struct socket *sock, int protocol,
|
|
|
|
|
- int kern)
|
|
|
|
|
|
|
+static int tipc_sk_create(struct net *net, struct socket *sock,
|
|
|
|
|
+ int protocol, int kern)
|
|
|
{
|
|
{
|
|
|
const struct proto_ops *ops;
|
|
const struct proto_ops *ops;
|
|
|
socket_state state;
|
|
socket_state state;
|
|
|
struct sock *sk;
|
|
struct sock *sk;
|
|
|
- struct tipc_port *tp_ptr;
|
|
|
|
|
|
|
+ struct tipc_sock *tsk;
|
|
|
|
|
+ struct tipc_port *port;
|
|
|
|
|
+ u32 ref;
|
|
|
|
|
|
|
|
/* Validate arguments */
|
|
/* Validate arguments */
|
|
|
if (unlikely(protocol != 0))
|
|
if (unlikely(protocol != 0))
|
|
@@ -178,8 +180,12 @@ static int tipc_sk_create(struct net *net, struct socket *sock, int protocol,
|
|
|
if (sk == NULL)
|
|
if (sk == NULL)
|
|
|
return -ENOMEM;
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
- tp_ptr = tipc_sk_port(sk);
|
|
|
|
|
- if (!tipc_port_init(tp_ptr, TIPC_LOW_IMPORTANCE)) {
|
|
|
|
|
|
|
+ tsk = tipc_sk(sk);
|
|
|
|
|
+ port = &tsk->port;
|
|
|
|
|
+
|
|
|
|
|
+ ref = tipc_port_init(port, TIPC_LOW_IMPORTANCE);
|
|
|
|
|
+ if (!ref) {
|
|
|
|
|
+ pr_warn("Socket registration failed, ref. table exhausted\n");
|
|
|
sk_free(sk);
|
|
sk_free(sk);
|
|
|
return -ENOMEM;
|
|
return -ENOMEM;
|
|
|
}
|
|
}
|
|
@@ -194,12 +200,12 @@ static int tipc_sk_create(struct net *net, struct socket *sock, int protocol,
|
|
|
sk->sk_data_ready = tipc_data_ready;
|
|
sk->sk_data_ready = tipc_data_ready;
|
|
|
sk->sk_write_space = tipc_write_space;
|
|
sk->sk_write_space = tipc_write_space;
|
|
|
tipc_sk(sk)->conn_timeout = CONN_TIMEOUT_DEFAULT;
|
|
tipc_sk(sk)->conn_timeout = CONN_TIMEOUT_DEFAULT;
|
|
|
- spin_unlock_bh(tp_ptr->lock);
|
|
|
|
|
|
|
+ tipc_port_unlock(port);
|
|
|
|
|
|
|
|
if (sock->state == SS_READY) {
|
|
if (sock->state == SS_READY) {
|
|
|
- tipc_port_set_unreturnable(tp_ptr, true);
|
|
|
|
|
|
|
+ tipc_port_set_unreturnable(port, true);
|
|
|
if (sock->type == SOCK_DGRAM)
|
|
if (sock->type == SOCK_DGRAM)
|
|
|
- tipc_port_set_unreliable(tp_ptr, true);
|
|
|
|
|
|
|
+ tipc_port_set_unreliable(port, true);
|
|
|
}
|
|
}
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
@@ -292,7 +298,8 @@ int tipc_sock_accept_local(struct socket *sock, struct socket **newsock,
|
|
|
static int tipc_release(struct socket *sock)
|
|
static int tipc_release(struct socket *sock)
|
|
|
{
|
|
{
|
|
|
struct sock *sk = sock->sk;
|
|
struct sock *sk = sock->sk;
|
|
|
- struct tipc_port *tport;
|
|
|
|
|
|
|
+ struct tipc_sock *tsk;
|
|
|
|
|
+ struct tipc_port *port;
|
|
|
struct sk_buff *buf;
|
|
struct sk_buff *buf;
|
|
|
int res;
|
|
int res;
|
|
|
|
|
|
|
@@ -303,7 +310,8 @@ static int tipc_release(struct socket *sock)
|
|
|
if (sk == NULL)
|
|
if (sk == NULL)
|
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
|
|
- tport = tipc_sk_port(sk);
|
|
|
|
|
|
|
+ tsk = tipc_sk(sk);
|
|
|
|
|
+ port = &tsk->port;
|
|
|
lock_sock(sk);
|
|
lock_sock(sk);
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -320,17 +328,16 @@ static int tipc_release(struct socket *sock)
|
|
|
if ((sock->state == SS_CONNECTING) ||
|
|
if ((sock->state == SS_CONNECTING) ||
|
|
|
(sock->state == SS_CONNECTED)) {
|
|
(sock->state == SS_CONNECTED)) {
|
|
|
sock->state = SS_DISCONNECTING;
|
|
sock->state = SS_DISCONNECTING;
|
|
|
- tipc_port_disconnect(tport->ref);
|
|
|
|
|
|
|
+ tipc_port_disconnect(port->ref);
|
|
|
}
|
|
}
|
|
|
tipc_reject_msg(buf, TIPC_ERR_NO_PORT);
|
|
tipc_reject_msg(buf, TIPC_ERR_NO_PORT);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /*
|
|
|
|
|
- * Delete TIPC port; this ensures no more messages are queued
|
|
|
|
|
- * (also disconnects an active connection & sends a 'FIN-' to peer)
|
|
|
|
|
|
|
+ /* Destroy TIPC port; also disconnects an active connection and
|
|
|
|
|
+ * sends a 'FIN-' to peer.
|
|
|
*/
|
|
*/
|
|
|
- tipc_port_destroy(tport);
|
|
|
|
|
|
|
+ tipc_port_destroy(port);
|
|
|
|
|
|
|
|
/* Discard any remaining (connection-based) messages in receive queue */
|
|
/* Discard any remaining (connection-based) messages in receive queue */
|
|
|
__skb_queue_purge(&sk->sk_receive_queue);
|
|
__skb_queue_purge(&sk->sk_receive_queue);
|
|
@@ -365,12 +372,12 @@ static int tipc_bind(struct socket *sock, struct sockaddr *uaddr,
|
|
|
{
|
|
{
|
|
|
struct sock *sk = sock->sk;
|
|
struct sock *sk = sock->sk;
|
|
|
struct sockaddr_tipc *addr = (struct sockaddr_tipc *)uaddr;
|
|
struct sockaddr_tipc *addr = (struct sockaddr_tipc *)uaddr;
|
|
|
- struct tipc_port *tport = tipc_sk_port(sock->sk);
|
|
|
|
|
|
|
+ struct tipc_sock *tsk = tipc_sk(sk);
|
|
|
int res = -EINVAL;
|
|
int res = -EINVAL;
|
|
|
|
|
|
|
|
lock_sock(sk);
|
|
lock_sock(sk);
|
|
|
if (unlikely(!uaddr_len)) {
|
|
if (unlikely(!uaddr_len)) {
|
|
|
- res = tipc_withdraw(tport, 0, NULL);
|
|
|
|
|
|
|
+ res = tipc_withdraw(&tsk->port, 0, NULL);
|
|
|
goto exit;
|
|
goto exit;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -398,8 +405,8 @@ static int tipc_bind(struct socket *sock, struct sockaddr *uaddr,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
res = (addr->scope > 0) ?
|
|
res = (addr->scope > 0) ?
|
|
|
- tipc_publish(tport, addr->scope, &addr->addr.nameseq) :
|
|
|
|
|
- tipc_withdraw(tport, -addr->scope, &addr->addr.nameseq);
|
|
|
|
|
|
|
+ tipc_publish(&tsk->port, addr->scope, &addr->addr.nameseq) :
|
|
|
|
|
+ tipc_withdraw(&tsk->port, -addr->scope, &addr->addr.nameseq);
|
|
|
exit:
|
|
exit:
|
|
|
release_sock(sk);
|
|
release_sock(sk);
|
|
|
return res;
|
|
return res;
|
|
@@ -422,17 +429,17 @@ static int tipc_getname(struct socket *sock, struct sockaddr *uaddr,
|
|
|
int *uaddr_len, int peer)
|
|
int *uaddr_len, int peer)
|
|
|
{
|
|
{
|
|
|
struct sockaddr_tipc *addr = (struct sockaddr_tipc *)uaddr;
|
|
struct sockaddr_tipc *addr = (struct sockaddr_tipc *)uaddr;
|
|
|
- struct tipc_port *port = tipc_sk_port(sock->sk);
|
|
|
|
|
|
|
+ struct tipc_sock *tsk = tipc_sk(sock->sk);
|
|
|
|
|
|
|
|
memset(addr, 0, sizeof(*addr));
|
|
memset(addr, 0, sizeof(*addr));
|
|
|
if (peer) {
|
|
if (peer) {
|
|
|
if ((sock->state != SS_CONNECTED) &&
|
|
if ((sock->state != SS_CONNECTED) &&
|
|
|
((peer != 2) || (sock->state != SS_DISCONNECTING)))
|
|
((peer != 2) || (sock->state != SS_DISCONNECTING)))
|
|
|
return -ENOTCONN;
|
|
return -ENOTCONN;
|
|
|
- addr->addr.id.ref = tipc_port_peerport(port);
|
|
|
|
|
- addr->addr.id.node = tipc_port_peernode(port);
|
|
|
|
|
|
|
+ addr->addr.id.ref = tipc_port_peerport(&tsk->port);
|
|
|
|
|
+ addr->addr.id.node = tipc_port_peernode(&tsk->port);
|
|
|
} else {
|
|
} else {
|
|
|
- addr->addr.id.ref = port->ref;
|
|
|
|
|
|
|
+ addr->addr.id.ref = tsk->port.ref;
|
|
|
addr->addr.id.node = tipc_own_addr;
|
|
addr->addr.id.node = tipc_own_addr;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -489,18 +496,19 @@ static unsigned int tipc_poll(struct file *file, struct socket *sock,
|
|
|
poll_table *wait)
|
|
poll_table *wait)
|
|
|
{
|
|
{
|
|
|
struct sock *sk = sock->sk;
|
|
struct sock *sk = sock->sk;
|
|
|
|
|
+ struct tipc_sock *tsk = tipc_sk(sk);
|
|
|
u32 mask = 0;
|
|
u32 mask = 0;
|
|
|
|
|
|
|
|
sock_poll_wait(file, sk_sleep(sk), wait);
|
|
sock_poll_wait(file, sk_sleep(sk), wait);
|
|
|
|
|
|
|
|
switch ((int)sock->state) {
|
|
switch ((int)sock->state) {
|
|
|
case SS_UNCONNECTED:
|
|
case SS_UNCONNECTED:
|
|
|
- if (!tipc_sk_port(sk)->congested)
|
|
|
|
|
|
|
+ if (!tsk->port.congested)
|
|
|
mask |= POLLOUT;
|
|
mask |= POLLOUT;
|
|
|
break;
|
|
break;
|
|
|
case SS_READY:
|
|
case SS_READY:
|
|
|
case SS_CONNECTED:
|
|
case SS_CONNECTED:
|
|
|
- if (!tipc_sk_port(sk)->congested)
|
|
|
|
|
|
|
+ if (!tsk->port.congested)
|
|
|
mask |= POLLOUT;
|
|
mask |= POLLOUT;
|
|
|
/* fall thru' */
|
|
/* fall thru' */
|
|
|
case SS_CONNECTING:
|
|
case SS_CONNECTING:
|
|
@@ -550,7 +558,7 @@ static int dest_name_check(struct sockaddr_tipc *dest, struct msghdr *m)
|
|
|
static int tipc_wait_for_sndmsg(struct socket *sock, long *timeo_p)
|
|
static int tipc_wait_for_sndmsg(struct socket *sock, long *timeo_p)
|
|
|
{
|
|
{
|
|
|
struct sock *sk = sock->sk;
|
|
struct sock *sk = sock->sk;
|
|
|
- struct tipc_port *tport = tipc_sk_port(sk);
|
|
|
|
|
|
|
+ struct tipc_sock *tsk = tipc_sk(sk);
|
|
|
DEFINE_WAIT(wait);
|
|
DEFINE_WAIT(wait);
|
|
|
int done;
|
|
int done;
|
|
|
|
|
|
|
@@ -566,12 +574,13 @@ static int tipc_wait_for_sndmsg(struct socket *sock, long *timeo_p)
|
|
|
return sock_intr_errno(*timeo_p);
|
|
return sock_intr_errno(*timeo_p);
|
|
|
|
|
|
|
|
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
|
|
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
|
|
|
- done = sk_wait_event(sk, timeo_p, !tport->congested);
|
|
|
|
|
|
|
+ done = sk_wait_event(sk, timeo_p, !tsk->port.congested);
|
|
|
finish_wait(sk_sleep(sk), &wait);
|
|
finish_wait(sk_sleep(sk), &wait);
|
|
|
} while (!done);
|
|
} while (!done);
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* tipc_sendmsg - send message in connectionless manner
|
|
* tipc_sendmsg - send message in connectionless manner
|
|
|
* @iocb: if NULL, indicates that socket lock is already held
|
|
* @iocb: if NULL, indicates that socket lock is already held
|
|
@@ -590,10 +599,11 @@ static int tipc_sendmsg(struct kiocb *iocb, struct socket *sock,
|
|
|
struct msghdr *m, size_t total_len)
|
|
struct msghdr *m, size_t total_len)
|
|
|
{
|
|
{
|
|
|
struct sock *sk = sock->sk;
|
|
struct sock *sk = sock->sk;
|
|
|
- struct tipc_port *tport = tipc_sk_port(sk);
|
|
|
|
|
|
|
+ struct tipc_sock *tsk = tipc_sk(sk);
|
|
|
DECLARE_SOCKADDR(struct sockaddr_tipc *, dest, m->msg_name);
|
|
DECLARE_SOCKADDR(struct sockaddr_tipc *, dest, m->msg_name);
|
|
|
int needs_conn;
|
|
int needs_conn;
|
|
|
long timeo;
|
|
long timeo;
|
|
|
|
|
+ u32 ref = tsk->port.ref;
|
|
|
int res = -EINVAL;
|
|
int res = -EINVAL;
|
|
|
|
|
|
|
|
if (unlikely(!dest))
|
|
if (unlikely(!dest))
|
|
@@ -617,13 +627,13 @@ static int tipc_sendmsg(struct kiocb *iocb, struct socket *sock,
|
|
|
res = -EISCONN;
|
|
res = -EISCONN;
|
|
|
goto exit;
|
|
goto exit;
|
|
|
}
|
|
}
|
|
|
- if (tport->published) {
|
|
|
|
|
|
|
+ if (tsk->port.published) {
|
|
|
res = -EOPNOTSUPP;
|
|
res = -EOPNOTSUPP;
|
|
|
goto exit;
|
|
goto exit;
|
|
|
}
|
|
}
|
|
|
if (dest->addrtype == TIPC_ADDR_NAME) {
|
|
if (dest->addrtype == TIPC_ADDR_NAME) {
|
|
|
- tport->conn_type = dest->addr.name.name.type;
|
|
|
|
|
- tport->conn_instance = dest->addr.name.name.instance;
|
|
|
|
|
|
|
+ tsk->port.conn_type = dest->addr.name.name.type;
|
|
|
|
|
+ tsk->port.conn_instance = dest->addr.name.name.instance;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* Abort any pending connection attempts (very unlikely) */
|
|
/* Abort any pending connection attempts (very unlikely) */
|
|
@@ -636,13 +646,13 @@ static int tipc_sendmsg(struct kiocb *iocb, struct socket *sock,
|
|
|
res = dest_name_check(dest, m);
|
|
res = dest_name_check(dest, m);
|
|
|
if (res)
|
|
if (res)
|
|
|
break;
|
|
break;
|
|
|
- res = tipc_send2name(tport->ref,
|
|
|
|
|
|
|
+ res = tipc_send2name(ref,
|
|
|
&dest->addr.name.name,
|
|
&dest->addr.name.name,
|
|
|
dest->addr.name.domain,
|
|
dest->addr.name.domain,
|
|
|
m->msg_iov,
|
|
m->msg_iov,
|
|
|
total_len);
|
|
total_len);
|
|
|
} else if (dest->addrtype == TIPC_ADDR_ID) {
|
|
} else if (dest->addrtype == TIPC_ADDR_ID) {
|
|
|
- res = tipc_send2port(tport->ref,
|
|
|
|
|
|
|
+ res = tipc_send2port(ref,
|
|
|
&dest->addr.id,
|
|
&dest->addr.id,
|
|
|
m->msg_iov,
|
|
m->msg_iov,
|
|
|
total_len);
|
|
total_len);
|
|
@@ -654,7 +664,7 @@ static int tipc_sendmsg(struct kiocb *iocb, struct socket *sock,
|
|
|
res = dest_name_check(dest, m);
|
|
res = dest_name_check(dest, m);
|
|
|
if (res)
|
|
if (res)
|
|
|
break;
|
|
break;
|
|
|
- res = tipc_port_mcast_xmit(tport->ref,
|
|
|
|
|
|
|
+ res = tipc_port_mcast_xmit(ref,
|
|
|
&dest->addr.nameseq,
|
|
&dest->addr.nameseq,
|
|
|
m->msg_iov,
|
|
m->msg_iov,
|
|
|
total_len);
|
|
total_len);
|
|
@@ -678,7 +688,8 @@ exit:
|
|
|
static int tipc_wait_for_sndpkt(struct socket *sock, long *timeo_p)
|
|
static int tipc_wait_for_sndpkt(struct socket *sock, long *timeo_p)
|
|
|
{
|
|
{
|
|
|
struct sock *sk = sock->sk;
|
|
struct sock *sk = sock->sk;
|
|
|
- struct tipc_port *tport = tipc_sk_port(sk);
|
|
|
|
|
|
|
+ struct tipc_sock *tsk = tipc_sk(sk);
|
|
|
|
|
+ struct tipc_port *port = &tsk->port;
|
|
|
DEFINE_WAIT(wait);
|
|
DEFINE_WAIT(wait);
|
|
|
int done;
|
|
int done;
|
|
|
|
|
|
|
@@ -697,7 +708,7 @@ static int tipc_wait_for_sndpkt(struct socket *sock, long *timeo_p)
|
|
|
|
|
|
|
|
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
|
|
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
|
|
|
done = sk_wait_event(sk, timeo_p,
|
|
done = sk_wait_event(sk, timeo_p,
|
|
|
- (!tport->congested || !tport->connected));
|
|
|
|
|
|
|
+ (!port->congested || !port->connected));
|
|
|
finish_wait(sk_sleep(sk), &wait);
|
|
finish_wait(sk_sleep(sk), &wait);
|
|
|
} while (!done);
|
|
} while (!done);
|
|
|
return 0;
|
|
return 0;
|
|
@@ -718,7 +729,7 @@ static int tipc_send_packet(struct kiocb *iocb, struct socket *sock,
|
|
|
struct msghdr *m, size_t total_len)
|
|
struct msghdr *m, size_t total_len)
|
|
|
{
|
|
{
|
|
|
struct sock *sk = sock->sk;
|
|
struct sock *sk = sock->sk;
|
|
|
- struct tipc_port *tport = tipc_sk_port(sk);
|
|
|
|
|
|
|
+ struct tipc_sock *tsk = tipc_sk(sk);
|
|
|
DECLARE_SOCKADDR(struct sockaddr_tipc *, dest, m->msg_name);
|
|
DECLARE_SOCKADDR(struct sockaddr_tipc *, dest, m->msg_name);
|
|
|
int res = -EINVAL;
|
|
int res = -EINVAL;
|
|
|
long timeo;
|
|
long timeo;
|
|
@@ -743,7 +754,7 @@ static int tipc_send_packet(struct kiocb *iocb, struct socket *sock,
|
|
|
|
|
|
|
|
timeo = sock_sndtimeo(sk, m->msg_flags & MSG_DONTWAIT);
|
|
timeo = sock_sndtimeo(sk, m->msg_flags & MSG_DONTWAIT);
|
|
|
do {
|
|
do {
|
|
|
- res = tipc_send(tport->ref, m->msg_iov, total_len);
|
|
|
|
|
|
|
+ res = tipc_send(tsk->port.ref, m->msg_iov, total_len);
|
|
|
if (likely(res != -ELINKCONG))
|
|
if (likely(res != -ELINKCONG))
|
|
|
break;
|
|
break;
|
|
|
res = tipc_wait_for_sndpkt(sock, &timeo);
|
|
res = tipc_wait_for_sndpkt(sock, &timeo);
|
|
@@ -772,7 +783,7 @@ static int tipc_send_stream(struct kiocb *iocb, struct socket *sock,
|
|
|
struct msghdr *m, size_t total_len)
|
|
struct msghdr *m, size_t total_len)
|
|
|
{
|
|
{
|
|
|
struct sock *sk = sock->sk;
|
|
struct sock *sk = sock->sk;
|
|
|
- struct tipc_port *tport = tipc_sk_port(sk);
|
|
|
|
|
|
|
+ struct tipc_sock *tsk = tipc_sk(sk);
|
|
|
struct msghdr my_msg;
|
|
struct msghdr my_msg;
|
|
|
struct iovec my_iov;
|
|
struct iovec my_iov;
|
|
|
struct iovec *curr_iov;
|
|
struct iovec *curr_iov;
|
|
@@ -820,14 +831,14 @@ static int tipc_send_stream(struct kiocb *iocb, struct socket *sock,
|
|
|
my_msg.msg_name = NULL;
|
|
my_msg.msg_name = NULL;
|
|
|
bytes_sent = 0;
|
|
bytes_sent = 0;
|
|
|
|
|
|
|
|
- hdr_size = msg_hdr_sz(&tport->phdr);
|
|
|
|
|
|
|
+ hdr_size = msg_hdr_sz(&tsk->port.phdr);
|
|
|
|
|
|
|
|
while (curr_iovlen--) {
|
|
while (curr_iovlen--) {
|
|
|
curr_start = curr_iov->iov_base;
|
|
curr_start = curr_iov->iov_base;
|
|
|
curr_left = curr_iov->iov_len;
|
|
curr_left = curr_iov->iov_len;
|
|
|
|
|
|
|
|
while (curr_left) {
|
|
while (curr_left) {
|
|
|
- bytes_to_send = tport->max_pkt - hdr_size;
|
|
|
|
|
|
|
+ bytes_to_send = tsk->port.max_pkt - hdr_size;
|
|
|
if (bytes_to_send > TIPC_MAX_USER_MSG_SIZE)
|
|
if (bytes_to_send > TIPC_MAX_USER_MSG_SIZE)
|
|
|
bytes_to_send = TIPC_MAX_USER_MSG_SIZE;
|
|
bytes_to_send = TIPC_MAX_USER_MSG_SIZE;
|
|
|
if (curr_left < bytes_to_send)
|
|
if (curr_left < bytes_to_send)
|
|
@@ -856,28 +867,29 @@ exit:
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* auto_connect - complete connection setup to a remote port
|
|
* auto_connect - complete connection setup to a remote port
|
|
|
- * @sock: socket structure
|
|
|
|
|
|
|
+ * @tsk: tipc socket structure
|
|
|
* @msg: peer's response message
|
|
* @msg: peer's response message
|
|
|
*
|
|
*
|
|
|
* Returns 0 on success, errno otherwise
|
|
* Returns 0 on success, errno otherwise
|
|
|
*/
|
|
*/
|
|
|
-static int auto_connect(struct socket *sock, struct tipc_msg *msg)
|
|
|
|
|
|
|
+static int auto_connect(struct tipc_sock *tsk, struct tipc_msg *msg)
|
|
|
{
|
|
{
|
|
|
- struct tipc_port *p_ptr = tipc_sk_port(sock->sk);
|
|
|
|
|
|
|
+ struct tipc_port *port = &tsk->port;
|
|
|
|
|
+ struct socket *sock = tsk->sk.sk_socket;
|
|
|
struct tipc_portid peer;
|
|
struct tipc_portid peer;
|
|
|
|
|
|
|
|
peer.ref = msg_origport(msg);
|
|
peer.ref = msg_origport(msg);
|
|
|
peer.node = msg_orignode(msg);
|
|
peer.node = msg_orignode(msg);
|
|
|
|
|
|
|
|
- p_ptr = tipc_port_deref(p_ptr->ref);
|
|
|
|
|
- if (!p_ptr)
|
|
|
|
|
|
|
+ port = tipc_port_deref(port->ref);
|
|
|
|
|
+ if (!port)
|
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
- __tipc_port_connect(p_ptr->ref, p_ptr, &peer);
|
|
|
|
|
|
|
+ __tipc_port_connect(port->ref, port, &peer);
|
|
|
|
|
|
|
|
if (msg_importance(msg) > TIPC_CRITICAL_IMPORTANCE)
|
|
if (msg_importance(msg) > TIPC_CRITICAL_IMPORTANCE)
|
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
- msg_set_importance(&p_ptr->phdr, (u32)msg_importance(msg));
|
|
|
|
|
|
|
+ msg_set_importance(&port->phdr, (u32)msg_importance(msg));
|
|
|
sock->state = SS_CONNECTED;
|
|
sock->state = SS_CONNECTED;
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
@@ -1023,7 +1035,8 @@ static int tipc_recvmsg(struct kiocb *iocb, struct socket *sock,
|
|
|
struct msghdr *m, size_t buf_len, int flags)
|
|
struct msghdr *m, size_t buf_len, int flags)
|
|
|
{
|
|
{
|
|
|
struct sock *sk = sock->sk;
|
|
struct sock *sk = sock->sk;
|
|
|
- struct tipc_port *tport = tipc_sk_port(sk);
|
|
|
|
|
|
|
+ struct tipc_sock *tsk = tipc_sk(sk);
|
|
|
|
|
+ struct tipc_port *port = &tsk->port;
|
|
|
struct sk_buff *buf;
|
|
struct sk_buff *buf;
|
|
|
struct tipc_msg *msg;
|
|
struct tipc_msg *msg;
|
|
|
long timeo;
|
|
long timeo;
|
|
@@ -1066,7 +1079,7 @@ restart:
|
|
|
set_orig_addr(m, msg);
|
|
set_orig_addr(m, msg);
|
|
|
|
|
|
|
|
/* Capture ancillary data (optional) */
|
|
/* Capture ancillary data (optional) */
|
|
|
- res = anc_data_recv(m, msg, tport);
|
|
|
|
|
|
|
+ res = anc_data_recv(m, msg, port);
|
|
|
if (res)
|
|
if (res)
|
|
|
goto exit;
|
|
goto exit;
|
|
|
|
|
|
|
@@ -1092,8 +1105,8 @@ restart:
|
|
|
/* Consume received message (optional) */
|
|
/* Consume received message (optional) */
|
|
|
if (likely(!(flags & MSG_PEEK))) {
|
|
if (likely(!(flags & MSG_PEEK))) {
|
|
|
if ((sock->state != SS_READY) &&
|
|
if ((sock->state != SS_READY) &&
|
|
|
- (++tport->conn_unacked >= TIPC_FLOW_CONTROL_WIN))
|
|
|
|
|
- tipc_acknowledge(tport->ref, tport->conn_unacked);
|
|
|
|
|
|
|
+ (++port->conn_unacked >= TIPC_FLOW_CONTROL_WIN))
|
|
|
|
|
+ tipc_acknowledge(port->ref, port->conn_unacked);
|
|
|
advance_rx_queue(sk);
|
|
advance_rx_queue(sk);
|
|
|
}
|
|
}
|
|
|
exit:
|
|
exit:
|
|
@@ -1117,7 +1130,8 @@ static int tipc_recv_stream(struct kiocb *iocb, struct socket *sock,
|
|
|
struct msghdr *m, size_t buf_len, int flags)
|
|
struct msghdr *m, size_t buf_len, int flags)
|
|
|
{
|
|
{
|
|
|
struct sock *sk = sock->sk;
|
|
struct sock *sk = sock->sk;
|
|
|
- struct tipc_port *tport = tipc_sk_port(sk);
|
|
|
|
|
|
|
+ struct tipc_sock *tsk = tipc_sk(sk);
|
|
|
|
|
+ struct tipc_port *port = &tsk->port;
|
|
|
struct sk_buff *buf;
|
|
struct sk_buff *buf;
|
|
|
struct tipc_msg *msg;
|
|
struct tipc_msg *msg;
|
|
|
long timeo;
|
|
long timeo;
|
|
@@ -1162,7 +1176,7 @@ restart:
|
|
|
/* Optionally capture sender's address & ancillary data of first msg */
|
|
/* Optionally capture sender's address & ancillary data of first msg */
|
|
|
if (sz_copied == 0) {
|
|
if (sz_copied == 0) {
|
|
|
set_orig_addr(m, msg);
|
|
set_orig_addr(m, msg);
|
|
|
- res = anc_data_recv(m, msg, tport);
|
|
|
|
|
|
|
+ res = anc_data_recv(m, msg, port);
|
|
|
if (res)
|
|
if (res)
|
|
|
goto exit;
|
|
goto exit;
|
|
|
}
|
|
}
|
|
@@ -1200,8 +1214,8 @@ restart:
|
|
|
|
|
|
|
|
/* Consume received message (optional) */
|
|
/* Consume received message (optional) */
|
|
|
if (likely(!(flags & MSG_PEEK))) {
|
|
if (likely(!(flags & MSG_PEEK))) {
|
|
|
- if (unlikely(++tport->conn_unacked >= TIPC_FLOW_CONTROL_WIN))
|
|
|
|
|
- tipc_acknowledge(tport->ref, tport->conn_unacked);
|
|
|
|
|
|
|
+ if (unlikely(++port->conn_unacked >= TIPC_FLOW_CONTROL_WIN))
|
|
|
|
|
+ tipc_acknowledge(port->ref, port->conn_unacked);
|
|
|
advance_rx_queue(sk);
|
|
advance_rx_queue(sk);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1253,15 +1267,16 @@ static void tipc_data_ready(struct sock *sk, int len)
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* filter_connect - Handle all incoming messages for a connection-based socket
|
|
* filter_connect - Handle all incoming messages for a connection-based socket
|
|
|
- * @port: TIPC port
|
|
|
|
|
|
|
+ * @tsk: TIPC socket
|
|
|
* @msg: message
|
|
* @msg: message
|
|
|
*
|
|
*
|
|
|
* Returns TIPC error status code and socket error status code
|
|
* Returns TIPC error status code and socket error status code
|
|
|
* once it encounters some errors
|
|
* once it encounters some errors
|
|
|
*/
|
|
*/
|
|
|
-static u32 filter_connect(struct tipc_port *port, struct sk_buff **buf)
|
|
|
|
|
|
|
+static u32 filter_connect(struct tipc_sock *tsk, struct sk_buff **buf)
|
|
|
{
|
|
{
|
|
|
- struct sock *sk = tipc_port_to_sk(port);
|
|
|
|
|
|
|
+ struct sock *sk = &tsk->sk;
|
|
|
|
|
+ struct tipc_port *port = &tsk->port;
|
|
|
struct socket *sock = sk->sk_socket;
|
|
struct socket *sock = sk->sk_socket;
|
|
|
struct tipc_msg *msg = buf_msg(*buf);
|
|
struct tipc_msg *msg = buf_msg(*buf);
|
|
|
|
|
|
|
@@ -1294,7 +1309,7 @@ static u32 filter_connect(struct tipc_port *port, struct sk_buff **buf)
|
|
|
if (unlikely(!msg_connected(msg)))
|
|
if (unlikely(!msg_connected(msg)))
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
- res = auto_connect(sock, msg);
|
|
|
|
|
|
|
+ res = auto_connect(tsk, msg);
|
|
|
if (res) {
|
|
if (res) {
|
|
|
sock->state = SS_DISCONNECTING;
|
|
sock->state = SS_DISCONNECTING;
|
|
|
sk->sk_err = -res;
|
|
sk->sk_err = -res;
|
|
@@ -1373,6 +1388,7 @@ static unsigned int rcvbuf_limit(struct sock *sk, struct sk_buff *buf)
|
|
|
static u32 filter_rcv(struct sock *sk, struct sk_buff *buf)
|
|
static u32 filter_rcv(struct sock *sk, struct sk_buff *buf)
|
|
|
{
|
|
{
|
|
|
struct socket *sock = sk->sk_socket;
|
|
struct socket *sock = sk->sk_socket;
|
|
|
|
|
+ struct tipc_sock *tsk = tipc_sk(sk);
|
|
|
struct tipc_msg *msg = buf_msg(buf);
|
|
struct tipc_msg *msg = buf_msg(buf);
|
|
|
unsigned int limit = rcvbuf_limit(sk, buf);
|
|
unsigned int limit = rcvbuf_limit(sk, buf);
|
|
|
u32 res = TIPC_OK;
|
|
u32 res = TIPC_OK;
|
|
@@ -1385,7 +1401,7 @@ static u32 filter_rcv(struct sock *sk, struct sk_buff *buf)
|
|
|
if (msg_connected(msg))
|
|
if (msg_connected(msg))
|
|
|
return TIPC_ERR_NO_PORT;
|
|
return TIPC_ERR_NO_PORT;
|
|
|
} else {
|
|
} else {
|
|
|
- res = filter_connect(tipc_sk_port(sk), &buf);
|
|
|
|
|
|
|
+ res = filter_connect(tsk, &buf);
|
|
|
if (res != TIPC_OK || buf == NULL)
|
|
if (res != TIPC_OK || buf == NULL)
|
|
|
return res;
|
|
return res;
|
|
|
}
|
|
}
|
|
@@ -1656,7 +1672,7 @@ static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags)
|
|
|
goto exit;
|
|
goto exit;
|
|
|
|
|
|
|
|
new_sk = new_sock->sk;
|
|
new_sk = new_sock->sk;
|
|
|
- new_port = tipc_sk_port(new_sk);
|
|
|
|
|
|
|
+ new_port = &tipc_sk(new_sk)->port;
|
|
|
new_ref = new_port->ref;
|
|
new_ref = new_port->ref;
|
|
|
msg = buf_msg(buf);
|
|
msg = buf_msg(buf);
|
|
|
|
|
|
|
@@ -1713,7 +1729,8 @@ exit:
|
|
|
static int tipc_shutdown(struct socket *sock, int how)
|
|
static int tipc_shutdown(struct socket *sock, int how)
|
|
|
{
|
|
{
|
|
|
struct sock *sk = sock->sk;
|
|
struct sock *sk = sock->sk;
|
|
|
- struct tipc_port *tport = tipc_sk_port(sk);
|
|
|
|
|
|
|
+ struct tipc_sock *tsk = tipc_sk(sk);
|
|
|
|
|
+ struct tipc_port *port = &tsk->port;
|
|
|
struct sk_buff *buf;
|
|
struct sk_buff *buf;
|
|
|
int res;
|
|
int res;
|
|
|
|
|
|
|
@@ -1734,10 +1751,10 @@ restart:
|
|
|
kfree_skb(buf);
|
|
kfree_skb(buf);
|
|
|
goto restart;
|
|
goto restart;
|
|
|
}
|
|
}
|
|
|
- tipc_port_disconnect(tport->ref);
|
|
|
|
|
|
|
+ tipc_port_disconnect(port->ref);
|
|
|
tipc_reject_msg(buf, TIPC_CONN_SHUTDOWN);
|
|
tipc_reject_msg(buf, TIPC_CONN_SHUTDOWN);
|
|
|
} else {
|
|
} else {
|
|
|
- tipc_port_shutdown(tport->ref);
|
|
|
|
|
|
|
+ tipc_port_shutdown(port->ref);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
sock->state = SS_DISCONNECTING;
|
|
sock->state = SS_DISCONNECTING;
|
|
@@ -1779,7 +1796,8 @@ static int tipc_setsockopt(struct socket *sock, int lvl, int opt,
|
|
|
char __user *ov, unsigned int ol)
|
|
char __user *ov, unsigned int ol)
|
|
|
{
|
|
{
|
|
|
struct sock *sk = sock->sk;
|
|
struct sock *sk = sock->sk;
|
|
|
- struct tipc_port *tport = tipc_sk_port(sk);
|
|
|
|
|
|
|
+ struct tipc_sock *tsk = tipc_sk(sk);
|
|
|
|
|
+ struct tipc_port *port = &tsk->port;
|
|
|
u32 value;
|
|
u32 value;
|
|
|
int res;
|
|
int res;
|
|
|
|
|
|
|
@@ -1797,16 +1815,16 @@ static int tipc_setsockopt(struct socket *sock, int lvl, int opt,
|
|
|
|
|
|
|
|
switch (opt) {
|
|
switch (opt) {
|
|
|
case TIPC_IMPORTANCE:
|
|
case TIPC_IMPORTANCE:
|
|
|
- tipc_port_set_importance(tport, value);
|
|
|
|
|
|
|
+ tipc_port_set_importance(port, value);
|
|
|
break;
|
|
break;
|
|
|
case TIPC_SRC_DROPPABLE:
|
|
case TIPC_SRC_DROPPABLE:
|
|
|
if (sock->type != SOCK_STREAM)
|
|
if (sock->type != SOCK_STREAM)
|
|
|
- tipc_port_set_unreliable(tport, value);
|
|
|
|
|
|
|
+ tipc_port_set_unreliable(port, value);
|
|
|
else
|
|
else
|
|
|
res = -ENOPROTOOPT;
|
|
res = -ENOPROTOOPT;
|
|
|
break;
|
|
break;
|
|
|
case TIPC_DEST_DROPPABLE:
|
|
case TIPC_DEST_DROPPABLE:
|
|
|
- tipc_port_set_unreturnable(tport, value);
|
|
|
|
|
|
|
+ tipc_port_set_unreturnable(port, value);
|
|
|
break;
|
|
break;
|
|
|
case TIPC_CONN_TIMEOUT:
|
|
case TIPC_CONN_TIMEOUT:
|
|
|
tipc_sk(sk)->conn_timeout = value;
|
|
tipc_sk(sk)->conn_timeout = value;
|
|
@@ -1838,7 +1856,8 @@ static int tipc_getsockopt(struct socket *sock, int lvl, int opt,
|
|
|
char __user *ov, int __user *ol)
|
|
char __user *ov, int __user *ol)
|
|
|
{
|
|
{
|
|
|
struct sock *sk = sock->sk;
|
|
struct sock *sk = sock->sk;
|
|
|
- struct tipc_port *tport = tipc_sk_port(sk);
|
|
|
|
|
|
|
+ struct tipc_sock *tsk = tipc_sk(sk);
|
|
|
|
|
+ struct tipc_port *port = &tsk->port;
|
|
|
int len;
|
|
int len;
|
|
|
u32 value;
|
|
u32 value;
|
|
|
int res;
|
|
int res;
|
|
@@ -1855,13 +1874,13 @@ static int tipc_getsockopt(struct socket *sock, int lvl, int opt,
|
|
|
|
|
|
|
|
switch (opt) {
|
|
switch (opt) {
|
|
|
case TIPC_IMPORTANCE:
|
|
case TIPC_IMPORTANCE:
|
|
|
- value = tipc_port_importance(tport);
|
|
|
|
|
|
|
+ value = tipc_port_importance(port);
|
|
|
break;
|
|
break;
|
|
|
case TIPC_SRC_DROPPABLE:
|
|
case TIPC_SRC_DROPPABLE:
|
|
|
- value = tipc_port_unreliable(tport);
|
|
|
|
|
|
|
+ value = tipc_port_unreliable(port);
|
|
|
break;
|
|
break;
|
|
|
case TIPC_DEST_DROPPABLE:
|
|
case TIPC_DEST_DROPPABLE:
|
|
|
- value = tipc_port_unreturnable(tport);
|
|
|
|
|
|
|
+ value = tipc_port_unreturnable(port);
|
|
|
break;
|
|
break;
|
|
|
case TIPC_CONN_TIMEOUT:
|
|
case TIPC_CONN_TIMEOUT:
|
|
|
value = tipc_sk(sk)->conn_timeout;
|
|
value = tipc_sk(sk)->conn_timeout;
|