diff options
author | Jon Paul Maloy <jon.maloy@ericsson.com> | 2014-08-22 18:09:18 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-08-23 14:18:35 -0400 |
commit | 2e84c60b77e4dd96068f568a5971e681bb7e6b68 (patch) | |
tree | ae8e430bdf2e9986a3802a006435988c3d9a9991 /net/tipc | |
parent | 0fc87aaebdfbf2c75112ce17aec093652c682acd (diff) |
tipc: remove include file port.h
We move the inline functions in the file port.h to socket.c, and modify
their names accordingly.
We move struct tipc_port and some macros to socket.h.
Finally, we remove the file port.h.
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/bcast.c | 1 | ||||
-rw-r--r-- | net/tipc/core.c | 2 | ||||
-rw-r--r-- | net/tipc/link.c | 1 | ||||
-rw-r--r-- | net/tipc/name_table.c | 1 | ||||
-rw-r--r-- | net/tipc/net.c | 1 | ||||
-rw-r--r-- | net/tipc/port.h | 145 | ||||
-rw-r--r-- | net/tipc/socket.c | 123 | ||||
-rw-r--r-- | net/tipc/socket.h | 39 | ||||
-rw-r--r-- | net/tipc/subscr.c | 1 |
9 files changed, 121 insertions, 193 deletions
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c index 9510fb2df566..b2bbe69b2554 100644 --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c | |||
@@ -37,7 +37,6 @@ | |||
37 | 37 | ||
38 | #include "core.h" | 38 | #include "core.h" |
39 | #include "link.h" | 39 | #include "link.h" |
40 | #include "port.h" | ||
41 | #include "socket.h" | 40 | #include "socket.h" |
42 | #include "msg.h" | 41 | #include "msg.h" |
43 | #include "bcast.h" | 42 | #include "bcast.h" |
diff --git a/net/tipc/core.c b/net/tipc/core.c index 676d18015dd8..b3b03ef30df5 100644 --- a/net/tipc/core.c +++ b/net/tipc/core.c | |||
@@ -39,7 +39,7 @@ | |||
39 | #include "name_table.h" | 39 | #include "name_table.h" |
40 | #include "subscr.h" | 40 | #include "subscr.h" |
41 | #include "config.h" | 41 | #include "config.h" |
42 | #include "port.h" | 42 | #include "socket.h" |
43 | 43 | ||
44 | #include <linux/module.h> | 44 | #include <linux/module.h> |
45 | 45 | ||
diff --git a/net/tipc/link.c b/net/tipc/link.c index 6c775a107a02..65410e18b8a6 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
@@ -36,7 +36,6 @@ | |||
36 | 36 | ||
37 | #include "core.h" | 37 | #include "core.h" |
38 | #include "link.h" | 38 | #include "link.h" |
39 | #include "port.h" | ||
40 | #include "socket.h" | 39 | #include "socket.h" |
41 | #include "name_distr.h" | 40 | #include "name_distr.h" |
42 | #include "discover.h" | 41 | #include "discover.h" |
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c index 9d7d37d95187..c058e30f84aa 100644 --- a/net/tipc/name_table.c +++ b/net/tipc/name_table.c | |||
@@ -39,7 +39,6 @@ | |||
39 | #include "name_table.h" | 39 | #include "name_table.h" |
40 | #include "name_distr.h" | 40 | #include "name_distr.h" |
41 | #include "subscr.h" | 41 | #include "subscr.h" |
42 | #include "port.h" | ||
43 | 42 | ||
44 | #define TIPC_NAMETBL_SIZE 1024 /* must be a power of 2 */ | 43 | #define TIPC_NAMETBL_SIZE 1024 /* must be a power of 2 */ |
45 | 44 | ||
diff --git a/net/tipc/net.c b/net/tipc/net.c index 421dd89152ac..93b9944a6a8b 100644 --- a/net/tipc/net.c +++ b/net/tipc/net.c | |||
@@ -38,7 +38,6 @@ | |||
38 | #include "net.h" | 38 | #include "net.h" |
39 | #include "name_distr.h" | 39 | #include "name_distr.h" |
40 | #include "subscr.h" | 40 | #include "subscr.h" |
41 | #include "port.h" | ||
42 | #include "socket.h" | 41 | #include "socket.h" |
43 | #include "node.h" | 42 | #include "node.h" |
44 | #include "config.h" | 43 | #include "config.h" |
diff --git a/net/tipc/port.h b/net/tipc/port.h deleted file mode 100644 index 38bf8cb3df1a..000000000000 --- a/net/tipc/port.h +++ /dev/null | |||
@@ -1,145 +0,0 @@ | |||
1 | /* | ||
2 | * net/tipc/port.h: Include file for TIPC port code | ||
3 | * | ||
4 | * Copyright (c) 1994-2007, 2014, Ericsson AB | ||
5 | * Copyright (c) 2004-2007, 2010-2013, Wind River Systems | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions are met: | ||
10 | * | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * 3. Neither the names of the copyright holders nor the names of its | ||
17 | * contributors may be used to endorse or promote products derived from | ||
18 | * this software without specific prior written permission. | ||
19 | * | ||
20 | * Alternatively, this software may be distributed under the terms of the | ||
21 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
22 | * Software Foundation. | ||
23 | * | ||
24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
28 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
29 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
30 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
31 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
32 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
34 | * POSSIBILITY OF SUCH DAMAGE. | ||
35 | */ | ||
36 | |||
37 | #ifndef _TIPC_PORT_H | ||
38 | #define _TIPC_PORT_H | ||
39 | |||
40 | #include "net.h" | ||
41 | #include "msg.h" | ||
42 | #include "node_subscr.h" | ||
43 | |||
44 | #define TIPC_CONNACK_INTV 256 | ||
45 | #define TIPC_FLOWCTRL_WIN (TIPC_CONNACK_INTV * 2) | ||
46 | #define TIPC_CONN_OVERLOAD_LIMIT ((TIPC_FLOWCTRL_WIN * 2 + 1) * \ | ||
47 | SKB_TRUESIZE(TIPC_MAX_USER_MSG_SIZE)) | ||
48 | |||
49 | /** | ||
50 | * struct tipc_port - TIPC port structure | ||
51 | * @lock: pointer to spinlock for controlling access to port | ||
52 | * @connected: non-zero if port is currently connected to a peer port | ||
53 | * @conn_type: TIPC type used when connection was established | ||
54 | * @conn_instance: TIPC instance used when connection was established | ||
55 | * @published: non-zero if port has one or more associated names | ||
56 | * @max_pkt: maximum packet size "hint" used when building messages sent by port | ||
57 | * @ref: unique reference to port in TIPC object registry | ||
58 | * @phdr: preformatted message header used when sending messages | ||
59 | * @port_list: adjacent ports in TIPC's global list of ports | ||
60 | * @publications: list of publications for port | ||
61 | * @pub_count: total # of publications port has made during its lifetime | ||
62 | * @probing_state: | ||
63 | * @probing_interval: | ||
64 | * @timer_ref: | ||
65 | */ | ||
66 | struct tipc_port { | ||
67 | int connected; | ||
68 | u32 conn_type; | ||
69 | u32 conn_instance; | ||
70 | int published; | ||
71 | u32 max_pkt; | ||
72 | u32 ref; | ||
73 | struct tipc_msg phdr; | ||
74 | struct list_head publications; | ||
75 | u32 pub_count; | ||
76 | u32 probing_state; | ||
77 | u32 probing_interval; | ||
78 | struct timer_list timer; | ||
79 | }; | ||
80 | |||
81 | /* | ||
82 | * TIPC port manipulation routines | ||
83 | */ | ||
84 | u32 tipc_port_init(struct tipc_port *p_ptr, | ||
85 | const unsigned int importance); | ||
86 | |||
87 | void tipc_port_destroy(struct tipc_port *p_ptr); | ||
88 | |||
89 | int tipc_publish(struct tipc_port *p_ptr, unsigned int scope, | ||
90 | struct tipc_name_seq const *name_seq); | ||
91 | |||
92 | int tipc_withdraw(struct tipc_port *p_ptr, unsigned int scope, | ||
93 | struct tipc_name_seq const *name_seq); | ||
94 | |||
95 | int tipc_port_peer_msg(struct tipc_port *p_ptr, struct tipc_msg *msg); | ||
96 | |||
97 | void tipc_port_reinit(void); | ||
98 | |||
99 | static inline u32 tipc_port_peernode(struct tipc_port *p_ptr) | ||
100 | { | ||
101 | return msg_destnode(&p_ptr->phdr); | ||
102 | } | ||
103 | |||
104 | static inline u32 tipc_port_peerport(struct tipc_port *p_ptr) | ||
105 | { | ||
106 | return msg_destport(&p_ptr->phdr); | ||
107 | } | ||
108 | |||
109 | static inline bool tipc_port_unreliable(struct tipc_port *port) | ||
110 | { | ||
111 | return msg_src_droppable(&port->phdr) != 0; | ||
112 | } | ||
113 | |||
114 | static inline void tipc_port_set_unreliable(struct tipc_port *port, | ||
115 | bool unreliable) | ||
116 | { | ||
117 | msg_set_src_droppable(&port->phdr, unreliable ? 1 : 0); | ||
118 | } | ||
119 | |||
120 | static inline bool tipc_port_unreturnable(struct tipc_port *port) | ||
121 | { | ||
122 | return msg_dest_droppable(&port->phdr) != 0; | ||
123 | } | ||
124 | |||
125 | static inline void tipc_port_set_unreturnable(struct tipc_port *port, | ||
126 | bool unreturnable) | ||
127 | { | ||
128 | msg_set_dest_droppable(&port->phdr, unreturnable ? 1 : 0); | ||
129 | } | ||
130 | |||
131 | |||
132 | static inline int tipc_port_importance(struct tipc_port *port) | ||
133 | { | ||
134 | return msg_importance(&port->phdr); | ||
135 | } | ||
136 | |||
137 | static inline int tipc_port_set_importance(struct tipc_port *port, int imp) | ||
138 | { | ||
139 | if (imp > TIPC_CRITICAL_IMPORTANCE) | ||
140 | return -EINVAL; | ||
141 | msg_set_importance(&port->phdr, (u32)imp); | ||
142 | return 0; | ||
143 | } | ||
144 | |||
145 | #endif | ||
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index ea33eab4fb9d..70eaceae1f8c 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
@@ -36,12 +36,12 @@ | |||
36 | 36 | ||
37 | #include "core.h" | 37 | #include "core.h" |
38 | #include "ref.h" | 38 | #include "ref.h" |
39 | #include "port.h" | ||
40 | #include "name_table.h" | 39 | #include "name_table.h" |
41 | #include "node.h" | 40 | #include "node.h" |
42 | #include "link.h" | 41 | #include "link.h" |
43 | #include <linux/export.h> | 42 | #include <linux/export.h> |
44 | #include "config.h" | 43 | #include "config.h" |
44 | #include "socket.h" | ||
45 | 45 | ||
46 | #define SS_LISTENING -1 /* socket is listening */ | 46 | #define SS_LISTENING -1 /* socket is listening */ |
47 | #define SS_READY -2 /* socket is connectionless */ | 47 | #define SS_READY -2 /* socket is connectionless */ |
@@ -114,24 +114,65 @@ static struct proto tipc_proto_kern; | |||
114 | * - port reference | 114 | * - port reference |
115 | */ | 115 | */ |
116 | 116 | ||
117 | #include "socket.h" | 117 | static u32 tsk_peer_node(struct tipc_port *p_ptr) |
118 | { | ||
119 | return msg_destnode(&p_ptr->phdr); | ||
120 | } | ||
121 | |||
122 | static u32 tsk_peer_port(struct tipc_port *p_ptr) | ||
123 | { | ||
124 | return msg_destport(&p_ptr->phdr); | ||
125 | } | ||
126 | |||
127 | static bool tsk_unreliable(struct tipc_port *port) | ||
128 | { | ||
129 | return msg_src_droppable(&port->phdr) != 0; | ||
130 | } | ||
131 | |||
132 | static void tsk_set_unreliable(struct tipc_port *port, bool unreliable) | ||
133 | { | ||
134 | msg_set_src_droppable(&port->phdr, unreliable ? 1 : 0); | ||
135 | } | ||
136 | |||
137 | static bool tsk_unreturnable(struct tipc_port *port) | ||
138 | { | ||
139 | return msg_dest_droppable(&port->phdr) != 0; | ||
140 | } | ||
141 | |||
142 | static void tsk_set_unreturnable(struct tipc_port *port, bool unreturnable) | ||
143 | { | ||
144 | msg_set_dest_droppable(&port->phdr, unreturnable ? 1 : 0); | ||
145 | } | ||
146 | |||
147 | static int tsk_importance(struct tipc_port *port) | ||
148 | { | ||
149 | return msg_importance(&port->phdr); | ||
150 | } | ||
151 | |||
152 | static int tsk_set_importance(struct tipc_port *port, int imp) | ||
153 | { | ||
154 | if (imp > TIPC_CRITICAL_IMPORTANCE) | ||
155 | return -EINVAL; | ||
156 | msg_set_importance(&port->phdr, (u32)imp); | ||
157 | return 0; | ||
158 | } | ||
118 | 159 | ||
119 | /** | 160 | /** |
120 | * advance_rx_queue - discard first buffer in socket receive queue | 161 | * tsk_advance_rx_queue - discard first buffer in socket receive queue |
121 | * | 162 | * |
122 | * Caller must hold socket lock | 163 | * Caller must hold socket lock |
123 | */ | 164 | */ |
124 | static void advance_rx_queue(struct sock *sk) | 165 | static void tsk_advance_rx_queue(struct sock *sk) |
125 | { | 166 | { |
126 | kfree_skb(__skb_dequeue(&sk->sk_receive_queue)); | 167 | kfree_skb(__skb_dequeue(&sk->sk_receive_queue)); |
127 | } | 168 | } |
128 | 169 | ||
129 | /** | 170 | /** |
130 | * reject_rx_queue - reject all buffers in socket receive queue | 171 | * tsk_rej_rx_queue - reject all buffers in socket receive queue |
131 | * | 172 | * |
132 | * Caller must hold socket lock | 173 | * Caller must hold socket lock |
133 | */ | 174 | */ |
134 | static void reject_rx_queue(struct sock *sk) | 175 | static void tsk_rej_rx_queue(struct sock *sk) |
135 | { | 176 | { |
136 | struct sk_buff *buf; | 177 | struct sk_buff *buf; |
137 | u32 dnode; | 178 | u32 dnode; |
@@ -142,14 +183,14 @@ static void reject_rx_queue(struct sock *sk) | |||
142 | } | 183 | } |
143 | } | 184 | } |
144 | 185 | ||
145 | /* tipc_sk_peer_msg - verify if message was sent by connected port's peer | 186 | /* tsk_peer_msg - verify if message was sent by connected port's peer |
146 | * | 187 | * |
147 | * Handles cases where the node's network address has changed from | 188 | * Handles cases where the node's network address has changed from |
148 | * the default of <0.0.0> to its configured setting. | 189 | * the default of <0.0.0> to its configured setting. |
149 | */ | 190 | */ |
150 | static bool tipc_sk_peer_msg(struct tipc_sock *tsk, struct tipc_msg *msg) | 191 | static bool tsk_peer_msg(struct tipc_sock *tsk, struct tipc_msg *msg) |
151 | { | 192 | { |
152 | u32 peer_port = tipc_port_peerport(&tsk->port); | 193 | u32 peer_port = tsk_peer_port(&tsk->port); |
153 | u32 orig_node; | 194 | u32 orig_node; |
154 | u32 peer_node; | 195 | u32 peer_node; |
155 | 196 | ||
@@ -160,7 +201,7 @@ static bool tipc_sk_peer_msg(struct tipc_sock *tsk, struct tipc_msg *msg) | |||
160 | return false; | 201 | return false; |
161 | 202 | ||
162 | orig_node = msg_orignode(msg); | 203 | orig_node = msg_orignode(msg); |
163 | peer_node = tipc_port_peernode(&tsk->port); | 204 | peer_node = tsk_peer_node(&tsk->port); |
164 | 205 | ||
165 | if (likely(orig_node == peer_node)) | 206 | if (likely(orig_node == peer_node)) |
166 | return true; | 207 | return true; |
@@ -258,9 +299,9 @@ static int tipc_sk_create(struct net *net, struct socket *sock, | |||
258 | atomic_set(&tsk->dupl_rcvcnt, 0); | 299 | atomic_set(&tsk->dupl_rcvcnt, 0); |
259 | 300 | ||
260 | if (sock->state == SS_READY) { | 301 | if (sock->state == SS_READY) { |
261 | tipc_port_set_unreturnable(port, true); | 302 | tsk_set_unreturnable(port, true); |
262 | if (sock->type == SOCK_DGRAM) | 303 | if (sock->type == SOCK_DGRAM) |
263 | tipc_port_set_unreliable(port, true); | 304 | tsk_set_unreliable(port, true); |
264 | } | 305 | } |
265 | return 0; | 306 | return 0; |
266 | } | 307 | } |
@@ -373,7 +414,7 @@ static int tipc_release(struct socket *sock) | |||
373 | * Reject all unreceived messages, except on an active connection | 414 | * Reject all unreceived messages, except on an active connection |
374 | * (which disconnects locally & sends a 'FIN+' to peer) | 415 | * (which disconnects locally & sends a 'FIN+' to peer) |
375 | */ | 416 | */ |
376 | dnode = tipc_port_peernode(port); | 417 | dnode = tsk_peer_node(port); |
377 | while (sock->state != SS_DISCONNECTING) { | 418 | while (sock->state != SS_DISCONNECTING) { |
378 | buf = __skb_dequeue(&sk->sk_receive_queue); | 419 | buf = __skb_dequeue(&sk->sk_receive_queue); |
379 | if (buf == NULL) | 420 | if (buf == NULL) |
@@ -398,7 +439,7 @@ static int tipc_release(struct socket *sock) | |||
398 | if (port->connected) { | 439 | if (port->connected) { |
399 | buf = tipc_msg_create(TIPC_CRITICAL_IMPORTANCE, TIPC_CONN_MSG, | 440 | buf = tipc_msg_create(TIPC_CRITICAL_IMPORTANCE, TIPC_CONN_MSG, |
400 | SHORT_H_SIZE, 0, dnode, tipc_own_addr, | 441 | SHORT_H_SIZE, 0, dnode, tipc_own_addr, |
401 | tipc_port_peerport(port), | 442 | tsk_peer_port(port), |
402 | port->ref, TIPC_ERR_NO_PORT); | 443 | port->ref, TIPC_ERR_NO_PORT); |
403 | if (buf) | 444 | if (buf) |
404 | tipc_link_xmit(buf, dnode, port->ref); | 445 | tipc_link_xmit(buf, dnode, port->ref); |
@@ -502,8 +543,8 @@ static int tipc_getname(struct socket *sock, struct sockaddr *uaddr, | |||
502 | if ((sock->state != SS_CONNECTED) && | 543 | if ((sock->state != SS_CONNECTED) && |
503 | ((peer != 2) || (sock->state != SS_DISCONNECTING))) | 544 | ((peer != 2) || (sock->state != SS_DISCONNECTING))) |
504 | return -ENOTCONN; | 545 | return -ENOTCONN; |
505 | addr->addr.id.ref = tipc_port_peerport(&tsk->port); | 546 | addr->addr.id.ref = tsk_peer_port(&tsk->port); |
506 | addr->addr.id.node = tipc_port_peernode(&tsk->port); | 547 | addr->addr.id.node = tsk_peer_node(&tsk->port); |
507 | } else { | 548 | } else { |
508 | addr->addr.id.ref = tsk->port.ref; | 549 | addr->addr.id.ref = tsk->port.ref; |
509 | addr->addr.id.node = tipc_own_addr; | 550 | addr->addr.id.node = tipc_own_addr; |
@@ -699,7 +740,7 @@ static int tipc_sk_proto_rcv(struct tipc_sock *tsk, u32 *dnode, | |||
699 | int conn_cong; | 740 | int conn_cong; |
700 | 741 | ||
701 | /* Ignore if connection cannot be validated: */ | 742 | /* Ignore if connection cannot be validated: */ |
702 | if (!tipc_sk_peer_msg(tsk, msg)) | 743 | if (!tsk_peer_msg(tsk, msg)) |
703 | goto exit; | 744 | goto exit; |
704 | 745 | ||
705 | port->probing_state = TIPC_CONN_OK; | 746 | port->probing_state = TIPC_CONN_OK; |
@@ -986,7 +1027,7 @@ static int tipc_send_stream(struct kiocb *iocb, struct socket *sock, | |||
986 | } | 1027 | } |
987 | 1028 | ||
988 | timeo = sock_sndtimeo(sk, m->msg_flags & MSG_DONTWAIT); | 1029 | timeo = sock_sndtimeo(sk, m->msg_flags & MSG_DONTWAIT); |
989 | dnode = tipc_port_peernode(port); | 1030 | dnode = tsk_peer_node(port); |
990 | 1031 | ||
991 | next: | 1032 | next: |
992 | mtu = port->max_pkt; | 1033 | mtu = port->max_pkt; |
@@ -1161,8 +1202,8 @@ static void tipc_sk_send_ack(struct tipc_port *port, uint ack) | |||
1161 | { | 1202 | { |
1162 | struct sk_buff *buf = NULL; | 1203 | struct sk_buff *buf = NULL; |
1163 | struct tipc_msg *msg; | 1204 | struct tipc_msg *msg; |
1164 | u32 peer_port = tipc_port_peerport(port); | 1205 | u32 peer_port = tsk_peer_port(port); |
1165 | u32 dnode = tipc_port_peernode(port); | 1206 | u32 dnode = tsk_peer_node(port); |
1166 | 1207 | ||
1167 | if (!port->connected) | 1208 | if (!port->connected) |
1168 | return; | 1209 | return; |
@@ -1260,7 +1301,7 @@ restart: | |||
1260 | 1301 | ||
1261 | /* Discard an empty non-errored message & try again */ | 1302 | /* Discard an empty non-errored message & try again */ |
1262 | if ((!sz) && (!err)) { | 1303 | if ((!sz) && (!err)) { |
1263 | advance_rx_queue(sk); | 1304 | tsk_advance_rx_queue(sk); |
1264 | goto restart; | 1305 | goto restart; |
1265 | } | 1306 | } |
1266 | 1307 | ||
@@ -1298,7 +1339,7 @@ restart: | |||
1298 | tipc_sk_send_ack(port, tsk->rcv_unacked); | 1339 | tipc_sk_send_ack(port, tsk->rcv_unacked); |
1299 | tsk->rcv_unacked = 0; | 1340 | tsk->rcv_unacked = 0; |
1300 | } | 1341 | } |
1301 | advance_rx_queue(sk); | 1342 | tsk_advance_rx_queue(sk); |
1302 | } | 1343 | } |
1303 | exit: | 1344 | exit: |
1304 | release_sock(sk); | 1345 | release_sock(sk); |
@@ -1360,7 +1401,7 @@ restart: | |||
1360 | 1401 | ||
1361 | /* Discard an empty non-errored message & try again */ | 1402 | /* Discard an empty non-errored message & try again */ |
1362 | if ((!sz) && (!err)) { | 1403 | if ((!sz) && (!err)) { |
1363 | advance_rx_queue(sk); | 1404 | tsk_advance_rx_queue(sk); |
1364 | goto restart; | 1405 | goto restart; |
1365 | } | 1406 | } |
1366 | 1407 | ||
@@ -1409,7 +1450,7 @@ restart: | |||
1409 | tipc_sk_send_ack(port, tsk->rcv_unacked); | 1450 | tipc_sk_send_ack(port, tsk->rcv_unacked); |
1410 | tsk->rcv_unacked = 0; | 1451 | tsk->rcv_unacked = 0; |
1411 | } | 1452 | } |
1412 | advance_rx_queue(sk); | 1453 | tsk_advance_rx_queue(sk); |
1413 | } | 1454 | } |
1414 | 1455 | ||
1415 | /* Loop around if more data is required */ | 1456 | /* Loop around if more data is required */ |
@@ -1480,12 +1521,12 @@ static int filter_connect(struct tipc_sock *tsk, struct sk_buff **buf) | |||
1480 | switch ((int)sock->state) { | 1521 | switch ((int)sock->state) { |
1481 | case SS_CONNECTED: | 1522 | case SS_CONNECTED: |
1482 | /* Accept only connection-based messages sent by peer */ | 1523 | /* Accept only connection-based messages sent by peer */ |
1483 | if (tipc_sk_peer_msg(tsk, msg)) { | 1524 | if (tsk_peer_msg(tsk, msg)) { |
1484 | if (unlikely(msg_errcode(msg))) { | 1525 | if (unlikely(msg_errcode(msg))) { |
1485 | sock->state = SS_DISCONNECTING; | 1526 | sock->state = SS_DISCONNECTING; |
1486 | port->connected = 0; | 1527 | port->connected = 0; |
1487 | /* let timer expire on it's own */ | 1528 | /* let timer expire on it's own */ |
1488 | tipc_node_remove_conn(tipc_port_peernode(port), | 1529 | tipc_node_remove_conn(tsk_peer_node(port), |
1489 | port->ref); | 1530 | port->ref); |
1490 | } | 1531 | } |
1491 | retval = TIPC_OK; | 1532 | retval = TIPC_OK; |
@@ -1919,13 +1960,13 @@ static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags) | |||
1919 | * Reject any stray messages received by new socket | 1960 | * Reject any stray messages received by new socket |
1920 | * before the socket lock was taken (very, very unlikely) | 1961 | * before the socket lock was taken (very, very unlikely) |
1921 | */ | 1962 | */ |
1922 | reject_rx_queue(new_sk); | 1963 | tsk_rej_rx_queue(new_sk); |
1923 | 1964 | ||
1924 | /* Connect new socket to it's peer */ | 1965 | /* Connect new socket to it's peer */ |
1925 | tipc_sk_finish_conn(new_port, msg_origport(msg), msg_orignode(msg)); | 1966 | tipc_sk_finish_conn(new_port, msg_origport(msg), msg_orignode(msg)); |
1926 | new_sock->state = SS_CONNECTED; | 1967 | new_sock->state = SS_CONNECTED; |
1927 | 1968 | ||
1928 | tipc_port_set_importance(new_port, msg_importance(msg)); | 1969 | tsk_set_importance(new_port, msg_importance(msg)); |
1929 | if (msg_named(msg)) { | 1970 | if (msg_named(msg)) { |
1930 | new_port->conn_type = msg_nametype(msg); | 1971 | new_port->conn_type = msg_nametype(msg); |
1931 | new_port->conn_instance = msg_nameinst(msg); | 1972 | new_port->conn_instance = msg_nameinst(msg); |
@@ -1938,7 +1979,7 @@ static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags) | |||
1938 | if (!msg_data_sz(msg)) { | 1979 | if (!msg_data_sz(msg)) { |
1939 | struct msghdr m = {NULL,}; | 1980 | struct msghdr m = {NULL,}; |
1940 | 1981 | ||
1941 | advance_rx_queue(sk); | 1982 | tsk_advance_rx_queue(sk); |
1942 | tipc_send_packet(NULL, new_sock, &m, 0); | 1983 | tipc_send_packet(NULL, new_sock, &m, 0); |
1943 | } else { | 1984 | } else { |
1944 | __skb_dequeue(&sk->sk_receive_queue); | 1985 | __skb_dequeue(&sk->sk_receive_queue); |
@@ -1990,11 +2031,11 @@ restart: | |||
1990 | tipc_link_xmit(buf, dnode, port->ref); | 2031 | tipc_link_xmit(buf, dnode, port->ref); |
1991 | tipc_node_remove_conn(dnode, port->ref); | 2032 | tipc_node_remove_conn(dnode, port->ref); |
1992 | } else { | 2033 | } else { |
1993 | dnode = tipc_port_peernode(port); | 2034 | dnode = tsk_peer_node(port); |
1994 | buf = tipc_msg_create(TIPC_CRITICAL_IMPORTANCE, | 2035 | buf = tipc_msg_create(TIPC_CRITICAL_IMPORTANCE, |
1995 | TIPC_CONN_MSG, SHORT_H_SIZE, | 2036 | TIPC_CONN_MSG, SHORT_H_SIZE, |
1996 | 0, dnode, tipc_own_addr, | 2037 | 0, dnode, tipc_own_addr, |
1997 | tipc_port_peerport(port), | 2038 | tsk_peer_port(port), |
1998 | port->ref, TIPC_CONN_SHUTDOWN); | 2039 | port->ref, TIPC_CONN_SHUTDOWN); |
1999 | tipc_link_xmit(buf, dnode, port->ref); | 2040 | tipc_link_xmit(buf, dnode, port->ref); |
2000 | } | 2041 | } |
@@ -2040,8 +2081,8 @@ static void tipc_sk_timeout(unsigned long ref) | |||
2040 | bh_unlock_sock(sk); | 2081 | bh_unlock_sock(sk); |
2041 | goto exit; | 2082 | goto exit; |
2042 | } | 2083 | } |
2043 | peer_port = tipc_port_peerport(port); | 2084 | peer_port = tsk_peer_port(port); |
2044 | peer_node = tipc_port_peernode(port); | 2085 | peer_node = tsk_peer_node(port); |
2045 | 2086 | ||
2046 | if (port->probing_state == TIPC_CONN_PROBING) { | 2087 | if (port->probing_state == TIPC_CONN_PROBING) { |
2047 | /* Previous probe not answered -> self abort */ | 2088 | /* Previous probe not answered -> self abort */ |
@@ -2132,8 +2173,8 @@ static int tipc_sk_show(struct tipc_port *port, char *buf, | |||
2132 | ret = tipc_snprintf(buf, len, "%-10u:", port->ref); | 2173 | ret = tipc_snprintf(buf, len, "%-10u:", port->ref); |
2133 | 2174 | ||
2134 | if (port->connected) { | 2175 | if (port->connected) { |
2135 | u32 dport = tipc_port_peerport(port); | 2176 | u32 dport = tsk_peer_port(port); |
2136 | u32 destnode = tipc_port_peernode(port); | 2177 | u32 destnode = tsk_peer_node(port); |
2137 | 2178 | ||
2138 | ret += tipc_snprintf(buf + ret, len - ret, | 2179 | ret += tipc_snprintf(buf + ret, len - ret, |
2139 | " connected to <%u.%u.%u:%u>", | 2180 | " connected to <%u.%u.%u:%u>", |
@@ -2248,16 +2289,16 @@ static int tipc_setsockopt(struct socket *sock, int lvl, int opt, | |||
2248 | 2289 | ||
2249 | switch (opt) { | 2290 | switch (opt) { |
2250 | case TIPC_IMPORTANCE: | 2291 | case TIPC_IMPORTANCE: |
2251 | res = tipc_port_set_importance(port, value); | 2292 | res = tsk_set_importance(port, value); |
2252 | break; | 2293 | break; |
2253 | case TIPC_SRC_DROPPABLE: | 2294 | case TIPC_SRC_DROPPABLE: |
2254 | if (sock->type != SOCK_STREAM) | 2295 | if (sock->type != SOCK_STREAM) |
2255 | tipc_port_set_unreliable(port, value); | 2296 | tsk_set_unreliable(port, value); |
2256 | else | 2297 | else |
2257 | res = -ENOPROTOOPT; | 2298 | res = -ENOPROTOOPT; |
2258 | break; | 2299 | break; |
2259 | case TIPC_DEST_DROPPABLE: | 2300 | case TIPC_DEST_DROPPABLE: |
2260 | tipc_port_set_unreturnable(port, value); | 2301 | tsk_set_unreturnable(port, value); |
2261 | break; | 2302 | break; |
2262 | case TIPC_CONN_TIMEOUT: | 2303 | case TIPC_CONN_TIMEOUT: |
2263 | tipc_sk(sk)->conn_timeout = value; | 2304 | tipc_sk(sk)->conn_timeout = value; |
@@ -2307,13 +2348,13 @@ static int tipc_getsockopt(struct socket *sock, int lvl, int opt, | |||
2307 | 2348 | ||
2308 | switch (opt) { | 2349 | switch (opt) { |
2309 | case TIPC_IMPORTANCE: | 2350 | case TIPC_IMPORTANCE: |
2310 | value = tipc_port_importance(port); | 2351 | value = tsk_importance(port); |
2311 | break; | 2352 | break; |
2312 | case TIPC_SRC_DROPPABLE: | 2353 | case TIPC_SRC_DROPPABLE: |
2313 | value = tipc_port_unreliable(port); | 2354 | value = tsk_unreliable(port); |
2314 | break; | 2355 | break; |
2315 | case TIPC_DEST_DROPPABLE: | 2356 | case TIPC_DEST_DROPPABLE: |
2316 | value = tipc_port_unreturnable(port); | 2357 | value = tsk_unreturnable(port); |
2317 | break; | 2358 | break; |
2318 | case TIPC_CONN_TIMEOUT: | 2359 | case TIPC_CONN_TIMEOUT: |
2319 | value = tipc_sk(sk)->conn_timeout; | 2360 | value = tipc_sk(sk)->conn_timeout; |
diff --git a/net/tipc/socket.h b/net/tipc/socket.h index 5d515be604a9..b98725e27b94 100644 --- a/net/tipc/socket.h +++ b/net/tipc/socket.h | |||
@@ -35,11 +35,48 @@ | |||
35 | #ifndef _TIPC_SOCK_H | 35 | #ifndef _TIPC_SOCK_H |
36 | #define _TIPC_SOCK_H | 36 | #define _TIPC_SOCK_H |
37 | 37 | ||
38 | #include "port.h" | ||
39 | #include <net/sock.h> | 38 | #include <net/sock.h> |
39 | #include "msg.h" | ||
40 | 40 | ||
41 | #define TIPC_CONN_OK 0 | 41 | #define TIPC_CONN_OK 0 |
42 | #define TIPC_CONN_PROBING 1 | 42 | #define TIPC_CONN_PROBING 1 |
43 | #define TIPC_CONNACK_INTV 256 | ||
44 | #define TIPC_FLOWCTRL_WIN (TIPC_CONNACK_INTV * 2) | ||
45 | #define TIPC_CONN_OVERLOAD_LIMIT ((TIPC_FLOWCTRL_WIN * 2 + 1) * \ | ||
46 | SKB_TRUESIZE(TIPC_MAX_USER_MSG_SIZE)) | ||
47 | |||
48 | /** | ||
49 | * struct tipc_port - TIPC port structure | ||
50 | * @lock: pointer to spinlock for controlling access to port | ||
51 | * @connected: non-zero if port is currently connected to a peer port | ||
52 | * @conn_type: TIPC type used when connection was established | ||
53 | * @conn_instance: TIPC instance used when connection was established | ||
54 | * @published: non-zero if port has one or more associated names | ||
55 | * @max_pkt: maximum packet size "hint" used when building messages sent by port | ||
56 | * @ref: unique reference to port in TIPC object registry | ||
57 | * @phdr: preformatted message header used when sending messages | ||
58 | * @port_list: adjacent ports in TIPC's global list of ports | ||
59 | * @publications: list of publications for port | ||
60 | * @pub_count: total # of publications port has made during its lifetime | ||
61 | * @probing_state: | ||
62 | * @probing_interval: | ||
63 | * @timer_ref: | ||
64 | */ | ||
65 | struct tipc_port { | ||
66 | int connected; | ||
67 | u32 conn_type; | ||
68 | u32 conn_instance; | ||
69 | int published; | ||
70 | u32 max_pkt; | ||
71 | u32 ref; | ||
72 | struct tipc_msg phdr; | ||
73 | struct list_head port_list; | ||
74 | struct list_head publications; | ||
75 | u32 pub_count; | ||
76 | u32 probing_state; | ||
77 | u32 probing_interval; | ||
78 | struct timer_list timer; | ||
79 | }; | ||
43 | 80 | ||
44 | /** | 81 | /** |
45 | * struct tipc_sock - TIPC socket structure | 82 | * struct tipc_sock - TIPC socket structure |
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c index 642437231ad5..31b5cb232a43 100644 --- a/net/tipc/subscr.c +++ b/net/tipc/subscr.c | |||
@@ -36,7 +36,6 @@ | |||
36 | 36 | ||
37 | #include "core.h" | 37 | #include "core.h" |
38 | #include "name_table.h" | 38 | #include "name_table.h" |
39 | #include "port.h" | ||
40 | #include "subscr.h" | 39 | #include "subscr.h" |
41 | 40 | ||
42 | /** | 41 | /** |