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.c234
1 files changed, 117 insertions, 117 deletions
diff --git a/net/tipc/port.c b/net/tipc/port.c
index 067bab2a0b98..aff5dc0c3773 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,29 +54,29 @@ 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} 70}
71 71
72static u32 port_out_seqno(struct port *p_ptr) 72static u32 port_out_seqno(struct tipc_port *p_ptr)
73{ 73{
74 return msg_transp_seqno(&p_ptr->publ.phdr); 74 return msg_transp_seqno(&p_ptr->phdr);
75} 75}
76 76
77static void port_incr_out_seqno(struct port *p_ptr) 77static void port_incr_out_seqno(struct tipc_port *p_ptr)
78{ 78{
79 struct tipc_msg *m = &p_ptr->publ.phdr; 79 struct tipc_msg *m = &p_ptr->phdr;
80 80
81 if (likely(!msg_routed(m))) 81 if (likely(!msg_routed(m)))
82 return; 82 return;
@@ -94,7 +94,7 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq,
94 struct sk_buff *buf; 94 struct sk_buff *buf;
95 struct sk_buff *ibuf = NULL; 95 struct sk_buff *ibuf = NULL;
96 struct port_list dports = {0, NULL, }; 96 struct port_list dports = {0, NULL, };
97 struct port *oport = tipc_port_deref(ref); 97 struct tipc_port *oport = tipc_port_deref(ref);
98 int ext_targets; 98 int ext_targets;
99 int res; 99 int res;
100 100
@@ -103,7 +103,7 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq,
103 103
104 /* Create multicast message */ 104 /* Create multicast message */
105 105
106 hdr = &oport->publ.phdr; 106 hdr = &oport->phdr;
107 msg_set_type(hdr, TIPC_MCAST_MSG); 107 msg_set_type(hdr, TIPC_MCAST_MSG);
108 msg_set_nametype(hdr, seq->type); 108 msg_set_nametype(hdr, seq->type);
109 msg_set_namelower(hdr, seq->lower); 109 msg_set_namelower(hdr, seq->lower);
@@ -211,7 +211,7 @@ struct tipc_port *tipc_createport_raw(void *usr_handle,
211 void (*wakeup)(struct tipc_port *), 211 void (*wakeup)(struct tipc_port *),
212 const u32 importance) 212 const u32 importance)
213{ 213{
214 struct port *p_ptr; 214 struct tipc_port *p_ptr;
215 struct tipc_msg *msg; 215 struct tipc_msg *msg;
216 u32 ref; 216 u32 ref;
217 217
@@ -220,17 +220,17 @@ struct tipc_port *tipc_createport_raw(void *usr_handle,
220 warn("Port creation failed, no memory\n"); 220 warn("Port creation failed, no memory\n");
221 return NULL; 221 return NULL;
222 } 222 }
223 ref = tipc_ref_acquire(p_ptr, &p_ptr->publ.lock); 223 ref = tipc_ref_acquire(p_ptr, &p_ptr->lock);
224 if (!ref) { 224 if (!ref) {
225 warn("Port creation failed, reference table exhausted\n"); 225 warn("Port creation failed, reference table exhausted\n");
226 kfree(p_ptr); 226 kfree(p_ptr);
227 return NULL; 227 return NULL;
228 } 228 }
229 229
230 p_ptr->publ.usr_handle = usr_handle; 230 p_ptr->usr_handle = usr_handle;
231 p_ptr->publ.max_pkt = MAX_PKT_DEFAULT; 231 p_ptr->max_pkt = MAX_PKT_DEFAULT;
232 p_ptr->publ.ref = ref; 232 p_ptr->ref = ref;
233 msg = &p_ptr->publ.phdr; 233 msg = &p_ptr->phdr;
234 tipc_msg_init(msg, importance, TIPC_NAMED_MSG, LONG_H_SIZE, 0); 234 tipc_msg_init(msg, importance, TIPC_NAMED_MSG, LONG_H_SIZE, 0);
235 msg_set_origport(msg, ref); 235 msg_set_origport(msg, ref);
236 p_ptr->last_in_seqno = 41; 236 p_ptr->last_in_seqno = 41;
@@ -246,12 +246,12 @@ struct tipc_port *tipc_createport_raw(void *usr_handle,
246 INIT_LIST_HEAD(&p_ptr->port_list); 246 INIT_LIST_HEAD(&p_ptr->port_list);
247 list_add_tail(&p_ptr->port_list, &ports); 247 list_add_tail(&p_ptr->port_list, &ports);
248 spin_unlock_bh(&tipc_port_list_lock); 248 spin_unlock_bh(&tipc_port_list_lock);
249 return &(p_ptr->publ); 249 return p_ptr;
250} 250}
251 251
252int tipc_deleteport(u32 ref) 252int tipc_deleteport(u32 ref)
253{ 253{
254 struct port *p_ptr; 254 struct tipc_port *p_ptr;
255 struct sk_buff *buf = NULL; 255 struct sk_buff *buf = NULL;
256 256
257 tipc_withdraw(ref, 0, NULL); 257 tipc_withdraw(ref, 0, NULL);
@@ -263,7 +263,7 @@ int tipc_deleteport(u32 ref)
263 tipc_port_unlock(p_ptr); 263 tipc_port_unlock(p_ptr);
264 264
265 k_cancel_timer(&p_ptr->timer); 265 k_cancel_timer(&p_ptr->timer);
266 if (p_ptr->publ.connected) { 266 if (p_ptr->connected) {
267 buf = port_build_peer_abort_msg(p_ptr, TIPC_ERR_NO_PORT); 267 buf = port_build_peer_abort_msg(p_ptr, TIPC_ERR_NO_PORT);
268 tipc_nodesub_unsubscribe(&p_ptr->subscription); 268 tipc_nodesub_unsubscribe(&p_ptr->subscription);
269 } 269 }
@@ -279,14 +279,14 @@ int tipc_deleteport(u32 ref)
279 return 0; 279 return 0;
280} 280}
281 281
282static int port_unreliable(struct port *p_ptr) 282static int port_unreliable(struct tipc_port *p_ptr)
283{ 283{
284 return msg_src_droppable(&p_ptr->publ.phdr); 284 return msg_src_droppable(&p_ptr->phdr);
285} 285}
286 286
287int tipc_portunreliable(u32 ref, unsigned int *isunreliable) 287int tipc_portunreliable(u32 ref, unsigned int *isunreliable)
288{ 288{
289 struct port *p_ptr; 289 struct tipc_port *p_ptr;
290 290
291 p_ptr = tipc_port_lock(ref); 291 p_ptr = tipc_port_lock(ref);
292 if (!p_ptr) 292 if (!p_ptr)
@@ -298,24 +298,24 @@ int tipc_portunreliable(u32 ref, unsigned int *isunreliable)
298 298
299int tipc_set_portunreliable(u32 ref, unsigned int isunreliable) 299int tipc_set_portunreliable(u32 ref, unsigned int isunreliable)
300{ 300{
301 struct port *p_ptr; 301 struct tipc_port *p_ptr;
302 302
303 p_ptr = tipc_port_lock(ref); 303 p_ptr = tipc_port_lock(ref);
304 if (!p_ptr) 304 if (!p_ptr)
305 return -EINVAL; 305 return -EINVAL;
306 msg_set_src_droppable(&p_ptr->publ.phdr, (isunreliable != 0)); 306 msg_set_src_droppable(&p_ptr->phdr, (isunreliable != 0));
307 tipc_port_unlock(p_ptr); 307 tipc_port_unlock(p_ptr);
308 return 0; 308 return 0;
309} 309}
310 310
311static int port_unreturnable(struct port *p_ptr) 311static int port_unreturnable(struct tipc_port *p_ptr)
312{ 312{
313 return msg_dest_droppable(&p_ptr->publ.phdr); 313 return msg_dest_droppable(&p_ptr->phdr);
314} 314}
315 315
316int tipc_portunreturnable(u32 ref, unsigned int *isunrejectable) 316int tipc_portunreturnable(u32 ref, unsigned int *isunrejectable)
317{ 317{
318 struct port *p_ptr; 318 struct tipc_port *p_ptr;
319 319
320 p_ptr = tipc_port_lock(ref); 320 p_ptr = tipc_port_lock(ref);
321 if (!p_ptr) 321 if (!p_ptr)
@@ -327,12 +327,12 @@ int tipc_portunreturnable(u32 ref, unsigned int *isunrejectable)
327 327
328int tipc_set_portunreturnable(u32 ref, unsigned int isunrejectable) 328int tipc_set_portunreturnable(u32 ref, unsigned int isunrejectable)
329{ 329{
330 struct port *p_ptr; 330 struct tipc_port *p_ptr;
331 331
332 p_ptr = tipc_port_lock(ref); 332 p_ptr = tipc_port_lock(ref);
333 if (!p_ptr) 333 if (!p_ptr)
334 return -EINVAL; 334 return -EINVAL;
335 msg_set_dest_droppable(&p_ptr->publ.phdr, (isunrejectable != 0)); 335 msg_set_dest_droppable(&p_ptr->phdr, (isunrejectable != 0));
336 tipc_port_unlock(p_ptr); 336 tipc_port_unlock(p_ptr);
337 return 0; 337 return 0;
338} 338}
@@ -413,10 +413,10 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err)
413 /* send self-abort message when rejecting on a connected port */ 413 /* send self-abort message when rejecting on a connected port */
414 if (msg_connected(msg)) { 414 if (msg_connected(msg)) {
415 struct sk_buff *abuf = NULL; 415 struct sk_buff *abuf = NULL;
416 struct port *p_ptr = tipc_port_lock(msg_destport(msg)); 416 struct tipc_port *p_ptr = tipc_port_lock(msg_destport(msg));
417 417
418 if (p_ptr) { 418 if (p_ptr) {
419 if (p_ptr->publ.connected) 419 if (p_ptr->connected)
420 abuf = port_build_self_abort_msg(p_ptr, err); 420 abuf = port_build_self_abort_msg(p_ptr, err);
421 tipc_port_unlock(p_ptr); 421 tipc_port_unlock(p_ptr);
422 } 422 }
@@ -429,7 +429,7 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err)
429 return data_sz; 429 return data_sz;
430} 430}
431 431
432int tipc_port_reject_sections(struct port *p_ptr, struct tipc_msg *hdr, 432int tipc_port_reject_sections(struct tipc_port *p_ptr, struct tipc_msg *hdr,
433 struct iovec const *msg_sect, u32 num_sect, 433 struct iovec const *msg_sect, u32 num_sect,
434 int err) 434 int err)
435{ 435{
@@ -446,13 +446,13 @@ int tipc_port_reject_sections(struct port *p_ptr, struct tipc_msg *hdr,
446 446
447static void port_timeout(unsigned long ref) 447static void port_timeout(unsigned long ref)
448{ 448{
449 struct port *p_ptr = tipc_port_lock(ref); 449 struct tipc_port *p_ptr = tipc_port_lock(ref);
450 struct sk_buff *buf = NULL; 450 struct sk_buff *buf = NULL;
451 451
452 if (!p_ptr) 452 if (!p_ptr)
453 return; 453 return;
454 454
455 if (!p_ptr->publ.connected) { 455 if (!p_ptr->connected) {
456 tipc_port_unlock(p_ptr); 456 tipc_port_unlock(p_ptr);
457 return; 457 return;
458 } 458 }
@@ -463,7 +463,7 @@ static void port_timeout(unsigned long ref)
463 } else { 463 } else {
464 buf = port_build_proto_msg(port_peerport(p_ptr), 464 buf = port_build_proto_msg(port_peerport(p_ptr),
465 port_peernode(p_ptr), 465 port_peernode(p_ptr),
466 p_ptr->publ.ref, 466 p_ptr->ref,
467 tipc_own_addr, 467 tipc_own_addr,
468 CONN_MANAGER, 468 CONN_MANAGER,
469 CONN_PROBE, 469 CONN_PROBE,
@@ -481,7 +481,7 @@ static void port_timeout(unsigned long ref)
481 481
482static void port_handle_node_down(unsigned long ref) 482static void port_handle_node_down(unsigned long ref)
483{ 483{
484 struct port *p_ptr = tipc_port_lock(ref); 484 struct tipc_port *p_ptr = tipc_port_lock(ref);
485 struct sk_buff *buf = NULL; 485 struct sk_buff *buf = NULL;
486 486
487 if (!p_ptr) 487 if (!p_ptr)
@@ -492,15 +492,15 @@ static void port_handle_node_down(unsigned long ref)
492} 492}
493 493
494 494
495static struct sk_buff *port_build_self_abort_msg(struct port *p_ptr, u32 err) 495static struct sk_buff *port_build_self_abort_msg(struct tipc_port *p_ptr, u32 err)
496{ 496{
497 u32 imp = msg_importance(&p_ptr->publ.phdr); 497 u32 imp = msg_importance(&p_ptr->phdr);
498 498
499 if (!p_ptr->publ.connected) 499 if (!p_ptr->connected)
500 return NULL; 500 return NULL;
501 if (imp < TIPC_CRITICAL_IMPORTANCE) 501 if (imp < TIPC_CRITICAL_IMPORTANCE)
502 imp++; 502 imp++;
503 return port_build_proto_msg(p_ptr->publ.ref, 503 return port_build_proto_msg(p_ptr->ref,
504 tipc_own_addr, 504 tipc_own_addr,
505 port_peerport(p_ptr), 505 port_peerport(p_ptr),
506 port_peernode(p_ptr), 506 port_peernode(p_ptr),
@@ -512,17 +512,17 @@ static struct sk_buff *port_build_self_abort_msg(struct port *p_ptr, u32 err)
512} 512}
513 513
514 514
515static struct sk_buff *port_build_peer_abort_msg(struct port *p_ptr, u32 err) 515static struct sk_buff *port_build_peer_abort_msg(struct tipc_port *p_ptr, u32 err)
516{ 516{
517 u32 imp = msg_importance(&p_ptr->publ.phdr); 517 u32 imp = msg_importance(&p_ptr->phdr);
518 518
519 if (!p_ptr->publ.connected) 519 if (!p_ptr->connected)
520 return NULL; 520 return NULL;
521 if (imp < TIPC_CRITICAL_IMPORTANCE) 521 if (imp < TIPC_CRITICAL_IMPORTANCE)
522 imp++; 522 imp++;
523 return port_build_proto_msg(port_peerport(p_ptr), 523 return port_build_proto_msg(port_peerport(p_ptr),
524 port_peernode(p_ptr), 524 port_peernode(p_ptr),
525 p_ptr->publ.ref, 525 p_ptr->ref,
526 tipc_own_addr, 526 tipc_own_addr,
527 imp, 527 imp,
528 TIPC_CONN_MSG, 528 TIPC_CONN_MSG,
@@ -534,31 +534,31 @@ static struct sk_buff *port_build_peer_abort_msg(struct port *p_ptr, u32 err)
534void tipc_port_recv_proto_msg(struct sk_buff *buf) 534void tipc_port_recv_proto_msg(struct sk_buff *buf)
535{ 535{
536 struct tipc_msg *msg = buf_msg(buf); 536 struct tipc_msg *msg = buf_msg(buf);
537 struct port *p_ptr = tipc_port_lock(msg_destport(msg)); 537 struct tipc_port *p_ptr = tipc_port_lock(msg_destport(msg));
538 u32 err = TIPC_OK; 538 u32 err = TIPC_OK;
539 struct sk_buff *r_buf = NULL; 539 struct sk_buff *r_buf = NULL;
540 struct sk_buff *abort_buf = NULL; 540 struct sk_buff *abort_buf = NULL;
541 541
542 if (!p_ptr) { 542 if (!p_ptr) {
543 err = TIPC_ERR_NO_PORT; 543 err = TIPC_ERR_NO_PORT;
544 } else if (p_ptr->publ.connected) { 544 } else if (p_ptr->connected) {
545 if ((port_peernode(p_ptr) != msg_orignode(msg)) || 545 if ((port_peernode(p_ptr) != msg_orignode(msg)) ||
546 (port_peerport(p_ptr) != msg_origport(msg))) { 546 (port_peerport(p_ptr) != msg_origport(msg))) {
547 err = TIPC_ERR_NO_PORT; 547 err = TIPC_ERR_NO_PORT;
548 } else if (msg_type(msg) == CONN_ACK) { 548 } else if (msg_type(msg) == CONN_ACK) {
549 int wakeup = tipc_port_congested(p_ptr) && 549 int wakeup = tipc_port_congested(p_ptr) &&
550 p_ptr->publ.congested && 550 p_ptr->congested &&
551 p_ptr->wakeup; 551 p_ptr->wakeup;
552 p_ptr->acked += msg_msgcnt(msg); 552 p_ptr->acked += msg_msgcnt(msg);
553 if (tipc_port_congested(p_ptr)) 553 if (tipc_port_congested(p_ptr))
554 goto exit; 554 goto exit;
555 p_ptr->publ.congested = 0; 555 p_ptr->congested = 0;
556 if (!wakeup) 556 if (!wakeup)
557 goto exit; 557 goto exit;
558 p_ptr->wakeup(&p_ptr->publ); 558 p_ptr->wakeup(p_ptr);
559 goto exit; 559 goto exit;
560 } 560 }
561 } else if (p_ptr->publ.published) { 561 } else if (p_ptr->published) {
562 err = TIPC_ERR_NO_PORT; 562 err = TIPC_ERR_NO_PORT;
563 } 563 }
564 if (err) { 564 if (err) {
@@ -596,29 +596,29 @@ exit:
596 buf_discard(buf); 596 buf_discard(buf);
597} 597}
598 598
599static void port_print(struct port *p_ptr, struct print_buf *buf, int full_id) 599static void port_print(struct tipc_port *p_ptr, struct print_buf *buf, int full_id)
600{ 600{
601 struct publication *publ; 601 struct publication *publ;
602 602
603 if (full_id) 603 if (full_id)
604 tipc_printf(buf, "<%u.%u.%u:%u>:", 604 tipc_printf(buf, "<%u.%u.%u:%u>:",
605 tipc_zone(tipc_own_addr), tipc_cluster(tipc_own_addr), 605 tipc_zone(tipc_own_addr), tipc_cluster(tipc_own_addr),
606 tipc_node(tipc_own_addr), p_ptr->publ.ref); 606 tipc_node(tipc_own_addr), p_ptr->ref);
607 else 607 else
608 tipc_printf(buf, "%-10u:", p_ptr->publ.ref); 608 tipc_printf(buf, "%-10u:", p_ptr->ref);
609 609
610 if (p_ptr->publ.connected) { 610 if (p_ptr->connected) {
611 u32 dport = port_peerport(p_ptr); 611 u32 dport = port_peerport(p_ptr);
612 u32 destnode = port_peernode(p_ptr); 612 u32 destnode = port_peernode(p_ptr);
613 613
614 tipc_printf(buf, " connected to <%u.%u.%u:%u>", 614 tipc_printf(buf, " connected to <%u.%u.%u:%u>",
615 tipc_zone(destnode), tipc_cluster(destnode), 615 tipc_zone(destnode), tipc_cluster(destnode),
616 tipc_node(destnode), dport); 616 tipc_node(destnode), dport);
617 if (p_ptr->publ.conn_type != 0) 617 if (p_ptr->conn_type != 0)
618 tipc_printf(buf, " via {%u,%u}", 618 tipc_printf(buf, " via {%u,%u}",
619 p_ptr->publ.conn_type, 619 p_ptr->conn_type,
620 p_ptr->publ.conn_instance); 620 p_ptr->conn_instance);
621 } else if (p_ptr->publ.published) { 621 } else if (p_ptr->published) {
622 tipc_printf(buf, " bound to"); 622 tipc_printf(buf, " bound to");
623 list_for_each_entry(publ, &p_ptr->publications, pport_list) { 623 list_for_each_entry(publ, &p_ptr->publications, pport_list) {
624 if (publ->lower == publ->upper) 624 if (publ->lower == publ->upper)
@@ -639,7 +639,7 @@ struct sk_buff *tipc_port_get_ports(void)
639 struct sk_buff *buf; 639 struct sk_buff *buf;
640 struct tlv_desc *rep_tlv; 640 struct tlv_desc *rep_tlv;
641 struct print_buf pb; 641 struct print_buf pb;
642 struct port *p_ptr; 642 struct tipc_port *p_ptr;
643 int str_len; 643 int str_len;
644 644
645 buf = tipc_cfg_reply_alloc(TLV_SPACE(MAX_PORT_QUERY)); 645 buf = tipc_cfg_reply_alloc(TLV_SPACE(MAX_PORT_QUERY));
@@ -650,9 +650,9 @@ struct sk_buff *tipc_port_get_ports(void)
650 tipc_printbuf_init(&pb, TLV_DATA(rep_tlv), MAX_PORT_QUERY); 650 tipc_printbuf_init(&pb, TLV_DATA(rep_tlv), MAX_PORT_QUERY);
651 spin_lock_bh(&tipc_port_list_lock); 651 spin_lock_bh(&tipc_port_list_lock);
652 list_for_each_entry(p_ptr, &ports, port_list) { 652 list_for_each_entry(p_ptr, &ports, port_list) {
653 spin_lock_bh(p_ptr->publ.lock); 653 spin_lock_bh(p_ptr->lock);
654 port_print(p_ptr, &pb, 0); 654 port_print(p_ptr, &pb, 0);
655 spin_unlock_bh(p_ptr->publ.lock); 655 spin_unlock_bh(p_ptr->lock);
656 } 656 }
657 spin_unlock_bh(&tipc_port_list_lock); 657 spin_unlock_bh(&tipc_port_list_lock);
658 str_len = tipc_printbuf_validate(&pb); 658 str_len = tipc_printbuf_validate(&pb);
@@ -665,12 +665,12 @@ struct sk_buff *tipc_port_get_ports(void)
665 665
666void tipc_port_reinit(void) 666void tipc_port_reinit(void)
667{ 667{
668 struct port *p_ptr; 668 struct tipc_port *p_ptr;
669 struct tipc_msg *msg; 669 struct tipc_msg *msg;
670 670
671 spin_lock_bh(&tipc_port_list_lock); 671 spin_lock_bh(&tipc_port_list_lock);
672 list_for_each_entry(p_ptr, &ports, port_list) { 672 list_for_each_entry(p_ptr, &ports, port_list) {
673 msg = &p_ptr->publ.phdr; 673 msg = &p_ptr->phdr;
674 if (msg_orignode(msg) == tipc_own_addr) 674 if (msg_orignode(msg) == tipc_own_addr)
675 break; 675 break;
676 msg_set_prevnode(msg, tipc_own_addr); 676 msg_set_prevnode(msg, tipc_own_addr);
@@ -695,7 +695,7 @@ static void port_dispatcher_sigh(void *dummy)
695 spin_unlock_bh(&queue_lock); 695 spin_unlock_bh(&queue_lock);
696 696
697 while (buf) { 697 while (buf) {
698 struct port *p_ptr; 698 struct tipc_port *p_ptr;
699 struct user_port *up_ptr; 699 struct user_port *up_ptr;
700 struct tipc_portid orig; 700 struct tipc_portid orig;
701 struct tipc_name_seq dseq; 701 struct tipc_name_seq dseq;
@@ -720,8 +720,8 @@ static void port_dispatcher_sigh(void *dummy)
720 orig.node = msg_orignode(msg); 720 orig.node = msg_orignode(msg);
721 up_ptr = p_ptr->user_port; 721 up_ptr = p_ptr->user_port;
722 usr_handle = up_ptr->usr_handle; 722 usr_handle = up_ptr->usr_handle;
723 connected = p_ptr->publ.connected; 723 connected = p_ptr->connected;
724 published = p_ptr->publ.published; 724 published = p_ptr->published;
725 725
726 if (unlikely(msg_errcode(msg))) 726 if (unlikely(msg_errcode(msg)))
727 goto err; 727 goto err;
@@ -742,10 +742,10 @@ static void port_dispatcher_sigh(void *dummy)
742 } else if ((msg_origport(msg) != peer_port) || 742 } else if ((msg_origport(msg) != peer_port) ||
743 (msg_orignode(msg) != peer_node)) 743 (msg_orignode(msg) != peer_node))
744 goto reject; 744 goto reject;
745 if (unlikely(++p_ptr->publ.conn_unacked >= 745 if (unlikely(++p_ptr->conn_unacked >=
746 TIPC_FLOW_CONTROL_WIN)) 746 TIPC_FLOW_CONTROL_WIN))
747 tipc_acknowledge(dref, 747 tipc_acknowledge(dref,
748 p_ptr->publ.conn_unacked); 748 p_ptr->conn_unacked);
749 skb_pull(buf, msg_hdr_sz(msg)); 749 skb_pull(buf, msg_hdr_sz(msg));
750 cb(usr_handle, dref, &buf, msg_data(msg), 750 cb(usr_handle, dref, &buf, msg_data(msg),
751 msg_data_sz(msg)); 751 msg_data_sz(msg));
@@ -872,7 +872,7 @@ static u32 port_dispatcher(struct tipc_port *dummy, struct sk_buff *buf)
872 872
873static void port_wakeup_sh(unsigned long ref) 873static void port_wakeup_sh(unsigned long ref)
874{ 874{
875 struct port *p_ptr; 875 struct tipc_port *p_ptr;
876 struct user_port *up_ptr; 876 struct user_port *up_ptr;
877 tipc_continue_event cb = NULL; 877 tipc_continue_event cb = NULL;
878 void *uh = NULL; 878 void *uh = NULL;
@@ -898,14 +898,14 @@ static void port_wakeup(struct tipc_port *p_ptr)
898 898
899void tipc_acknowledge(u32 ref, u32 ack) 899void tipc_acknowledge(u32 ref, u32 ack)
900{ 900{
901 struct port *p_ptr; 901 struct tipc_port *p_ptr;
902 struct sk_buff *buf = NULL; 902 struct sk_buff *buf = NULL;
903 903
904 p_ptr = tipc_port_lock(ref); 904 p_ptr = tipc_port_lock(ref);
905 if (!p_ptr) 905 if (!p_ptr)
906 return; 906 return;
907 if (p_ptr->publ.connected) { 907 if (p_ptr->connected) {
908 p_ptr->publ.conn_unacked -= ack; 908 p_ptr->conn_unacked -= ack;
909 buf = port_build_proto_msg(port_peerport(p_ptr), 909 buf = port_build_proto_msg(port_peerport(p_ptr),
910 port_peernode(p_ptr), 910 port_peernode(p_ptr),
911 ref, 911 ref,
@@ -936,14 +936,14 @@ int tipc_createport(void *usr_handle,
936 u32 *portref) 936 u32 *portref)
937{ 937{
938 struct user_port *up_ptr; 938 struct user_port *up_ptr;
939 struct port *p_ptr; 939 struct tipc_port *p_ptr;
940 940
941 up_ptr = kmalloc(sizeof(*up_ptr), GFP_ATOMIC); 941 up_ptr = kmalloc(sizeof(*up_ptr), GFP_ATOMIC);
942 if (!up_ptr) { 942 if (!up_ptr) {
943 warn("Port creation failed, no memory\n"); 943 warn("Port creation failed, no memory\n");
944 return -ENOMEM; 944 return -ENOMEM;
945 } 945 }
946 p_ptr = (struct port *)tipc_createport_raw(NULL, port_dispatcher, 946 p_ptr = (struct tipc_port *)tipc_createport_raw(NULL, port_dispatcher,
947 port_wakeup, importance); 947 port_wakeup, importance);
948 if (!p_ptr) { 948 if (!p_ptr) {
949 kfree(up_ptr); 949 kfree(up_ptr);
@@ -952,7 +952,7 @@ int tipc_createport(void *usr_handle,
952 952
953 p_ptr->user_port = up_ptr; 953 p_ptr->user_port = up_ptr;
954 up_ptr->usr_handle = usr_handle; 954 up_ptr->usr_handle = usr_handle;
955 up_ptr->ref = p_ptr->publ.ref; 955 up_ptr->ref = p_ptr->ref;
956 up_ptr->err_cb = error_cb; 956 up_ptr->err_cb = error_cb;
957 up_ptr->named_err_cb = named_error_cb; 957 up_ptr->named_err_cb = named_error_cb;
958 up_ptr->conn_err_cb = conn_error_cb; 958 up_ptr->conn_err_cb = conn_error_cb;
@@ -960,26 +960,26 @@ int tipc_createport(void *usr_handle,
960 up_ptr->named_msg_cb = named_msg_cb; 960 up_ptr->named_msg_cb = named_msg_cb;
961 up_ptr->conn_msg_cb = conn_msg_cb; 961 up_ptr->conn_msg_cb = conn_msg_cb;
962 up_ptr->continue_event_cb = continue_event_cb; 962 up_ptr->continue_event_cb = continue_event_cb;
963 *portref = p_ptr->publ.ref; 963 *portref = p_ptr->ref;
964 tipc_port_unlock(p_ptr); 964 tipc_port_unlock(p_ptr);
965 return 0; 965 return 0;
966} 966}
967 967
968int tipc_portimportance(u32 ref, unsigned int *importance) 968int tipc_portimportance(u32 ref, unsigned int *importance)
969{ 969{
970 struct port *p_ptr; 970 struct tipc_port *p_ptr;
971 971
972 p_ptr = tipc_port_lock(ref); 972 p_ptr = tipc_port_lock(ref);
973 if (!p_ptr) 973 if (!p_ptr)
974 return -EINVAL; 974 return -EINVAL;
975 *importance = (unsigned int)msg_importance(&p_ptr->publ.phdr); 975 *importance = (unsigned int)msg_importance(&p_ptr->phdr);
976 tipc_port_unlock(p_ptr); 976 tipc_port_unlock(p_ptr);
977 return 0; 977 return 0;
978} 978}
979 979
980int tipc_set_portimportance(u32 ref, unsigned int imp) 980int tipc_set_portimportance(u32 ref, unsigned int imp)
981{ 981{
982 struct port *p_ptr; 982 struct tipc_port *p_ptr;
983 983
984 if (imp > TIPC_CRITICAL_IMPORTANCE) 984 if (imp > TIPC_CRITICAL_IMPORTANCE)
985 return -EINVAL; 985 return -EINVAL;
@@ -987,7 +987,7 @@ int tipc_set_portimportance(u32 ref, unsigned int imp)
987 p_ptr = tipc_port_lock(ref); 987 p_ptr = tipc_port_lock(ref);
988 if (!p_ptr) 988 if (!p_ptr)
989 return -EINVAL; 989 return -EINVAL;
990 msg_set_importance(&p_ptr->publ.phdr, (u32)imp); 990 msg_set_importance(&p_ptr->phdr, (u32)imp);
991 tipc_port_unlock(p_ptr); 991 tipc_port_unlock(p_ptr);
992 return 0; 992 return 0;
993} 993}
@@ -995,7 +995,7 @@ int tipc_set_portimportance(u32 ref, unsigned int imp)
995 995
996int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq) 996int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
997{ 997{
998 struct port *p_ptr; 998 struct tipc_port *p_ptr;
999 struct publication *publ; 999 struct publication *publ;
1000 u32 key; 1000 u32 key;
1001 int res = -EINVAL; 1001 int res = -EINVAL;
@@ -1004,7 +1004,7 @@ int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
1004 if (!p_ptr) 1004 if (!p_ptr)
1005 return -EINVAL; 1005 return -EINVAL;
1006 1006
1007 if (p_ptr->publ.connected) 1007 if (p_ptr->connected)
1008 goto exit; 1008 goto exit;
1009 if (seq->lower > seq->upper) 1009 if (seq->lower > seq->upper)
1010 goto exit; 1010 goto exit;
@@ -1016,11 +1016,11 @@ int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
1016 goto exit; 1016 goto exit;
1017 } 1017 }
1018 publ = tipc_nametbl_publish(seq->type, seq->lower, seq->upper, 1018 publ = tipc_nametbl_publish(seq->type, seq->lower, seq->upper,
1019 scope, p_ptr->publ.ref, key); 1019 scope, p_ptr->ref, key);
1020 if (publ) { 1020 if (publ) {
1021 list_add(&publ->pport_list, &p_ptr->publications); 1021 list_add(&publ->pport_list, &p_ptr->publications);
1022 p_ptr->pub_count++; 1022 p_ptr->pub_count++;
1023 p_ptr->publ.published = 1; 1023 p_ptr->published = 1;
1024 res = 0; 1024 res = 0;
1025 } 1025 }
1026exit: 1026exit:
@@ -1030,7 +1030,7 @@ exit:
1030 1030
1031int tipc_withdraw(u32 ref, unsigned int scope, struct tipc_name_seq const *seq) 1031int tipc_withdraw(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
1032{ 1032{
1033 struct port *p_ptr; 1033 struct tipc_port *p_ptr;
1034 struct publication *publ; 1034 struct publication *publ;
1035 struct publication *tpubl; 1035 struct publication *tpubl;
1036 int res = -EINVAL; 1036 int res = -EINVAL;
@@ -1063,37 +1063,37 @@ int tipc_withdraw(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
1063 } 1063 }
1064 } 1064 }
1065 if (list_empty(&p_ptr->publications)) 1065 if (list_empty(&p_ptr->publications))
1066 p_ptr->publ.published = 0; 1066 p_ptr->published = 0;
1067 tipc_port_unlock(p_ptr); 1067 tipc_port_unlock(p_ptr);
1068 return res; 1068 return res;
1069} 1069}
1070 1070
1071int tipc_connect2port(u32 ref, struct tipc_portid const *peer) 1071int tipc_connect2port(u32 ref, struct tipc_portid const *peer)
1072{ 1072{
1073 struct port *p_ptr; 1073 struct tipc_port *p_ptr;
1074 struct tipc_msg *msg; 1074 struct tipc_msg *msg;
1075 int res = -EINVAL; 1075 int res = -EINVAL;
1076 1076
1077 p_ptr = tipc_port_lock(ref); 1077 p_ptr = tipc_port_lock(ref);
1078 if (!p_ptr) 1078 if (!p_ptr)
1079 return -EINVAL; 1079 return -EINVAL;
1080 if (p_ptr->publ.published || p_ptr->publ.connected) 1080 if (p_ptr->published || p_ptr->connected)
1081 goto exit; 1081 goto exit;
1082 if (!peer->ref) 1082 if (!peer->ref)
1083 goto exit; 1083 goto exit;
1084 1084
1085 msg = &p_ptr->publ.phdr; 1085 msg = &p_ptr->phdr;
1086 msg_set_destnode(msg, peer->node); 1086 msg_set_destnode(msg, peer->node);
1087 msg_set_destport(msg, peer->ref); 1087 msg_set_destport(msg, peer->ref);
1088 msg_set_orignode(msg, tipc_own_addr); 1088 msg_set_orignode(msg, tipc_own_addr);
1089 msg_set_origport(msg, p_ptr->publ.ref); 1089 msg_set_origport(msg, p_ptr->ref);
1090 msg_set_transp_seqno(msg, 42); 1090 msg_set_transp_seqno(msg, 42);
1091 msg_set_type(msg, TIPC_CONN_MSG); 1091 msg_set_type(msg, TIPC_CONN_MSG);
1092 msg_set_hdr_sz(msg, SHORT_H_SIZE); 1092 msg_set_hdr_sz(msg, SHORT_H_SIZE);
1093 1093
1094 p_ptr->probing_interval = PROBING_INTERVAL; 1094 p_ptr->probing_interval = PROBING_INTERVAL;
1095 p_ptr->probing_state = CONFIRMED; 1095 p_ptr->probing_state = CONFIRMED;
1096 p_ptr->publ.connected = 1; 1096 p_ptr->connected = 1;
1097 k_start_timer(&p_ptr->timer, p_ptr->probing_interval); 1097 k_start_timer(&p_ptr->timer, p_ptr->probing_interval);
1098 1098
1099 tipc_nodesub_subscribe(&p_ptr->subscription, peer->node, 1099 tipc_nodesub_subscribe(&p_ptr->subscription, peer->node,
@@ -1102,7 +1102,7 @@ int tipc_connect2port(u32 ref, struct tipc_portid const *peer)
1102 res = 0; 1102 res = 0;
1103exit: 1103exit:
1104 tipc_port_unlock(p_ptr); 1104 tipc_port_unlock(p_ptr);
1105 p_ptr->publ.max_pkt = tipc_link_get_max_pkt(peer->node, ref); 1105 p_ptr->max_pkt = tipc_link_get_max_pkt(peer->node, ref);
1106 return res; 1106 return res;
1107} 1107}
1108 1108
@@ -1120,7 +1120,7 @@ int tipc_disconnect_port(struct tipc_port *tp_ptr)
1120 tp_ptr->connected = 0; 1120 tp_ptr->connected = 0;
1121 /* let timer expire on it's own to avoid deadlock! */ 1121 /* let timer expire on it's own to avoid deadlock! */
1122 tipc_nodesub_unsubscribe( 1122 tipc_nodesub_unsubscribe(
1123 &((struct port *)tp_ptr)->subscription); 1123 &((struct tipc_port *)tp_ptr)->subscription);
1124 res = 0; 1124 res = 0;
1125 } else { 1125 } else {
1126 res = -ENOTCONN; 1126 res = -ENOTCONN;
@@ -1135,7 +1135,7 @@ int tipc_disconnect_port(struct tipc_port *tp_ptr)
1135 1135
1136int tipc_disconnect(u32 ref) 1136int tipc_disconnect(u32 ref)
1137{ 1137{
1138 struct port *p_ptr; 1138 struct tipc_port *p_ptr;
1139 int res; 1139 int res;
1140 1140
1141 p_ptr = tipc_port_lock(ref); 1141 p_ptr = tipc_port_lock(ref);
@@ -1151,15 +1151,15 @@ int tipc_disconnect(u32 ref)
1151 */ 1151 */
1152int tipc_shutdown(u32 ref) 1152int tipc_shutdown(u32 ref)
1153{ 1153{
1154 struct port *p_ptr; 1154 struct tipc_port *p_ptr;
1155 struct sk_buff *buf = NULL; 1155 struct sk_buff *buf = NULL;
1156 1156
1157 p_ptr = tipc_port_lock(ref); 1157 p_ptr = tipc_port_lock(ref);
1158 if (!p_ptr) 1158 if (!p_ptr)
1159 return -EINVAL; 1159 return -EINVAL;
1160 1160
1161 if (p_ptr->publ.connected) { 1161 if (p_ptr->connected) {
1162 u32 imp = msg_importance(&p_ptr->publ.phdr); 1162 u32 imp = msg_importance(&p_ptr->phdr);
1163 if (imp < TIPC_CRITICAL_IMPORTANCE) 1163 if (imp < TIPC_CRITICAL_IMPORTANCE)
1164 imp++; 1164 imp++;
1165 buf = port_build_proto_msg(port_peerport(p_ptr), 1165 buf = port_build_proto_msg(port_peerport(p_ptr),
@@ -1182,13 +1182,13 @@ int tipc_shutdown(u32 ref)
1182 * message for this node. 1182 * message for this node.
1183 */ 1183 */
1184 1184
1185static int tipc_port_recv_sections(struct port *sender, unsigned int num_sect, 1185static int tipc_port_recv_sections(struct tipc_port *sender, unsigned int num_sect,
1186 struct iovec const *msg_sect) 1186 struct iovec const *msg_sect)
1187{ 1187{
1188 struct sk_buff *buf; 1188 struct sk_buff *buf;
1189 int res; 1189 int res;
1190 1190
1191 res = tipc_msg_build(&sender->publ.phdr, msg_sect, num_sect, 1191 res = tipc_msg_build(&sender->phdr, msg_sect, num_sect,
1192 MAX_MSG_SIZE, !sender->user_port, &buf); 1192 MAX_MSG_SIZE, !sender->user_port, &buf);
1193 if (likely(buf)) 1193 if (likely(buf))
1194 tipc_port_recv_msg(buf); 1194 tipc_port_recv_msg(buf);
@@ -1201,15 +1201,15 @@ static int tipc_port_recv_sections(struct port *sender, unsigned int num_sect,
1201 1201
1202int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect) 1202int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect)
1203{ 1203{
1204 struct port *p_ptr; 1204 struct tipc_port *p_ptr;
1205 u32 destnode; 1205 u32 destnode;
1206 int res; 1206 int res;
1207 1207
1208 p_ptr = tipc_port_deref(ref); 1208 p_ptr = tipc_port_deref(ref);
1209 if (!p_ptr || !p_ptr->publ.connected) 1209 if (!p_ptr || !p_ptr->connected)
1210 return -EINVAL; 1210 return -EINVAL;
1211 1211
1212 p_ptr->publ.congested = 1; 1212 p_ptr->congested = 1;
1213 if (!tipc_port_congested(p_ptr)) { 1213 if (!tipc_port_congested(p_ptr)) {
1214 destnode = port_peernode(p_ptr); 1214 destnode = port_peernode(p_ptr);
1215 if (likely(destnode != tipc_own_addr)) 1215 if (likely(destnode != tipc_own_addr))
@@ -1220,13 +1220,13 @@ int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect)
1220 1220
1221 if (likely(res != -ELINKCONG)) { 1221 if (likely(res != -ELINKCONG)) {
1222 port_incr_out_seqno(p_ptr); 1222 port_incr_out_seqno(p_ptr);
1223 p_ptr->publ.congested = 0; 1223 p_ptr->congested = 0;
1224 p_ptr->sent++; 1224 p_ptr->sent++;
1225 return res; 1225 return res;
1226 } 1226 }
1227 } 1227 }
1228 if (port_unreliable(p_ptr)) { 1228 if (port_unreliable(p_ptr)) {
1229 p_ptr->publ.congested = 0; 1229 p_ptr->congested = 0;
1230 /* Just calculate msg length and return */ 1230 /* Just calculate msg length and return */
1231 return tipc_msg_calc_data_size(msg_sect, num_sect); 1231 return tipc_msg_calc_data_size(msg_sect, num_sect);
1232 } 1232 }
@@ -1240,17 +1240,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, 1240int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain,
1241 unsigned int num_sect, struct iovec const *msg_sect) 1241 unsigned int num_sect, struct iovec const *msg_sect)
1242{ 1242{
1243 struct port *p_ptr; 1243 struct tipc_port *p_ptr;
1244 struct tipc_msg *msg; 1244 struct tipc_msg *msg;
1245 u32 destnode = domain; 1245 u32 destnode = domain;
1246 u32 destport; 1246 u32 destport;
1247 int res; 1247 int res;
1248 1248
1249 p_ptr = tipc_port_deref(ref); 1249 p_ptr = tipc_port_deref(ref);
1250 if (!p_ptr || p_ptr->publ.connected) 1250 if (!p_ptr || p_ptr->connected)
1251 return -EINVAL; 1251 return -EINVAL;
1252 1252
1253 msg = &p_ptr->publ.phdr; 1253 msg = &p_ptr->phdr;
1254 msg_set_type(msg, TIPC_NAMED_MSG); 1254 msg_set_type(msg, TIPC_NAMED_MSG);
1255 msg_set_orignode(msg, tipc_own_addr); 1255 msg_set_orignode(msg, tipc_own_addr);
1256 msg_set_origport(msg, ref); 1256 msg_set_origport(msg, ref);
@@ -1287,15 +1287,15 @@ int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain,
1287int tipc_send2port(u32 ref, struct tipc_portid const *dest, 1287int tipc_send2port(u32 ref, struct tipc_portid const *dest,
1288 unsigned int num_sect, struct iovec const *msg_sect) 1288 unsigned int num_sect, struct iovec const *msg_sect)
1289{ 1289{
1290 struct port *p_ptr; 1290 struct tipc_port *p_ptr;
1291 struct tipc_msg *msg; 1291 struct tipc_msg *msg;
1292 int res; 1292 int res;
1293 1293
1294 p_ptr = tipc_port_deref(ref); 1294 p_ptr = tipc_port_deref(ref);
1295 if (!p_ptr || p_ptr->publ.connected) 1295 if (!p_ptr || p_ptr->connected)
1296 return -EINVAL; 1296 return -EINVAL;
1297 1297
1298 msg = &p_ptr->publ.phdr; 1298 msg = &p_ptr->phdr;
1299 msg_set_type(msg, TIPC_DIRECT_MSG); 1299 msg_set_type(msg, TIPC_DIRECT_MSG);
1300 msg_set_orignode(msg, tipc_own_addr); 1300 msg_set_orignode(msg, tipc_own_addr);
1301 msg_set_origport(msg, ref); 1301 msg_set_origport(msg, ref);
@@ -1322,15 +1322,15 @@ int tipc_send2port(u32 ref, struct tipc_portid const *dest,
1322int tipc_send_buf2port(u32 ref, struct tipc_portid const *dest, 1322int tipc_send_buf2port(u32 ref, struct tipc_portid const *dest,
1323 struct sk_buff *buf, unsigned int dsz) 1323 struct sk_buff *buf, unsigned int dsz)
1324{ 1324{
1325 struct port *p_ptr; 1325 struct tipc_port *p_ptr;
1326 struct tipc_msg *msg; 1326 struct tipc_msg *msg;
1327 int res; 1327 int res;
1328 1328
1329 p_ptr = (struct port *)tipc_ref_deref(ref); 1329 p_ptr = (struct tipc_port *)tipc_ref_deref(ref);
1330 if (!p_ptr || p_ptr->publ.connected) 1330 if (!p_ptr || p_ptr->connected)
1331 return -EINVAL; 1331 return -EINVAL;
1332 1332
1333 msg = &p_ptr->publ.phdr; 1333 msg = &p_ptr->phdr;
1334 msg_set_type(msg, TIPC_DIRECT_MSG); 1334 msg_set_type(msg, TIPC_DIRECT_MSG);
1335 msg_set_orignode(msg, tipc_own_addr); 1335 msg_set_orignode(msg, tipc_own_addr);
1336 msg_set_origport(msg, ref); 1336 msg_set_origport(msg, ref);