tipc: remove redundant 'peer_name' field in struct tipc_sock
The field 'peer_name' in struct tipc_sock is redundant, since
this information already is available from tipc_port, to which
tipc_sock has a reference.
We remove the field, and ensure that peer node and peer port
info instead is fetched via the functions that already exist
for this purpose.
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>
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 336e18d..6265577 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -48,7 +48,6 @@
struct tipc_sock {
struct sock sk;
struct tipc_port *p;
- struct tipc_portid peer_name;
unsigned int conn_timeout;
};
@@ -445,8 +444,9 @@
if ((sock->state != SS_CONNECTED) &&
((peer != 2) || (sock->state != SS_DISCONNECTING)))
return -ENOTCONN;
- addr->addr.id.ref = tsock->peer_name.ref;
- addr->addr.id.node = tsock->peer_name.node;
+
+ addr->addr.id.ref = tipc_port_peerport(tsock->p);
+ addr->addr.id.node = tipc_port_peernode(tsock->p);
} else {
addr->addr.id.ref = tsock->p->ref;
addr->addr.id.node = tipc_own_addr;
@@ -881,14 +881,16 @@
{
struct tipc_sock *tsock = tipc_sk(sock->sk);
struct tipc_port *p_ptr;
+ struct tipc_portid peer;
- tsock->peer_name.ref = msg_origport(msg);
- tsock->peer_name.node = msg_orignode(msg);
+ peer.ref = msg_origport(msg);
+ peer.node = msg_orignode(msg);
+
p_ptr = tipc_port_deref(tsock->p->ref);
if (!p_ptr)
return -EINVAL;
- __tipc_port_connect(tsock->p->ref, p_ptr, &tsock->peer_name);
+ __tipc_port_connect(p_ptr->ref, p_ptr, &peer);
if (msg_importance(msg) > TIPC_CRITICAL_IMPORTANCE)
return -EINVAL;
@@ -1662,6 +1664,7 @@
struct tipc_sock *new_tsock;
struct tipc_port *new_tport;
struct tipc_msg *msg;
+ struct tipc_portid peer;
u32 new_ref;
long timeo;
int res;
@@ -1700,9 +1703,9 @@
reject_rx_queue(new_sk);
/* Connect new socket to it's peer */
- new_tsock->peer_name.ref = msg_origport(msg);
- new_tsock->peer_name.node = msg_orignode(msg);
- tipc_port_connect(new_ref, &new_tsock->peer_name);
+ peer.ref = msg_origport(msg);
+ peer.node = msg_orignode(msg);
+ tipc_port_connect(new_ref, &peer);
new_sock->state = SS_CONNECTED;
tipc_set_portimportance(new_ref, msg_importance(msg));