diff options
author | Jon Paul Maloy <jon.maloy@ericsson.com> | 2014-03-12 11:31:13 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-03-12 15:53:49 -0400 |
commit | 5c311421a28051036a114aec972d36c72114ed4c (patch) | |
tree | b8210cd9a14a3fc205ca254d33de80bf185f2a0c /net/tipc/socket.c | |
parent | 58ed944241794087df1edadfa66795c966bf1604 (diff) |
tipc: eliminate redundant lookups in registry
As an artefact from the native interface, the message sending functions
in the port takes a port ref as first parameter, and then looks up in
the registry to find the corresponding port pointer. This despite the
fact that the only currently existing caller, tipc_sock, already knows
this pointer.
We change the signature of these functions to take a struct tipc_port*
argument, and remove the redundant lookups.
We also remove an unmotivated extra lookup in the function
socket.c:auto_connect(), and, as the lookup functions tipc_port_deref()
and ref_deref() now become unused, we remove these two functions.
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/socket.c')
-rw-r--r-- | net/tipc/socket.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index 9cea92ee6c82..2a89bdb331b5 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
@@ -600,10 +600,10 @@ static int tipc_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
600 | { | 600 | { |
601 | struct sock *sk = sock->sk; | 601 | struct sock *sk = sock->sk; |
602 | struct tipc_sock *tsk = tipc_sk(sk); | 602 | struct tipc_sock *tsk = tipc_sk(sk); |
603 | struct tipc_port *port = &tsk->port; | ||
603 | DECLARE_SOCKADDR(struct sockaddr_tipc *, dest, m->msg_name); | 604 | DECLARE_SOCKADDR(struct sockaddr_tipc *, dest, m->msg_name); |
604 | int needs_conn; | 605 | int needs_conn; |
605 | long timeo; | 606 | long timeo; |
606 | u32 ref = tsk->port.ref; | ||
607 | int res = -EINVAL; | 607 | int res = -EINVAL; |
608 | 608 | ||
609 | if (unlikely(!dest)) | 609 | if (unlikely(!dest)) |
@@ -646,13 +646,13 @@ static int tipc_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
646 | res = dest_name_check(dest, m); | 646 | res = dest_name_check(dest, m); |
647 | if (res) | 647 | if (res) |
648 | break; | 648 | break; |
649 | res = tipc_send2name(ref, | 649 | res = tipc_send2name(port, |
650 | &dest->addr.name.name, | 650 | &dest->addr.name.name, |
651 | dest->addr.name.domain, | 651 | dest->addr.name.domain, |
652 | m->msg_iov, | 652 | m->msg_iov, |
653 | total_len); | 653 | total_len); |
654 | } else if (dest->addrtype == TIPC_ADDR_ID) { | 654 | } else if (dest->addrtype == TIPC_ADDR_ID) { |
655 | res = tipc_send2port(ref, | 655 | res = tipc_send2port(port, |
656 | &dest->addr.id, | 656 | &dest->addr.id, |
657 | m->msg_iov, | 657 | m->msg_iov, |
658 | total_len); | 658 | total_len); |
@@ -664,7 +664,7 @@ static int tipc_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
664 | res = dest_name_check(dest, m); | 664 | res = dest_name_check(dest, m); |
665 | if (res) | 665 | if (res) |
666 | break; | 666 | break; |
667 | res = tipc_port_mcast_xmit(ref, | 667 | res = tipc_port_mcast_xmit(port, |
668 | &dest->addr.nameseq, | 668 | &dest->addr.nameseq, |
669 | m->msg_iov, | 669 | m->msg_iov, |
670 | total_len); | 670 | total_len); |
@@ -754,7 +754,7 @@ static int tipc_send_packet(struct kiocb *iocb, struct socket *sock, | |||
754 | 754 | ||
755 | timeo = sock_sndtimeo(sk, m->msg_flags & MSG_DONTWAIT); | 755 | timeo = sock_sndtimeo(sk, m->msg_flags & MSG_DONTWAIT); |
756 | do { | 756 | do { |
757 | res = tipc_send(tsk->port.ref, m->msg_iov, total_len); | 757 | res = tipc_send(&tsk->port, m->msg_iov, total_len); |
758 | if (likely(res != -ELINKCONG)) | 758 | if (likely(res != -ELINKCONG)) |
759 | break; | 759 | break; |
760 | res = tipc_wait_for_sndpkt(sock, &timeo); | 760 | res = tipc_wait_for_sndpkt(sock, &timeo); |
@@ -881,10 +881,6 @@ static int auto_connect(struct tipc_sock *tsk, struct tipc_msg *msg) | |||
881 | peer.ref = msg_origport(msg); | 881 | peer.ref = msg_origport(msg); |
882 | peer.node = msg_orignode(msg); | 882 | peer.node = msg_orignode(msg); |
883 | 883 | ||
884 | port = tipc_port_deref(port->ref); | ||
885 | if (!port) | ||
886 | return -EINVAL; | ||
887 | |||
888 | __tipc_port_connect(port->ref, port, &peer); | 884 | __tipc_port_connect(port->ref, port, &peer); |
889 | 885 | ||
890 | if (msg_importance(msg) > TIPC_CRITICAL_IMPORTANCE) | 886 | if (msg_importance(msg) > TIPC_CRITICAL_IMPORTANCE) |