From 24be34b5a0c9114541891d29dff1152bb1a8df34 Mon Sep 17 00:00:00 2001 From: Jon Paul Maloy Date: Wed, 12 Mar 2014 11:31:10 -0400 Subject: tipc: eliminate upcall function pointers between port and socket MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Due to the original one-to-many relation between port and user API layers, upcalls to the API have been performed via function pointers, installed in struct tipc_port at creation. Since this relation now always is one-to-one, we can instead use ordinary function calls. We remove the function pointers 'dispatcher' and ´wakeup' from struct tipc_port, and replace them with calls to the renamed functions tipc_sk_rcv() and tipc_sk_wakeup(). At the same time we change the name and signature of the functions tipc_createport() and tipc_deleteport() to reflect their new role as mere initialization/destruction functions. Signed-off-by: Jon Maloy Reviewed-by: Ying Xue Reviewed-by: Erik Hugne Signed-off-by: David S. Miller --- net/tipc/socket.c | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) (limited to 'net/tipc/socket.c') diff --git a/net/tipc/socket.c b/net/tipc/socket.c index 912665d409de..d147eaaa6d58 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c @@ -44,10 +44,7 @@ #define CONN_TIMEOUT_DEFAULT 8000 /* default connect timeout = 8s */ - static int backlog_rcv(struct sock *sk, struct sk_buff *skb); -static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf); -static void wakeupdispatch(struct tipc_port *tport); static void tipc_data_ready(struct sock *sk, int len); static void tipc_write_space(struct sock *sk); static int tipc_release(struct socket *sock); @@ -181,10 +178,8 @@ static int tipc_sk_create(struct net *net, struct socket *sock, int protocol, if (sk == NULL) return -ENOMEM; - /* Allocate TIPC port for socket to use */ - tp_ptr = tipc_createport(sk, &dispatch, &wakeupdispatch, - TIPC_LOW_IMPORTANCE); - if (unlikely(!tp_ptr)) { + tp_ptr = tipc_sk_port(sk); + if (!tipc_port_init(tp_ptr, TIPC_LOW_IMPORTANCE)) { sk_free(sk); return -ENOMEM; } @@ -199,7 +194,6 @@ static int tipc_sk_create(struct net *net, struct socket *sock, int protocol, sk->sk_data_ready = tipc_data_ready; sk->sk_write_space = tipc_write_space; tipc_sk(sk)->conn_timeout = CONN_TIMEOUT_DEFAULT; - spin_unlock_bh(tp_ptr->lock); if (sock->state == SS_READY) { @@ -207,7 +201,6 @@ static int tipc_sk_create(struct net *net, struct socket *sock, int protocol, if (sock->type == SOCK_DGRAM) tipc_set_portunreliable(tp_ptr->ref, 1); } - return 0; } @@ -337,7 +330,7 @@ static int tipc_release(struct socket *sock) * Delete TIPC port; this ensures no more messages are queued * (also disconnects an active connection & sends a 'FIN-' to peer) */ - res = tipc_deleteport(tport); + tipc_port_destroy(tport); /* Discard any remaining (connection-based) messages in receive queue */ __skb_queue_purge(&sk->sk_receive_queue); @@ -1430,17 +1423,16 @@ static int backlog_rcv(struct sock *sk, struct sk_buff *buf) } /** - * dispatch - handle incoming message - * @tport: TIPC port that received message + * tipc_sk_rcv - handle incoming message + * @sk: socket receiving message * @buf: message * * Called with port lock already taken. * * Returns TIPC error status code (TIPC_OK if message is not to be rejected) */ -static u32 dispatch(struct tipc_port *port, struct sk_buff *buf) +u32 tipc_sk_rcv(struct sock *sk, struct sk_buff *buf) { - struct sock *sk = tipc_port_to_sk(port); u32 res; /* @@ -1463,18 +1455,6 @@ static u32 dispatch(struct tipc_port *port, struct sk_buff *buf) return res; } -/** - * wakeupdispatch - wake up port after congestion - * @tport: port to wakeup - * - * Called with port lock already taken. - */ -static void wakeupdispatch(struct tipc_port *port) -{ - struct sock *sk = tipc_port_to_sk(port); - sk->sk_write_space(sk); -} - static int tipc_wait_for_connect(struct socket *sock, long *timeo_p) { struct sock *sk = sock->sk; -- cgit v1.2.3