aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Paul Maloy <jon.maloy@ericsson.com>2014-03-12 11:31:08 -0400
committerDavid S. Miller <davem@davemloft.net>2014-03-12 15:53:49 -0400
commitf9fef18c6d688697e72d1020a7c43a50c1331a58 (patch)
treec256dcf97aae43ab23c2a28cbf763e421f0dec64
parent978813ee89674fdb6bb6585153166b7603173cd2 (diff)
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>
-rw-r--r--net/tipc/port.c25
-rw-r--r--net/tipc/port.h11
-rw-r--r--net/tipc/socket.c21
3 files changed, 30 insertions, 27 deletions
diff --git a/net/tipc/port.c b/net/tipc/port.c
index c7c2b549a39e..d1abe1104120 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -54,17 +54,6 @@ static struct sk_buff *port_build_self_abort_msg(struct tipc_port *, u32 err);
54static struct sk_buff *port_build_peer_abort_msg(struct tipc_port *, u32 err); 54static struct sk_buff *port_build_peer_abort_msg(struct tipc_port *, u32 err);
55static void port_timeout(unsigned long ref); 55static void port_timeout(unsigned long ref);
56 56
57
58static u32 port_peernode(struct tipc_port *p_ptr)
59{
60 return msg_destnode(&p_ptr->phdr);
61}
62
63static u32 port_peerport(struct tipc_port *p_ptr)
64{
65 return msg_destport(&p_ptr->phdr);
66}
67
68/** 57/**
69 * tipc_port_peer_msg - verify message was sent by connected port's peer 58 * tipc_port_peer_msg - verify message was sent by connected port's peer
70 * 59 *
@@ -76,11 +65,11 @@ int tipc_port_peer_msg(struct tipc_port *p_ptr, struct tipc_msg *msg)
76 u32 peernode; 65 u32 peernode;
77 u32 orignode; 66 u32 orignode;
78 67
79 if (msg_origport(msg) != port_peerport(p_ptr)) 68 if (msg_origport(msg) != tipc_port_peerport(p_ptr))
80 return 0; 69 return 0;
81 70
82 orignode = msg_orignode(msg); 71 orignode = msg_orignode(msg);
83 peernode = port_peernode(p_ptr); 72 peernode = tipc_port_peernode(p_ptr);
84 return (orignode == peernode) || 73 return (orignode == peernode) ||
85 (!orignode && (peernode == tipc_own_addr)) || 74 (!orignode && (peernode == tipc_own_addr)) ||
86 (!peernode && (orignode == tipc_own_addr)); 75 (!peernode && (orignode == tipc_own_addr));
@@ -351,8 +340,8 @@ static struct sk_buff *port_build_proto_msg(struct tipc_port *p_ptr,
351 if (buf) { 340 if (buf) {
352 msg = buf_msg(buf); 341 msg = buf_msg(buf);
353 tipc_msg_init(msg, CONN_MANAGER, type, INT_H_SIZE, 342 tipc_msg_init(msg, CONN_MANAGER, type, INT_H_SIZE,
354 port_peernode(p_ptr)); 343 tipc_port_peernode(p_ptr));
355 msg_set_destport(msg, port_peerport(p_ptr)); 344 msg_set_destport(msg, tipc_port_peerport(p_ptr));
356 msg_set_origport(msg, p_ptr->ref); 345 msg_set_origport(msg, p_ptr->ref);
357 msg_set_msgcnt(msg, ack); 346 msg_set_msgcnt(msg, ack);
358 } 347 }
@@ -585,8 +574,8 @@ static int port_print(struct tipc_port *p_ptr, char *buf, int len, int full_id)
585 ret = tipc_snprintf(buf, len, "%-10u:", p_ptr->ref); 574 ret = tipc_snprintf(buf, len, "%-10u:", p_ptr->ref);
586 575
587 if (p_ptr->connected) { 576 if (p_ptr->connected) {
588 u32 dport = port_peerport(p_ptr); 577 u32 dport = tipc_port_peerport(p_ptr);
589 u32 destnode = port_peernode(p_ptr); 578 u32 destnode = tipc_port_peernode(p_ptr);
590 579
591 ret += tipc_snprintf(buf + ret, len - ret, 580 ret += tipc_snprintf(buf + ret, len - ret,
592 " connected to <%u.%u.%u:%u>", 581 " connected to <%u.%u.%u:%u>",
@@ -926,7 +915,7 @@ int tipc_send(u32 ref, struct iovec const *msg_sect, unsigned int len)
926 915
927 p_ptr->congested = 1; 916 p_ptr->congested = 1;
928 if (!tipc_port_congested(p_ptr)) { 917 if (!tipc_port_congested(p_ptr)) {
929 destnode = port_peernode(p_ptr); 918 destnode = tipc_port_peernode(p_ptr);
930 if (likely(!in_own_node(destnode))) 919 if (likely(!in_own_node(destnode)))
931 res = tipc_link_iovec_xmit_fast(p_ptr, msg_sect, len, 920 res = tipc_link_iovec_xmit_fast(p_ptr, msg_sect, len,
932 destnode); 921 destnode);
diff --git a/net/tipc/port.h b/net/tipc/port.h
index 3ec3e94e4334..4a2a1ac8686c 100644
--- a/net/tipc/port.h
+++ b/net/tipc/port.h
@@ -198,4 +198,15 @@ static inline int tipc_port_congested(struct tipc_port *p_ptr)
198 return (p_ptr->sent - p_ptr->acked) >= (TIPC_FLOW_CONTROL_WIN * 2); 198 return (p_ptr->sent - p_ptr->acked) >= (TIPC_FLOW_CONTROL_WIN * 2);
199} 199}
200 200
201
202static inline u32 tipc_port_peernode(struct tipc_port *p_ptr)
203{
204 return msg_destnode(&p_ptr->phdr);
205}
206
207static inline u32 tipc_port_peerport(struct tipc_port *p_ptr)
208{
209 return msg_destport(&p_ptr->phdr);
210}
211
201#endif 212#endif
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 336e18d6cf46..62655772adda 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -48,7 +48,6 @@
48struct tipc_sock { 48struct tipc_sock {
49 struct sock sk; 49 struct sock sk;
50 struct tipc_port *p; 50 struct tipc_port *p;
51 struct tipc_portid peer_name;
52 unsigned int conn_timeout; 51 unsigned int conn_timeout;
53}; 52};
54 53
@@ -445,8 +444,9 @@ static int tipc_getname(struct socket *sock, struct sockaddr *uaddr,
445 if ((sock->state != SS_CONNECTED) && 444 if ((sock->state != SS_CONNECTED) &&
446 ((peer != 2) || (sock->state != SS_DISCONNECTING))) 445 ((peer != 2) || (sock->state != SS_DISCONNECTING)))
447 return -ENOTCONN; 446 return -ENOTCONN;
448 addr->addr.id.ref = tsock->peer_name.ref; 447
449 addr->addr.id.node = tsock->peer_name.node; 448 addr->addr.id.ref = tipc_port_peerport(tsock->p);
449 addr->addr.id.node = tipc_port_peernode(tsock->p);
450 } else { 450 } else {
451 addr->addr.id.ref = tsock->p->ref; 451 addr->addr.id.ref = tsock->p->ref;
452 addr->addr.id.node = tipc_own_addr; 452 addr->addr.id.node = tipc_own_addr;
@@ -881,14 +881,16 @@ static int auto_connect(struct socket *sock, struct tipc_msg *msg)
881{ 881{
882 struct tipc_sock *tsock = tipc_sk(sock->sk); 882 struct tipc_sock *tsock = tipc_sk(sock->sk);
883 struct tipc_port *p_ptr; 883 struct tipc_port *p_ptr;
884 struct tipc_portid peer;
885
886 peer.ref = msg_origport(msg);
887 peer.node = msg_orignode(msg);
884 888
885 tsock->peer_name.ref = msg_origport(msg);
886 tsock->peer_name.node = msg_orignode(msg);
887 p_ptr = tipc_port_deref(tsock->p->ref); 889 p_ptr = tipc_port_deref(tsock->p->ref);
888 if (!p_ptr) 890 if (!p_ptr)
889 return -EINVAL; 891 return -EINVAL;
890 892
891 __tipc_port_connect(tsock->p->ref, p_ptr, &tsock->peer_name); 893 __tipc_port_connect(p_ptr->ref, p_ptr, &peer);
892 894
893 if (msg_importance(msg) > TIPC_CRITICAL_IMPORTANCE) 895 if (msg_importance(msg) > TIPC_CRITICAL_IMPORTANCE)
894 return -EINVAL; 896 return -EINVAL;
@@ -1662,6 +1664,7 @@ static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags)
1662 struct tipc_sock *new_tsock; 1664 struct tipc_sock *new_tsock;
1663 struct tipc_port *new_tport; 1665 struct tipc_port *new_tport;
1664 struct tipc_msg *msg; 1666 struct tipc_msg *msg;
1667 struct tipc_portid peer;
1665 u32 new_ref; 1668 u32 new_ref;
1666 long timeo; 1669 long timeo;
1667 int res; 1670 int res;
@@ -1700,9 +1703,9 @@ static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags)
1700 reject_rx_queue(new_sk); 1703 reject_rx_queue(new_sk);
1701 1704
1702 /* Connect new socket to it's peer */ 1705 /* Connect new socket to it's peer */
1703 new_tsock->peer_name.ref = msg_origport(msg); 1706 peer.ref = msg_origport(msg);
1704 new_tsock->peer_name.node = msg_orignode(msg); 1707 peer.node = msg_orignode(msg);
1705 tipc_port_connect(new_ref, &new_tsock->peer_name); 1708 tipc_port_connect(new_ref, &peer);
1706 new_sock->state = SS_CONNECTED; 1709 new_sock->state = SS_CONNECTED;
1707 1710
1708 tipc_set_portimportance(new_ref, msg_importance(msg)); 1711 tipc_set_portimportance(new_ref, msg_importance(msg));