Commit f9fef18c authored by Jon Paul Maloy's avatar Jon Paul Maloy Committed by David S. Miller

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: default avatarJon Maloy <jon.maloy@ericsson.com>
Reviewed-by: default avatarYing Xue <ying.xue@windriver.com>
Reviewed-by: default avatarErik Hugne <erik.hugne@ericsson.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 978813ee
...@@ -54,17 +54,6 @@ static struct sk_buff *port_build_self_abort_msg(struct tipc_port *, u32 err); ...@@ -54,17 +54,6 @@ static struct sk_buff *port_build_self_abort_msg(struct tipc_port *, u32 err);
static struct sk_buff *port_build_peer_abort_msg(struct tipc_port *, u32 err); static struct sk_buff *port_build_peer_abort_msg(struct tipc_port *, u32 err);
static void port_timeout(unsigned long ref); static void port_timeout(unsigned long ref);
static u32 port_peernode(struct tipc_port *p_ptr)
{
return msg_destnode(&p_ptr->phdr);
}
static u32 port_peerport(struct tipc_port *p_ptr)
{
return msg_destport(&p_ptr->phdr);
}
/** /**
* tipc_port_peer_msg - verify message was sent by connected port's peer * tipc_port_peer_msg - verify message was sent by connected port's peer
* *
...@@ -76,11 +65,11 @@ int tipc_port_peer_msg(struct tipc_port *p_ptr, struct tipc_msg *msg) ...@@ -76,11 +65,11 @@ int tipc_port_peer_msg(struct tipc_port *p_ptr, struct tipc_msg *msg)
u32 peernode; u32 peernode;
u32 orignode; u32 orignode;
if (msg_origport(msg) != port_peerport(p_ptr)) if (msg_origport(msg) != tipc_port_peerport(p_ptr))
return 0; return 0;
orignode = msg_orignode(msg); orignode = msg_orignode(msg);
peernode = port_peernode(p_ptr); peernode = tipc_port_peernode(p_ptr);
return (orignode == peernode) || return (orignode == peernode) ||
(!orignode && (peernode == tipc_own_addr)) || (!orignode && (peernode == tipc_own_addr)) ||
(!peernode && (orignode == tipc_own_addr)); (!peernode && (orignode == tipc_own_addr));
...@@ -351,8 +340,8 @@ static struct sk_buff *port_build_proto_msg(struct tipc_port *p_ptr, ...@@ -351,8 +340,8 @@ static struct sk_buff *port_build_proto_msg(struct tipc_port *p_ptr,
if (buf) { if (buf) {
msg = buf_msg(buf); msg = buf_msg(buf);
tipc_msg_init(msg, CONN_MANAGER, type, INT_H_SIZE, tipc_msg_init(msg, CONN_MANAGER, type, INT_H_SIZE,
port_peernode(p_ptr)); tipc_port_peernode(p_ptr));
msg_set_destport(msg, port_peerport(p_ptr)); msg_set_destport(msg, tipc_port_peerport(p_ptr));
msg_set_origport(msg, p_ptr->ref); msg_set_origport(msg, p_ptr->ref);
msg_set_msgcnt(msg, ack); msg_set_msgcnt(msg, ack);
} }
...@@ -585,8 +574,8 @@ static int port_print(struct tipc_port *p_ptr, char *buf, int len, int full_id) ...@@ -585,8 +574,8 @@ static int port_print(struct tipc_port *p_ptr, char *buf, int len, int full_id)
ret = tipc_snprintf(buf, len, "%-10u:", p_ptr->ref); ret = tipc_snprintf(buf, len, "%-10u:", p_ptr->ref);
if (p_ptr->connected) { if (p_ptr->connected) {
u32 dport = port_peerport(p_ptr); u32 dport = tipc_port_peerport(p_ptr);
u32 destnode = port_peernode(p_ptr); u32 destnode = tipc_port_peernode(p_ptr);
ret += tipc_snprintf(buf + ret, len - ret, ret += tipc_snprintf(buf + ret, len - ret,
" connected to <%u.%u.%u:%u>", " connected to <%u.%u.%u:%u>",
...@@ -926,7 +915,7 @@ int tipc_send(u32 ref, struct iovec const *msg_sect, unsigned int len) ...@@ -926,7 +915,7 @@ int tipc_send(u32 ref, struct iovec const *msg_sect, unsigned int len)
p_ptr->congested = 1; p_ptr->congested = 1;
if (!tipc_port_congested(p_ptr)) { if (!tipc_port_congested(p_ptr)) {
destnode = port_peernode(p_ptr); destnode = tipc_port_peernode(p_ptr);
if (likely(!in_own_node(destnode))) if (likely(!in_own_node(destnode)))
res = tipc_link_iovec_xmit_fast(p_ptr, msg_sect, len, res = tipc_link_iovec_xmit_fast(p_ptr, msg_sect, len,
destnode); destnode);
......
...@@ -198,4 +198,15 @@ static inline int tipc_port_congested(struct tipc_port *p_ptr) ...@@ -198,4 +198,15 @@ static inline int tipc_port_congested(struct tipc_port *p_ptr)
return (p_ptr->sent - p_ptr->acked) >= (TIPC_FLOW_CONTROL_WIN * 2); return (p_ptr->sent - p_ptr->acked) >= (TIPC_FLOW_CONTROL_WIN * 2);
} }
static inline u32 tipc_port_peernode(struct tipc_port *p_ptr)
{
return msg_destnode(&p_ptr->phdr);
}
static inline u32 tipc_port_peerport(struct tipc_port *p_ptr)
{
return msg_destport(&p_ptr->phdr);
}
#endif #endif
...@@ -48,7 +48,6 @@ ...@@ -48,7 +48,6 @@
struct tipc_sock { struct tipc_sock {
struct sock sk; struct sock sk;
struct tipc_port *p; struct tipc_port *p;
struct tipc_portid peer_name;
unsigned int conn_timeout; unsigned int conn_timeout;
}; };
...@@ -445,8 +444,9 @@ static int tipc_getname(struct socket *sock, struct sockaddr *uaddr, ...@@ -445,8 +444,9 @@ static int tipc_getname(struct socket *sock, struct sockaddr *uaddr,
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 = 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 { } else {
addr->addr.id.ref = tsock->p->ref; addr->addr.id.ref = tsock->p->ref;
addr->addr.id.node = tipc_own_addr; addr->addr.id.node = tipc_own_addr;
...@@ -881,14 +881,16 @@ static int auto_connect(struct socket *sock, struct tipc_msg *msg) ...@@ -881,14 +881,16 @@ static int auto_connect(struct socket *sock, struct tipc_msg *msg)
{ {
struct tipc_sock *tsock = tipc_sk(sock->sk); struct tipc_sock *tsock = tipc_sk(sock->sk);
struct tipc_port *p_ptr; struct tipc_port *p_ptr;
struct tipc_portid peer;
peer.ref = msg_origport(msg);
peer.node = msg_orignode(msg);
tsock->peer_name.ref = msg_origport(msg);
tsock->peer_name.node = msg_orignode(msg);
p_ptr = tipc_port_deref(tsock->p->ref); p_ptr = tipc_port_deref(tsock->p->ref);
if (!p_ptr) if (!p_ptr)
return -EINVAL; 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) if (msg_importance(msg) > TIPC_CRITICAL_IMPORTANCE)
return -EINVAL; return -EINVAL;
...@@ -1662,6 +1664,7 @@ static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags) ...@@ -1662,6 +1664,7 @@ static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags)
struct tipc_sock *new_tsock; struct tipc_sock *new_tsock;
struct tipc_port *new_tport; struct tipc_port *new_tport;
struct tipc_msg *msg; struct tipc_msg *msg;
struct tipc_portid peer;
u32 new_ref; u32 new_ref;
long timeo; long timeo;
int res; int res;
...@@ -1700,9 +1703,9 @@ static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags) ...@@ -1700,9 +1703,9 @@ static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags)
reject_rx_queue(new_sk); reject_rx_queue(new_sk);
/* Connect new socket to it's peer */ /* Connect new socket to it's peer */
new_tsock->peer_name.ref = msg_origport(msg); peer.ref = msg_origport(msg);
new_tsock->peer_name.node = msg_orignode(msg); peer.node = msg_orignode(msg);
tipc_port_connect(new_ref, &new_tsock->peer_name); tipc_port_connect(new_ref, &peer);
new_sock->state = SS_CONNECTED; new_sock->state = SS_CONNECTED;
tipc_set_portimportance(new_ref, msg_importance(msg)); tipc_set_portimportance(new_ref, msg_importance(msg));
......
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