diff options
Diffstat (limited to 'net/tipc/port.c')
-rw-r--r-- | net/tipc/port.c | 77 |
1 files changed, 41 insertions, 36 deletions
diff --git a/net/tipc/port.c b/net/tipc/port.c index 2ad37a4db376..07c42fba672b 100644 --- a/net/tipc/port.c +++ b/net/tipc/port.c | |||
@@ -69,7 +69,7 @@ static u32 port_peerport(struct tipc_port *p_ptr) | |||
69 | return msg_destport(&p_ptr->phdr); | 69 | return msg_destport(&p_ptr->phdr); |
70 | } | 70 | } |
71 | 71 | ||
72 | /* | 72 | /** |
73 | * tipc_port_peer_msg - verify message was sent by connected port's peer | 73 | * tipc_port_peer_msg - verify message was sent by connected port's peer |
74 | * | 74 | * |
75 | * Handles cases where the node's network address has changed from | 75 | * Handles cases where the node's network address has changed from |
@@ -191,7 +191,7 @@ void tipc_port_recv_mcast(struct sk_buff *buf, struct tipc_port_list *dp) | |||
191 | struct sk_buff *b = skb_clone(buf, GFP_ATOMIC); | 191 | struct sk_buff *b = skb_clone(buf, GFP_ATOMIC); |
192 | 192 | ||
193 | if (b == NULL) { | 193 | if (b == NULL) { |
194 | warn("Unable to deliver multicast message(s)\n"); | 194 | pr_warn("Unable to deliver multicast message(s)\n"); |
195 | goto exit; | 195 | goto exit; |
196 | } | 196 | } |
197 | if ((index == 0) && (cnt != 0)) | 197 | if ((index == 0) && (cnt != 0)) |
@@ -221,12 +221,12 @@ struct tipc_port *tipc_createport_raw(void *usr_handle, | |||
221 | 221 | ||
222 | p_ptr = kzalloc(sizeof(*p_ptr), GFP_ATOMIC); | 222 | p_ptr = kzalloc(sizeof(*p_ptr), GFP_ATOMIC); |
223 | if (!p_ptr) { | 223 | if (!p_ptr) { |
224 | warn("Port creation failed, no memory\n"); | 224 | pr_warn("Port creation failed, no memory\n"); |
225 | return NULL; | 225 | return NULL; |
226 | } | 226 | } |
227 | ref = tipc_ref_acquire(p_ptr, &p_ptr->lock); | 227 | ref = tipc_ref_acquire(p_ptr, &p_ptr->lock); |
228 | if (!ref) { | 228 | if (!ref) { |
229 | warn("Port creation failed, reference table exhausted\n"); | 229 | pr_warn("Port creation failed, ref. table exhausted\n"); |
230 | kfree(p_ptr); | 230 | kfree(p_ptr); |
231 | return NULL; | 231 | return NULL; |
232 | } | 232 | } |
@@ -581,67 +581,73 @@ exit: | |||
581 | kfree_skb(buf); | 581 | kfree_skb(buf); |
582 | } | 582 | } |
583 | 583 | ||
584 | static void port_print(struct tipc_port *p_ptr, struct print_buf *buf, int full_id) | 584 | static int port_print(struct tipc_port *p_ptr, char *buf, int len, int full_id) |
585 | { | 585 | { |
586 | struct publication *publ; | 586 | struct publication *publ; |
587 | int ret; | ||
587 | 588 | ||
588 | if (full_id) | 589 | if (full_id) |
589 | tipc_printf(buf, "<%u.%u.%u:%u>:", | 590 | ret = tipc_snprintf(buf, len, "<%u.%u.%u:%u>:", |
590 | tipc_zone(tipc_own_addr), tipc_cluster(tipc_own_addr), | 591 | tipc_zone(tipc_own_addr), |
591 | tipc_node(tipc_own_addr), p_ptr->ref); | 592 | tipc_cluster(tipc_own_addr), |
593 | tipc_node(tipc_own_addr), p_ptr->ref); | ||
592 | else | 594 | else |
593 | tipc_printf(buf, "%-10u:", p_ptr->ref); | 595 | ret = tipc_snprintf(buf, len, "%-10u:", p_ptr->ref); |
594 | 596 | ||
595 | if (p_ptr->connected) { | 597 | if (p_ptr->connected) { |
596 | u32 dport = port_peerport(p_ptr); | 598 | u32 dport = port_peerport(p_ptr); |
597 | u32 destnode = port_peernode(p_ptr); | 599 | u32 destnode = port_peernode(p_ptr); |
598 | 600 | ||
599 | tipc_printf(buf, " connected to <%u.%u.%u:%u>", | 601 | ret += tipc_snprintf(buf + ret, len - ret, |
600 | tipc_zone(destnode), tipc_cluster(destnode), | 602 | " connected to <%u.%u.%u:%u>", |
601 | tipc_node(destnode), dport); | 603 | tipc_zone(destnode), |
604 | tipc_cluster(destnode), | ||
605 | tipc_node(destnode), dport); | ||
602 | if (p_ptr->conn_type != 0) | 606 | if (p_ptr->conn_type != 0) |
603 | tipc_printf(buf, " via {%u,%u}", | 607 | ret += tipc_snprintf(buf + ret, len - ret, |
604 | p_ptr->conn_type, | 608 | " via {%u,%u}", p_ptr->conn_type, |
605 | p_ptr->conn_instance); | 609 | p_ptr->conn_instance); |
606 | } else if (p_ptr->published) { | 610 | } else if (p_ptr->published) { |
607 | tipc_printf(buf, " bound to"); | 611 | ret += tipc_snprintf(buf + ret, len - ret, " bound to"); |
608 | list_for_each_entry(publ, &p_ptr->publications, pport_list) { | 612 | list_for_each_entry(publ, &p_ptr->publications, pport_list) { |
609 | if (publ->lower == publ->upper) | 613 | if (publ->lower == publ->upper) |
610 | tipc_printf(buf, " {%u,%u}", publ->type, | 614 | ret += tipc_snprintf(buf + ret, len - ret, |
611 | publ->lower); | 615 | " {%u,%u}", publ->type, |
616 | publ->lower); | ||
612 | else | 617 | else |
613 | tipc_printf(buf, " {%u,%u,%u}", publ->type, | 618 | ret += tipc_snprintf(buf + ret, len - ret, |
614 | publ->lower, publ->upper); | 619 | " {%u,%u,%u}", publ->type, |
620 | publ->lower, publ->upper); | ||
615 | } | 621 | } |
616 | } | 622 | } |
617 | tipc_printf(buf, "\n"); | 623 | ret += tipc_snprintf(buf + ret, len - ret, "\n"); |
624 | return ret; | ||
618 | } | 625 | } |
619 | 626 | ||
620 | #define MAX_PORT_QUERY 32768 | ||
621 | |||
622 | struct sk_buff *tipc_port_get_ports(void) | 627 | struct sk_buff *tipc_port_get_ports(void) |
623 | { | 628 | { |
624 | struct sk_buff *buf; | 629 | struct sk_buff *buf; |
625 | struct tlv_desc *rep_tlv; | 630 | struct tlv_desc *rep_tlv; |
626 | struct print_buf pb; | 631 | char *pb; |
632 | int pb_len; | ||
627 | struct tipc_port *p_ptr; | 633 | struct tipc_port *p_ptr; |
628 | int str_len; | 634 | int str_len = 0; |
629 | 635 | ||
630 | buf = tipc_cfg_reply_alloc(TLV_SPACE(MAX_PORT_QUERY)); | 636 | buf = tipc_cfg_reply_alloc(TLV_SPACE(ULTRA_STRING_MAX_LEN)); |
631 | if (!buf) | 637 | if (!buf) |
632 | return NULL; | 638 | return NULL; |
633 | rep_tlv = (struct tlv_desc *)buf->data; | 639 | rep_tlv = (struct tlv_desc *)buf->data; |
640 | pb = TLV_DATA(rep_tlv); | ||
641 | pb_len = ULTRA_STRING_MAX_LEN; | ||
634 | 642 | ||
635 | tipc_printbuf_init(&pb, TLV_DATA(rep_tlv), MAX_PORT_QUERY); | ||
636 | spin_lock_bh(&tipc_port_list_lock); | 643 | spin_lock_bh(&tipc_port_list_lock); |
637 | list_for_each_entry(p_ptr, &ports, port_list) { | 644 | list_for_each_entry(p_ptr, &ports, port_list) { |
638 | spin_lock_bh(p_ptr->lock); | 645 | spin_lock_bh(p_ptr->lock); |
639 | port_print(p_ptr, &pb, 0); | 646 | str_len += port_print(p_ptr, pb, pb_len, 0); |
640 | spin_unlock_bh(p_ptr->lock); | 647 | spin_unlock_bh(p_ptr->lock); |
641 | } | 648 | } |
642 | spin_unlock_bh(&tipc_port_list_lock); | 649 | spin_unlock_bh(&tipc_port_list_lock); |
643 | str_len = tipc_printbuf_validate(&pb); | 650 | str_len += 1; /* for "\0" */ |
644 | |||
645 | skb_put(buf, TLV_SPACE(str_len)); | 651 | skb_put(buf, TLV_SPACE(str_len)); |
646 | TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len); | 652 | TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len); |
647 | 653 | ||
@@ -906,11 +912,11 @@ int tipc_createport(void *usr_handle, | |||
906 | 912 | ||
907 | up_ptr = kmalloc(sizeof(*up_ptr), GFP_ATOMIC); | 913 | up_ptr = kmalloc(sizeof(*up_ptr), GFP_ATOMIC); |
908 | if (!up_ptr) { | 914 | if (!up_ptr) { |
909 | warn("Port creation failed, no memory\n"); | 915 | pr_warn("Port creation failed, no memory\n"); |
910 | return -ENOMEM; | 916 | return -ENOMEM; |
911 | } | 917 | } |
912 | p_ptr = (struct tipc_port *)tipc_createport_raw(NULL, port_dispatcher, | 918 | p_ptr = tipc_createport_raw(NULL, port_dispatcher, port_wakeup, |
913 | port_wakeup, importance); | 919 | importance); |
914 | if (!p_ptr) { | 920 | if (!p_ptr) { |
915 | kfree(up_ptr); | 921 | kfree(up_ptr); |
916 | return -ENOMEM; | 922 | return -ENOMEM; |
@@ -1078,8 +1084,7 @@ int tipc_disconnect_port(struct tipc_port *tp_ptr) | |||
1078 | if (tp_ptr->connected) { | 1084 | if (tp_ptr->connected) { |
1079 | tp_ptr->connected = 0; | 1085 | tp_ptr->connected = 0; |
1080 | /* let timer expire on it's own to avoid deadlock! */ | 1086 | /* let timer expire on it's own to avoid deadlock! */ |
1081 | tipc_nodesub_unsubscribe( | 1087 | tipc_nodesub_unsubscribe(&tp_ptr->subscription); |
1082 | &((struct tipc_port *)tp_ptr)->subscription); | ||
1083 | res = 0; | 1088 | res = 0; |
1084 | } else { | 1089 | } else { |
1085 | res = -ENOTCONN; | 1090 | res = -ENOTCONN; |
@@ -1099,7 +1104,7 @@ int tipc_disconnect(u32 ref) | |||
1099 | p_ptr = tipc_port_lock(ref); | 1104 | p_ptr = tipc_port_lock(ref); |
1100 | if (!p_ptr) | 1105 | if (!p_ptr) |
1101 | return -EINVAL; | 1106 | return -EINVAL; |
1102 | res = tipc_disconnect_port((struct tipc_port *)p_ptr); | 1107 | res = tipc_disconnect_port(p_ptr); |
1103 | tipc_port_unlock(p_ptr); | 1108 | tipc_port_unlock(p_ptr); |
1104 | return res; | 1109 | return res; |
1105 | } | 1110 | } |