aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/port.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc/port.c')
-rw-r--r--net/tipc/port.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/net/tipc/port.c b/net/tipc/port.c
index 7b027e99a5c9..5d24a195ea3d 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -190,33 +190,32 @@ exit:
190 tipc_port_list_free(dp); 190 tipc_port_list_free(dp);
191} 191}
192 192
193/** 193
194 * tipc_createport - create a generic TIPC port 194void tipc_port_wakeup(struct tipc_port *port)
195{
196 tipc_sk_wakeup(tipc_port_to_sk(port));
197}
198
199/* tipc_port_init - intiate TIPC port and lock it
195 * 200 *
196 * Returns pointer to (locked) TIPC port, or NULL if unable to create it 201 * Returns obtained reference if initialization is successful, zero otherwise
197 */ 202 */
198struct tipc_port *tipc_createport(struct sock *sk, 203u32 tipc_port_init(struct tipc_port *p_ptr,
199 u32 (*dispatcher)(struct tipc_port *, 204 const unsigned int importance)
200 struct sk_buff *),
201 void (*wakeup)(struct tipc_port *),
202 const u32 importance)
203{ 205{
204 struct tipc_port *p_ptr = tipc_sk_port(sk);
205 struct tipc_msg *msg; 206 struct tipc_msg *msg;
206 u32 ref; 207 u32 ref;
207 208
208 ref = tipc_ref_acquire(p_ptr, &p_ptr->lock); 209 ref = tipc_ref_acquire(p_ptr, &p_ptr->lock);
209 if (!ref) { 210 if (!ref) {
210 pr_warn("Port registration failed, ref. table exhausted\n"); 211 pr_warn("Port registration failed, ref. table exhausted\n");
211 return NULL; 212 return 0;
212 } 213 }
213 214
214 p_ptr->max_pkt = MAX_PKT_DEFAULT; 215 p_ptr->max_pkt = MAX_PKT_DEFAULT;
215 p_ptr->ref = ref; 216 p_ptr->ref = ref;
216 INIT_LIST_HEAD(&p_ptr->wait_list); 217 INIT_LIST_HEAD(&p_ptr->wait_list);
217 INIT_LIST_HEAD(&p_ptr->subscription.nodesub_list); 218 INIT_LIST_HEAD(&p_ptr->subscription.nodesub_list);
218 p_ptr->dispatcher = dispatcher;
219 p_ptr->wakeup = wakeup;
220 k_init_timer(&p_ptr->timer, (Handler)port_timeout, ref); 219 k_init_timer(&p_ptr->timer, (Handler)port_timeout, ref);
221 INIT_LIST_HEAD(&p_ptr->publications); 220 INIT_LIST_HEAD(&p_ptr->publications);
222 INIT_LIST_HEAD(&p_ptr->port_list); 221 INIT_LIST_HEAD(&p_ptr->port_list);
@@ -232,10 +231,10 @@ struct tipc_port *tipc_createport(struct sock *sk,
232 msg_set_origport(msg, ref); 231 msg_set_origport(msg, ref);
233 list_add_tail(&p_ptr->port_list, &ports); 232 list_add_tail(&p_ptr->port_list, &ports);
234 spin_unlock_bh(&tipc_port_list_lock); 233 spin_unlock_bh(&tipc_port_list_lock);
235 return p_ptr; 234 return ref;
236} 235}
237 236
238int tipc_deleteport(struct tipc_port *p_ptr) 237void tipc_port_destroy(struct tipc_port *p_ptr)
239{ 238{
240 struct sk_buff *buf = NULL; 239 struct sk_buff *buf = NULL;
241 240
@@ -257,7 +256,6 @@ int tipc_deleteport(struct tipc_port *p_ptr)
257 spin_unlock_bh(&tipc_port_list_lock); 256 spin_unlock_bh(&tipc_port_list_lock);
258 k_term_timer(&p_ptr->timer); 257 k_term_timer(&p_ptr->timer);
259 tipc_net_route_msg(buf); 258 tipc_net_route_msg(buf);
260 return 0;
261} 259}
262 260
263static int port_unreliable(struct tipc_port *p_ptr) 261static int port_unreliable(struct tipc_port *p_ptr)
@@ -530,13 +528,12 @@ void tipc_port_proto_rcv(struct sk_buff *buf)
530 /* Process protocol message sent by peer */ 528 /* Process protocol message sent by peer */
531 switch (msg_type(msg)) { 529 switch (msg_type(msg)) {
532 case CONN_ACK: 530 case CONN_ACK:
533 wakeable = tipc_port_congested(p_ptr) && p_ptr->congested && 531 wakeable = tipc_port_congested(p_ptr) && p_ptr->congested;
534 p_ptr->wakeup;
535 p_ptr->acked += msg_msgcnt(msg); 532 p_ptr->acked += msg_msgcnt(msg);
536 if (!tipc_port_congested(p_ptr)) { 533 if (!tipc_port_congested(p_ptr)) {
537 p_ptr->congested = 0; 534 p_ptr->congested = 0;
538 if (wakeable) 535 if (wakeable)
539 p_ptr->wakeup(p_ptr); 536 tipc_port_wakeup(p_ptr);
540 } 537 }
541 break; 538 break;
542 case CONN_PROBE: 539 case CONN_PROBE:
@@ -865,7 +862,7 @@ int tipc_port_rcv(struct sk_buff *buf)
865 /* validate destination & pass to port, otherwise reject message */ 862 /* validate destination & pass to port, otherwise reject message */
866 p_ptr = tipc_port_lock(destport); 863 p_ptr = tipc_port_lock(destport);
867 if (likely(p_ptr)) { 864 if (likely(p_ptr)) {
868 err = p_ptr->dispatcher(p_ptr, buf); 865 err = tipc_sk_rcv(tipc_port_to_sk(p_ptr), buf);
869 tipc_port_unlock(p_ptr); 866 tipc_port_unlock(p_ptr);
870 if (likely(!err)) 867 if (likely(!err))
871 return dsz; 868 return dsz;