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>
This commit is contained in:
parent
978813ee89
commit
f9fef18c6d
@ -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 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
|
||||
*
|
||||
@ -76,11 +65,11 @@ int tipc_port_peer_msg(struct tipc_port *p_ptr, struct tipc_msg *msg)
|
||||
u32 peernode;
|
||||
u32 orignode;
|
||||
|
||||
if (msg_origport(msg) != port_peerport(p_ptr))
|
||||
if (msg_origport(msg) != tipc_port_peerport(p_ptr))
|
||||
return 0;
|
||||
|
||||
orignode = msg_orignode(msg);
|
||||
peernode = port_peernode(p_ptr);
|
||||
peernode = tipc_port_peernode(p_ptr);
|
||||
return (orignode == peernode) ||
|
||||
(!orignode && (peernode == 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,
|
||||
if (buf) {
|
||||
msg = buf_msg(buf);
|
||||
tipc_msg_init(msg, CONN_MANAGER, type, INT_H_SIZE,
|
||||
port_peernode(p_ptr));
|
||||
msg_set_destport(msg, port_peerport(p_ptr));
|
||||
tipc_port_peernode(p_ptr));
|
||||
msg_set_destport(msg, tipc_port_peerport(p_ptr));
|
||||
msg_set_origport(msg, p_ptr->ref);
|
||||
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)
|
||||
ret = tipc_snprintf(buf, len, "%-10u:", p_ptr->ref);
|
||||
|
||||
if (p_ptr->connected) {
|
||||
u32 dport = port_peerport(p_ptr);
|
||||
u32 destnode = port_peernode(p_ptr);
|
||||
u32 dport = tipc_port_peerport(p_ptr);
|
||||
u32 destnode = tipc_port_peernode(p_ptr);
|
||||
|
||||
ret += tipc_snprintf(buf + ret, len - ret,
|
||||
" connected to <%u.%u.%u:%u>",
|
||||
@ -926,7 +915,7 @@ int tipc_send(u32 ref, struct iovec const *msg_sect, unsigned int len)
|
||||
|
||||
p_ptr->congested = 1;
|
||||
if (!tipc_port_congested(p_ptr)) {
|
||||
destnode = port_peernode(p_ptr);
|
||||
destnode = tipc_port_peernode(p_ptr);
|
||||
if (likely(!in_own_node(destnode)))
|
||||
res = tipc_link_iovec_xmit_fast(p_ptr, msg_sect, len,
|
||||
destnode);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
|
@ -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 @@ static int tipc_getname(struct socket *sock, struct sockaddr *uaddr,
|
||||
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 @@ static int auto_connect(struct socket *sock, struct tipc_msg *msg)
|
||||
{
|
||||
struct tipc_sock *tsock = tipc_sk(sock->sk);
|
||||
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);
|
||||
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 @@ static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags)
|
||||
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 @@ static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags)
|
||||
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));
|
||||
|
Loading…
Reference in New Issue
Block a user