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.c306
1 files changed, 147 insertions, 159 deletions
diff --git a/net/tipc/port.c b/net/tipc/port.c
index 067bab2a0b98..6ff78f9c7d65 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -2,7 +2,7 @@
2 * net/tipc/port.c: TIPC port code 2 * net/tipc/port.c: TIPC port code
3 * 3 *
4 * Copyright (c) 1992-2007, Ericsson AB 4 * Copyright (c) 1992-2007, Ericsson AB
5 * Copyright (c) 2004-2008, Wind River Systems 5 * Copyright (c) 2004-2008, 2010-2011, Wind River Systems
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
@@ -54,33 +54,19 @@ static DEFINE_SPINLOCK(queue_lock);
54 54
55static LIST_HEAD(ports); 55static LIST_HEAD(ports);
56static void port_handle_node_down(unsigned long ref); 56static void port_handle_node_down(unsigned long ref);
57static struct sk_buff *port_build_self_abort_msg(struct port *, u32 err); 57static struct sk_buff *port_build_self_abort_msg(struct tipc_port *, u32 err);
58static struct sk_buff *port_build_peer_abort_msg(struct port *, u32 err); 58static struct sk_buff *port_build_peer_abort_msg(struct tipc_port *, u32 err);
59static void port_timeout(unsigned long ref); 59static void port_timeout(unsigned long ref);
60 60
61 61
62static u32 port_peernode(struct port *p_ptr) 62static u32 port_peernode(struct tipc_port *p_ptr)
63{ 63{
64 return msg_destnode(&p_ptr->publ.phdr); 64 return msg_destnode(&p_ptr->phdr);
65} 65}
66 66
67static u32 port_peerport(struct port *p_ptr) 67static u32 port_peerport(struct tipc_port *p_ptr)
68{ 68{
69 return msg_destport(&p_ptr->publ.phdr); 69 return msg_destport(&p_ptr->phdr);
70}
71
72static u32 port_out_seqno(struct port *p_ptr)
73{
74 return msg_transp_seqno(&p_ptr->publ.phdr);
75}
76
77static void port_incr_out_seqno(struct port *p_ptr)
78{
79 struct tipc_msg *m = &p_ptr->publ.phdr;
80
81 if (likely(!msg_routed(m)))
82 return;
83 msg_set_transp_seqno(m, (msg_transp_seqno(m) + 1));
84} 70}
85 71
86/** 72/**
@@ -94,7 +80,7 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq,
94 struct sk_buff *buf; 80 struct sk_buff *buf;
95 struct sk_buff *ibuf = NULL; 81 struct sk_buff *ibuf = NULL;
96 struct port_list dports = {0, NULL, }; 82 struct port_list dports = {0, NULL, };
97 struct port *oport = tipc_port_deref(ref); 83 struct tipc_port *oport = tipc_port_deref(ref);
98 int ext_targets; 84 int ext_targets;
99 int res; 85 int res;
100 86
@@ -103,7 +89,7 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq,
103 89
104 /* Create multicast message */ 90 /* Create multicast message */
105 91
106 hdr = &oport->publ.phdr; 92 hdr = &oport->phdr;
107 msg_set_type(hdr, TIPC_MCAST_MSG); 93 msg_set_type(hdr, TIPC_MCAST_MSG);
108 msg_set_nametype(hdr, seq->type); 94 msg_set_nametype(hdr, seq->type);
109 msg_set_namelower(hdr, seq->lower); 95 msg_set_namelower(hdr, seq->lower);
@@ -211,7 +197,7 @@ struct tipc_port *tipc_createport_raw(void *usr_handle,
211 void (*wakeup)(struct tipc_port *), 197 void (*wakeup)(struct tipc_port *),
212 const u32 importance) 198 const u32 importance)
213{ 199{
214 struct port *p_ptr; 200 struct tipc_port *p_ptr;
215 struct tipc_msg *msg; 201 struct tipc_msg *msg;
216 u32 ref; 202 u32 ref;
217 203
@@ -220,21 +206,19 @@ struct tipc_port *tipc_createport_raw(void *usr_handle,
220 warn("Port creation failed, no memory\n"); 206 warn("Port creation failed, no memory\n");
221 return NULL; 207 return NULL;
222 } 208 }
223 ref = tipc_ref_acquire(p_ptr, &p_ptr->publ.lock); 209 ref = tipc_ref_acquire(p_ptr, &p_ptr->lock);
224 if (!ref) { 210 if (!ref) {
225 warn("Port creation failed, reference table exhausted\n"); 211 warn("Port creation failed, reference table exhausted\n");
226 kfree(p_ptr); 212 kfree(p_ptr);
227 return NULL; 213 return NULL;
228 } 214 }
229 215
230 p_ptr->publ.usr_handle = usr_handle; 216 p_ptr->usr_handle = usr_handle;
231 p_ptr->publ.max_pkt = MAX_PKT_DEFAULT; 217 p_ptr->max_pkt = MAX_PKT_DEFAULT;
232 p_ptr->publ.ref = ref; 218 p_ptr->ref = ref;
233 msg = &p_ptr->publ.phdr; 219 msg = &p_ptr->phdr;
234 tipc_msg_init(msg, importance, TIPC_NAMED_MSG, LONG_H_SIZE, 0); 220 tipc_msg_init(msg, importance, TIPC_NAMED_MSG, LONG_H_SIZE, 0);
235 msg_set_origport(msg, ref); 221 msg_set_origport(msg, ref);
236 p_ptr->last_in_seqno = 41;
237 p_ptr->sent = 1;
238 INIT_LIST_HEAD(&p_ptr->wait_list); 222 INIT_LIST_HEAD(&p_ptr->wait_list);
239 INIT_LIST_HEAD(&p_ptr->subscription.nodesub_list); 223 INIT_LIST_HEAD(&p_ptr->subscription.nodesub_list);
240 p_ptr->dispatcher = dispatcher; 224 p_ptr->dispatcher = dispatcher;
@@ -246,12 +230,12 @@ struct tipc_port *tipc_createport_raw(void *usr_handle,
246 INIT_LIST_HEAD(&p_ptr->port_list); 230 INIT_LIST_HEAD(&p_ptr->port_list);
247 list_add_tail(&p_ptr->port_list, &ports); 231 list_add_tail(&p_ptr->port_list, &ports);
248 spin_unlock_bh(&tipc_port_list_lock); 232 spin_unlock_bh(&tipc_port_list_lock);
249 return &(p_ptr->publ); 233 return p_ptr;
250} 234}
251 235
252int tipc_deleteport(u32 ref) 236int tipc_deleteport(u32 ref)
253{ 237{
254 struct port *p_ptr; 238 struct tipc_port *p_ptr;
255 struct sk_buff *buf = NULL; 239 struct sk_buff *buf = NULL;
256 240
257 tipc_withdraw(ref, 0, NULL); 241 tipc_withdraw(ref, 0, NULL);
@@ -263,7 +247,7 @@ int tipc_deleteport(u32 ref)
263 tipc_port_unlock(p_ptr); 247 tipc_port_unlock(p_ptr);
264 248
265 k_cancel_timer(&p_ptr->timer); 249 k_cancel_timer(&p_ptr->timer);
266 if (p_ptr->publ.connected) { 250 if (p_ptr->connected) {
267 buf = port_build_peer_abort_msg(p_ptr, TIPC_ERR_NO_PORT); 251 buf = port_build_peer_abort_msg(p_ptr, TIPC_ERR_NO_PORT);
268 tipc_nodesub_unsubscribe(&p_ptr->subscription); 252 tipc_nodesub_unsubscribe(&p_ptr->subscription);
269 } 253 }
@@ -279,14 +263,14 @@ int tipc_deleteport(u32 ref)
279 return 0; 263 return 0;
280} 264}
281 265
282static int port_unreliable(struct port *p_ptr) 266static int port_unreliable(struct tipc_port *p_ptr)
283{ 267{
284 return msg_src_droppable(&p_ptr->publ.phdr); 268 return msg_src_droppable(&p_ptr->phdr);
285} 269}
286 270
287int tipc_portunreliable(u32 ref, unsigned int *isunreliable) 271int tipc_portunreliable(u32 ref, unsigned int *isunreliable)
288{ 272{
289 struct port *p_ptr; 273 struct tipc_port *p_ptr;
290 274
291 p_ptr = tipc_port_lock(ref); 275 p_ptr = tipc_port_lock(ref);
292 if (!p_ptr) 276 if (!p_ptr)
@@ -298,24 +282,24 @@ int tipc_portunreliable(u32 ref, unsigned int *isunreliable)
298 282
299int tipc_set_portunreliable(u32 ref, unsigned int isunreliable) 283int tipc_set_portunreliable(u32 ref, unsigned int isunreliable)
300{ 284{
301 struct port *p_ptr; 285 struct tipc_port *p_ptr;
302 286
303 p_ptr = tipc_port_lock(ref); 287 p_ptr = tipc_port_lock(ref);
304 if (!p_ptr) 288 if (!p_ptr)
305 return -EINVAL; 289 return -EINVAL;
306 msg_set_src_droppable(&p_ptr->publ.phdr, (isunreliable != 0)); 290 msg_set_src_droppable(&p_ptr->phdr, (isunreliable != 0));
307 tipc_port_unlock(p_ptr); 291 tipc_port_unlock(p_ptr);
308 return 0; 292 return 0;
309} 293}
310 294
311static int port_unreturnable(struct port *p_ptr) 295static int port_unreturnable(struct tipc_port *p_ptr)
312{ 296{
313 return msg_dest_droppable(&p_ptr->publ.phdr); 297 return msg_dest_droppable(&p_ptr->phdr);
314} 298}
315 299
316int tipc_portunreturnable(u32 ref, unsigned int *isunrejectable) 300int tipc_portunreturnable(u32 ref, unsigned int *isunrejectable)
317{ 301{
318 struct port *p_ptr; 302 struct tipc_port *p_ptr;
319 303
320 p_ptr = tipc_port_lock(ref); 304 p_ptr = tipc_port_lock(ref);
321 if (!p_ptr) 305 if (!p_ptr)
@@ -327,12 +311,12 @@ int tipc_portunreturnable(u32 ref, unsigned int *isunrejectable)
327 311
328int tipc_set_portunreturnable(u32 ref, unsigned int isunrejectable) 312int tipc_set_portunreturnable(u32 ref, unsigned int isunrejectable)
329{ 313{
330 struct port *p_ptr; 314 struct tipc_port *p_ptr;
331 315
332 p_ptr = tipc_port_lock(ref); 316 p_ptr = tipc_port_lock(ref);
333 if (!p_ptr) 317 if (!p_ptr)
334 return -EINVAL; 318 return -EINVAL;
335 msg_set_dest_droppable(&p_ptr->publ.phdr, (isunrejectable != 0)); 319 msg_set_dest_droppable(&p_ptr->phdr, (isunrejectable != 0));
336 tipc_port_unlock(p_ptr); 320 tipc_port_unlock(p_ptr);
337 return 0; 321 return 0;
338} 322}
@@ -345,7 +329,7 @@ int tipc_set_portunreturnable(u32 ref, unsigned int isunrejectable)
345static struct sk_buff *port_build_proto_msg(u32 destport, u32 destnode, 329static struct sk_buff *port_build_proto_msg(u32 destport, u32 destnode,
346 u32 origport, u32 orignode, 330 u32 origport, u32 orignode,
347 u32 usr, u32 type, u32 err, 331 u32 usr, u32 type, u32 err,
348 u32 seqno, u32 ack) 332 u32 ack)
349{ 333{
350 struct sk_buff *buf; 334 struct sk_buff *buf;
351 struct tipc_msg *msg; 335 struct tipc_msg *msg;
@@ -358,7 +342,6 @@ static struct sk_buff *port_build_proto_msg(u32 destport, u32 destnode,
358 msg_set_destport(msg, destport); 342 msg_set_destport(msg, destport);
359 msg_set_origport(msg, origport); 343 msg_set_origport(msg, origport);
360 msg_set_orignode(msg, orignode); 344 msg_set_orignode(msg, orignode);
361 msg_set_transp_seqno(msg, seqno);
362 msg_set_msgcnt(msg, ack); 345 msg_set_msgcnt(msg, ack);
363 } 346 }
364 return buf; 347 return buf;
@@ -413,10 +396,10 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err)
413 /* send self-abort message when rejecting on a connected port */ 396 /* send self-abort message when rejecting on a connected port */
414 if (msg_connected(msg)) { 397 if (msg_connected(msg)) {
415 struct sk_buff *abuf = NULL; 398 struct sk_buff *abuf = NULL;
416 struct port *p_ptr = tipc_port_lock(msg_destport(msg)); 399 struct tipc_port *p_ptr = tipc_port_lock(msg_destport(msg));
417 400
418 if (p_ptr) { 401 if (p_ptr) {
419 if (p_ptr->publ.connected) 402 if (p_ptr->connected)
420 abuf = port_build_self_abort_msg(p_ptr, err); 403 abuf = port_build_self_abort_msg(p_ptr, err);
421 tipc_port_unlock(p_ptr); 404 tipc_port_unlock(p_ptr);
422 } 405 }
@@ -429,7 +412,7 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err)
429 return data_sz; 412 return data_sz;
430} 413}
431 414
432int tipc_port_reject_sections(struct port *p_ptr, struct tipc_msg *hdr, 415int tipc_port_reject_sections(struct tipc_port *p_ptr, struct tipc_msg *hdr,
433 struct iovec const *msg_sect, u32 num_sect, 416 struct iovec const *msg_sect, u32 num_sect,
434 int err) 417 int err)
435{ 418{
@@ -446,13 +429,13 @@ int tipc_port_reject_sections(struct port *p_ptr, struct tipc_msg *hdr,
446 429
447static void port_timeout(unsigned long ref) 430static void port_timeout(unsigned long ref)
448{ 431{
449 struct port *p_ptr = tipc_port_lock(ref); 432 struct tipc_port *p_ptr = tipc_port_lock(ref);
450 struct sk_buff *buf = NULL; 433 struct sk_buff *buf = NULL;
451 434
452 if (!p_ptr) 435 if (!p_ptr)
453 return; 436 return;
454 437
455 if (!p_ptr->publ.connected) { 438 if (!p_ptr->connected) {
456 tipc_port_unlock(p_ptr); 439 tipc_port_unlock(p_ptr);
457 return; 440 return;
458 } 441 }
@@ -463,14 +446,12 @@ static void port_timeout(unsigned long ref)
463 } else { 446 } else {
464 buf = port_build_proto_msg(port_peerport(p_ptr), 447 buf = port_build_proto_msg(port_peerport(p_ptr),
465 port_peernode(p_ptr), 448 port_peernode(p_ptr),
466 p_ptr->publ.ref, 449 p_ptr->ref,
467 tipc_own_addr, 450 tipc_own_addr,
468 CONN_MANAGER, 451 CONN_MANAGER,
469 CONN_PROBE, 452 CONN_PROBE,
470 TIPC_OK, 453 TIPC_OK,
471 port_out_seqno(p_ptr),
472 0); 454 0);
473 port_incr_out_seqno(p_ptr);
474 p_ptr->probing_state = PROBING; 455 p_ptr->probing_state = PROBING;
475 k_start_timer(&p_ptr->timer, p_ptr->probing_interval); 456 k_start_timer(&p_ptr->timer, p_ptr->probing_interval);
476 } 457 }
@@ -481,7 +462,7 @@ static void port_timeout(unsigned long ref)
481 462
482static void port_handle_node_down(unsigned long ref) 463static void port_handle_node_down(unsigned long ref)
483{ 464{
484 struct port *p_ptr = tipc_port_lock(ref); 465 struct tipc_port *p_ptr = tipc_port_lock(ref);
485 struct sk_buff *buf = NULL; 466 struct sk_buff *buf = NULL;
486 467
487 if (!p_ptr) 468 if (!p_ptr)
@@ -492,73 +473,71 @@ static void port_handle_node_down(unsigned long ref)
492} 473}
493 474
494 475
495static struct sk_buff *port_build_self_abort_msg(struct port *p_ptr, u32 err) 476static struct sk_buff *port_build_self_abort_msg(struct tipc_port *p_ptr, u32 err)
496{ 477{
497 u32 imp = msg_importance(&p_ptr->publ.phdr); 478 u32 imp = msg_importance(&p_ptr->phdr);
498 479
499 if (!p_ptr->publ.connected) 480 if (!p_ptr->connected)
500 return NULL; 481 return NULL;
501 if (imp < TIPC_CRITICAL_IMPORTANCE) 482 if (imp < TIPC_CRITICAL_IMPORTANCE)
502 imp++; 483 imp++;
503 return port_build_proto_msg(p_ptr->publ.ref, 484 return port_build_proto_msg(p_ptr->ref,
504 tipc_own_addr, 485 tipc_own_addr,
505 port_peerport(p_ptr), 486 port_peerport(p_ptr),
506 port_peernode(p_ptr), 487 port_peernode(p_ptr),
507 imp, 488 imp,
508 TIPC_CONN_MSG, 489 TIPC_CONN_MSG,
509 err, 490 err,
510 p_ptr->last_in_seqno + 1,
511 0); 491 0);
512} 492}
513 493
514 494
515static struct sk_buff *port_build_peer_abort_msg(struct port *p_ptr, u32 err) 495static struct sk_buff *port_build_peer_abort_msg(struct tipc_port *p_ptr, u32 err)
516{ 496{
517 u32 imp = msg_importance(&p_ptr->publ.phdr); 497 u32 imp = msg_importance(&p_ptr->phdr);
518 498
519 if (!p_ptr->publ.connected) 499 if (!p_ptr->connected)
520 return NULL; 500 return NULL;
521 if (imp < TIPC_CRITICAL_IMPORTANCE) 501 if (imp < TIPC_CRITICAL_IMPORTANCE)
522 imp++; 502 imp++;
523 return port_build_proto_msg(port_peerport(p_ptr), 503 return port_build_proto_msg(port_peerport(p_ptr),
524 port_peernode(p_ptr), 504 port_peernode(p_ptr),
525 p_ptr->publ.ref, 505 p_ptr->ref,
526 tipc_own_addr, 506 tipc_own_addr,
527 imp, 507 imp,
528 TIPC_CONN_MSG, 508 TIPC_CONN_MSG,
529 err, 509 err,
530 port_out_seqno(p_ptr),
531 0); 510 0);
532} 511}
533 512
534void tipc_port_recv_proto_msg(struct sk_buff *buf) 513void tipc_port_recv_proto_msg(struct sk_buff *buf)
535{ 514{
536 struct tipc_msg *msg = buf_msg(buf); 515 struct tipc_msg *msg = buf_msg(buf);
537 struct port *p_ptr = tipc_port_lock(msg_destport(msg)); 516 struct tipc_port *p_ptr = tipc_port_lock(msg_destport(msg));
538 u32 err = TIPC_OK; 517 u32 err = TIPC_OK;
539 struct sk_buff *r_buf = NULL; 518 struct sk_buff *r_buf = NULL;
540 struct sk_buff *abort_buf = NULL; 519 struct sk_buff *abort_buf = NULL;
541 520
542 if (!p_ptr) { 521 if (!p_ptr) {
543 err = TIPC_ERR_NO_PORT; 522 err = TIPC_ERR_NO_PORT;
544 } else if (p_ptr->publ.connected) { 523 } else if (p_ptr->connected) {
545 if ((port_peernode(p_ptr) != msg_orignode(msg)) || 524 if ((port_peernode(p_ptr) != msg_orignode(msg)) ||
546 (port_peerport(p_ptr) != msg_origport(msg))) { 525 (port_peerport(p_ptr) != msg_origport(msg))) {
547 err = TIPC_ERR_NO_PORT; 526 err = TIPC_ERR_NO_PORT;
548 } else if (msg_type(msg) == CONN_ACK) { 527 } else if (msg_type(msg) == CONN_ACK) {
549 int wakeup = tipc_port_congested(p_ptr) && 528 int wakeup = tipc_port_congested(p_ptr) &&
550 p_ptr->publ.congested && 529 p_ptr->congested &&
551 p_ptr->wakeup; 530 p_ptr->wakeup;
552 p_ptr->acked += msg_msgcnt(msg); 531 p_ptr->acked += msg_msgcnt(msg);
553 if (tipc_port_congested(p_ptr)) 532 if (tipc_port_congested(p_ptr))
554 goto exit; 533 goto exit;
555 p_ptr->publ.congested = 0; 534 p_ptr->congested = 0;
556 if (!wakeup) 535 if (!wakeup)
557 goto exit; 536 goto exit;
558 p_ptr->wakeup(&p_ptr->publ); 537 p_ptr->wakeup(p_ptr);
559 goto exit; 538 goto exit;
560 } 539 }
561 } else if (p_ptr->publ.published) { 540 } else if (p_ptr->published) {
562 err = TIPC_ERR_NO_PORT; 541 err = TIPC_ERR_NO_PORT;
563 } 542 }
564 if (err) { 543 if (err) {
@@ -569,7 +548,6 @@ void tipc_port_recv_proto_msg(struct sk_buff *buf)
569 TIPC_HIGH_IMPORTANCE, 548 TIPC_HIGH_IMPORTANCE,
570 TIPC_CONN_MSG, 549 TIPC_CONN_MSG,
571 err, 550 err,
572 0,
573 0); 551 0);
574 goto exit; 552 goto exit;
575 } 553 }
@@ -583,11 +561,9 @@ void tipc_port_recv_proto_msg(struct sk_buff *buf)
583 CONN_MANAGER, 561 CONN_MANAGER,
584 CONN_PROBE_REPLY, 562 CONN_PROBE_REPLY,
585 TIPC_OK, 563 TIPC_OK,
586 port_out_seqno(p_ptr),
587 0); 564 0);
588 } 565 }
589 p_ptr->probing_state = CONFIRMED; 566 p_ptr->probing_state = CONFIRMED;
590 port_incr_out_seqno(p_ptr);
591exit: 567exit:
592 if (p_ptr) 568 if (p_ptr)
593 tipc_port_unlock(p_ptr); 569 tipc_port_unlock(p_ptr);
@@ -596,29 +572,29 @@ exit:
596 buf_discard(buf); 572 buf_discard(buf);
597} 573}
598 574
599static void port_print(struct port *p_ptr, struct print_buf *buf, int full_id) 575static void port_print(struct tipc_port *p_ptr, struct print_buf *buf, int full_id)
600{ 576{
601 struct publication *publ; 577 struct publication *publ;
602 578
603 if (full_id) 579 if (full_id)
604 tipc_printf(buf, "<%u.%u.%u:%u>:", 580 tipc_printf(buf, "<%u.%u.%u:%u>:",
605 tipc_zone(tipc_own_addr), tipc_cluster(tipc_own_addr), 581 tipc_zone(tipc_own_addr), tipc_cluster(tipc_own_addr),
606 tipc_node(tipc_own_addr), p_ptr->publ.ref); 582 tipc_node(tipc_own_addr), p_ptr->ref);
607 else 583 else
608 tipc_printf(buf, "%-10u:", p_ptr->publ.ref); 584 tipc_printf(buf, "%-10u:", p_ptr->ref);
609 585
610 if (p_ptr->publ.connected) { 586 if (p_ptr->connected) {
611 u32 dport = port_peerport(p_ptr); 587 u32 dport = port_peerport(p_ptr);
612 u32 destnode = port_peernode(p_ptr); 588 u32 destnode = port_peernode(p_ptr);
613 589
614 tipc_printf(buf, " connected to <%u.%u.%u:%u>", 590 tipc_printf(buf, " connected to <%u.%u.%u:%u>",
615 tipc_zone(destnode), tipc_cluster(destnode), 591 tipc_zone(destnode), tipc_cluster(destnode),
616 tipc_node(destnode), dport); 592 tipc_node(destnode), dport);
617 if (p_ptr->publ.conn_type != 0) 593 if (p_ptr->conn_type != 0)
618 tipc_printf(buf, " via {%u,%u}", 594 tipc_printf(buf, " via {%u,%u}",
619 p_ptr->publ.conn_type, 595 p_ptr->conn_type,
620 p_ptr->publ.conn_instance); 596 p_ptr->conn_instance);
621 } else if (p_ptr->publ.published) { 597 } else if (p_ptr->published) {
622 tipc_printf(buf, " bound to"); 598 tipc_printf(buf, " bound to");
623 list_for_each_entry(publ, &p_ptr->publications, pport_list) { 599 list_for_each_entry(publ, &p_ptr->publications, pport_list) {
624 if (publ->lower == publ->upper) 600 if (publ->lower == publ->upper)
@@ -639,7 +615,7 @@ struct sk_buff *tipc_port_get_ports(void)
639 struct sk_buff *buf; 615 struct sk_buff *buf;
640 struct tlv_desc *rep_tlv; 616 struct tlv_desc *rep_tlv;
641 struct print_buf pb; 617 struct print_buf pb;
642 struct port *p_ptr; 618 struct tipc_port *p_ptr;
643 int str_len; 619 int str_len;
644 620
645 buf = tipc_cfg_reply_alloc(TLV_SPACE(MAX_PORT_QUERY)); 621 buf = tipc_cfg_reply_alloc(TLV_SPACE(MAX_PORT_QUERY));
@@ -650,9 +626,9 @@ struct sk_buff *tipc_port_get_ports(void)
650 tipc_printbuf_init(&pb, TLV_DATA(rep_tlv), MAX_PORT_QUERY); 626 tipc_printbuf_init(&pb, TLV_DATA(rep_tlv), MAX_PORT_QUERY);
651 spin_lock_bh(&tipc_port_list_lock); 627 spin_lock_bh(&tipc_port_list_lock);
652 list_for_each_entry(p_ptr, &ports, port_list) { 628 list_for_each_entry(p_ptr, &ports, port_list) {
653 spin_lock_bh(p_ptr->publ.lock); 629 spin_lock_bh(p_ptr->lock);
654 port_print(p_ptr, &pb, 0); 630 port_print(p_ptr, &pb, 0);
655 spin_unlock_bh(p_ptr->publ.lock); 631 spin_unlock_bh(p_ptr->lock);
656 } 632 }
657 spin_unlock_bh(&tipc_port_list_lock); 633 spin_unlock_bh(&tipc_port_list_lock);
658 str_len = tipc_printbuf_validate(&pb); 634 str_len = tipc_printbuf_validate(&pb);
@@ -665,12 +641,12 @@ struct sk_buff *tipc_port_get_ports(void)
665 641
666void tipc_port_reinit(void) 642void tipc_port_reinit(void)
667{ 643{
668 struct port *p_ptr; 644 struct tipc_port *p_ptr;
669 struct tipc_msg *msg; 645 struct tipc_msg *msg;
670 646
671 spin_lock_bh(&tipc_port_list_lock); 647 spin_lock_bh(&tipc_port_list_lock);
672 list_for_each_entry(p_ptr, &ports, port_list) { 648 list_for_each_entry(p_ptr, &ports, port_list) {
673 msg = &p_ptr->publ.phdr; 649 msg = &p_ptr->phdr;
674 if (msg_orignode(msg) == tipc_own_addr) 650 if (msg_orignode(msg) == tipc_own_addr)
675 break; 651 break;
676 msg_set_prevnode(msg, tipc_own_addr); 652 msg_set_prevnode(msg, tipc_own_addr);
@@ -695,7 +671,7 @@ static void port_dispatcher_sigh(void *dummy)
695 spin_unlock_bh(&queue_lock); 671 spin_unlock_bh(&queue_lock);
696 672
697 while (buf) { 673 while (buf) {
698 struct port *p_ptr; 674 struct tipc_port *p_ptr;
699 struct user_port *up_ptr; 675 struct user_port *up_ptr;
700 struct tipc_portid orig; 676 struct tipc_portid orig;
701 struct tipc_name_seq dseq; 677 struct tipc_name_seq dseq;
@@ -720,8 +696,8 @@ static void port_dispatcher_sigh(void *dummy)
720 orig.node = msg_orignode(msg); 696 orig.node = msg_orignode(msg);
721 up_ptr = p_ptr->user_port; 697 up_ptr = p_ptr->user_port;
722 usr_handle = up_ptr->usr_handle; 698 usr_handle = up_ptr->usr_handle;
723 connected = p_ptr->publ.connected; 699 connected = p_ptr->connected;
724 published = p_ptr->publ.published; 700 published = p_ptr->published;
725 701
726 if (unlikely(msg_errcode(msg))) 702 if (unlikely(msg_errcode(msg)))
727 goto err; 703 goto err;
@@ -732,6 +708,7 @@ static void port_dispatcher_sigh(void *dummy)
732 tipc_conn_msg_event cb = up_ptr->conn_msg_cb; 708 tipc_conn_msg_event cb = up_ptr->conn_msg_cb;
733 u32 peer_port = port_peerport(p_ptr); 709 u32 peer_port = port_peerport(p_ptr);
734 u32 peer_node = port_peernode(p_ptr); 710 u32 peer_node = port_peernode(p_ptr);
711 u32 dsz;
735 712
736 tipc_port_unlock(p_ptr); 713 tipc_port_unlock(p_ptr);
737 if (unlikely(!cb)) 714 if (unlikely(!cb))
@@ -742,13 +719,14 @@ static void port_dispatcher_sigh(void *dummy)
742 } else if ((msg_origport(msg) != peer_port) || 719 } else if ((msg_origport(msg) != peer_port) ||
743 (msg_orignode(msg) != peer_node)) 720 (msg_orignode(msg) != peer_node))
744 goto reject; 721 goto reject;
745 if (unlikely(++p_ptr->publ.conn_unacked >= 722 dsz = msg_data_sz(msg);
746 TIPC_FLOW_CONTROL_WIN)) 723 if (unlikely(dsz &&
724 (++p_ptr->conn_unacked >=
725 TIPC_FLOW_CONTROL_WIN)))
747 tipc_acknowledge(dref, 726 tipc_acknowledge(dref,
748 p_ptr->publ.conn_unacked); 727 p_ptr->conn_unacked);
749 skb_pull(buf, msg_hdr_sz(msg)); 728 skb_pull(buf, msg_hdr_sz(msg));
750 cb(usr_handle, dref, &buf, msg_data(msg), 729 cb(usr_handle, dref, &buf, msg_data(msg), dsz);
751 msg_data_sz(msg));
752 break; 730 break;
753 } 731 }
754 case TIPC_DIRECT_MSG:{ 732 case TIPC_DIRECT_MSG:{
@@ -872,7 +850,7 @@ static u32 port_dispatcher(struct tipc_port *dummy, struct sk_buff *buf)
872 850
873static void port_wakeup_sh(unsigned long ref) 851static void port_wakeup_sh(unsigned long ref)
874{ 852{
875 struct port *p_ptr; 853 struct tipc_port *p_ptr;
876 struct user_port *up_ptr; 854 struct user_port *up_ptr;
877 tipc_continue_event cb = NULL; 855 tipc_continue_event cb = NULL;
878 void *uh = NULL; 856 void *uh = NULL;
@@ -898,14 +876,14 @@ static void port_wakeup(struct tipc_port *p_ptr)
898 876
899void tipc_acknowledge(u32 ref, u32 ack) 877void tipc_acknowledge(u32 ref, u32 ack)
900{ 878{
901 struct port *p_ptr; 879 struct tipc_port *p_ptr;
902 struct sk_buff *buf = NULL; 880 struct sk_buff *buf = NULL;
903 881
904 p_ptr = tipc_port_lock(ref); 882 p_ptr = tipc_port_lock(ref);
905 if (!p_ptr) 883 if (!p_ptr)
906 return; 884 return;
907 if (p_ptr->publ.connected) { 885 if (p_ptr->connected) {
908 p_ptr->publ.conn_unacked -= ack; 886 p_ptr->conn_unacked -= ack;
909 buf = port_build_proto_msg(port_peerport(p_ptr), 887 buf = port_build_proto_msg(port_peerport(p_ptr),
910 port_peernode(p_ptr), 888 port_peernode(p_ptr),
911 ref, 889 ref,
@@ -913,7 +891,6 @@ void tipc_acknowledge(u32 ref, u32 ack)
913 CONN_MANAGER, 891 CONN_MANAGER,
914 CONN_ACK, 892 CONN_ACK,
915 TIPC_OK, 893 TIPC_OK,
916 port_out_seqno(p_ptr),
917 ack); 894 ack);
918 } 895 }
919 tipc_port_unlock(p_ptr); 896 tipc_port_unlock(p_ptr);
@@ -936,14 +913,14 @@ int tipc_createport(void *usr_handle,
936 u32 *portref) 913 u32 *portref)
937{ 914{
938 struct user_port *up_ptr; 915 struct user_port *up_ptr;
939 struct port *p_ptr; 916 struct tipc_port *p_ptr;
940 917
941 up_ptr = kmalloc(sizeof(*up_ptr), GFP_ATOMIC); 918 up_ptr = kmalloc(sizeof(*up_ptr), GFP_ATOMIC);
942 if (!up_ptr) { 919 if (!up_ptr) {
943 warn("Port creation failed, no memory\n"); 920 warn("Port creation failed, no memory\n");
944 return -ENOMEM; 921 return -ENOMEM;
945 } 922 }
946 p_ptr = (struct port *)tipc_createport_raw(NULL, port_dispatcher, 923 p_ptr = (struct tipc_port *)tipc_createport_raw(NULL, port_dispatcher,
947 port_wakeup, importance); 924 port_wakeup, importance);
948 if (!p_ptr) { 925 if (!p_ptr) {
949 kfree(up_ptr); 926 kfree(up_ptr);
@@ -952,7 +929,7 @@ int tipc_createport(void *usr_handle,
952 929
953 p_ptr->user_port = up_ptr; 930 p_ptr->user_port = up_ptr;
954 up_ptr->usr_handle = usr_handle; 931 up_ptr->usr_handle = usr_handle;
955 up_ptr->ref = p_ptr->publ.ref; 932 up_ptr->ref = p_ptr->ref;
956 up_ptr->err_cb = error_cb; 933 up_ptr->err_cb = error_cb;
957 up_ptr->named_err_cb = named_error_cb; 934 up_ptr->named_err_cb = named_error_cb;
958 up_ptr->conn_err_cb = conn_error_cb; 935 up_ptr->conn_err_cb = conn_error_cb;
@@ -960,26 +937,26 @@ int tipc_createport(void *usr_handle,
960 up_ptr->named_msg_cb = named_msg_cb; 937 up_ptr->named_msg_cb = named_msg_cb;
961 up_ptr->conn_msg_cb = conn_msg_cb; 938 up_ptr->conn_msg_cb = conn_msg_cb;
962 up_ptr->continue_event_cb = continue_event_cb; 939 up_ptr->continue_event_cb = continue_event_cb;
963 *portref = p_ptr->publ.ref; 940 *portref = p_ptr->ref;
964 tipc_port_unlock(p_ptr); 941 tipc_port_unlock(p_ptr);
965 return 0; 942 return 0;
966} 943}
967 944
968int tipc_portimportance(u32 ref, unsigned int *importance) 945int tipc_portimportance(u32 ref, unsigned int *importance)
969{ 946{
970 struct port *p_ptr; 947 struct tipc_port *p_ptr;
971 948
972 p_ptr = tipc_port_lock(ref); 949 p_ptr = tipc_port_lock(ref);
973 if (!p_ptr) 950 if (!p_ptr)
974 return -EINVAL; 951 return -EINVAL;
975 *importance = (unsigned int)msg_importance(&p_ptr->publ.phdr); 952 *importance = (unsigned int)msg_importance(&p_ptr->phdr);
976 tipc_port_unlock(p_ptr); 953 tipc_port_unlock(p_ptr);
977 return 0; 954 return 0;
978} 955}
979 956
980int tipc_set_portimportance(u32 ref, unsigned int imp) 957int tipc_set_portimportance(u32 ref, unsigned int imp)
981{ 958{
982 struct port *p_ptr; 959 struct tipc_port *p_ptr;
983 960
984 if (imp > TIPC_CRITICAL_IMPORTANCE) 961 if (imp > TIPC_CRITICAL_IMPORTANCE)
985 return -EINVAL; 962 return -EINVAL;
@@ -987,7 +964,7 @@ int tipc_set_portimportance(u32 ref, unsigned int imp)
987 p_ptr = tipc_port_lock(ref); 964 p_ptr = tipc_port_lock(ref);
988 if (!p_ptr) 965 if (!p_ptr)
989 return -EINVAL; 966 return -EINVAL;
990 msg_set_importance(&p_ptr->publ.phdr, (u32)imp); 967 msg_set_importance(&p_ptr->phdr, (u32)imp);
991 tipc_port_unlock(p_ptr); 968 tipc_port_unlock(p_ptr);
992 return 0; 969 return 0;
993} 970}
@@ -995,7 +972,7 @@ int tipc_set_portimportance(u32 ref, unsigned int imp)
995 972
996int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq) 973int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
997{ 974{
998 struct port *p_ptr; 975 struct tipc_port *p_ptr;
999 struct publication *publ; 976 struct publication *publ;
1000 u32 key; 977 u32 key;
1001 int res = -EINVAL; 978 int res = -EINVAL;
@@ -1004,7 +981,7 @@ int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
1004 if (!p_ptr) 981 if (!p_ptr)
1005 return -EINVAL; 982 return -EINVAL;
1006 983
1007 if (p_ptr->publ.connected) 984 if (p_ptr->connected)
1008 goto exit; 985 goto exit;
1009 if (seq->lower > seq->upper) 986 if (seq->lower > seq->upper)
1010 goto exit; 987 goto exit;
@@ -1016,11 +993,11 @@ int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
1016 goto exit; 993 goto exit;
1017 } 994 }
1018 publ = tipc_nametbl_publish(seq->type, seq->lower, seq->upper, 995 publ = tipc_nametbl_publish(seq->type, seq->lower, seq->upper,
1019 scope, p_ptr->publ.ref, key); 996 scope, p_ptr->ref, key);
1020 if (publ) { 997 if (publ) {
1021 list_add(&publ->pport_list, &p_ptr->publications); 998 list_add(&publ->pport_list, &p_ptr->publications);
1022 p_ptr->pub_count++; 999 p_ptr->pub_count++;
1023 p_ptr->publ.published = 1; 1000 p_ptr->published = 1;
1024 res = 0; 1001 res = 0;
1025 } 1002 }
1026exit: 1003exit:
@@ -1030,7 +1007,7 @@ exit:
1030 1007
1031int tipc_withdraw(u32 ref, unsigned int scope, struct tipc_name_seq const *seq) 1008int tipc_withdraw(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
1032{ 1009{
1033 struct port *p_ptr; 1010 struct tipc_port *p_ptr;
1034 struct publication *publ; 1011 struct publication *publ;
1035 struct publication *tpubl; 1012 struct publication *tpubl;
1036 int res = -EINVAL; 1013 int res = -EINVAL;
@@ -1063,37 +1040,36 @@ int tipc_withdraw(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
1063 } 1040 }
1064 } 1041 }
1065 if (list_empty(&p_ptr->publications)) 1042 if (list_empty(&p_ptr->publications))
1066 p_ptr->publ.published = 0; 1043 p_ptr->published = 0;
1067 tipc_port_unlock(p_ptr); 1044 tipc_port_unlock(p_ptr);
1068 return res; 1045 return res;
1069} 1046}
1070 1047
1071int tipc_connect2port(u32 ref, struct tipc_portid const *peer) 1048int tipc_connect2port(u32 ref, struct tipc_portid const *peer)
1072{ 1049{
1073 struct port *p_ptr; 1050 struct tipc_port *p_ptr;
1074 struct tipc_msg *msg; 1051 struct tipc_msg *msg;
1075 int res = -EINVAL; 1052 int res = -EINVAL;
1076 1053
1077 p_ptr = tipc_port_lock(ref); 1054 p_ptr = tipc_port_lock(ref);
1078 if (!p_ptr) 1055 if (!p_ptr)
1079 return -EINVAL; 1056 return -EINVAL;
1080 if (p_ptr->publ.published || p_ptr->publ.connected) 1057 if (p_ptr->published || p_ptr->connected)
1081 goto exit; 1058 goto exit;
1082 if (!peer->ref) 1059 if (!peer->ref)
1083 goto exit; 1060 goto exit;
1084 1061
1085 msg = &p_ptr->publ.phdr; 1062 msg = &p_ptr->phdr;
1086 msg_set_destnode(msg, peer->node); 1063 msg_set_destnode(msg, peer->node);
1087 msg_set_destport(msg, peer->ref); 1064 msg_set_destport(msg, peer->ref);
1088 msg_set_orignode(msg, tipc_own_addr); 1065 msg_set_orignode(msg, tipc_own_addr);
1089 msg_set_origport(msg, p_ptr->publ.ref); 1066 msg_set_origport(msg, p_ptr->ref);
1090 msg_set_transp_seqno(msg, 42);
1091 msg_set_type(msg, TIPC_CONN_MSG); 1067 msg_set_type(msg, TIPC_CONN_MSG);
1092 msg_set_hdr_sz(msg, SHORT_H_SIZE); 1068 msg_set_hdr_sz(msg, SHORT_H_SIZE);
1093 1069
1094 p_ptr->probing_interval = PROBING_INTERVAL; 1070 p_ptr->probing_interval = PROBING_INTERVAL;
1095 p_ptr->probing_state = CONFIRMED; 1071 p_ptr->probing_state = CONFIRMED;
1096 p_ptr->publ.connected = 1; 1072 p_ptr->connected = 1;
1097 k_start_timer(&p_ptr->timer, p_ptr->probing_interval); 1073 k_start_timer(&p_ptr->timer, p_ptr->probing_interval);
1098 1074
1099 tipc_nodesub_subscribe(&p_ptr->subscription, peer->node, 1075 tipc_nodesub_subscribe(&p_ptr->subscription, peer->node,
@@ -1102,7 +1078,7 @@ int tipc_connect2port(u32 ref, struct tipc_portid const *peer)
1102 res = 0; 1078 res = 0;
1103exit: 1079exit:
1104 tipc_port_unlock(p_ptr); 1080 tipc_port_unlock(p_ptr);
1105 p_ptr->publ.max_pkt = tipc_link_get_max_pkt(peer->node, ref); 1081 p_ptr->max_pkt = tipc_link_get_max_pkt(peer->node, ref);
1106 return res; 1082 return res;
1107} 1083}
1108 1084
@@ -1120,7 +1096,7 @@ int tipc_disconnect_port(struct tipc_port *tp_ptr)
1120 tp_ptr->connected = 0; 1096 tp_ptr->connected = 0;
1121 /* let timer expire on it's own to avoid deadlock! */ 1097 /* let timer expire on it's own to avoid deadlock! */
1122 tipc_nodesub_unsubscribe( 1098 tipc_nodesub_unsubscribe(
1123 &((struct port *)tp_ptr)->subscription); 1099 &((struct tipc_port *)tp_ptr)->subscription);
1124 res = 0; 1100 res = 0;
1125 } else { 1101 } else {
1126 res = -ENOTCONN; 1102 res = -ENOTCONN;
@@ -1135,7 +1111,7 @@ int tipc_disconnect_port(struct tipc_port *tp_ptr)
1135 1111
1136int tipc_disconnect(u32 ref) 1112int tipc_disconnect(u32 ref)
1137{ 1113{
1138 struct port *p_ptr; 1114 struct tipc_port *p_ptr;
1139 int res; 1115 int res;
1140 1116
1141 p_ptr = tipc_port_lock(ref); 1117 p_ptr = tipc_port_lock(ref);
@@ -1151,15 +1127,15 @@ int tipc_disconnect(u32 ref)
1151 */ 1127 */
1152int tipc_shutdown(u32 ref) 1128int tipc_shutdown(u32 ref)
1153{ 1129{
1154 struct port *p_ptr; 1130 struct tipc_port *p_ptr;
1155 struct sk_buff *buf = NULL; 1131 struct sk_buff *buf = NULL;
1156 1132
1157 p_ptr = tipc_port_lock(ref); 1133 p_ptr = tipc_port_lock(ref);
1158 if (!p_ptr) 1134 if (!p_ptr)
1159 return -EINVAL; 1135 return -EINVAL;
1160 1136
1161 if (p_ptr->publ.connected) { 1137 if (p_ptr->connected) {
1162 u32 imp = msg_importance(&p_ptr->publ.phdr); 1138 u32 imp = msg_importance(&p_ptr->phdr);
1163 if (imp < TIPC_CRITICAL_IMPORTANCE) 1139 if (imp < TIPC_CRITICAL_IMPORTANCE)
1164 imp++; 1140 imp++;
1165 buf = port_build_proto_msg(port_peerport(p_ptr), 1141 buf = port_build_proto_msg(port_peerport(p_ptr),
@@ -1169,7 +1145,6 @@ int tipc_shutdown(u32 ref)
1169 imp, 1145 imp,
1170 TIPC_CONN_MSG, 1146 TIPC_CONN_MSG,
1171 TIPC_CONN_SHUTDOWN, 1147 TIPC_CONN_SHUTDOWN,
1172 port_out_seqno(p_ptr),
1173 0); 1148 0);
1174 } 1149 }
1175 tipc_port_unlock(p_ptr); 1150 tipc_port_unlock(p_ptr);
@@ -1182,13 +1157,13 @@ int tipc_shutdown(u32 ref)
1182 * message for this node. 1157 * message for this node.
1183 */ 1158 */
1184 1159
1185static int tipc_port_recv_sections(struct port *sender, unsigned int num_sect, 1160static int tipc_port_recv_sections(struct tipc_port *sender, unsigned int num_sect,
1186 struct iovec const *msg_sect) 1161 struct iovec const *msg_sect)
1187{ 1162{
1188 struct sk_buff *buf; 1163 struct sk_buff *buf;
1189 int res; 1164 int res;
1190 1165
1191 res = tipc_msg_build(&sender->publ.phdr, msg_sect, num_sect, 1166 res = tipc_msg_build(&sender->phdr, msg_sect, num_sect,
1192 MAX_MSG_SIZE, !sender->user_port, &buf); 1167 MAX_MSG_SIZE, !sender->user_port, &buf);
1193 if (likely(buf)) 1168 if (likely(buf))
1194 tipc_port_recv_msg(buf); 1169 tipc_port_recv_msg(buf);
@@ -1201,15 +1176,15 @@ static int tipc_port_recv_sections(struct port *sender, unsigned int num_sect,
1201 1176
1202int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect) 1177int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect)
1203{ 1178{
1204 struct port *p_ptr; 1179 struct tipc_port *p_ptr;
1205 u32 destnode; 1180 u32 destnode;
1206 int res; 1181 int res;
1207 1182
1208 p_ptr = tipc_port_deref(ref); 1183 p_ptr = tipc_port_deref(ref);
1209 if (!p_ptr || !p_ptr->publ.connected) 1184 if (!p_ptr || !p_ptr->connected)
1210 return -EINVAL; 1185 return -EINVAL;
1211 1186
1212 p_ptr->publ.congested = 1; 1187 p_ptr->congested = 1;
1213 if (!tipc_port_congested(p_ptr)) { 1188 if (!tipc_port_congested(p_ptr)) {
1214 destnode = port_peernode(p_ptr); 1189 destnode = port_peernode(p_ptr);
1215 if (likely(destnode != tipc_own_addr)) 1190 if (likely(destnode != tipc_own_addr))
@@ -1219,14 +1194,14 @@ int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect)
1219 res = tipc_port_recv_sections(p_ptr, num_sect, msg_sect); 1194 res = tipc_port_recv_sections(p_ptr, num_sect, msg_sect);
1220 1195
1221 if (likely(res != -ELINKCONG)) { 1196 if (likely(res != -ELINKCONG)) {
1222 port_incr_out_seqno(p_ptr); 1197 p_ptr->congested = 0;
1223 p_ptr->publ.congested = 0; 1198 if (res > 0)
1224 p_ptr->sent++; 1199 p_ptr->sent++;
1225 return res; 1200 return res;
1226 } 1201 }
1227 } 1202 }
1228 if (port_unreliable(p_ptr)) { 1203 if (port_unreliable(p_ptr)) {
1229 p_ptr->publ.congested = 0; 1204 p_ptr->congested = 0;
1230 /* Just calculate msg length and return */ 1205 /* Just calculate msg length and return */
1231 return tipc_msg_calc_data_size(msg_sect, num_sect); 1206 return tipc_msg_calc_data_size(msg_sect, num_sect);
1232 } 1207 }
@@ -1240,17 +1215,17 @@ int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect)
1240int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain, 1215int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain,
1241 unsigned int num_sect, struct iovec const *msg_sect) 1216 unsigned int num_sect, struct iovec const *msg_sect)
1242{ 1217{
1243 struct port *p_ptr; 1218 struct tipc_port *p_ptr;
1244 struct tipc_msg *msg; 1219 struct tipc_msg *msg;
1245 u32 destnode = domain; 1220 u32 destnode = domain;
1246 u32 destport; 1221 u32 destport;
1247 int res; 1222 int res;
1248 1223
1249 p_ptr = tipc_port_deref(ref); 1224 p_ptr = tipc_port_deref(ref);
1250 if (!p_ptr || p_ptr->publ.connected) 1225 if (!p_ptr || p_ptr->connected)
1251 return -EINVAL; 1226 return -EINVAL;
1252 1227
1253 msg = &p_ptr->publ.phdr; 1228 msg = &p_ptr->phdr;
1254 msg_set_type(msg, TIPC_NAMED_MSG); 1229 msg_set_type(msg, TIPC_NAMED_MSG);
1255 msg_set_orignode(msg, tipc_own_addr); 1230 msg_set_orignode(msg, tipc_own_addr);
1256 msg_set_origport(msg, ref); 1231 msg_set_origport(msg, ref);
@@ -1263,13 +1238,17 @@ int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain,
1263 msg_set_destport(msg, destport); 1238 msg_set_destport(msg, destport);
1264 1239
1265 if (likely(destport)) { 1240 if (likely(destport)) {
1266 p_ptr->sent++;
1267 if (likely(destnode == tipc_own_addr)) 1241 if (likely(destnode == tipc_own_addr))
1268 return tipc_port_recv_sections(p_ptr, num_sect, msg_sect); 1242 res = tipc_port_recv_sections(p_ptr, num_sect,
1269 res = tipc_link_send_sections_fast(p_ptr, msg_sect, num_sect, 1243 msg_sect);
1270 destnode); 1244 else
1271 if (likely(res != -ELINKCONG)) 1245 res = tipc_link_send_sections_fast(p_ptr, msg_sect,
1246 num_sect, destnode);
1247 if (likely(res != -ELINKCONG)) {
1248 if (res > 0)
1249 p_ptr->sent++;
1272 return res; 1250 return res;
1251 }
1273 if (port_unreliable(p_ptr)) { 1252 if (port_unreliable(p_ptr)) {
1274 /* Just calculate msg length and return */ 1253 /* Just calculate msg length and return */
1275 return tipc_msg_calc_data_size(msg_sect, num_sect); 1254 return tipc_msg_calc_data_size(msg_sect, num_sect);
@@ -1287,27 +1266,32 @@ int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain,
1287int tipc_send2port(u32 ref, struct tipc_portid const *dest, 1266int tipc_send2port(u32 ref, struct tipc_portid const *dest,
1288 unsigned int num_sect, struct iovec const *msg_sect) 1267 unsigned int num_sect, struct iovec const *msg_sect)
1289{ 1268{
1290 struct port *p_ptr; 1269 struct tipc_port *p_ptr;
1291 struct tipc_msg *msg; 1270 struct tipc_msg *msg;
1292 int res; 1271 int res;
1293 1272
1294 p_ptr = tipc_port_deref(ref); 1273 p_ptr = tipc_port_deref(ref);
1295 if (!p_ptr || p_ptr->publ.connected) 1274 if (!p_ptr || p_ptr->connected)
1296 return -EINVAL; 1275 return -EINVAL;
1297 1276
1298 msg = &p_ptr->publ.phdr; 1277 msg = &p_ptr->phdr;
1299 msg_set_type(msg, TIPC_DIRECT_MSG); 1278 msg_set_type(msg, TIPC_DIRECT_MSG);
1300 msg_set_orignode(msg, tipc_own_addr); 1279 msg_set_orignode(msg, tipc_own_addr);
1301 msg_set_origport(msg, ref); 1280 msg_set_origport(msg, ref);
1302 msg_set_destnode(msg, dest->node); 1281 msg_set_destnode(msg, dest->node);
1303 msg_set_destport(msg, dest->ref); 1282 msg_set_destport(msg, dest->ref);
1304 msg_set_hdr_sz(msg, DIR_MSG_H_SIZE); 1283 msg_set_hdr_sz(msg, DIR_MSG_H_SIZE);
1305 p_ptr->sent++; 1284
1306 if (dest->node == tipc_own_addr) 1285 if (dest->node == tipc_own_addr)
1307 return tipc_port_recv_sections(p_ptr, num_sect, msg_sect); 1286 res = tipc_port_recv_sections(p_ptr, num_sect, msg_sect);
1308 res = tipc_link_send_sections_fast(p_ptr, msg_sect, num_sect, dest->node); 1287 else
1309 if (likely(res != -ELINKCONG)) 1288 res = tipc_link_send_sections_fast(p_ptr, msg_sect, num_sect,
1289 dest->node);
1290 if (likely(res != -ELINKCONG)) {
1291 if (res > 0)
1292 p_ptr->sent++;
1310 return res; 1293 return res;
1294 }
1311 if (port_unreliable(p_ptr)) { 1295 if (port_unreliable(p_ptr)) {
1312 /* Just calculate msg length and return */ 1296 /* Just calculate msg length and return */
1313 return tipc_msg_calc_data_size(msg_sect, num_sect); 1297 return tipc_msg_calc_data_size(msg_sect, num_sect);
@@ -1322,15 +1306,15 @@ int tipc_send2port(u32 ref, struct tipc_portid const *dest,
1322int tipc_send_buf2port(u32 ref, struct tipc_portid const *dest, 1306int tipc_send_buf2port(u32 ref, struct tipc_portid const *dest,
1323 struct sk_buff *buf, unsigned int dsz) 1307 struct sk_buff *buf, unsigned int dsz)
1324{ 1308{
1325 struct port *p_ptr; 1309 struct tipc_port *p_ptr;
1326 struct tipc_msg *msg; 1310 struct tipc_msg *msg;
1327 int res; 1311 int res;
1328 1312
1329 p_ptr = (struct port *)tipc_ref_deref(ref); 1313 p_ptr = (struct tipc_port *)tipc_ref_deref(ref);
1330 if (!p_ptr || p_ptr->publ.connected) 1314 if (!p_ptr || p_ptr->connected)
1331 return -EINVAL; 1315 return -EINVAL;
1332 1316
1333 msg = &p_ptr->publ.phdr; 1317 msg = &p_ptr->phdr;
1334 msg_set_type(msg, TIPC_DIRECT_MSG); 1318 msg_set_type(msg, TIPC_DIRECT_MSG);
1335 msg_set_orignode(msg, tipc_own_addr); 1319 msg_set_orignode(msg, tipc_own_addr);
1336 msg_set_origport(msg, ref); 1320 msg_set_origport(msg, ref);
@@ -1343,12 +1327,16 @@ int tipc_send_buf2port(u32 ref, struct tipc_portid const *dest,
1343 1327
1344 skb_push(buf, DIR_MSG_H_SIZE); 1328 skb_push(buf, DIR_MSG_H_SIZE);
1345 skb_copy_to_linear_data(buf, msg, DIR_MSG_H_SIZE); 1329 skb_copy_to_linear_data(buf, msg, DIR_MSG_H_SIZE);
1346 p_ptr->sent++; 1330
1347 if (dest->node == tipc_own_addr) 1331 if (dest->node == tipc_own_addr)
1348 return tipc_port_recv_msg(buf); 1332 res = tipc_port_recv_msg(buf);
1349 res = tipc_send_buf_fast(buf, dest->node); 1333 else
1350 if (likely(res != -ELINKCONG)) 1334 res = tipc_send_buf_fast(buf, dest->node);
1335 if (likely(res != -ELINKCONG)) {
1336 if (res > 0)
1337 p_ptr->sent++;
1351 return res; 1338 return res;
1339 }
1352 if (port_unreliable(p_ptr)) 1340 if (port_unreliable(p_ptr))
1353 return dsz; 1341 return dsz;
1354 return -ELINKCONG; 1342 return -ELINKCONG;