aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/link.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc/link.c')
-rw-r--r--net/tipc/link.c394
1 files changed, 197 insertions, 197 deletions
diff --git a/net/tipc/link.c b/net/tipc/link.c
index 1bb983c8130b..71c2f2fd405c 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * net/tipc/link.c: TIPC link code 2 * net/tipc/link.c: TIPC link code
3 * 3 *
4 * Copyright (c) 1996-2006, Ericsson AB 4 * Copyright (c) 1996-2006, Ericsson AB
5 * Copyright (c) 2004-2006, Wind River Systems 5 * Copyright (c) 2004-2006, Wind River Systems
6 * All rights reserved. 6 * All rights reserved.
@@ -50,29 +50,29 @@
50#include "bcast.h" 50#include "bcast.h"
51 51
52 52
53/* 53/*
54 * Limit for deferred reception queue: 54 * Limit for deferred reception queue:
55 */ 55 */
56 56
57#define DEF_QUEUE_LIMIT 256u 57#define DEF_QUEUE_LIMIT 256u
58 58
59/* 59/*
60 * Link state events: 60 * Link state events:
61 */ 61 */
62 62
63#define STARTING_EVT 856384768 /* link processing trigger */ 63#define STARTING_EVT 856384768 /* link processing trigger */
64#define TRAFFIC_MSG_EVT 560815u /* rx'd ??? */ 64#define TRAFFIC_MSG_EVT 560815u /* rx'd ??? */
65#define TIMEOUT_EVT 560817u /* link timer expired */ 65#define TIMEOUT_EVT 560817u /* link timer expired */
66 66
67/* 67/*
68 * The following two 'message types' is really just implementation 68 * The following two 'message types' is really just implementation
69 * data conveniently stored in the message header. 69 * data conveniently stored in the message header.
70 * They must not be considered part of the protocol 70 * They must not be considered part of the protocol
71 */ 71 */
72#define OPEN_MSG 0 72#define OPEN_MSG 0
73#define CLOSED_MSG 1 73#define CLOSED_MSG 1
74 74
75/* 75/*
76 * State value stored in 'exp_msg_count' 76 * State value stored in 'exp_msg_count'
77 */ 77 */
78 78
@@ -97,7 +97,7 @@ struct link_name {
97 97
98/* LINK EVENT CODE IS NOT SUPPORTED AT PRESENT */ 98/* LINK EVENT CODE IS NOT SUPPORTED AT PRESENT */
99 99
100/** 100/**
101 * struct link_event - link up/down event notification 101 * struct link_event - link up/down event notification
102 */ 102 */
103 103
@@ -121,7 +121,7 @@ static int link_send_sections_long(struct port *sender,
121static void link_check_defragm_bufs(struct link *l_ptr); 121static void link_check_defragm_bufs(struct link *l_ptr);
122static void link_state_event(struct link *l_ptr, u32 event); 122static void link_state_event(struct link *l_ptr, u32 event);
123static void link_reset_statistics(struct link *l_ptr); 123static void link_reset_statistics(struct link *l_ptr);
124static void link_print(struct link *l_ptr, struct print_buf *buf, 124static void link_print(struct link *l_ptr, struct print_buf *buf,
125 const char *str); 125 const char *str);
126 126
127/* 127/*
@@ -136,13 +136,13 @@ static void link_print(struct link *l_ptr, struct print_buf *buf,
136 * 136 *
137 * To enable per-link debugging, use LINK_LOG_BUF_SIZE to specify the size 137 * To enable per-link debugging, use LINK_LOG_BUF_SIZE to specify the size
138 * of the print buffer used by each link. If LINK_LOG_BUF_SIZE is set to 0, 138 * of the print buffer used by each link. If LINK_LOG_BUF_SIZE is set to 0,
139 * the dbg_link_XXX() routines simply send their output to the standard 139 * the dbg_link_XXX() routines simply send their output to the standard
140 * debug print buffer (DBG_OUTPUT), if it has been defined; this can be useful 140 * debug print buffer (DBG_OUTPUT), if it has been defined; this can be useful
141 * when there is only a single link in the system being debugged. 141 * when there is only a single link in the system being debugged.
142 * 142 *
143 * Notes: 143 * Notes:
144 * - When enabled, LINK_LOG_BUF_SIZE should be set to at least TIPC_PB_MIN_SIZE 144 * - When enabled, LINK_LOG_BUF_SIZE should be set to at least TIPC_PB_MIN_SIZE
145 * - "l_ptr" must be valid when using dbg_link_XXX() macros 145 * - "l_ptr" must be valid when using dbg_link_XXX() macros
146 */ 146 */
147 147
148#define LINK_LOG_BUF_SIZE 0 148#define LINK_LOG_BUF_SIZE 0
@@ -222,18 +222,18 @@ static u32 link_max_pkt(struct link *l_ptr)
222static void link_init_max_pkt(struct link *l_ptr) 222static void link_init_max_pkt(struct link *l_ptr)
223{ 223{
224 u32 max_pkt; 224 u32 max_pkt;
225 225
226 max_pkt = (l_ptr->b_ptr->publ.mtu & ~3); 226 max_pkt = (l_ptr->b_ptr->publ.mtu & ~3);
227 if (max_pkt > MAX_MSG_SIZE) 227 if (max_pkt > MAX_MSG_SIZE)
228 max_pkt = MAX_MSG_SIZE; 228 max_pkt = MAX_MSG_SIZE;
229 229
230 l_ptr->max_pkt_target = max_pkt; 230 l_ptr->max_pkt_target = max_pkt;
231 if (l_ptr->max_pkt_target < MAX_PKT_DEFAULT) 231 if (l_ptr->max_pkt_target < MAX_PKT_DEFAULT)
232 l_ptr->max_pkt = l_ptr->max_pkt_target; 232 l_ptr->max_pkt = l_ptr->max_pkt_target;
233 else 233 else
234 l_ptr->max_pkt = MAX_PKT_DEFAULT; 234 l_ptr->max_pkt = MAX_PKT_DEFAULT;
235 235
236 l_ptr->max_pkt_probes = 0; 236 l_ptr->max_pkt_probes = 0;
237} 237}
238 238
239static u32 link_next_sent(struct link *l_ptr) 239static u32 link_next_sent(struct link *l_ptr)
@@ -269,7 +269,7 @@ int tipc_link_is_active(struct link *l_ptr)
269 * link_name_validate - validate & (optionally) deconstruct link name 269 * link_name_validate - validate & (optionally) deconstruct link name
270 * @name - ptr to link name string 270 * @name - ptr to link name string
271 * @name_parts - ptr to area for link name components (or NULL if not needed) 271 * @name_parts - ptr to area for link name components (or NULL if not needed)
272 * 272 *
273 * Returns 1 if link name is valid, otherwise 0. 273 * Returns 1 if link name is valid, otherwise 0.
274 */ 274 */
275 275
@@ -317,8 +317,8 @@ static int link_name_validate(const char *name, struct link_name *name_parts)
317 &z_peer, &c_peer, &n_peer, &dummy) != 3) || 317 &z_peer, &c_peer, &n_peer, &dummy) != 3) ||
318 (z_local > 255) || (c_local > 4095) || (n_local > 4095) || 318 (z_local > 255) || (c_local > 4095) || (n_local > 4095) ||
319 (z_peer > 255) || (c_peer > 4095) || (n_peer > 4095) || 319 (z_peer > 255) || (c_peer > 4095) || (n_peer > 4095) ||
320 (if_local_len <= 1) || (if_local_len > TIPC_MAX_IF_NAME) || 320 (if_local_len <= 1) || (if_local_len > TIPC_MAX_IF_NAME) ||
321 (if_peer_len <= 1) || (if_peer_len > TIPC_MAX_IF_NAME) || 321 (if_peer_len <= 1) || (if_peer_len > TIPC_MAX_IF_NAME) ||
322 (strspn(if_local, tipc_alphabet) != (if_local_len - 1)) || 322 (strspn(if_local, tipc_alphabet) != (if_local_len - 1)) ||
323 (strspn(if_peer, tipc_alphabet) != (if_peer_len - 1))) 323 (strspn(if_peer, tipc_alphabet) != (if_peer_len - 1)))
324 return 0; 324 return 0;
@@ -337,7 +337,7 @@ static int link_name_validate(const char *name, struct link_name *name_parts)
337/** 337/**
338 * link_timeout - handle expiration of link timer 338 * link_timeout - handle expiration of link timer
339 * @l_ptr: pointer to link 339 * @l_ptr: pointer to link
340 * 340 *
341 * This routine must not grab "tipc_net_lock" to avoid a potential deadlock conflict 341 * This routine must not grab "tipc_net_lock" to avoid a potential deadlock conflict
342 * with tipc_link_delete(). (There is no risk that the node will be deleted by 342 * with tipc_link_delete(). (There is no risk that the node will be deleted by
343 * another thread because tipc_link_delete() always cancels the link timer before 343 * another thread because tipc_link_delete() always cancels the link timer before
@@ -406,7 +406,7 @@ static void link_set_timer(struct link *l_ptr, u32 time)
406 * @b_ptr: pointer to associated bearer 406 * @b_ptr: pointer to associated bearer
407 * @peer: network address of node at other end of link 407 * @peer: network address of node at other end of link
408 * @media_addr: media address to use when sending messages over link 408 * @media_addr: media address to use when sending messages over link
409 * 409 *
410 * Returns pointer to link. 410 * Returns pointer to link.
411 */ 411 */
412 412
@@ -427,7 +427,7 @@ struct link *tipc_link_create(struct bearer *b_ptr, const u32 peer,
427 if_name = strchr(b_ptr->publ.name, ':') + 1; 427 if_name = strchr(b_ptr->publ.name, ':') + 1;
428 sprintf(l_ptr->name, "%u.%u.%u:%s-%u.%u.%u:", 428 sprintf(l_ptr->name, "%u.%u.%u:%s-%u.%u.%u:",
429 tipc_zone(tipc_own_addr), tipc_cluster(tipc_own_addr), 429 tipc_zone(tipc_own_addr), tipc_cluster(tipc_own_addr),
430 tipc_node(tipc_own_addr), 430 tipc_node(tipc_own_addr),
431 if_name, 431 if_name,
432 tipc_zone(peer), tipc_cluster(peer), tipc_node(peer)); 432 tipc_zone(peer), tipc_cluster(peer), tipc_node(peer));
433 /* note: peer i/f is appended to link name by reset/activate */ 433 /* note: peer i/f is appended to link name by reset/activate */
@@ -478,17 +478,17 @@ struct link *tipc_link_create(struct bearer *b_ptr, const u32 peer,
478 478
479 dbg("tipc_link_create(): tolerance = %u,cont intv = %u, abort_limit = %u\n", 479 dbg("tipc_link_create(): tolerance = %u,cont intv = %u, abort_limit = %u\n",
480 l_ptr->tolerance, l_ptr->continuity_interval, l_ptr->abort_limit); 480 l_ptr->tolerance, l_ptr->continuity_interval, l_ptr->abort_limit);
481 481
482 return l_ptr; 482 return l_ptr;
483} 483}
484 484
485/** 485/**
486 * tipc_link_delete - delete a link 486 * tipc_link_delete - delete a link
487 * @l_ptr: pointer to link 487 * @l_ptr: pointer to link
488 * 488 *
489 * Note: 'tipc_net_lock' is write_locked, bearer is locked. 489 * Note: 'tipc_net_lock' is write_locked, bearer is locked.
490 * This routine must not grab the node lock until after link timer cancellation 490 * This routine must not grab the node lock until after link timer cancellation
491 * to avoid a potential deadlock situation. 491 * to avoid a potential deadlock situation.
492 */ 492 */
493 493
494void tipc_link_delete(struct link *l_ptr) 494void tipc_link_delete(struct link *l_ptr)
@@ -501,7 +501,7 @@ void tipc_link_delete(struct link *l_ptr)
501 dbg("tipc_link_delete()\n"); 501 dbg("tipc_link_delete()\n");
502 502
503 k_cancel_timer(&l_ptr->timer); 503 k_cancel_timer(&l_ptr->timer);
504 504
505 tipc_node_lock(l_ptr->owner); 505 tipc_node_lock(l_ptr->owner);
506 tipc_link_reset(l_ptr); 506 tipc_link_reset(l_ptr);
507 tipc_node_detach_link(l_ptr->owner, l_ptr); 507 tipc_node_detach_link(l_ptr->owner, l_ptr);
@@ -521,12 +521,12 @@ void tipc_link_start(struct link *l_ptr)
521} 521}
522 522
523/** 523/**
524 * link_schedule_port - schedule port for deferred sending 524 * link_schedule_port - schedule port for deferred sending
525 * @l_ptr: pointer to link 525 * @l_ptr: pointer to link
526 * @origport: reference to sending port 526 * @origport: reference to sending port
527 * @sz: amount of data to be sent 527 * @sz: amount of data to be sent
528 * 528 *
529 * Schedules port for renewed sending of messages after link congestion 529 * Schedules port for renewed sending of messages after link congestion
530 * has abated. 530 * has abated.
531 */ 531 */
532 532
@@ -567,7 +567,7 @@ void tipc_link_wakeup_ports(struct link *l_ptr, int all)
567 return; 567 return;
568 if (link_congested(l_ptr)) 568 if (link_congested(l_ptr))
569 goto exit; 569 goto exit;
570 list_for_each_entry_safe(p_ptr, temp_p_ptr, &l_ptr->waiting_ports, 570 list_for_each_entry_safe(p_ptr, temp_p_ptr, &l_ptr->waiting_ports,
571 wait_list) { 571 wait_list) {
572 if (win <= 0) 572 if (win <= 0)
573 break; 573 break;
@@ -584,7 +584,7 @@ exit:
584 spin_unlock_bh(&tipc_port_list_lock); 584 spin_unlock_bh(&tipc_port_list_lock);
585} 585}
586 586
587/** 587/**
588 * link_release_outqueue - purge link's outbound message queue 588 * link_release_outqueue - purge link's outbound message queue
589 * @l_ptr: pointer to link 589 * @l_ptr: pointer to link
590 */ 590 */
@@ -621,7 +621,7 @@ void tipc_link_reset_fragments(struct link *l_ptr)
621 l_ptr->defragm_buf = NULL; 621 l_ptr->defragm_buf = NULL;
622} 622}
623 623
624/** 624/**
625 * tipc_link_stop - purge all inbound and outbound messages associated with link 625 * tipc_link_stop - purge all inbound and outbound messages associated with link
626 * @l_ptr: pointer to link 626 * @l_ptr: pointer to link
627 */ 627 */
@@ -665,7 +665,7 @@ static void link_send_event(void (*fcn)(u32 a, char *n, int up),
665 struct link *l_ptr, int up) 665 struct link *l_ptr, int up)
666{ 666{
667 struct link_event *ev; 667 struct link_event *ev;
668 668
669 ev = kmalloc(sizeof(*ev), GFP_ATOMIC); 669 ev = kmalloc(sizeof(*ev), GFP_ATOMIC);
670 if (!ev) { 670 if (!ev) {
671 warn("Link event allocation failure\n"); 671 warn("Link event allocation failure\n");
@@ -690,15 +690,15 @@ void tipc_link_reset(struct link *l_ptr)
690 u32 prev_state = l_ptr->state; 690 u32 prev_state = l_ptr->state;
691 u32 checkpoint = l_ptr->next_in_no; 691 u32 checkpoint = l_ptr->next_in_no;
692 int was_active_link = tipc_link_is_active(l_ptr); 692 int was_active_link = tipc_link_is_active(l_ptr);
693 693
694 msg_set_session(l_ptr->pmsg, msg_session(l_ptr->pmsg) + 1); 694 msg_set_session(l_ptr->pmsg, msg_session(l_ptr->pmsg) + 1);
695 695
696 /* Link is down, accept any session: */ 696 /* Link is down, accept any session: */
697 l_ptr->peer_session = 0; 697 l_ptr->peer_session = 0;
698 698
699 /* Prepare for max packet size negotiation */ 699 /* Prepare for max packet size negotiation */
700 link_init_max_pkt(l_ptr); 700 link_init_max_pkt(l_ptr);
701 701
702 l_ptr->state = RESET_UNKNOWN; 702 l_ptr->state = RESET_UNKNOWN;
703 dbg_link_state("Resetting Link\n"); 703 dbg_link_state("Resetting Link\n");
704 704
@@ -770,7 +770,7 @@ static void link_activate(struct link *l_ptr)
770 770
771static void link_state_event(struct link *l_ptr, unsigned event) 771static void link_state_event(struct link *l_ptr, unsigned event)
772{ 772{
773 struct link *other; 773 struct link *other;
774 u32 cont_intv = l_ptr->continuity_interval; 774 u32 cont_intv = l_ptr->continuity_interval;
775 775
776 if (!l_ptr->started && (event != STARTING_EVT)) 776 if (!l_ptr->started && (event != STARTING_EVT))
@@ -799,11 +799,11 @@ static void link_state_event(struct link *l_ptr, unsigned event)
799 if (l_ptr->next_in_no != l_ptr->checkpoint) { 799 if (l_ptr->next_in_no != l_ptr->checkpoint) {
800 l_ptr->checkpoint = l_ptr->next_in_no; 800 l_ptr->checkpoint = l_ptr->next_in_no;
801 if (tipc_bclink_acks_missing(l_ptr->owner)) { 801 if (tipc_bclink_acks_missing(l_ptr->owner)) {
802 tipc_link_send_proto_msg(l_ptr, STATE_MSG, 802 tipc_link_send_proto_msg(l_ptr, STATE_MSG,
803 0, 0, 0, 0, 0); 803 0, 0, 0, 0, 0);
804 l_ptr->fsm_msg_cnt++; 804 l_ptr->fsm_msg_cnt++;
805 } else if (l_ptr->max_pkt < l_ptr->max_pkt_target) { 805 } else if (l_ptr->max_pkt < l_ptr->max_pkt_target) {
806 tipc_link_send_proto_msg(l_ptr, STATE_MSG, 806 tipc_link_send_proto_msg(l_ptr, STATE_MSG,
807 1, 0, 0, 0, 0); 807 1, 0, 0, 0, 0);
808 l_ptr->fsm_msg_cnt++; 808 l_ptr->fsm_msg_cnt++;
809 } 809 }
@@ -819,7 +819,7 @@ static void link_state_event(struct link *l_ptr, unsigned event)
819 break; 819 break;
820 case RESET_MSG: 820 case RESET_MSG:
821 dbg_link("RES -> RR\n"); 821 dbg_link("RES -> RR\n");
822 info("Resetting link <%s>, requested by peer\n", 822 info("Resetting link <%s>, requested by peer\n",
823 l_ptr->name); 823 l_ptr->name);
824 tipc_link_reset(l_ptr); 824 tipc_link_reset(l_ptr);
825 l_ptr->state = RESET_RESET; 825 l_ptr->state = RESET_RESET;
@@ -871,7 +871,7 @@ static void link_state_event(struct link *l_ptr, unsigned event)
871 dbg_link("Probing %u/%u,timer = %u ms)\n", 871 dbg_link("Probing %u/%u,timer = %u ms)\n",
872 l_ptr->fsm_msg_cnt, l_ptr->abort_limit, 872 l_ptr->fsm_msg_cnt, l_ptr->abort_limit,
873 cont_intv / 4); 873 cont_intv / 4);
874 tipc_link_send_proto_msg(l_ptr, STATE_MSG, 874 tipc_link_send_proto_msg(l_ptr, STATE_MSG,
875 1, 0, 0, 0, 0); 875 1, 0, 0, 0, 0);
876 l_ptr->fsm_msg_cnt++; 876 l_ptr->fsm_msg_cnt++;
877 link_set_timer(l_ptr, cont_intv / 4); 877 link_set_timer(l_ptr, cont_intv / 4);
@@ -977,11 +977,11 @@ static void link_state_event(struct link *l_ptr, unsigned event)
977 977
978/* 978/*
979 * link_bundle_buf(): Append contents of a buffer to 979 * link_bundle_buf(): Append contents of a buffer to
980 * the tail of an existing one. 980 * the tail of an existing one.
981 */ 981 */
982 982
983static int link_bundle_buf(struct link *l_ptr, 983static int link_bundle_buf(struct link *l_ptr,
984 struct sk_buff *bundler, 984 struct sk_buff *bundler,
985 struct sk_buff *buf) 985 struct sk_buff *buf)
986{ 986{
987 struct tipc_msg *bundler_msg = buf_msg(bundler); 987 struct tipc_msg *bundler_msg = buf_msg(bundler);
@@ -1030,8 +1030,8 @@ static void link_add_to_outqueue(struct link *l_ptr,
1030 l_ptr->out_queue_size++; 1030 l_ptr->out_queue_size++;
1031} 1031}
1032 1032
1033/* 1033/*
1034 * tipc_link_send_buf() is the 'full path' for messages, called from 1034 * tipc_link_send_buf() is the 'full path' for messages, called from
1035 * inside TIPC when the 'fast path' in tipc_send_buf 1035 * inside TIPC when the 'fast path' in tipc_send_buf
1036 * has failed, and from link_send() 1036 * has failed, and from link_send()
1037 */ 1037 */
@@ -1074,7 +1074,7 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf)
1074 if (queue_size > l_ptr->stats.max_queue_sz) 1074 if (queue_size > l_ptr->stats.max_queue_sz)
1075 l_ptr->stats.max_queue_sz = queue_size; 1075 l_ptr->stats.max_queue_sz = queue_size;
1076 1076
1077 if (likely(!tipc_bearer_congested(l_ptr->b_ptr, l_ptr) && 1077 if (likely(!tipc_bearer_congested(l_ptr->b_ptr, l_ptr) &&
1078 !link_congested(l_ptr))) { 1078 !link_congested(l_ptr))) {
1079 link_add_to_outqueue(l_ptr, buf, msg); 1079 link_add_to_outqueue(l_ptr, buf, msg);
1080 1080
@@ -1094,7 +1094,7 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf)
1094 1094
1095 /* Try adding message to an existing bundle */ 1095 /* Try adding message to an existing bundle */
1096 1096
1097 if (l_ptr->next_out && 1097 if (l_ptr->next_out &&
1098 link_bundle_buf(l_ptr, l_ptr->last_out, buf)) { 1098 link_bundle_buf(l_ptr, l_ptr->last_out, buf)) {
1099 tipc_bearer_resolve_congestion(l_ptr->b_ptr, l_ptr); 1099 tipc_bearer_resolve_congestion(l_ptr->b_ptr, l_ptr);
1100 return dsz; 1100 return dsz;
@@ -1109,7 +1109,7 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf)
1109 if (bundler) { 1109 if (bundler) {
1110 msg_init(&bundler_hdr, MSG_BUNDLER, OPEN_MSG, 1110 msg_init(&bundler_hdr, MSG_BUNDLER, OPEN_MSG,
1111 TIPC_OK, INT_H_SIZE, l_ptr->addr); 1111 TIPC_OK, INT_H_SIZE, l_ptr->addr);
1112 memcpy(bundler->data, (unchar *)&bundler_hdr, 1112 memcpy(bundler->data, (unchar *)&bundler_hdr,
1113 INT_H_SIZE); 1113 INT_H_SIZE);
1114 skb_trim(bundler, INT_H_SIZE); 1114 skb_trim(bundler, INT_H_SIZE);
1115 link_bundle_buf(l_ptr, bundler, buf); 1115 link_bundle_buf(l_ptr, bundler, buf);
@@ -1126,8 +1126,8 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf)
1126 return dsz; 1126 return dsz;
1127} 1127}
1128 1128
1129/* 1129/*
1130 * tipc_link_send(): same as tipc_link_send_buf(), but the link to use has 1130 * tipc_link_send(): same as tipc_link_send_buf(), but the link to use has
1131 * not been selected yet, and the the owner node is not locked 1131 * not been selected yet, and the the owner node is not locked
1132 * Called by TIPC internal users, e.g. the name distributor 1132 * Called by TIPC internal users, e.g. the name distributor
1133 */ 1133 */
@@ -1161,8 +1161,8 @@ int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector)
1161 return res; 1161 return res;
1162} 1162}
1163 1163
1164/* 1164/*
1165 * link_send_buf_fast: Entry for data messages where the 1165 * link_send_buf_fast: Entry for data messages where the
1166 * destination link is known and the header is complete, 1166 * destination link is known and the header is complete,
1167 * inclusive total message length. Very time critical. 1167 * inclusive total message length. Very time critical.
1168 * Link is locked. Returns user data length. 1168 * Link is locked. Returns user data length.
@@ -1197,8 +1197,8 @@ static int link_send_buf_fast(struct link *l_ptr, struct sk_buff *buf,
1197 return tipc_link_send_buf(l_ptr, buf); /* All other cases */ 1197 return tipc_link_send_buf(l_ptr, buf); /* All other cases */
1198} 1198}
1199 1199
1200/* 1200/*
1201 * tipc_send_buf_fast: Entry for data messages where the 1201 * tipc_send_buf_fast: Entry for data messages where the
1202 * destination node is known and the header is complete, 1202 * destination node is known and the header is complete,
1203 * inclusive total message length. 1203 * inclusive total message length.
1204 * Returns user data length. 1204 * Returns user data length.
@@ -1236,15 +1236,15 @@ int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode)
1236} 1236}
1237 1237
1238 1238
1239/* 1239/*
1240 * tipc_link_send_sections_fast: Entry for messages where the 1240 * tipc_link_send_sections_fast: Entry for messages where the
1241 * destination processor is known and the header is complete, 1241 * destination processor is known and the header is complete,
1242 * except for total message length. 1242 * except for total message length.
1243 * Returns user data length or errno. 1243 * Returns user data length or errno.
1244 */ 1244 */
1245int tipc_link_send_sections_fast(struct port *sender, 1245int tipc_link_send_sections_fast(struct port *sender,
1246 struct iovec const *msg_sect, 1246 struct iovec const *msg_sect,
1247 const u32 num_sect, 1247 const u32 num_sect,
1248 u32 destaddr) 1248 u32 destaddr)
1249{ 1249{
1250 struct tipc_msg *hdr = &sender->publ.phdr; 1250 struct tipc_msg *hdr = &sender->publ.phdr;
@@ -1287,14 +1287,14 @@ exit:
1287 1287
1288 /* Exit if link (or bearer) is congested */ 1288 /* Exit if link (or bearer) is congested */
1289 1289
1290 if (link_congested(l_ptr) || 1290 if (link_congested(l_ptr) ||
1291 !list_empty(&l_ptr->b_ptr->cong_links)) { 1291 !list_empty(&l_ptr->b_ptr->cong_links)) {
1292 res = link_schedule_port(l_ptr, 1292 res = link_schedule_port(l_ptr,
1293 sender->publ.ref, res); 1293 sender->publ.ref, res);
1294 goto exit; 1294 goto exit;
1295 } 1295 }
1296 1296
1297 /* 1297 /*
1298 * Message size exceeds max_pkt hint; update hint, 1298 * Message size exceeds max_pkt hint; update hint,
1299 * then re-try fast path or fragment the message 1299 * then re-try fast path or fragment the message
1300 */ 1300 */
@@ -1324,10 +1324,10 @@ exit:
1324 return res; 1324 return res;
1325} 1325}
1326 1326
1327/* 1327/*
1328 * link_send_sections_long(): Entry for long messages where the 1328 * link_send_sections_long(): Entry for long messages where the
1329 * destination node is known and the header is complete, 1329 * destination node is known and the header is complete,
1330 * inclusive total message length. 1330 * inclusive total message length.
1331 * Link and bearer congestion status have been checked to be ok, 1331 * Link and bearer congestion status have been checked to be ok,
1332 * and are ignored if they change. 1332 * and are ignored if they change.
1333 * 1333 *
@@ -1357,9 +1357,9 @@ static int link_send_sections_long(struct port *sender,
1357 1357
1358again: 1358again:
1359 fragm_no = 1; 1359 fragm_no = 1;
1360 max_pkt = sender->max_pkt - INT_H_SIZE; 1360 max_pkt = sender->max_pkt - INT_H_SIZE;
1361 /* leave room for tunnel header in case of link changeover */ 1361 /* leave room for tunnel header in case of link changeover */
1362 fragm_sz = max_pkt - INT_H_SIZE; 1362 fragm_sz = max_pkt - INT_H_SIZE;
1363 /* leave room for fragmentation header in each fragment */ 1363 /* leave room for fragmentation header in each fragment */
1364 rest = dsz; 1364 rest = dsz;
1365 fragm_crs = 0; 1365 fragm_crs = 0;
@@ -1440,7 +1440,7 @@ error:
1440 if (!buf) 1440 if (!buf)
1441 goto error; 1441 goto error;
1442 1442
1443 buf->next = NULL; 1443 buf->next = NULL;
1444 prev->next = buf; 1444 prev->next = buf;
1445 memcpy(buf->data, (unchar *)&fragm_hdr, INT_H_SIZE); 1445 memcpy(buf->data, (unchar *)&fragm_hdr, INT_H_SIZE);
1446 fragm_crs = INT_H_SIZE; 1446 fragm_crs = INT_H_SIZE;
@@ -1450,7 +1450,7 @@ error:
1450 } 1450 }
1451 while (rest > 0); 1451 while (rest > 0);
1452 1452
1453 /* 1453 /*
1454 * Now we have a buffer chain. Select a link and check 1454 * Now we have a buffer chain. Select a link and check
1455 * that packet size is still OK 1455 * that packet size is still OK
1456 */ 1456 */
@@ -1506,7 +1506,7 @@ reject:
1506 return dsz; 1506 return dsz;
1507} 1507}
1508 1508
1509/* 1509/*
1510 * tipc_link_push_packet: Push one unsent packet to the media 1510 * tipc_link_push_packet: Push one unsent packet to the media
1511 */ 1511 */
1512u32 tipc_link_push_packet(struct link *l_ptr) 1512u32 tipc_link_push_packet(struct link *l_ptr)
@@ -1519,7 +1519,7 @@ u32 tipc_link_push_packet(struct link *l_ptr)
1519 /* consider that buffers may have been released in meantime */ 1519 /* consider that buffers may have been released in meantime */
1520 1520
1521 if (r_q_size && buf) { 1521 if (r_q_size && buf) {
1522 u32 last = lesser(mod(r_q_head + r_q_size), 1522 u32 last = lesser(mod(r_q_head + r_q_size),
1523 link_last_sent(l_ptr)); 1523 link_last_sent(l_ptr));
1524 u32 first = msg_seqno(buf_msg(buf)); 1524 u32 first = msg_seqno(buf_msg(buf));
1525 1525
@@ -1535,7 +1535,7 @@ u32 tipc_link_push_packet(struct link *l_ptr)
1535 1535
1536 if (r_q_size && buf && !skb_cloned(buf)) { 1536 if (r_q_size && buf && !skb_cloned(buf)) {
1537 msg_set_ack(buf_msg(buf), mod(l_ptr->next_in_no - 1)); 1537 msg_set_ack(buf_msg(buf), mod(l_ptr->next_in_no - 1));
1538 msg_set_bcast_ack(buf_msg(buf), l_ptr->owner->bclink.last_in); 1538 msg_set_bcast_ack(buf_msg(buf), l_ptr->owner->bclink.last_in);
1539 if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) { 1539 if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) {
1540 msg_dbg(buf_msg(buf), ">DEF-RETR>"); 1540 msg_dbg(buf_msg(buf), ">DEF-RETR>");
1541 l_ptr->retransm_queue_head = mod(++r_q_head); 1541 l_ptr->retransm_queue_head = mod(++r_q_head);
@@ -1554,7 +1554,7 @@ u32 tipc_link_push_packet(struct link *l_ptr)
1554 buf = l_ptr->proto_msg_queue; 1554 buf = l_ptr->proto_msg_queue;
1555 if (buf) { 1555 if (buf) {
1556 msg_set_ack(buf_msg(buf), mod(l_ptr->next_in_no - 1)); 1556 msg_set_ack(buf_msg(buf), mod(l_ptr->next_in_no - 1));
1557 msg_set_bcast_ack(buf_msg(buf),l_ptr->owner->bclink.last_in); 1557 msg_set_bcast_ack(buf_msg(buf),l_ptr->owner->bclink.last_in);
1558 if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) { 1558 if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) {
1559 msg_dbg(buf_msg(buf), ">DEF-PROT>"); 1559 msg_dbg(buf_msg(buf), ">DEF-PROT>");
1560 l_ptr->unacked_window = 0; 1560 l_ptr->unacked_window = 0;
@@ -1578,7 +1578,7 @@ u32 tipc_link_push_packet(struct link *l_ptr)
1578 1578
1579 if (mod(next - first) < l_ptr->queue_limit[0]) { 1579 if (mod(next - first) < l_ptr->queue_limit[0]) {
1580 msg_set_ack(msg, mod(l_ptr->next_in_no - 1)); 1580 msg_set_ack(msg, mod(l_ptr->next_in_no - 1));
1581 msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); 1581 msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in);
1582 if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) { 1582 if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) {
1583 if (msg_user(msg) == MSG_BUNDLER) 1583 if (msg_user(msg) == MSG_BUNDLER)
1584 msg_set_type(msg, CLOSED_MSG); 1584 msg_set_type(msg, CLOSED_MSG);
@@ -1629,12 +1629,12 @@ static void link_reset_all(unsigned long addr)
1629 1629
1630 tipc_node_lock(n_ptr); 1630 tipc_node_lock(n_ptr);
1631 1631
1632 warn("Resetting all links to %s\n", 1632 warn("Resetting all links to %s\n",
1633 addr_string_fill(addr_string, n_ptr->addr)); 1633 addr_string_fill(addr_string, n_ptr->addr));
1634 1634
1635 for (i = 0; i < MAX_BEARERS; i++) { 1635 for (i = 0; i < MAX_BEARERS; i++) {
1636 if (n_ptr->links[i]) { 1636 if (n_ptr->links[i]) {
1637 link_print(n_ptr->links[i], TIPC_OUTPUT, 1637 link_print(n_ptr->links[i], TIPC_OUTPUT,
1638 "Resetting link\n"); 1638 "Resetting link\n");
1639 tipc_link_reset(n_ptr->links[i]); 1639 tipc_link_reset(n_ptr->links[i]);
1640 } 1640 }
@@ -1689,7 +1689,7 @@ static void link_retransmit_failure(struct link *l_ptr, struct sk_buff *buf)
1689 } 1689 }
1690} 1690}
1691 1691
1692void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf, 1692void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf,
1693 u32 retransmits) 1693 u32 retransmits)
1694{ 1694{
1695 struct tipc_msg *msg; 1695 struct tipc_msg *msg;
@@ -1698,7 +1698,7 @@ void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf,
1698 return; 1698 return;
1699 1699
1700 msg = buf_msg(buf); 1700 msg = buf_msg(buf);
1701 1701
1702 dbg("Retransmitting %u in link %x\n", retransmits, l_ptr); 1702 dbg("Retransmitting %u in link %x\n", retransmits, l_ptr);
1703 1703
1704 if (tipc_bearer_congested(l_ptr->b_ptr, l_ptr)) { 1704 if (tipc_bearer_congested(l_ptr->b_ptr, l_ptr)) {
@@ -1728,7 +1728,7 @@ void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf,
1728 while (retransmits && (buf != l_ptr->next_out) && buf && !skb_cloned(buf)) { 1728 while (retransmits && (buf != l_ptr->next_out) && buf && !skb_cloned(buf)) {
1729 msg = buf_msg(buf); 1729 msg = buf_msg(buf);
1730 msg_set_ack(msg, mod(l_ptr->next_in_no - 1)); 1730 msg_set_ack(msg, mod(l_ptr->next_in_no - 1));
1731 msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); 1731 msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in);
1732 if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) { 1732 if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) {
1733 msg_dbg(buf_msg(buf), ">RETR>"); 1733 msg_dbg(buf_msg(buf), ">RETR>");
1734 buf = buf->next; 1734 buf = buf->next;
@@ -1746,7 +1746,7 @@ void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf,
1746 l_ptr->retransm_queue_head = l_ptr->retransm_queue_size = 0; 1746 l_ptr->retransm_queue_head = l_ptr->retransm_queue_size = 0;
1747} 1747}
1748 1748
1749/* 1749/*
1750 * link_recv_non_seq: Receive packets which are outside 1750 * link_recv_non_seq: Receive packets which are outside
1751 * the link sequence flow 1751 * the link sequence flow
1752 */ 1752 */
@@ -1761,11 +1761,11 @@ static void link_recv_non_seq(struct sk_buff *buf)
1761 tipc_bclink_recv_pkt(buf); 1761 tipc_bclink_recv_pkt(buf);
1762} 1762}
1763 1763
1764/** 1764/**
1765 * link_insert_deferred_queue - insert deferred messages back into receive chain 1765 * link_insert_deferred_queue - insert deferred messages back into receive chain
1766 */ 1766 */
1767 1767
1768static struct sk_buff *link_insert_deferred_queue(struct link *l_ptr, 1768static struct sk_buff *link_insert_deferred_queue(struct link *l_ptr,
1769 struct sk_buff *buf) 1769 struct sk_buff *buf)
1770{ 1770{
1771 u32 seq_no; 1771 u32 seq_no;
@@ -1813,11 +1813,11 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr)
1813 link_recv_non_seq(buf); 1813 link_recv_non_seq(buf);
1814 continue; 1814 continue;
1815 } 1815 }
1816 1816
1817 if (unlikely(!msg_short(msg) && 1817 if (unlikely(!msg_short(msg) &&
1818 (msg_destnode(msg) != tipc_own_addr))) 1818 (msg_destnode(msg) != tipc_own_addr)))
1819 goto cont; 1819 goto cont;
1820 1820
1821 n_ptr = tipc_node_find(msg_prevnode(msg)); 1821 n_ptr = tipc_node_find(msg_prevnode(msg));
1822 if (unlikely(!n_ptr)) 1822 if (unlikely(!n_ptr))
1823 goto cont; 1823 goto cont;
@@ -1828,8 +1828,8 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr)
1828 tipc_node_unlock(n_ptr); 1828 tipc_node_unlock(n_ptr);
1829 goto cont; 1829 goto cont;
1830 } 1830 }
1831 /* 1831 /*
1832 * Release acked messages 1832 * Release acked messages
1833 */ 1833 */
1834 if (less(n_ptr->bclink.acked, msg_bcast_ack(msg))) { 1834 if (less(n_ptr->bclink.acked, msg_bcast_ack(msg))) {
1835 if (tipc_node_is_up(n_ptr) && n_ptr->bclink.supported) 1835 if (tipc_node_is_up(n_ptr) && n_ptr->bclink.supported)
@@ -1837,7 +1837,7 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr)
1837 } 1837 }
1838 1838
1839 crs = l_ptr->first_out; 1839 crs = l_ptr->first_out;
1840 while ((crs != l_ptr->next_out) && 1840 while ((crs != l_ptr->next_out) &&
1841 less_eq(msg_seqno(buf_msg(crs)), ackd)) { 1841 less_eq(msg_seqno(buf_msg(crs)), ackd)) {
1842 struct sk_buff *next = crs->next; 1842 struct sk_buff *next = crs->next;
1843 1843
@@ -1875,7 +1875,7 @@ deliver:
1875 switch (msg_user(msg)) { 1875 switch (msg_user(msg)) {
1876 case MSG_BUNDLER: 1876 case MSG_BUNDLER:
1877 l_ptr->stats.recv_bundles++; 1877 l_ptr->stats.recv_bundles++;
1878 l_ptr->stats.recv_bundled += 1878 l_ptr->stats.recv_bundled +=
1879 msg_msgcnt(msg); 1879 msg_msgcnt(msg);
1880 tipc_node_unlock(n_ptr); 1880 tipc_node_unlock(n_ptr);
1881 tipc_link_recv_bundle(buf); 1881 tipc_link_recv_bundle(buf);
@@ -1894,7 +1894,7 @@ deliver:
1894 continue; 1894 continue;
1895 case MSG_FRAGMENTER: 1895 case MSG_FRAGMENTER:
1896 l_ptr->stats.recv_fragments++; 1896 l_ptr->stats.recv_fragments++;
1897 if (tipc_link_recv_fragment(&l_ptr->defragm_buf, 1897 if (tipc_link_recv_fragment(&l_ptr->defragm_buf,
1898 &buf, &msg)) { 1898 &buf, &msg)) {
1899 l_ptr->stats.recv_fragmented++; 1899 l_ptr->stats.recv_fragmented++;
1900 goto deliver; 1900 goto deliver;
@@ -1905,7 +1905,7 @@ deliver:
1905 if (link_recv_changeover_msg(&l_ptr, &buf)) { 1905 if (link_recv_changeover_msg(&l_ptr, &buf)) {
1906 msg = buf_msg(buf); 1906 msg = buf_msg(buf);
1907 seq_no = msg_seqno(msg); 1907 seq_no = msg_seqno(msg);
1908 TIPC_SKB_CB(buf)->handle 1908 TIPC_SKB_CB(buf)->handle
1909 = b_ptr; 1909 = b_ptr;
1910 if (type == ORIGINAL_MSG) 1910 if (type == ORIGINAL_MSG)
1911 goto deliver; 1911 goto deliver;
@@ -1948,8 +1948,8 @@ cont:
1948 read_unlock_bh(&tipc_net_lock); 1948 read_unlock_bh(&tipc_net_lock);
1949} 1949}
1950 1950
1951/* 1951/*
1952 * link_defer_buf(): Sort a received out-of-sequence packet 1952 * link_defer_buf(): Sort a received out-of-sequence packet
1953 * into the deferred reception queue. 1953 * into the deferred reception queue.
1954 * Returns the increase of the queue length,i.e. 0 or 1 1954 * Returns the increase of the queue length,i.e. 0 or 1
1955 */ 1955 */
@@ -1986,7 +1986,7 @@ u32 tipc_link_defer_pkt(struct sk_buff **head,
1986 if (prev) 1986 if (prev)
1987 prev->next = buf; 1987 prev->next = buf;
1988 else 1988 else
1989 *head = buf; 1989 *head = buf;
1990 return 1; 1990 return 1;
1991 } 1991 }
1992 if (seq_no == msg_seqno(msg)) { 1992 if (seq_no == msg_seqno(msg)) {
@@ -2003,11 +2003,11 @@ u32 tipc_link_defer_pkt(struct sk_buff **head,
2003 return 0; 2003 return 0;
2004} 2004}
2005 2005
2006/** 2006/**
2007 * link_handle_out_of_seq_msg - handle arrival of out-of-sequence packet 2007 * link_handle_out_of_seq_msg - handle arrival of out-of-sequence packet
2008 */ 2008 */
2009 2009
2010static void link_handle_out_of_seq_msg(struct link *l_ptr, 2010static void link_handle_out_of_seq_msg(struct link *l_ptr,
2011 struct sk_buff *buf) 2011 struct sk_buff *buf)
2012{ 2012{
2013 u32 seq_no = msg_seqno(buf_msg(buf)); 2013 u32 seq_no = msg_seqno(buf_msg(buf));
@@ -2017,14 +2017,14 @@ static void link_handle_out_of_seq_msg(struct link *l_ptr,
2017 return; 2017 return;
2018 } 2018 }
2019 2019
2020 dbg("rx OOS msg: seq_no %u, expecting %u (%u)\n", 2020 dbg("rx OOS msg: seq_no %u, expecting %u (%u)\n",
2021 seq_no, mod(l_ptr->next_in_no), l_ptr->next_in_no); 2021 seq_no, mod(l_ptr->next_in_no), l_ptr->next_in_no);
2022 2022
2023 /* Record OOS packet arrival (force mismatch on next timeout) */ 2023 /* Record OOS packet arrival (force mismatch on next timeout) */
2024 2024
2025 l_ptr->checkpoint--; 2025 l_ptr->checkpoint--;
2026 2026
2027 /* 2027 /*
2028 * Discard packet if a duplicate; otherwise add it to deferred queue 2028 * Discard packet if a duplicate; otherwise add it to deferred queue
2029 * and notify peer of gap as per protocol specification 2029 * and notify peer of gap as per protocol specification
2030 */ 2030 */
@@ -2053,13 +2053,13 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg,
2053{ 2053{
2054 struct sk_buff *buf = NULL; 2054 struct sk_buff *buf = NULL;
2055 struct tipc_msg *msg = l_ptr->pmsg; 2055 struct tipc_msg *msg = l_ptr->pmsg;
2056 u32 msg_size = sizeof(l_ptr->proto_msg); 2056 u32 msg_size = sizeof(l_ptr->proto_msg);
2057 2057
2058 if (link_blocked(l_ptr)) 2058 if (link_blocked(l_ptr))
2059 return; 2059 return;
2060 msg_set_type(msg, msg_typ); 2060 msg_set_type(msg, msg_typ);
2061 msg_set_net_plane(msg, l_ptr->b_ptr->net_plane); 2061 msg_set_net_plane(msg, l_ptr->b_ptr->net_plane);
2062 msg_set_bcast_ack(msg, mod(l_ptr->owner->bclink.last_in)); 2062 msg_set_bcast_ack(msg, mod(l_ptr->owner->bclink.last_in));
2063 msg_set_last_bcast(msg, tipc_bclink_get_last_sent()); 2063 msg_set_last_bcast(msg, tipc_bclink_get_last_sent());
2064 2064
2065 if (msg_typ == STATE_MSG) { 2065 if (msg_typ == STATE_MSG) {
@@ -2082,23 +2082,23 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg,
2082 msg_set_max_pkt(msg, ack_mtu); 2082 msg_set_max_pkt(msg, ack_mtu);
2083 msg_set_ack(msg, mod(l_ptr->next_in_no - 1)); 2083 msg_set_ack(msg, mod(l_ptr->next_in_no - 1));
2084 msg_set_probe(msg, probe_msg != 0); 2084 msg_set_probe(msg, probe_msg != 0);
2085 if (probe_msg) { 2085 if (probe_msg) {
2086 u32 mtu = l_ptr->max_pkt; 2086 u32 mtu = l_ptr->max_pkt;
2087 2087
2088 if ((mtu < l_ptr->max_pkt_target) && 2088 if ((mtu < l_ptr->max_pkt_target) &&
2089 link_working_working(l_ptr) && 2089 link_working_working(l_ptr) &&
2090 l_ptr->fsm_msg_cnt) { 2090 l_ptr->fsm_msg_cnt) {
2091 msg_size = (mtu + (l_ptr->max_pkt_target - mtu)/2 + 2) & ~3; 2091 msg_size = (mtu + (l_ptr->max_pkt_target - mtu)/2 + 2) & ~3;
2092 if (l_ptr->max_pkt_probes == 10) { 2092 if (l_ptr->max_pkt_probes == 10) {
2093 l_ptr->max_pkt_target = (msg_size - 4); 2093 l_ptr->max_pkt_target = (msg_size - 4);
2094 l_ptr->max_pkt_probes = 0; 2094 l_ptr->max_pkt_probes = 0;
2095 msg_size = (mtu + (l_ptr->max_pkt_target - mtu)/2 + 2) & ~3; 2095 msg_size = (mtu + (l_ptr->max_pkt_target - mtu)/2 + 2) & ~3;
2096 } 2096 }
2097 l_ptr->max_pkt_probes++; 2097 l_ptr->max_pkt_probes++;
2098 } 2098 }
2099 2099
2100 l_ptr->stats.sent_probes++; 2100 l_ptr->stats.sent_probes++;
2101 } 2101 }
2102 l_ptr->stats.sent_states++; 2102 l_ptr->stats.sent_states++;
2103 } else { /* RESET_MSG or ACTIVATE_MSG */ 2103 } else { /* RESET_MSG or ACTIVATE_MSG */
2104 msg_set_ack(msg, mod(l_ptr->reset_checkpoint - 1)); 2104 msg_set_ack(msg, mod(l_ptr->reset_checkpoint - 1));
@@ -2144,7 +2144,7 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg,
2144 return; 2144 return;
2145 2145
2146 memcpy(buf->data, (unchar *)msg, sizeof(l_ptr->proto_msg)); 2146 memcpy(buf->data, (unchar *)msg, sizeof(l_ptr->proto_msg));
2147 msg_set_size(buf_msg(buf), msg_size); 2147 msg_set_size(buf_msg(buf), msg_size);
2148 2148
2149 if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) { 2149 if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) {
2150 l_ptr->unacked_window = 0; 2150 l_ptr->unacked_window = 0;
@@ -2160,15 +2160,15 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg,
2160 2160
2161/* 2161/*
2162 * Receive protocol message : 2162 * Receive protocol message :
2163 * Note that network plane id propagates through the network, and may 2163 * Note that network plane id propagates through the network, and may
2164 * change at any time. The node with lowest address rules 2164 * change at any time. The node with lowest address rules
2165 */ 2165 */
2166 2166
2167static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf) 2167static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf)
2168{ 2168{
2169 u32 rec_gap = 0; 2169 u32 rec_gap = 0;
2170 u32 max_pkt_info; 2170 u32 max_pkt_info;
2171 u32 max_pkt_ack; 2171 u32 max_pkt_ack;
2172 u32 msg_tol; 2172 u32 msg_tol;
2173 struct tipc_msg *msg = buf_msg(buf); 2173 struct tipc_msg *msg = buf_msg(buf);
2174 2174
@@ -2188,12 +2188,12 @@ static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf)
2188 l_ptr->owner->permit_changeover = msg_redundant_link(msg); 2188 l_ptr->owner->permit_changeover = msg_redundant_link(msg);
2189 2189
2190 switch (msg_type(msg)) { 2190 switch (msg_type(msg)) {
2191 2191
2192 case RESET_MSG: 2192 case RESET_MSG:
2193 if (!link_working_unknown(l_ptr) && l_ptr->peer_session) { 2193 if (!link_working_unknown(l_ptr) && l_ptr->peer_session) {
2194 if (msg_session(msg) == l_ptr->peer_session) { 2194 if (msg_session(msg) == l_ptr->peer_session) {
2195 dbg("Duplicate RESET: %u<->%u\n", 2195 dbg("Duplicate RESET: %u<->%u\n",
2196 msg_session(msg), l_ptr->peer_session); 2196 msg_session(msg), l_ptr->peer_session);
2197 break; /* duplicate: ignore */ 2197 break; /* duplicate: ignore */
2198 } 2198 }
2199 } 2199 }
@@ -2211,13 +2211,13 @@ static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf)
2211 l_ptr->priority = msg_linkprio(msg); 2211 l_ptr->priority = msg_linkprio(msg);
2212 2212
2213 max_pkt_info = msg_max_pkt(msg); 2213 max_pkt_info = msg_max_pkt(msg);
2214 if (max_pkt_info) { 2214 if (max_pkt_info) {
2215 if (max_pkt_info < l_ptr->max_pkt_target) 2215 if (max_pkt_info < l_ptr->max_pkt_target)
2216 l_ptr->max_pkt_target = max_pkt_info; 2216 l_ptr->max_pkt_target = max_pkt_info;
2217 if (l_ptr->max_pkt > l_ptr->max_pkt_target) 2217 if (l_ptr->max_pkt > l_ptr->max_pkt_target)
2218 l_ptr->max_pkt = l_ptr->max_pkt_target; 2218 l_ptr->max_pkt = l_ptr->max_pkt_target;
2219 } else { 2219 } else {
2220 l_ptr->max_pkt = l_ptr->max_pkt_target; 2220 l_ptr->max_pkt = l_ptr->max_pkt_target;
2221 } 2221 }
2222 l_ptr->owner->bclink.supported = (max_pkt_info != 0); 2222 l_ptr->owner->bclink.supported = (max_pkt_info != 0);
2223 2223
@@ -2235,8 +2235,8 @@ static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf)
2235 2235
2236 if ((msg_tol = msg_link_tolerance(msg))) 2236 if ((msg_tol = msg_link_tolerance(msg)))
2237 link_set_supervision_props(l_ptr, msg_tol); 2237 link_set_supervision_props(l_ptr, msg_tol);
2238 2238
2239 if (msg_linkprio(msg) && 2239 if (msg_linkprio(msg) &&
2240 (msg_linkprio(msg) != l_ptr->priority)) { 2240 (msg_linkprio(msg) != l_ptr->priority)) {
2241 warn("Resetting link <%s>, priority change %u->%u\n", 2241 warn("Resetting link <%s>, priority change %u->%u\n",
2242 l_ptr->name, l_ptr->priority, msg_linkprio(msg)); 2242 l_ptr->name, l_ptr->priority, msg_linkprio(msg));
@@ -2250,25 +2250,25 @@ static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf)
2250 break; 2250 break;
2251 2251
2252 if (less_eq(mod(l_ptr->next_in_no), msg_next_sent(msg))) { 2252 if (less_eq(mod(l_ptr->next_in_no), msg_next_sent(msg))) {
2253 rec_gap = mod(msg_next_sent(msg) - 2253 rec_gap = mod(msg_next_sent(msg) -
2254 mod(l_ptr->next_in_no)); 2254 mod(l_ptr->next_in_no));
2255 } 2255 }
2256 2256
2257 max_pkt_ack = msg_max_pkt(msg); 2257 max_pkt_ack = msg_max_pkt(msg);
2258 if (max_pkt_ack > l_ptr->max_pkt) { 2258 if (max_pkt_ack > l_ptr->max_pkt) {
2259 dbg("Link <%s> updated MTU %u -> %u\n", 2259 dbg("Link <%s> updated MTU %u -> %u\n",
2260 l_ptr->name, l_ptr->max_pkt, max_pkt_ack); 2260 l_ptr->name, l_ptr->max_pkt, max_pkt_ack);
2261 l_ptr->max_pkt = max_pkt_ack; 2261 l_ptr->max_pkt = max_pkt_ack;
2262 l_ptr->max_pkt_probes = 0; 2262 l_ptr->max_pkt_probes = 0;
2263 } 2263 }
2264 2264
2265 max_pkt_ack = 0; 2265 max_pkt_ack = 0;
2266 if (msg_probe(msg)) { 2266 if (msg_probe(msg)) {
2267 l_ptr->stats.recv_probes++; 2267 l_ptr->stats.recv_probes++;
2268 if (msg_size(msg) > sizeof(l_ptr->proto_msg)) { 2268 if (msg_size(msg) > sizeof(l_ptr->proto_msg)) {
2269 max_pkt_ack = msg_size(msg); 2269 max_pkt_ack = msg_size(msg);
2270 } 2270 }
2271 } 2271 }
2272 2272
2273 /* Protocol message before retransmits, reduce loss risk */ 2273 /* Protocol message before retransmits, reduce loss risk */
2274 2274
@@ -2294,11 +2294,11 @@ exit:
2294 2294
2295 2295
2296/* 2296/*
2297 * tipc_link_tunnel(): Send one message via a link belonging to 2297 * tipc_link_tunnel(): Send one message via a link belonging to
2298 * another bearer. Owner node is locked. 2298 * another bearer. Owner node is locked.
2299 */ 2299 */
2300void tipc_link_tunnel(struct link *l_ptr, 2300void tipc_link_tunnel(struct link *l_ptr,
2301 struct tipc_msg *tunnel_hdr, 2301 struct tipc_msg *tunnel_hdr,
2302 struct tipc_msg *msg, 2302 struct tipc_msg *msg,
2303 u32 selector) 2303 u32 selector)
2304{ 2304{
@@ -2374,7 +2374,7 @@ void tipc_link_changeover(struct link *l_ptr)
2374 return; 2374 return;
2375 } 2375 }
2376 2376
2377 split_bundles = (l_ptr->owner->active_links[0] != 2377 split_bundles = (l_ptr->owner->active_links[0] !=
2378 l_ptr->owner->active_links[1]); 2378 l_ptr->owner->active_links[1]);
2379 2379
2380 while (crs) { 2380 while (crs) {
@@ -2418,7 +2418,7 @@ void tipc_link_send_duplicate(struct link *l_ptr, struct link *tunnel)
2418 if (msg_user(msg) == MSG_BUNDLER) 2418 if (msg_user(msg) == MSG_BUNDLER)
2419 msg_set_type(msg, CLOSED_MSG); 2419 msg_set_type(msg, CLOSED_MSG);
2420 msg_set_ack(msg, mod(l_ptr->next_in_no - 1)); /* Update */ 2420 msg_set_ack(msg, mod(l_ptr->next_in_no - 1)); /* Update */
2421 msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); 2421 msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in);
2422 msg_set_size(&tunnel_hdr, length + INT_H_SIZE); 2422 msg_set_size(&tunnel_hdr, length + INT_H_SIZE);
2423 outbuf = buf_acquire(length + INT_H_SIZE); 2423 outbuf = buf_acquire(length + INT_H_SIZE);
2424 if (outbuf == NULL) { 2424 if (outbuf == NULL) {
@@ -2445,7 +2445,7 @@ void tipc_link_send_duplicate(struct link *l_ptr, struct link *tunnel)
2445 * @skb: encapsulating message buffer 2445 * @skb: encapsulating message buffer
2446 * @from_pos: offset to extract from 2446 * @from_pos: offset to extract from
2447 * 2447 *
2448 * Returns a new message buffer containing an embedded message. The 2448 * Returns a new message buffer containing an embedded message. The
2449 * encapsulating message itself is left unchanged. 2449 * encapsulating message itself is left unchanged.
2450 */ 2450 */
2451 2451
@@ -2461,7 +2461,7 @@ static struct sk_buff *buf_extract(struct sk_buff *skb, u32 from_pos)
2461 return eb; 2461 return eb;
2462} 2462}
2463 2463
2464/* 2464/*
2465 * link_recv_changeover_msg(): Receive tunneled packet sent 2465 * link_recv_changeover_msg(): Receive tunneled packet sent
2466 * via other link. Node is locked. Return extracted buffer. 2466 * via other link. Node is locked. Return extracted buffer.
2467 */ 2467 */
@@ -2482,7 +2482,7 @@ static int link_recv_changeover_msg(struct link **l_ptr,
2482 goto exit; 2482 goto exit;
2483 } 2483 }
2484 if (dest_link == *l_ptr) { 2484 if (dest_link == *l_ptr) {
2485 err("Unexpected changeover message on link <%s>\n", 2485 err("Unexpected changeover message on link <%s>\n",
2486 (*l_ptr)->name); 2486 (*l_ptr)->name);
2487 goto exit; 2487 goto exit;
2488 } 2488 }
@@ -2582,9 +2582,9 @@ void tipc_link_recv_bundle(struct sk_buff *buf)
2582 */ 2582 */
2583 2583
2584 2584
2585/* 2585/*
2586 * tipc_link_send_long_buf: Entry for buffers needing fragmentation. 2586 * tipc_link_send_long_buf: Entry for buffers needing fragmentation.
2587 * The buffer is complete, inclusive total message length. 2587 * The buffer is complete, inclusive total message length.
2588 * Returns user data length. 2588 * Returns user data length.
2589 */ 2589 */
2590int tipc_link_send_long_buf(struct link *l_ptr, struct sk_buff *buf) 2590int tipc_link_send_long_buf(struct link *l_ptr, struct sk_buff *buf)
@@ -2650,9 +2650,9 @@ exit:
2650 return dsz; 2650 return dsz;
2651} 2651}
2652 2652
2653/* 2653/*
2654 * A pending message being re-assembled must store certain values 2654 * A pending message being re-assembled must store certain values
2655 * to handle subsequent fragments correctly. The following functions 2655 * to handle subsequent fragments correctly. The following functions
2656 * help storing these values in unused, available fields in the 2656 * help storing these values in unused, available fields in the
2657 * pending message. This makes dynamic memory allocation unecessary. 2657 * pending message. This makes dynamic memory allocation unecessary.
2658 */ 2658 */
@@ -2692,11 +2692,11 @@ static void incr_timer_cnt(struct sk_buff *buf)
2692 msg_incr_reroute_cnt(buf_msg(buf)); 2692 msg_incr_reroute_cnt(buf_msg(buf));
2693} 2693}
2694 2694
2695/* 2695/*
2696 * tipc_link_recv_fragment(): Called with node lock on. Returns 2696 * tipc_link_recv_fragment(): Called with node lock on. Returns
2697 * the reassembled buffer if message is complete. 2697 * the reassembled buffer if message is complete.
2698 */ 2698 */
2699int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb, 2699int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,
2700 struct tipc_msg **m) 2700 struct tipc_msg **m)
2701{ 2701{
2702 struct sk_buff *prev = NULL; 2702 struct sk_buff *prev = NULL;
@@ -2737,9 +2737,9 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,
2737 2737
2738 /* Prepare buffer for subsequent fragments. */ 2738 /* Prepare buffer for subsequent fragments. */
2739 2739
2740 set_long_msg_seqno(pbuf, long_msg_seq_no); 2740 set_long_msg_seqno(pbuf, long_msg_seq_no);
2741 set_fragm_size(pbuf,fragm_sz); 2741 set_fragm_size(pbuf,fragm_sz);
2742 set_expected_frags(pbuf,exp_fragm_cnt - 1); 2742 set_expected_frags(pbuf,exp_fragm_cnt - 1);
2743 } else { 2743 } else {
2744 warn("Link unable to reassemble fragmented message\n"); 2744 warn("Link unable to reassemble fragmented message\n");
2745 } 2745 }
@@ -2765,7 +2765,7 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,
2765 *m = buf_msg(pbuf); 2765 *m = buf_msg(pbuf);
2766 return 1; 2766 return 1;
2767 } 2767 }
2768 set_expected_frags(pbuf,exp_frags); 2768 set_expected_frags(pbuf,exp_frags);
2769 return 0; 2769 return 0;
2770 } 2770 }
2771 dbg(" Discarding orphan fragment %x\n",fbuf); 2771 dbg(" Discarding orphan fragment %x\n",fbuf);
@@ -2849,10 +2849,10 @@ void tipc_link_set_queue_limits(struct link *l_ptr, u32 window)
2849 * link_find_link - locate link by name 2849 * link_find_link - locate link by name
2850 * @name - ptr to link name string 2850 * @name - ptr to link name string
2851 * @node - ptr to area to be filled with ptr to associated node 2851 * @node - ptr to area to be filled with ptr to associated node
2852 * 2852 *
2853 * Caller must hold 'tipc_net_lock' to ensure node and bearer are not deleted; 2853 * Caller must hold 'tipc_net_lock' to ensure node and bearer are not deleted;
2854 * this also prevents link deletion. 2854 * this also prevents link deletion.
2855 * 2855 *
2856 * Returns pointer to link (or 0 if invalid link name). 2856 * Returns pointer to link (or 0 if invalid link name).
2857 */ 2857 */
2858 2858
@@ -2860,7 +2860,7 @@ static struct link *link_find_link(const char *name, struct node **node)
2860{ 2860{
2861 struct link_name link_name_parts; 2861 struct link_name link_name_parts;
2862 struct bearer *b_ptr; 2862 struct bearer *b_ptr;
2863 struct link *l_ptr; 2863 struct link *l_ptr;
2864 2864
2865 if (!link_name_validate(name, &link_name_parts)) 2865 if (!link_name_validate(name, &link_name_parts))
2866 return NULL; 2866 return NULL;
@@ -2869,7 +2869,7 @@ static struct link *link_find_link(const char *name, struct node **node)
2869 if (!b_ptr) 2869 if (!b_ptr)
2870 return NULL; 2870 return NULL;
2871 2871
2872 *node = tipc_node_find(link_name_parts.addr_peer); 2872 *node = tipc_node_find(link_name_parts.addr_peer);
2873 if (!*node) 2873 if (!*node)
2874 return NULL; 2874 return NULL;
2875 2875
@@ -2880,14 +2880,14 @@ static struct link *link_find_link(const char *name, struct node **node)
2880 return l_ptr; 2880 return l_ptr;
2881} 2881}
2882 2882
2883struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space, 2883struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space,
2884 u16 cmd) 2884 u16 cmd)
2885{ 2885{
2886 struct tipc_link_config *args; 2886 struct tipc_link_config *args;
2887 u32 new_value; 2887 u32 new_value;
2888 struct link *l_ptr; 2888 struct link *l_ptr;
2889 struct node *node; 2889 struct node *node;
2890 int res; 2890 int res;
2891 2891
2892 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_CONFIG)) 2892 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_CONFIG))
2893 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); 2893 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
@@ -2899,40 +2899,40 @@ struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space
2899 if ((cmd == TIPC_CMD_SET_LINK_WINDOW) && 2899 if ((cmd == TIPC_CMD_SET_LINK_WINDOW) &&
2900 (tipc_bclink_set_queue_limits(new_value) == 0)) 2900 (tipc_bclink_set_queue_limits(new_value) == 0))
2901 return tipc_cfg_reply_none(); 2901 return tipc_cfg_reply_none();
2902 return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED 2902 return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
2903 " (cannot change setting on broadcast link)"); 2903 " (cannot change setting on broadcast link)");
2904 } 2904 }
2905 2905
2906 read_lock_bh(&tipc_net_lock); 2906 read_lock_bh(&tipc_net_lock);
2907 l_ptr = link_find_link(args->name, &node); 2907 l_ptr = link_find_link(args->name, &node);
2908 if (!l_ptr) { 2908 if (!l_ptr) {
2909 read_unlock_bh(&tipc_net_lock); 2909 read_unlock_bh(&tipc_net_lock);
2910 return tipc_cfg_reply_error_string("link not found"); 2910 return tipc_cfg_reply_error_string("link not found");
2911 } 2911 }
2912 2912
2913 tipc_node_lock(node); 2913 tipc_node_lock(node);
2914 res = -EINVAL; 2914 res = -EINVAL;
2915 switch (cmd) { 2915 switch (cmd) {
2916 case TIPC_CMD_SET_LINK_TOL: 2916 case TIPC_CMD_SET_LINK_TOL:
2917 if ((new_value >= TIPC_MIN_LINK_TOL) && 2917 if ((new_value >= TIPC_MIN_LINK_TOL) &&
2918 (new_value <= TIPC_MAX_LINK_TOL)) { 2918 (new_value <= TIPC_MAX_LINK_TOL)) {
2919 link_set_supervision_props(l_ptr, new_value); 2919 link_set_supervision_props(l_ptr, new_value);
2920 tipc_link_send_proto_msg(l_ptr, STATE_MSG, 2920 tipc_link_send_proto_msg(l_ptr, STATE_MSG,
2921 0, 0, new_value, 0, 0); 2921 0, 0, new_value, 0, 0);
2922 res = TIPC_OK; 2922 res = TIPC_OK;
2923 } 2923 }
2924 break; 2924 break;
2925 case TIPC_CMD_SET_LINK_PRI: 2925 case TIPC_CMD_SET_LINK_PRI:
2926 if ((new_value >= TIPC_MIN_LINK_PRI) && 2926 if ((new_value >= TIPC_MIN_LINK_PRI) &&
2927 (new_value <= TIPC_MAX_LINK_PRI)) { 2927 (new_value <= TIPC_MAX_LINK_PRI)) {
2928 l_ptr->priority = new_value; 2928 l_ptr->priority = new_value;
2929 tipc_link_send_proto_msg(l_ptr, STATE_MSG, 2929 tipc_link_send_proto_msg(l_ptr, STATE_MSG,
2930 0, 0, 0, new_value, 0); 2930 0, 0, 0, new_value, 0);
2931 res = TIPC_OK; 2931 res = TIPC_OK;
2932 } 2932 }
2933 break; 2933 break;
2934 case TIPC_CMD_SET_LINK_WINDOW: 2934 case TIPC_CMD_SET_LINK_WINDOW:
2935 if ((new_value >= TIPC_MIN_LINK_WIN) && 2935 if ((new_value >= TIPC_MIN_LINK_WIN) &&
2936 (new_value <= TIPC_MAX_LINK_WIN)) { 2936 (new_value <= TIPC_MAX_LINK_WIN)) {
2937 tipc_link_set_queue_limits(l_ptr, new_value); 2937 tipc_link_set_queue_limits(l_ptr, new_value);
2938 res = TIPC_OK; 2938 res = TIPC_OK;
@@ -2943,7 +2943,7 @@ struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space
2943 2943
2944 read_unlock_bh(&tipc_net_lock); 2944 read_unlock_bh(&tipc_net_lock);
2945 if (res) 2945 if (res)
2946 return tipc_cfg_reply_error_string("cannot change link setting"); 2946 return tipc_cfg_reply_error_string("cannot change link setting");
2947 2947
2948 return tipc_cfg_reply_none(); 2948 return tipc_cfg_reply_none();
2949} 2949}
@@ -2963,7 +2963,7 @@ static void link_reset_statistics(struct link *l_ptr)
2963struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area, int req_tlv_space) 2963struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area, int req_tlv_space)
2964{ 2964{
2965 char *link_name; 2965 char *link_name;
2966 struct link *l_ptr; 2966 struct link *l_ptr;
2967 struct node *node; 2967 struct node *node;
2968 2968
2969 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_NAME)) 2969 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_NAME))
@@ -2977,7 +2977,7 @@ struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area, int req_tlv_
2977 } 2977 }
2978 2978
2979 read_lock_bh(&tipc_net_lock); 2979 read_lock_bh(&tipc_net_lock);
2980 l_ptr = link_find_link(link_name, &node); 2980 l_ptr = link_find_link(link_name, &node);
2981 if (!l_ptr) { 2981 if (!l_ptr) {
2982 read_unlock_bh(&tipc_net_lock); 2982 read_unlock_bh(&tipc_net_lock);
2983 return tipc_cfg_reply_error_string("link not found"); 2983 return tipc_cfg_reply_error_string("link not found");
@@ -3004,14 +3004,14 @@ static u32 percent(u32 count, u32 total)
3004 * @name: link name 3004 * @name: link name
3005 * @buf: print buffer area 3005 * @buf: print buffer area
3006 * @buf_size: size of print buffer area 3006 * @buf_size: size of print buffer area
3007 * 3007 *
3008 * Returns length of print buffer data string (or 0 if error) 3008 * Returns length of print buffer data string (or 0 if error)
3009 */ 3009 */
3010 3010
3011static int tipc_link_stats(const char *name, char *buf, const u32 buf_size) 3011static int tipc_link_stats(const char *name, char *buf, const u32 buf_size)
3012{ 3012{
3013 struct print_buf pb; 3013 struct print_buf pb;
3014 struct link *l_ptr; 3014 struct link *l_ptr;
3015 struct node *node; 3015 struct node *node;
3016 char *status; 3016 char *status;
3017 u32 profile_total = 0; 3017 u32 profile_total = 0;
@@ -3022,7 +3022,7 @@ static int tipc_link_stats(const char *name, char *buf, const u32 buf_size)
3022 tipc_printbuf_init(&pb, buf, buf_size); 3022 tipc_printbuf_init(&pb, buf, buf_size);
3023 3023
3024 read_lock_bh(&tipc_net_lock); 3024 read_lock_bh(&tipc_net_lock);
3025 l_ptr = link_find_link(name, &node); 3025 l_ptr = link_find_link(name, &node);
3026 if (!l_ptr) { 3026 if (!l_ptr) {
3027 read_unlock_bh(&tipc_net_lock); 3027 read_unlock_bh(&tipc_net_lock);
3028 return 0; 3028 return 0;
@@ -3036,28 +3036,28 @@ static int tipc_link_stats(const char *name, char *buf, const u32 buf_size)
3036 else 3036 else
3037 status = "DEFUNCT"; 3037 status = "DEFUNCT";
3038 tipc_printf(&pb, "Link <%s>\n" 3038 tipc_printf(&pb, "Link <%s>\n"
3039 " %s MTU:%u Priority:%u Tolerance:%u ms" 3039 " %s MTU:%u Priority:%u Tolerance:%u ms"
3040 " Window:%u packets\n", 3040 " Window:%u packets\n",
3041 l_ptr->name, status, link_max_pkt(l_ptr), 3041 l_ptr->name, status, link_max_pkt(l_ptr),
3042 l_ptr->priority, l_ptr->tolerance, l_ptr->queue_limit[0]); 3042 l_ptr->priority, l_ptr->tolerance, l_ptr->queue_limit[0]);
3043 tipc_printf(&pb, " RX packets:%u fragments:%u/%u bundles:%u/%u\n", 3043 tipc_printf(&pb, " RX packets:%u fragments:%u/%u bundles:%u/%u\n",
3044 l_ptr->next_in_no - l_ptr->stats.recv_info, 3044 l_ptr->next_in_no - l_ptr->stats.recv_info,
3045 l_ptr->stats.recv_fragments, 3045 l_ptr->stats.recv_fragments,
3046 l_ptr->stats.recv_fragmented, 3046 l_ptr->stats.recv_fragmented,
3047 l_ptr->stats.recv_bundles, 3047 l_ptr->stats.recv_bundles,
3048 l_ptr->stats.recv_bundled); 3048 l_ptr->stats.recv_bundled);
3049 tipc_printf(&pb, " TX packets:%u fragments:%u/%u bundles:%u/%u\n", 3049 tipc_printf(&pb, " TX packets:%u fragments:%u/%u bundles:%u/%u\n",
3050 l_ptr->next_out_no - l_ptr->stats.sent_info, 3050 l_ptr->next_out_no - l_ptr->stats.sent_info,
3051 l_ptr->stats.sent_fragments, 3051 l_ptr->stats.sent_fragments,
3052 l_ptr->stats.sent_fragmented, 3052 l_ptr->stats.sent_fragmented,
3053 l_ptr->stats.sent_bundles, 3053 l_ptr->stats.sent_bundles,
3054 l_ptr->stats.sent_bundled); 3054 l_ptr->stats.sent_bundled);
3055 profile_total = l_ptr->stats.msg_length_counts; 3055 profile_total = l_ptr->stats.msg_length_counts;
3056 if (!profile_total) 3056 if (!profile_total)
3057 profile_total = 1; 3057 profile_total = 1;
3058 tipc_printf(&pb, " TX profile sample:%u packets average:%u octets\n" 3058 tipc_printf(&pb, " TX profile sample:%u packets average:%u octets\n"
3059 " 0-64:%u%% -256:%u%% -1024:%u%% -4096:%u%% " 3059 " 0-64:%u%% -256:%u%% -1024:%u%% -4096:%u%% "
3060 "-16354:%u%% -32768:%u%% -66000:%u%%\n", 3060 "-16354:%u%% -32768:%u%% -66000:%u%%\n",
3061 l_ptr->stats.msg_length_counts, 3061 l_ptr->stats.msg_length_counts,
3062 l_ptr->stats.msg_lengths_total / profile_total, 3062 l_ptr->stats.msg_lengths_total / profile_total,
3063 percent(l_ptr->stats.msg_length_profile[0], profile_total), 3063 percent(l_ptr->stats.msg_length_profile[0], profile_total),
@@ -3067,21 +3067,21 @@ static int tipc_link_stats(const char *name, char *buf, const u32 buf_size)
3067 percent(l_ptr->stats.msg_length_profile[4], profile_total), 3067 percent(l_ptr->stats.msg_length_profile[4], profile_total),
3068 percent(l_ptr->stats.msg_length_profile[5], profile_total), 3068 percent(l_ptr->stats.msg_length_profile[5], profile_total),
3069 percent(l_ptr->stats.msg_length_profile[6], profile_total)); 3069 percent(l_ptr->stats.msg_length_profile[6], profile_total));
3070 tipc_printf(&pb, " RX states:%u probes:%u naks:%u defs:%u dups:%u\n", 3070 tipc_printf(&pb, " RX states:%u probes:%u naks:%u defs:%u dups:%u\n",
3071 l_ptr->stats.recv_states, 3071 l_ptr->stats.recv_states,
3072 l_ptr->stats.recv_probes, 3072 l_ptr->stats.recv_probes,
3073 l_ptr->stats.recv_nacks, 3073 l_ptr->stats.recv_nacks,
3074 l_ptr->stats.deferred_recv, 3074 l_ptr->stats.deferred_recv,
3075 l_ptr->stats.duplicates); 3075 l_ptr->stats.duplicates);
3076 tipc_printf(&pb, " TX states:%u probes:%u naks:%u acks:%u dups:%u\n", 3076 tipc_printf(&pb, " TX states:%u probes:%u naks:%u acks:%u dups:%u\n",
3077 l_ptr->stats.sent_states, 3077 l_ptr->stats.sent_states,
3078 l_ptr->stats.sent_probes, 3078 l_ptr->stats.sent_probes,
3079 l_ptr->stats.sent_nacks, 3079 l_ptr->stats.sent_nacks,
3080 l_ptr->stats.sent_acks, 3080 l_ptr->stats.sent_acks,
3081 l_ptr->stats.retransmitted); 3081 l_ptr->stats.retransmitted);
3082 tipc_printf(&pb, " Congestion bearer:%u link:%u Send queue max:%u avg:%u\n", 3082 tipc_printf(&pb, " Congestion bearer:%u link:%u Send queue max:%u avg:%u\n",
3083 l_ptr->stats.bearer_congs, 3083 l_ptr->stats.bearer_congs,
3084 l_ptr->stats.link_congs, 3084 l_ptr->stats.link_congs,
3085 l_ptr->stats.max_queue_sz, 3085 l_ptr->stats.max_queue_sz,
3086 l_ptr->stats.queue_sz_counts 3086 l_ptr->stats.queue_sz_counts
3087 ? (l_ptr->stats.accu_queue_sz / l_ptr->stats.queue_sz_counts) 3087 ? (l_ptr->stats.accu_queue_sz / l_ptr->stats.queue_sz_counts)
@@ -3113,7 +3113,7 @@ struct sk_buff *tipc_link_cmd_show_stats(const void *req_tlv_area, int req_tlv_s
3113 (char *)TLV_DATA(rep_tlv), MAX_LINK_STATS_INFO); 3113 (char *)TLV_DATA(rep_tlv), MAX_LINK_STATS_INFO);
3114 if (!str_len) { 3114 if (!str_len) {
3115 buf_discard(buf); 3115 buf_discard(buf);
3116 return tipc_cfg_reply_error_string("link not found"); 3116 return tipc_cfg_reply_error_string("link not found");
3117 } 3117 }
3118 3118
3119 skb_put(buf, TLV_SPACE(str_len)); 3119 skb_put(buf, TLV_SPACE(str_len));
@@ -3164,7 +3164,7 @@ int link_control(const char *name, u32 op, u32 val)
3164 * tipc_link_get_max_pkt - get maximum packet size to use when sending to destination 3164 * tipc_link_get_max_pkt - get maximum packet size to use when sending to destination
3165 * @dest: network address of destination node 3165 * @dest: network address of destination node
3166 * @selector: used to select from set of active links 3166 * @selector: used to select from set of active links
3167 * 3167 *
3168 * If no active link can be found, uses default maximum packet size. 3168 * If no active link can be found, uses default maximum packet size.
3169 */ 3169 */
3170 3170
@@ -3173,11 +3173,11 @@ u32 tipc_link_get_max_pkt(u32 dest, u32 selector)
3173 struct node *n_ptr; 3173 struct node *n_ptr;
3174 struct link *l_ptr; 3174 struct link *l_ptr;
3175 u32 res = MAX_PKT_DEFAULT; 3175 u32 res = MAX_PKT_DEFAULT;
3176 3176
3177 if (dest == tipc_own_addr) 3177 if (dest == tipc_own_addr)
3178 return MAX_MSG_SIZE; 3178 return MAX_MSG_SIZE;
3179 3179
3180 read_lock_bh(&tipc_net_lock); 3180 read_lock_bh(&tipc_net_lock);
3181 n_ptr = tipc_node_select(dest, selector); 3181 n_ptr = tipc_node_select(dest, selector);
3182 if (n_ptr) { 3182 if (n_ptr) {
3183 tipc_node_lock(n_ptr); 3183 tipc_node_lock(n_ptr);
@@ -3186,7 +3186,7 @@ u32 tipc_link_get_max_pkt(u32 dest, u32 selector)
3186 res = link_max_pkt(l_ptr); 3186 res = link_max_pkt(l_ptr);
3187 tipc_node_unlock(n_ptr); 3187 tipc_node_unlock(n_ptr);
3188 } 3188 }
3189 read_unlock_bh(&tipc_net_lock); 3189 read_unlock_bh(&tipc_net_lock);
3190 return res; 3190 return res;
3191} 3191}
3192 3192
@@ -3244,8 +3244,8 @@ static void link_print(struct link *l_ptr, struct print_buf *buf,
3244 tipc_printf(buf, "%u]", 3244 tipc_printf(buf, "%u]",
3245 msg_seqno(buf_msg 3245 msg_seqno(buf_msg
3246 (l_ptr->last_out)), l_ptr->out_queue_size); 3246 (l_ptr->last_out)), l_ptr->out_queue_size);
3247 if ((mod(msg_seqno(buf_msg(l_ptr->last_out)) - 3247 if ((mod(msg_seqno(buf_msg(l_ptr->last_out)) -
3248 msg_seqno(buf_msg(l_ptr->first_out))) 3248 msg_seqno(buf_msg(l_ptr->first_out)))
3249 != (l_ptr->out_queue_size - 1)) 3249 != (l_ptr->out_queue_size - 1))
3250 || (l_ptr->last_out->next != 0)) { 3250 || (l_ptr->last_out->next != 0)) {
3251 tipc_printf(buf, "\nSend queue inconsistency\n"); 3251 tipc_printf(buf, "\nSend queue inconsistency\n");