diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-03-19 20:02:01 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-03-19 20:02:01 -0400 |
commit | 10ce3cc919f50c2043b41ca968b43c26a3672600 (patch) | |
tree | ea409366a5208aced495bc0516a08b81fd43222e /net/tipc/link.c | |
parent | 24e3e5ae1e4c2a3a32f5b1f96b4e3fd721806acd (diff) | |
parent | 5c6a7a62c130afef3d61c1dee153012231ff5cd9 (diff) |
Merge branch 'next' into for-linus
Diffstat (limited to 'net/tipc/link.c')
-rw-r--r-- | net/tipc/link.c | 346 |
1 files changed, 208 insertions, 138 deletions
diff --git a/net/tipc/link.c b/net/tipc/link.c index ae98a72da11a..ac1832a66f8a 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
@@ -71,35 +71,36 @@ | |||
71 | #define START_CHANGEOVER 100000u | 71 | #define START_CHANGEOVER 100000u |
72 | 72 | ||
73 | /** | 73 | /** |
74 | * struct link_name - deconstructed link name | 74 | * struct tipc_link_name - deconstructed link name |
75 | * @addr_local: network address of node at this end | 75 | * @addr_local: network address of node at this end |
76 | * @if_local: name of interface at this end | 76 | * @if_local: name of interface at this end |
77 | * @addr_peer: network address of node at far end | 77 | * @addr_peer: network address of node at far end |
78 | * @if_peer: name of interface at far end | 78 | * @if_peer: name of interface at far end |
79 | */ | 79 | */ |
80 | 80 | ||
81 | struct link_name { | 81 | struct tipc_link_name { |
82 | u32 addr_local; | 82 | u32 addr_local; |
83 | char if_local[TIPC_MAX_IF_NAME]; | 83 | char if_local[TIPC_MAX_IF_NAME]; |
84 | u32 addr_peer; | 84 | u32 addr_peer; |
85 | char if_peer[TIPC_MAX_IF_NAME]; | 85 | char if_peer[TIPC_MAX_IF_NAME]; |
86 | }; | 86 | }; |
87 | 87 | ||
88 | static void link_handle_out_of_seq_msg(struct link *l_ptr, | 88 | static void link_handle_out_of_seq_msg(struct tipc_link *l_ptr, |
89 | struct sk_buff *buf); | 89 | struct sk_buff *buf); |
90 | static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf); | 90 | static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf); |
91 | static int link_recv_changeover_msg(struct link **l_ptr, struct sk_buff **buf); | 91 | static int link_recv_changeover_msg(struct tipc_link **l_ptr, |
92 | static void link_set_supervision_props(struct link *l_ptr, u32 tolerance); | 92 | struct sk_buff **buf); |
93 | static void link_set_supervision_props(struct tipc_link *l_ptr, u32 tolerance); | ||
93 | static int link_send_sections_long(struct tipc_port *sender, | 94 | static int link_send_sections_long(struct tipc_port *sender, |
94 | struct iovec const *msg_sect, | 95 | struct iovec const *msg_sect, |
95 | u32 num_sect, unsigned int total_len, | 96 | u32 num_sect, unsigned int total_len, |
96 | u32 destnode); | 97 | u32 destnode); |
97 | static void link_check_defragm_bufs(struct link *l_ptr); | 98 | static void link_check_defragm_bufs(struct tipc_link *l_ptr); |
98 | static void link_state_event(struct link *l_ptr, u32 event); | 99 | static void link_state_event(struct tipc_link *l_ptr, u32 event); |
99 | static void link_reset_statistics(struct link *l_ptr); | 100 | static void link_reset_statistics(struct tipc_link *l_ptr); |
100 | static void link_print(struct link *l_ptr, const char *str); | 101 | static void link_print(struct tipc_link *l_ptr, const char *str); |
101 | static void link_start(struct link *l_ptr); | 102 | static void link_start(struct tipc_link *l_ptr); |
102 | static int link_send_long_buf(struct link *l_ptr, struct sk_buff *buf); | 103 | static int link_send_long_buf(struct tipc_link *l_ptr, struct sk_buff *buf); |
103 | 104 | ||
104 | /* | 105 | /* |
105 | * Simple link routines | 106 | * Simple link routines |
@@ -110,7 +111,7 @@ static unsigned int align(unsigned int i) | |||
110 | return (i + 3) & ~3u; | 111 | return (i + 3) & ~3u; |
111 | } | 112 | } |
112 | 113 | ||
113 | static void link_init_max_pkt(struct link *l_ptr) | 114 | static void link_init_max_pkt(struct tipc_link *l_ptr) |
114 | { | 115 | { |
115 | u32 max_pkt; | 116 | u32 max_pkt; |
116 | 117 | ||
@@ -127,14 +128,14 @@ static void link_init_max_pkt(struct link *l_ptr) | |||
127 | l_ptr->max_pkt_probes = 0; | 128 | l_ptr->max_pkt_probes = 0; |
128 | } | 129 | } |
129 | 130 | ||
130 | static u32 link_next_sent(struct link *l_ptr) | 131 | static u32 link_next_sent(struct tipc_link *l_ptr) |
131 | { | 132 | { |
132 | if (l_ptr->next_out) | 133 | if (l_ptr->next_out) |
133 | return msg_seqno(buf_msg(l_ptr->next_out)); | 134 | return buf_seqno(l_ptr->next_out); |
134 | return mod(l_ptr->next_out_no); | 135 | return mod(l_ptr->next_out_no); |
135 | } | 136 | } |
136 | 137 | ||
137 | static u32 link_last_sent(struct link *l_ptr) | 138 | static u32 link_last_sent(struct tipc_link *l_ptr) |
138 | { | 139 | { |
139 | return mod(link_next_sent(l_ptr) - 1); | 140 | return mod(link_next_sent(l_ptr) - 1); |
140 | } | 141 | } |
@@ -143,28 +144,29 @@ static u32 link_last_sent(struct link *l_ptr) | |||
143 | * Simple non-static link routines (i.e. referenced outside this file) | 144 | * Simple non-static link routines (i.e. referenced outside this file) |
144 | */ | 145 | */ |
145 | 146 | ||
146 | int tipc_link_is_up(struct link *l_ptr) | 147 | int tipc_link_is_up(struct tipc_link *l_ptr) |
147 | { | 148 | { |
148 | if (!l_ptr) | 149 | if (!l_ptr) |
149 | return 0; | 150 | return 0; |
150 | return link_working_working(l_ptr) || link_working_unknown(l_ptr); | 151 | return link_working_working(l_ptr) || link_working_unknown(l_ptr); |
151 | } | 152 | } |
152 | 153 | ||
153 | int tipc_link_is_active(struct link *l_ptr) | 154 | int tipc_link_is_active(struct tipc_link *l_ptr) |
154 | { | 155 | { |
155 | return (l_ptr->owner->active_links[0] == l_ptr) || | 156 | return (l_ptr->owner->active_links[0] == l_ptr) || |
156 | (l_ptr->owner->active_links[1] == l_ptr); | 157 | (l_ptr->owner->active_links[1] == l_ptr); |
157 | } | 158 | } |
158 | 159 | ||
159 | /** | 160 | /** |
160 | * link_name_validate - validate & (optionally) deconstruct link name | 161 | * link_name_validate - validate & (optionally) deconstruct tipc_link name |
161 | * @name - ptr to link name string | 162 | * @name - ptr to link name string |
162 | * @name_parts - ptr to area for link name components (or NULL if not needed) | 163 | * @name_parts - ptr to area for link name components (or NULL if not needed) |
163 | * | 164 | * |
164 | * Returns 1 if link name is valid, otherwise 0. | 165 | * Returns 1 if link name is valid, otherwise 0. |
165 | */ | 166 | */ |
166 | 167 | ||
167 | static int link_name_validate(const char *name, struct link_name *name_parts) | 168 | static int link_name_validate(const char *name, |
169 | struct tipc_link_name *name_parts) | ||
168 | { | 170 | { |
169 | char name_copy[TIPC_MAX_LINK_NAME]; | 171 | char name_copy[TIPC_MAX_LINK_NAME]; |
170 | char *addr_local; | 172 | char *addr_local; |
@@ -238,7 +240,7 @@ static int link_name_validate(const char *name, struct link_name *name_parts) | |||
238 | * tipc_node_delete() is called.) | 240 | * tipc_node_delete() is called.) |
239 | */ | 241 | */ |
240 | 242 | ||
241 | static void link_timeout(struct link *l_ptr) | 243 | static void link_timeout(struct tipc_link *l_ptr) |
242 | { | 244 | { |
243 | tipc_node_lock(l_ptr->owner); | 245 | tipc_node_lock(l_ptr->owner); |
244 | 246 | ||
@@ -287,7 +289,7 @@ static void link_timeout(struct link *l_ptr) | |||
287 | tipc_node_unlock(l_ptr->owner); | 289 | tipc_node_unlock(l_ptr->owner); |
288 | } | 290 | } |
289 | 291 | ||
290 | static void link_set_timer(struct link *l_ptr, u32 time) | 292 | static void link_set_timer(struct tipc_link *l_ptr, u32 time) |
291 | { | 293 | { |
292 | k_start_timer(&l_ptr->timer, time); | 294 | k_start_timer(&l_ptr->timer, time); |
293 | } | 295 | } |
@@ -301,11 +303,11 @@ static void link_set_timer(struct link *l_ptr, u32 time) | |||
301 | * Returns pointer to link. | 303 | * Returns pointer to link. |
302 | */ | 304 | */ |
303 | 305 | ||
304 | struct link *tipc_link_create(struct tipc_node *n_ptr, | 306 | struct tipc_link *tipc_link_create(struct tipc_node *n_ptr, |
305 | struct tipc_bearer *b_ptr, | 307 | struct tipc_bearer *b_ptr, |
306 | const struct tipc_media_addr *media_addr) | 308 | const struct tipc_media_addr *media_addr) |
307 | { | 309 | { |
308 | struct link *l_ptr; | 310 | struct tipc_link *l_ptr; |
309 | struct tipc_msg *msg; | 311 | struct tipc_msg *msg; |
310 | char *if_name; | 312 | char *if_name; |
311 | char addr_string[16]; | 313 | char addr_string[16]; |
@@ -343,7 +345,7 @@ struct link *tipc_link_create(struct tipc_node *n_ptr, | |||
343 | l_ptr->checkpoint = 1; | 345 | l_ptr->checkpoint = 1; |
344 | l_ptr->peer_session = INVALID_SESSION; | 346 | l_ptr->peer_session = INVALID_SESSION; |
345 | l_ptr->b_ptr = b_ptr; | 347 | l_ptr->b_ptr = b_ptr; |
346 | link_set_supervision_props(l_ptr, b_ptr->media->tolerance); | 348 | link_set_supervision_props(l_ptr, b_ptr->tolerance); |
347 | l_ptr->state = RESET_UNKNOWN; | 349 | l_ptr->state = RESET_UNKNOWN; |
348 | 350 | ||
349 | l_ptr->pmsg = (struct tipc_msg *)&l_ptr->proto_msg; | 351 | l_ptr->pmsg = (struct tipc_msg *)&l_ptr->proto_msg; |
@@ -355,7 +357,7 @@ struct link *tipc_link_create(struct tipc_node *n_ptr, | |||
355 | strcpy((char *)msg_data(msg), if_name); | 357 | strcpy((char *)msg_data(msg), if_name); |
356 | 358 | ||
357 | l_ptr->priority = b_ptr->priority; | 359 | l_ptr->priority = b_ptr->priority; |
358 | tipc_link_set_queue_limits(l_ptr, b_ptr->media->window); | 360 | tipc_link_set_queue_limits(l_ptr, b_ptr->window); |
359 | 361 | ||
360 | link_init_max_pkt(l_ptr); | 362 | link_init_max_pkt(l_ptr); |
361 | 363 | ||
@@ -382,7 +384,7 @@ struct link *tipc_link_create(struct tipc_node *n_ptr, | |||
382 | * to avoid a potential deadlock situation. | 384 | * to avoid a potential deadlock situation. |
383 | */ | 385 | */ |
384 | 386 | ||
385 | void tipc_link_delete(struct link *l_ptr) | 387 | void tipc_link_delete(struct tipc_link *l_ptr) |
386 | { | 388 | { |
387 | if (!l_ptr) { | 389 | if (!l_ptr) { |
388 | err("Attempt to delete non-existent link\n"); | 390 | err("Attempt to delete non-existent link\n"); |
@@ -401,7 +403,7 @@ void tipc_link_delete(struct link *l_ptr) | |||
401 | kfree(l_ptr); | 403 | kfree(l_ptr); |
402 | } | 404 | } |
403 | 405 | ||
404 | static void link_start(struct link *l_ptr) | 406 | static void link_start(struct tipc_link *l_ptr) |
405 | { | 407 | { |
406 | tipc_node_lock(l_ptr->owner); | 408 | tipc_node_lock(l_ptr->owner); |
407 | link_state_event(l_ptr, STARTING_EVT); | 409 | link_state_event(l_ptr, STARTING_EVT); |
@@ -418,7 +420,7 @@ static void link_start(struct link *l_ptr) | |||
418 | * has abated. | 420 | * has abated. |
419 | */ | 421 | */ |
420 | 422 | ||
421 | static int link_schedule_port(struct link *l_ptr, u32 origport, u32 sz) | 423 | static int link_schedule_port(struct tipc_link *l_ptr, u32 origport, u32 sz) |
422 | { | 424 | { |
423 | struct tipc_port *p_ptr; | 425 | struct tipc_port *p_ptr; |
424 | 426 | ||
@@ -440,7 +442,7 @@ exit: | |||
440 | return -ELINKCONG; | 442 | return -ELINKCONG; |
441 | } | 443 | } |
442 | 444 | ||
443 | void tipc_link_wakeup_ports(struct link *l_ptr, int all) | 445 | void tipc_link_wakeup_ports(struct tipc_link *l_ptr, int all) |
444 | { | 446 | { |
445 | struct tipc_port *p_ptr; | 447 | struct tipc_port *p_ptr; |
446 | struct tipc_port *temp_p_ptr; | 448 | struct tipc_port *temp_p_ptr; |
@@ -475,7 +477,7 @@ exit: | |||
475 | * @l_ptr: pointer to link | 477 | * @l_ptr: pointer to link |
476 | */ | 478 | */ |
477 | 479 | ||
478 | static void link_release_outqueue(struct link *l_ptr) | 480 | static void link_release_outqueue(struct tipc_link *l_ptr) |
479 | { | 481 | { |
480 | struct sk_buff *buf = l_ptr->first_out; | 482 | struct sk_buff *buf = l_ptr->first_out; |
481 | struct sk_buff *next; | 483 | struct sk_buff *next; |
@@ -494,7 +496,7 @@ static void link_release_outqueue(struct link *l_ptr) | |||
494 | * @l_ptr: pointer to link | 496 | * @l_ptr: pointer to link |
495 | */ | 497 | */ |
496 | 498 | ||
497 | void tipc_link_reset_fragments(struct link *l_ptr) | 499 | void tipc_link_reset_fragments(struct tipc_link *l_ptr) |
498 | { | 500 | { |
499 | struct sk_buff *buf = l_ptr->defragm_buf; | 501 | struct sk_buff *buf = l_ptr->defragm_buf; |
500 | struct sk_buff *next; | 502 | struct sk_buff *next; |
@@ -512,7 +514,7 @@ void tipc_link_reset_fragments(struct link *l_ptr) | |||
512 | * @l_ptr: pointer to link | 514 | * @l_ptr: pointer to link |
513 | */ | 515 | */ |
514 | 516 | ||
515 | void tipc_link_stop(struct link *l_ptr) | 517 | void tipc_link_stop(struct tipc_link *l_ptr) |
516 | { | 518 | { |
517 | struct sk_buff *buf; | 519 | struct sk_buff *buf; |
518 | struct sk_buff *next; | 520 | struct sk_buff *next; |
@@ -537,7 +539,7 @@ void tipc_link_stop(struct link *l_ptr) | |||
537 | l_ptr->proto_msg_queue = NULL; | 539 | l_ptr->proto_msg_queue = NULL; |
538 | } | 540 | } |
539 | 541 | ||
540 | void tipc_link_reset(struct link *l_ptr) | 542 | void tipc_link_reset(struct tipc_link *l_ptr) |
541 | { | 543 | { |
542 | struct sk_buff *buf; | 544 | struct sk_buff *buf; |
543 | u32 prev_state = l_ptr->state; | 545 | u32 prev_state = l_ptr->state; |
@@ -597,7 +599,7 @@ void tipc_link_reset(struct link *l_ptr) | |||
597 | } | 599 | } |
598 | 600 | ||
599 | 601 | ||
600 | static void link_activate(struct link *l_ptr) | 602 | static void link_activate(struct tipc_link *l_ptr) |
601 | { | 603 | { |
602 | l_ptr->next_in_no = l_ptr->stats.recv_info = 1; | 604 | l_ptr->next_in_no = l_ptr->stats.recv_info = 1; |
603 | tipc_node_link_up(l_ptr->owner, l_ptr); | 605 | tipc_node_link_up(l_ptr->owner, l_ptr); |
@@ -610,9 +612,9 @@ static void link_activate(struct link *l_ptr) | |||
610 | * @event: state machine event to process | 612 | * @event: state machine event to process |
611 | */ | 613 | */ |
612 | 614 | ||
613 | static void link_state_event(struct link *l_ptr, unsigned event) | 615 | static void link_state_event(struct tipc_link *l_ptr, unsigned event) |
614 | { | 616 | { |
615 | struct link *other; | 617 | struct tipc_link *other; |
616 | u32 cont_intv = l_ptr->continuity_interval; | 618 | u32 cont_intv = l_ptr->continuity_interval; |
617 | 619 | ||
618 | if (!l_ptr->started && (event != STARTING_EVT)) | 620 | if (!l_ptr->started && (event != STARTING_EVT)) |
@@ -784,7 +786,7 @@ static void link_state_event(struct link *l_ptr, unsigned event) | |||
784 | * the tail of an existing one. | 786 | * the tail of an existing one. |
785 | */ | 787 | */ |
786 | 788 | ||
787 | static int link_bundle_buf(struct link *l_ptr, | 789 | static int link_bundle_buf(struct tipc_link *l_ptr, |
788 | struct sk_buff *bundler, | 790 | struct sk_buff *bundler, |
789 | struct sk_buff *buf) | 791 | struct sk_buff *buf) |
790 | { | 792 | { |
@@ -813,7 +815,7 @@ static int link_bundle_buf(struct link *l_ptr, | |||
813 | return 1; | 815 | return 1; |
814 | } | 816 | } |
815 | 817 | ||
816 | static void link_add_to_outqueue(struct link *l_ptr, | 818 | static void link_add_to_outqueue(struct tipc_link *l_ptr, |
817 | struct sk_buff *buf, | 819 | struct sk_buff *buf, |
818 | struct tipc_msg *msg) | 820 | struct tipc_msg *msg) |
819 | { | 821 | { |
@@ -834,7 +836,7 @@ static void link_add_to_outqueue(struct link *l_ptr, | |||
834 | l_ptr->stats.max_queue_sz = l_ptr->out_queue_size; | 836 | l_ptr->stats.max_queue_sz = l_ptr->out_queue_size; |
835 | } | 837 | } |
836 | 838 | ||
837 | static void link_add_chain_to_outqueue(struct link *l_ptr, | 839 | static void link_add_chain_to_outqueue(struct tipc_link *l_ptr, |
838 | struct sk_buff *buf_chain, | 840 | struct sk_buff *buf_chain, |
839 | u32 long_msgno) | 841 | u32 long_msgno) |
840 | { | 842 | { |
@@ -859,7 +861,7 @@ static void link_add_chain_to_outqueue(struct link *l_ptr, | |||
859 | * has failed, and from link_send() | 861 | * has failed, and from link_send() |
860 | */ | 862 | */ |
861 | 863 | ||
862 | int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf) | 864 | int tipc_link_send_buf(struct tipc_link *l_ptr, struct sk_buff *buf) |
863 | { | 865 | { |
864 | struct tipc_msg *msg = buf_msg(buf); | 866 | struct tipc_msg *msg = buf_msg(buf); |
865 | u32 size = msg_size(msg); | 867 | u32 size = msg_size(msg); |
@@ -954,7 +956,7 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf) | |||
954 | 956 | ||
955 | int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector) | 957 | int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector) |
956 | { | 958 | { |
957 | struct link *l_ptr; | 959 | struct tipc_link *l_ptr; |
958 | struct tipc_node *n_ptr; | 960 | struct tipc_node *n_ptr; |
959 | int res = -ELINKCONG; | 961 | int res = -ELINKCONG; |
960 | 962 | ||
@@ -988,7 +990,7 @@ int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector) | |||
988 | void tipc_link_send_names(struct list_head *message_list, u32 dest) | 990 | void tipc_link_send_names(struct list_head *message_list, u32 dest) |
989 | { | 991 | { |
990 | struct tipc_node *n_ptr; | 992 | struct tipc_node *n_ptr; |
991 | struct link *l_ptr; | 993 | struct tipc_link *l_ptr; |
992 | struct sk_buff *buf; | 994 | struct sk_buff *buf; |
993 | struct sk_buff *temp_buf; | 995 | struct sk_buff *temp_buf; |
994 | 996 | ||
@@ -1027,7 +1029,7 @@ void tipc_link_send_names(struct list_head *message_list, u32 dest) | |||
1027 | * Link is locked. Returns user data length. | 1029 | * Link is locked. Returns user data length. |
1028 | */ | 1030 | */ |
1029 | 1031 | ||
1030 | static int link_send_buf_fast(struct link *l_ptr, struct sk_buff *buf, | 1032 | static int link_send_buf_fast(struct tipc_link *l_ptr, struct sk_buff *buf, |
1031 | u32 *used_max_pkt) | 1033 | u32 *used_max_pkt) |
1032 | { | 1034 | { |
1033 | struct tipc_msg *msg = buf_msg(buf); | 1035 | struct tipc_msg *msg = buf_msg(buf); |
@@ -1061,7 +1063,7 @@ static int link_send_buf_fast(struct link *l_ptr, struct sk_buff *buf, | |||
1061 | */ | 1063 | */ |
1062 | int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode) | 1064 | int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode) |
1063 | { | 1065 | { |
1064 | struct link *l_ptr; | 1066 | struct tipc_link *l_ptr; |
1065 | struct tipc_node *n_ptr; | 1067 | struct tipc_node *n_ptr; |
1066 | int res; | 1068 | int res; |
1067 | u32 selector = msg_origport(buf_msg(buf)) & 1; | 1069 | u32 selector = msg_origport(buf_msg(buf)) & 1; |
@@ -1100,7 +1102,7 @@ int tipc_link_send_sections_fast(struct tipc_port *sender, | |||
1100 | u32 destaddr) | 1102 | u32 destaddr) |
1101 | { | 1103 | { |
1102 | struct tipc_msg *hdr = &sender->phdr; | 1104 | struct tipc_msg *hdr = &sender->phdr; |
1103 | struct link *l_ptr; | 1105 | struct tipc_link *l_ptr; |
1104 | struct sk_buff *buf; | 1106 | struct sk_buff *buf; |
1105 | struct tipc_node *node; | 1107 | struct tipc_node *node; |
1106 | int res; | 1108 | int res; |
@@ -1195,7 +1197,7 @@ static int link_send_sections_long(struct tipc_port *sender, | |||
1195 | unsigned int total_len, | 1197 | unsigned int total_len, |
1196 | u32 destaddr) | 1198 | u32 destaddr) |
1197 | { | 1199 | { |
1198 | struct link *l_ptr; | 1200 | struct tipc_link *l_ptr; |
1199 | struct tipc_node *node; | 1201 | struct tipc_node *node; |
1200 | struct tipc_msg *hdr = &sender->phdr; | 1202 | struct tipc_msg *hdr = &sender->phdr; |
1201 | u32 dsz = total_len; | 1203 | u32 dsz = total_len; |
@@ -1342,7 +1344,7 @@ reject: | |||
1342 | /* | 1344 | /* |
1343 | * tipc_link_push_packet: Push one unsent packet to the media | 1345 | * tipc_link_push_packet: Push one unsent packet to the media |
1344 | */ | 1346 | */ |
1345 | u32 tipc_link_push_packet(struct link *l_ptr) | 1347 | u32 tipc_link_push_packet(struct tipc_link *l_ptr) |
1346 | { | 1348 | { |
1347 | struct sk_buff *buf = l_ptr->first_out; | 1349 | struct sk_buff *buf = l_ptr->first_out; |
1348 | u32 r_q_size = l_ptr->retransm_queue_size; | 1350 | u32 r_q_size = l_ptr->retransm_queue_size; |
@@ -1354,7 +1356,7 @@ u32 tipc_link_push_packet(struct link *l_ptr) | |||
1354 | if (r_q_size && buf) { | 1356 | if (r_q_size && buf) { |
1355 | u32 last = lesser(mod(r_q_head + r_q_size), | 1357 | u32 last = lesser(mod(r_q_head + r_q_size), |
1356 | link_last_sent(l_ptr)); | 1358 | link_last_sent(l_ptr)); |
1357 | u32 first = msg_seqno(buf_msg(buf)); | 1359 | u32 first = buf_seqno(buf); |
1358 | 1360 | ||
1359 | while (buf && less(first, r_q_head)) { | 1361 | while (buf && less(first, r_q_head)) { |
1360 | first = mod(first + 1); | 1362 | first = mod(first + 1); |
@@ -1403,7 +1405,7 @@ u32 tipc_link_push_packet(struct link *l_ptr) | |||
1403 | if (buf) { | 1405 | if (buf) { |
1404 | struct tipc_msg *msg = buf_msg(buf); | 1406 | struct tipc_msg *msg = buf_msg(buf); |
1405 | u32 next = msg_seqno(msg); | 1407 | u32 next = msg_seqno(msg); |
1406 | u32 first = msg_seqno(buf_msg(l_ptr->first_out)); | 1408 | u32 first = buf_seqno(l_ptr->first_out); |
1407 | 1409 | ||
1408 | if (mod(next - first) < l_ptr->queue_limit[0]) { | 1410 | if (mod(next - first) < l_ptr->queue_limit[0]) { |
1409 | msg_set_ack(msg, mod(l_ptr->next_in_no - 1)); | 1411 | msg_set_ack(msg, mod(l_ptr->next_in_no - 1)); |
@@ -1426,7 +1428,7 @@ u32 tipc_link_push_packet(struct link *l_ptr) | |||
1426 | * push_queue(): push out the unsent messages of a link where | 1428 | * push_queue(): push out the unsent messages of a link where |
1427 | * congestion has abated. Node is locked | 1429 | * congestion has abated. Node is locked |
1428 | */ | 1430 | */ |
1429 | void tipc_link_push_queue(struct link *l_ptr) | 1431 | void tipc_link_push_queue(struct tipc_link *l_ptr) |
1430 | { | 1432 | { |
1431 | u32 res; | 1433 | u32 res; |
1432 | 1434 | ||
@@ -1470,7 +1472,8 @@ static void link_reset_all(unsigned long addr) | |||
1470 | read_unlock_bh(&tipc_net_lock); | 1472 | read_unlock_bh(&tipc_net_lock); |
1471 | } | 1473 | } |
1472 | 1474 | ||
1473 | static void link_retransmit_failure(struct link *l_ptr, struct sk_buff *buf) | 1475 | static void link_retransmit_failure(struct tipc_link *l_ptr, |
1476 | struct sk_buff *buf) | ||
1474 | { | 1477 | { |
1475 | struct tipc_msg *msg = buf_msg(buf); | 1478 | struct tipc_msg *msg = buf_msg(buf); |
1476 | 1479 | ||
@@ -1514,7 +1517,7 @@ static void link_retransmit_failure(struct link *l_ptr, struct sk_buff *buf) | |||
1514 | } | 1517 | } |
1515 | } | 1518 | } |
1516 | 1519 | ||
1517 | void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf, | 1520 | void tipc_link_retransmit(struct tipc_link *l_ptr, struct sk_buff *buf, |
1518 | u32 retransmits) | 1521 | u32 retransmits) |
1519 | { | 1522 | { |
1520 | struct tipc_msg *msg; | 1523 | struct tipc_msg *msg; |
@@ -1558,7 +1561,7 @@ void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf, | |||
1558 | } else { | 1561 | } else { |
1559 | tipc_bearer_schedule(l_ptr->b_ptr, l_ptr); | 1562 | tipc_bearer_schedule(l_ptr->b_ptr, l_ptr); |
1560 | l_ptr->stats.bearer_congs++; | 1563 | l_ptr->stats.bearer_congs++; |
1561 | l_ptr->retransm_queue_head = msg_seqno(buf_msg(buf)); | 1564 | l_ptr->retransm_queue_head = buf_seqno(buf); |
1562 | l_ptr->retransm_queue_size = retransmits; | 1565 | l_ptr->retransm_queue_size = retransmits; |
1563 | return; | 1566 | return; |
1564 | } | 1567 | } |
@@ -1571,7 +1574,7 @@ void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf, | |||
1571 | * link_insert_deferred_queue - insert deferred messages back into receive chain | 1574 | * link_insert_deferred_queue - insert deferred messages back into receive chain |
1572 | */ | 1575 | */ |
1573 | 1576 | ||
1574 | static struct sk_buff *link_insert_deferred_queue(struct link *l_ptr, | 1577 | static struct sk_buff *link_insert_deferred_queue(struct tipc_link *l_ptr, |
1575 | struct sk_buff *buf) | 1578 | struct sk_buff *buf) |
1576 | { | 1579 | { |
1577 | u32 seq_no; | 1580 | u32 seq_no; |
@@ -1579,7 +1582,7 @@ static struct sk_buff *link_insert_deferred_queue(struct link *l_ptr, | |||
1579 | if (l_ptr->oldest_deferred_in == NULL) | 1582 | if (l_ptr->oldest_deferred_in == NULL) |
1580 | return buf; | 1583 | return buf; |
1581 | 1584 | ||
1582 | seq_no = msg_seqno(buf_msg(l_ptr->oldest_deferred_in)); | 1585 | seq_no = buf_seqno(l_ptr->oldest_deferred_in); |
1583 | if (seq_no == mod(l_ptr->next_in_no)) { | 1586 | if (seq_no == mod(l_ptr->next_in_no)) { |
1584 | l_ptr->newest_deferred_in->next = buf; | 1587 | l_ptr->newest_deferred_in->next = buf; |
1585 | buf = l_ptr->oldest_deferred_in; | 1588 | buf = l_ptr->oldest_deferred_in; |
@@ -1653,7 +1656,7 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr) | |||
1653 | read_lock_bh(&tipc_net_lock); | 1656 | read_lock_bh(&tipc_net_lock); |
1654 | while (head) { | 1657 | while (head) { |
1655 | struct tipc_node *n_ptr; | 1658 | struct tipc_node *n_ptr; |
1656 | struct link *l_ptr; | 1659 | struct tipc_link *l_ptr; |
1657 | struct sk_buff *crs; | 1660 | struct sk_buff *crs; |
1658 | struct sk_buff *buf = head; | 1661 | struct sk_buff *buf = head; |
1659 | struct tipc_msg *msg; | 1662 | struct tipc_msg *msg; |
@@ -1733,14 +1736,12 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr) | |||
1733 | 1736 | ||
1734 | /* Release acked messages */ | 1737 | /* Release acked messages */ |
1735 | 1738 | ||
1736 | if (less(n_ptr->bclink.acked, msg_bcast_ack(msg))) { | 1739 | if (tipc_node_is_up(n_ptr) && n_ptr->bclink.supported) |
1737 | if (tipc_node_is_up(n_ptr) && n_ptr->bclink.supported) | 1740 | tipc_bclink_acknowledge(n_ptr, msg_bcast_ack(msg)); |
1738 | tipc_bclink_acknowledge(n_ptr, msg_bcast_ack(msg)); | ||
1739 | } | ||
1740 | 1741 | ||
1741 | crs = l_ptr->first_out; | 1742 | crs = l_ptr->first_out; |
1742 | while ((crs != l_ptr->next_out) && | 1743 | while ((crs != l_ptr->next_out) && |
1743 | less_eq(msg_seqno(buf_msg(crs)), ackd)) { | 1744 | less_eq(buf_seqno(crs), ackd)) { |
1744 | struct sk_buff *next = crs->next; | 1745 | struct sk_buff *next = crs->next; |
1745 | 1746 | ||
1746 | buf_discard(crs); | 1747 | buf_discard(crs); |
@@ -1863,7 +1864,7 @@ u32 tipc_link_defer_pkt(struct sk_buff **head, | |||
1863 | { | 1864 | { |
1864 | struct sk_buff *prev = NULL; | 1865 | struct sk_buff *prev = NULL; |
1865 | struct sk_buff *crs = *head; | 1866 | struct sk_buff *crs = *head; |
1866 | u32 seq_no = msg_seqno(buf_msg(buf)); | 1867 | u32 seq_no = buf_seqno(buf); |
1867 | 1868 | ||
1868 | buf->next = NULL; | 1869 | buf->next = NULL; |
1869 | 1870 | ||
@@ -1874,7 +1875,7 @@ u32 tipc_link_defer_pkt(struct sk_buff **head, | |||
1874 | } | 1875 | } |
1875 | 1876 | ||
1876 | /* Last ? */ | 1877 | /* Last ? */ |
1877 | if (less(msg_seqno(buf_msg(*tail)), seq_no)) { | 1878 | if (less(buf_seqno(*tail), seq_no)) { |
1878 | (*tail)->next = buf; | 1879 | (*tail)->next = buf; |
1879 | *tail = buf; | 1880 | *tail = buf; |
1880 | return 1; | 1881 | return 1; |
@@ -1908,10 +1909,10 @@ u32 tipc_link_defer_pkt(struct sk_buff **head, | |||
1908 | * link_handle_out_of_seq_msg - handle arrival of out-of-sequence packet | 1909 | * link_handle_out_of_seq_msg - handle arrival of out-of-sequence packet |
1909 | */ | 1910 | */ |
1910 | 1911 | ||
1911 | static void link_handle_out_of_seq_msg(struct link *l_ptr, | 1912 | static void link_handle_out_of_seq_msg(struct tipc_link *l_ptr, |
1912 | struct sk_buff *buf) | 1913 | struct sk_buff *buf) |
1913 | { | 1914 | { |
1914 | u32 seq_no = msg_seqno(buf_msg(buf)); | 1915 | u32 seq_no = buf_seqno(buf); |
1915 | 1916 | ||
1916 | if (likely(msg_user(buf_msg(buf)) == LINK_PROTOCOL)) { | 1917 | if (likely(msg_user(buf_msg(buf)) == LINK_PROTOCOL)) { |
1917 | link_recv_proto_msg(l_ptr, buf); | 1918 | link_recv_proto_msg(l_ptr, buf); |
@@ -1946,8 +1947,9 @@ static void link_handle_out_of_seq_msg(struct link *l_ptr, | |||
1946 | /* | 1947 | /* |
1947 | * Send protocol message to the other endpoint. | 1948 | * Send protocol message to the other endpoint. |
1948 | */ | 1949 | */ |
1949 | void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg, | 1950 | void tipc_link_send_proto_msg(struct tipc_link *l_ptr, u32 msg_typ, |
1950 | u32 gap, u32 tolerance, u32 priority, u32 ack_mtu) | 1951 | int probe_msg, u32 gap, u32 tolerance, |
1952 | u32 priority, u32 ack_mtu) | ||
1951 | { | 1953 | { |
1952 | struct sk_buff *buf = NULL; | 1954 | struct sk_buff *buf = NULL; |
1953 | struct tipc_msg *msg = l_ptr->pmsg; | 1955 | struct tipc_msg *msg = l_ptr->pmsg; |
@@ -1973,10 +1975,10 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg, | |||
1973 | if (!tipc_link_is_up(l_ptr)) | 1975 | if (!tipc_link_is_up(l_ptr)) |
1974 | return; | 1976 | return; |
1975 | if (l_ptr->next_out) | 1977 | if (l_ptr->next_out) |
1976 | next_sent = msg_seqno(buf_msg(l_ptr->next_out)); | 1978 | next_sent = buf_seqno(l_ptr->next_out); |
1977 | msg_set_next_sent(msg, next_sent); | 1979 | msg_set_next_sent(msg, next_sent); |
1978 | if (l_ptr->oldest_deferred_in) { | 1980 | if (l_ptr->oldest_deferred_in) { |
1979 | u32 rec = msg_seqno(buf_msg(l_ptr->oldest_deferred_in)); | 1981 | u32 rec = buf_seqno(l_ptr->oldest_deferred_in); |
1980 | gap = mod(rec - mod(l_ptr->next_in_no)); | 1982 | gap = mod(rec - mod(l_ptr->next_in_no)); |
1981 | } | 1983 | } |
1982 | msg_set_seq_gap(msg, gap); | 1984 | msg_set_seq_gap(msg, gap); |
@@ -2064,7 +2066,7 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg, | |||
2064 | * change at any time. The node with lowest address rules | 2066 | * change at any time. The node with lowest address rules |
2065 | */ | 2067 | */ |
2066 | 2068 | ||
2067 | static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf) | 2069 | static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf) |
2068 | { | 2070 | { |
2069 | u32 rec_gap = 0; | 2071 | u32 rec_gap = 0; |
2070 | u32 max_pkt_info; | 2072 | u32 max_pkt_info; |
@@ -2197,12 +2199,12 @@ exit: | |||
2197 | * tipc_link_tunnel(): Send one message via a link belonging to | 2199 | * tipc_link_tunnel(): Send one message via a link belonging to |
2198 | * another bearer. Owner node is locked. | 2200 | * another bearer. Owner node is locked. |
2199 | */ | 2201 | */ |
2200 | static void tipc_link_tunnel(struct link *l_ptr, | 2202 | static void tipc_link_tunnel(struct tipc_link *l_ptr, |
2201 | struct tipc_msg *tunnel_hdr, | 2203 | struct tipc_msg *tunnel_hdr, |
2202 | struct tipc_msg *msg, | 2204 | struct tipc_msg *msg, |
2203 | u32 selector) | 2205 | u32 selector) |
2204 | { | 2206 | { |
2205 | struct link *tunnel; | 2207 | struct tipc_link *tunnel; |
2206 | struct sk_buff *buf; | 2208 | struct sk_buff *buf; |
2207 | u32 length = msg_size(msg); | 2209 | u32 length = msg_size(msg); |
2208 | 2210 | ||
@@ -2231,11 +2233,11 @@ static void tipc_link_tunnel(struct link *l_ptr, | |||
2231 | * Owner node is locked. | 2233 | * Owner node is locked. |
2232 | */ | 2234 | */ |
2233 | 2235 | ||
2234 | void tipc_link_changeover(struct link *l_ptr) | 2236 | void tipc_link_changeover(struct tipc_link *l_ptr) |
2235 | { | 2237 | { |
2236 | u32 msgcount = l_ptr->out_queue_size; | 2238 | u32 msgcount = l_ptr->out_queue_size; |
2237 | struct sk_buff *crs = l_ptr->first_out; | 2239 | struct sk_buff *crs = l_ptr->first_out; |
2238 | struct link *tunnel = l_ptr->owner->active_links[0]; | 2240 | struct tipc_link *tunnel = l_ptr->owner->active_links[0]; |
2239 | struct tipc_msg tunnel_hdr; | 2241 | struct tipc_msg tunnel_hdr; |
2240 | int split_bundles; | 2242 | int split_bundles; |
2241 | 2243 | ||
@@ -2294,7 +2296,7 @@ void tipc_link_changeover(struct link *l_ptr) | |||
2294 | } | 2296 | } |
2295 | } | 2297 | } |
2296 | 2298 | ||
2297 | void tipc_link_send_duplicate(struct link *l_ptr, struct link *tunnel) | 2299 | void tipc_link_send_duplicate(struct tipc_link *l_ptr, struct tipc_link *tunnel) |
2298 | { | 2300 | { |
2299 | struct sk_buff *iter; | 2301 | struct sk_buff *iter; |
2300 | struct tipc_msg tunnel_hdr; | 2302 | struct tipc_msg tunnel_hdr; |
@@ -2358,11 +2360,11 @@ static struct sk_buff *buf_extract(struct sk_buff *skb, u32 from_pos) | |||
2358 | * via other link. Node is locked. Return extracted buffer. | 2360 | * via other link. Node is locked. Return extracted buffer. |
2359 | */ | 2361 | */ |
2360 | 2362 | ||
2361 | static int link_recv_changeover_msg(struct link **l_ptr, | 2363 | static int link_recv_changeover_msg(struct tipc_link **l_ptr, |
2362 | struct sk_buff **buf) | 2364 | struct sk_buff **buf) |
2363 | { | 2365 | { |
2364 | struct sk_buff *tunnel_buf = *buf; | 2366 | struct sk_buff *tunnel_buf = *buf; |
2365 | struct link *dest_link; | 2367 | struct tipc_link *dest_link; |
2366 | struct tipc_msg *msg; | 2368 | struct tipc_msg *msg; |
2367 | struct tipc_msg *tunnel_msg = buf_msg(tunnel_buf); | 2369 | struct tipc_msg *tunnel_msg = buf_msg(tunnel_buf); |
2368 | u32 msg_typ = msg_type(tunnel_msg); | 2370 | u32 msg_typ = msg_type(tunnel_msg); |
@@ -2462,7 +2464,7 @@ void tipc_link_recv_bundle(struct sk_buff *buf) | |||
2462 | * The buffer is complete, inclusive total message length. | 2464 | * The buffer is complete, inclusive total message length. |
2463 | * Returns user data length. | 2465 | * Returns user data length. |
2464 | */ | 2466 | */ |
2465 | static int link_send_long_buf(struct link *l_ptr, struct sk_buff *buf) | 2467 | static int link_send_long_buf(struct tipc_link *l_ptr, struct sk_buff *buf) |
2466 | { | 2468 | { |
2467 | struct sk_buff *buf_chain = NULL; | 2469 | struct sk_buff *buf_chain = NULL; |
2468 | struct sk_buff *buf_chain_tail = (struct sk_buff *)&buf_chain; | 2470 | struct sk_buff *buf_chain_tail = (struct sk_buff *)&buf_chain; |
@@ -2591,7 +2593,7 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb, | |||
2591 | 2593 | ||
2592 | /* Is there an incomplete message waiting for this fragment? */ | 2594 | /* Is there an incomplete message waiting for this fragment? */ |
2593 | 2595 | ||
2594 | while (pbuf && ((msg_seqno(buf_msg(pbuf)) != long_msg_seq_no) || | 2596 | while (pbuf && ((buf_seqno(pbuf) != long_msg_seq_no) || |
2595 | (msg_orignode(fragm) != msg_orignode(buf_msg(pbuf))))) { | 2597 | (msg_orignode(fragm) != msg_orignode(buf_msg(pbuf))))) { |
2596 | prev = pbuf; | 2598 | prev = pbuf; |
2597 | pbuf = pbuf->next; | 2599 | pbuf = pbuf->next; |
@@ -2658,7 +2660,7 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb, | |||
2658 | * @l_ptr: pointer to link | 2660 | * @l_ptr: pointer to link |
2659 | */ | 2661 | */ |
2660 | 2662 | ||
2661 | static void link_check_defragm_bufs(struct link *l_ptr) | 2663 | static void link_check_defragm_bufs(struct tipc_link *l_ptr) |
2662 | { | 2664 | { |
2663 | struct sk_buff *prev = NULL; | 2665 | struct sk_buff *prev = NULL; |
2664 | struct sk_buff *next = NULL; | 2666 | struct sk_buff *next = NULL; |
@@ -2688,7 +2690,7 @@ static void link_check_defragm_bufs(struct link *l_ptr) | |||
2688 | 2690 | ||
2689 | 2691 | ||
2690 | 2692 | ||
2691 | static void link_set_supervision_props(struct link *l_ptr, u32 tolerance) | 2693 | static void link_set_supervision_props(struct tipc_link *l_ptr, u32 tolerance) |
2692 | { | 2694 | { |
2693 | if ((tolerance < TIPC_MIN_LINK_TOL) || (tolerance > TIPC_MAX_LINK_TOL)) | 2695 | if ((tolerance < TIPC_MIN_LINK_TOL) || (tolerance > TIPC_MAX_LINK_TOL)) |
2694 | return; | 2696 | return; |
@@ -2700,7 +2702,7 @@ static void link_set_supervision_props(struct link *l_ptr, u32 tolerance) | |||
2700 | } | 2702 | } |
2701 | 2703 | ||
2702 | 2704 | ||
2703 | void tipc_link_set_queue_limits(struct link *l_ptr, u32 window) | 2705 | void tipc_link_set_queue_limits(struct tipc_link *l_ptr, u32 window) |
2704 | { | 2706 | { |
2705 | /* Data messages from this node, inclusive FIRST_FRAGM */ | 2707 | /* Data messages from this node, inclusive FIRST_FRAGM */ |
2706 | l_ptr->queue_limit[TIPC_LOW_IMPORTANCE] = window; | 2708 | l_ptr->queue_limit[TIPC_LOW_IMPORTANCE] = window; |
@@ -2730,11 +2732,12 @@ void tipc_link_set_queue_limits(struct link *l_ptr, u32 window) | |||
2730 | * Returns pointer to link (or 0 if invalid link name). | 2732 | * Returns pointer to link (or 0 if invalid link name). |
2731 | */ | 2733 | */ |
2732 | 2734 | ||
2733 | static struct link *link_find_link(const char *name, struct tipc_node **node) | 2735 | static struct tipc_link *link_find_link(const char *name, |
2736 | struct tipc_node **node) | ||
2734 | { | 2737 | { |
2735 | struct link_name link_name_parts; | 2738 | struct tipc_link_name link_name_parts; |
2736 | struct tipc_bearer *b_ptr; | 2739 | struct tipc_bearer *b_ptr; |
2737 | struct link *l_ptr; | 2740 | struct tipc_link *l_ptr; |
2738 | 2741 | ||
2739 | if (!link_name_validate(name, &link_name_parts)) | 2742 | if (!link_name_validate(name, &link_name_parts)) |
2740 | return NULL; | 2743 | return NULL; |
@@ -2754,13 +2757,113 @@ static struct link *link_find_link(const char *name, struct tipc_node **node) | |||
2754 | return l_ptr; | 2757 | return l_ptr; |
2755 | } | 2758 | } |
2756 | 2759 | ||
2760 | /** | ||
2761 | * link_value_is_valid -- validate proposed link tolerance/priority/window | ||
2762 | * | ||
2763 | * @cmd - value type (TIPC_CMD_SET_LINK_*) | ||
2764 | * @new_value - the new value | ||
2765 | * | ||
2766 | * Returns 1 if value is within range, 0 if not. | ||
2767 | */ | ||
2768 | |||
2769 | static int link_value_is_valid(u16 cmd, u32 new_value) | ||
2770 | { | ||
2771 | switch (cmd) { | ||
2772 | case TIPC_CMD_SET_LINK_TOL: | ||
2773 | return (new_value >= TIPC_MIN_LINK_TOL) && | ||
2774 | (new_value <= TIPC_MAX_LINK_TOL); | ||
2775 | case TIPC_CMD_SET_LINK_PRI: | ||
2776 | return (new_value <= TIPC_MAX_LINK_PRI); | ||
2777 | case TIPC_CMD_SET_LINK_WINDOW: | ||
2778 | return (new_value >= TIPC_MIN_LINK_WIN) && | ||
2779 | (new_value <= TIPC_MAX_LINK_WIN); | ||
2780 | } | ||
2781 | return 0; | ||
2782 | } | ||
2783 | |||
2784 | |||
2785 | /** | ||
2786 | * link_cmd_set_value - change priority/tolerance/window for link/bearer/media | ||
2787 | * @name - ptr to link, bearer, or media name | ||
2788 | * @new_value - new value of link, bearer, or media setting | ||
2789 | * @cmd - which link, bearer, or media attribute to set (TIPC_CMD_SET_LINK_*) | ||
2790 | * | ||
2791 | * Caller must hold 'tipc_net_lock' to ensure link/bearer/media is not deleted. | ||
2792 | * | ||
2793 | * Returns 0 if value updated and negative value on error. | ||
2794 | */ | ||
2795 | |||
2796 | static int link_cmd_set_value(const char *name, u32 new_value, u16 cmd) | ||
2797 | { | ||
2798 | struct tipc_node *node; | ||
2799 | struct tipc_link *l_ptr; | ||
2800 | struct tipc_bearer *b_ptr; | ||
2801 | struct tipc_media *m_ptr; | ||
2802 | |||
2803 | l_ptr = link_find_link(name, &node); | ||
2804 | if (l_ptr) { | ||
2805 | /* | ||
2806 | * acquire node lock for tipc_link_send_proto_msg(). | ||
2807 | * see "TIPC locking policy" in net.c. | ||
2808 | */ | ||
2809 | tipc_node_lock(node); | ||
2810 | switch (cmd) { | ||
2811 | case TIPC_CMD_SET_LINK_TOL: | ||
2812 | link_set_supervision_props(l_ptr, new_value); | ||
2813 | tipc_link_send_proto_msg(l_ptr, | ||
2814 | STATE_MSG, 0, 0, new_value, 0, 0); | ||
2815 | break; | ||
2816 | case TIPC_CMD_SET_LINK_PRI: | ||
2817 | l_ptr->priority = new_value; | ||
2818 | tipc_link_send_proto_msg(l_ptr, | ||
2819 | STATE_MSG, 0, 0, 0, new_value, 0); | ||
2820 | break; | ||
2821 | case TIPC_CMD_SET_LINK_WINDOW: | ||
2822 | tipc_link_set_queue_limits(l_ptr, new_value); | ||
2823 | break; | ||
2824 | } | ||
2825 | tipc_node_unlock(node); | ||
2826 | return 0; | ||
2827 | } | ||
2828 | |||
2829 | b_ptr = tipc_bearer_find(name); | ||
2830 | if (b_ptr) { | ||
2831 | switch (cmd) { | ||
2832 | case TIPC_CMD_SET_LINK_TOL: | ||
2833 | b_ptr->tolerance = new_value; | ||
2834 | return 0; | ||
2835 | case TIPC_CMD_SET_LINK_PRI: | ||
2836 | b_ptr->priority = new_value; | ||
2837 | return 0; | ||
2838 | case TIPC_CMD_SET_LINK_WINDOW: | ||
2839 | b_ptr->window = new_value; | ||
2840 | return 0; | ||
2841 | } | ||
2842 | return -EINVAL; | ||
2843 | } | ||
2844 | |||
2845 | m_ptr = tipc_media_find(name); | ||
2846 | if (!m_ptr) | ||
2847 | return -ENODEV; | ||
2848 | switch (cmd) { | ||
2849 | case TIPC_CMD_SET_LINK_TOL: | ||
2850 | m_ptr->tolerance = new_value; | ||
2851 | return 0; | ||
2852 | case TIPC_CMD_SET_LINK_PRI: | ||
2853 | m_ptr->priority = new_value; | ||
2854 | return 0; | ||
2855 | case TIPC_CMD_SET_LINK_WINDOW: | ||
2856 | m_ptr->window = new_value; | ||
2857 | return 0; | ||
2858 | } | ||
2859 | return -EINVAL; | ||
2860 | } | ||
2861 | |||
2757 | struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space, | 2862 | struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space, |
2758 | u16 cmd) | 2863 | u16 cmd) |
2759 | { | 2864 | { |
2760 | struct tipc_link_config *args; | 2865 | struct tipc_link_config *args; |
2761 | u32 new_value; | 2866 | u32 new_value; |
2762 | struct link *l_ptr; | ||
2763 | struct tipc_node *node; | ||
2764 | int res; | 2867 | int res; |
2765 | 2868 | ||
2766 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_CONFIG)) | 2869 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_CONFIG)) |
@@ -2769,6 +2872,10 @@ struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space | |||
2769 | args = (struct tipc_link_config *)TLV_DATA(req_tlv_area); | 2872 | args = (struct tipc_link_config *)TLV_DATA(req_tlv_area); |
2770 | new_value = ntohl(args->value); | 2873 | new_value = ntohl(args->value); |
2771 | 2874 | ||
2875 | if (!link_value_is_valid(cmd, new_value)) | ||
2876 | return tipc_cfg_reply_error_string( | ||
2877 | "cannot change, value invalid"); | ||
2878 | |||
2772 | if (!strcmp(args->name, tipc_bclink_name)) { | 2879 | if (!strcmp(args->name, tipc_bclink_name)) { |
2773 | if ((cmd == TIPC_CMD_SET_LINK_WINDOW) && | 2880 | if ((cmd == TIPC_CMD_SET_LINK_WINDOW) && |
2774 | (tipc_bclink_set_queue_limits(new_value) == 0)) | 2881 | (tipc_bclink_set_queue_limits(new_value) == 0)) |
@@ -2778,43 +2885,7 @@ struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space | |||
2778 | } | 2885 | } |
2779 | 2886 | ||
2780 | read_lock_bh(&tipc_net_lock); | 2887 | read_lock_bh(&tipc_net_lock); |
2781 | l_ptr = link_find_link(args->name, &node); | 2888 | res = link_cmd_set_value(args->name, new_value, cmd); |
2782 | if (!l_ptr) { | ||
2783 | read_unlock_bh(&tipc_net_lock); | ||
2784 | return tipc_cfg_reply_error_string("link not found"); | ||
2785 | } | ||
2786 | |||
2787 | tipc_node_lock(node); | ||
2788 | res = -EINVAL; | ||
2789 | switch (cmd) { | ||
2790 | case TIPC_CMD_SET_LINK_TOL: | ||
2791 | if ((new_value >= TIPC_MIN_LINK_TOL) && | ||
2792 | (new_value <= TIPC_MAX_LINK_TOL)) { | ||
2793 | link_set_supervision_props(l_ptr, new_value); | ||
2794 | tipc_link_send_proto_msg(l_ptr, STATE_MSG, | ||
2795 | 0, 0, new_value, 0, 0); | ||
2796 | res = 0; | ||
2797 | } | ||
2798 | break; | ||
2799 | case TIPC_CMD_SET_LINK_PRI: | ||
2800 | if ((new_value >= TIPC_MIN_LINK_PRI) && | ||
2801 | (new_value <= TIPC_MAX_LINK_PRI)) { | ||
2802 | l_ptr->priority = new_value; | ||
2803 | tipc_link_send_proto_msg(l_ptr, STATE_MSG, | ||
2804 | 0, 0, 0, new_value, 0); | ||
2805 | res = 0; | ||
2806 | } | ||
2807 | break; | ||
2808 | case TIPC_CMD_SET_LINK_WINDOW: | ||
2809 | if ((new_value >= TIPC_MIN_LINK_WIN) && | ||
2810 | (new_value <= TIPC_MAX_LINK_WIN)) { | ||
2811 | tipc_link_set_queue_limits(l_ptr, new_value); | ||
2812 | res = 0; | ||
2813 | } | ||
2814 | break; | ||
2815 | } | ||
2816 | tipc_node_unlock(node); | ||
2817 | |||
2818 | read_unlock_bh(&tipc_net_lock); | 2889 | read_unlock_bh(&tipc_net_lock); |
2819 | if (res) | 2890 | if (res) |
2820 | return tipc_cfg_reply_error_string("cannot change link setting"); | 2891 | return tipc_cfg_reply_error_string("cannot change link setting"); |
@@ -2827,7 +2898,7 @@ struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space | |||
2827 | * @l_ptr: pointer to link | 2898 | * @l_ptr: pointer to link |
2828 | */ | 2899 | */ |
2829 | 2900 | ||
2830 | static void link_reset_statistics(struct link *l_ptr) | 2901 | static void link_reset_statistics(struct tipc_link *l_ptr) |
2831 | { | 2902 | { |
2832 | memset(&l_ptr->stats, 0, sizeof(l_ptr->stats)); | 2903 | memset(&l_ptr->stats, 0, sizeof(l_ptr->stats)); |
2833 | l_ptr->stats.sent_info = l_ptr->next_out_no; | 2904 | l_ptr->stats.sent_info = l_ptr->next_out_no; |
@@ -2837,7 +2908,7 @@ static void link_reset_statistics(struct link *l_ptr) | |||
2837 | struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area, int req_tlv_space) | 2908 | struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area, int req_tlv_space) |
2838 | { | 2909 | { |
2839 | char *link_name; | 2910 | char *link_name; |
2840 | struct link *l_ptr; | 2911 | struct tipc_link *l_ptr; |
2841 | struct tipc_node *node; | 2912 | struct tipc_node *node; |
2842 | 2913 | ||
2843 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_NAME)) | 2914 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_NAME)) |
@@ -2885,7 +2956,7 @@ static u32 percent(u32 count, u32 total) | |||
2885 | static int tipc_link_stats(const char *name, char *buf, const u32 buf_size) | 2956 | static int tipc_link_stats(const char *name, char *buf, const u32 buf_size) |
2886 | { | 2957 | { |
2887 | struct print_buf pb; | 2958 | struct print_buf pb; |
2888 | struct link *l_ptr; | 2959 | struct tipc_link *l_ptr; |
2889 | struct tipc_node *node; | 2960 | struct tipc_node *node; |
2890 | char *status; | 2961 | char *status; |
2891 | u32 profile_total = 0; | 2962 | u32 profile_total = 0; |
@@ -3007,7 +3078,7 @@ struct sk_buff *tipc_link_cmd_show_stats(const void *req_tlv_area, int req_tlv_s | |||
3007 | u32 tipc_link_get_max_pkt(u32 dest, u32 selector) | 3078 | u32 tipc_link_get_max_pkt(u32 dest, u32 selector) |
3008 | { | 3079 | { |
3009 | struct tipc_node *n_ptr; | 3080 | struct tipc_node *n_ptr; |
3010 | struct link *l_ptr; | 3081 | struct tipc_link *l_ptr; |
3011 | u32 res = MAX_PKT_DEFAULT; | 3082 | u32 res = MAX_PKT_DEFAULT; |
3012 | 3083 | ||
3013 | if (dest == tipc_own_addr) | 3084 | if (dest == tipc_own_addr) |
@@ -3026,7 +3097,7 @@ u32 tipc_link_get_max_pkt(u32 dest, u32 selector) | |||
3026 | return res; | 3097 | return res; |
3027 | } | 3098 | } |
3028 | 3099 | ||
3029 | static void link_print(struct link *l_ptr, const char *str) | 3100 | static void link_print(struct tipc_link *l_ptr, const char *str) |
3030 | { | 3101 | { |
3031 | char print_area[256]; | 3102 | char print_area[256]; |
3032 | struct print_buf pb; | 3103 | struct print_buf pb; |
@@ -3046,13 +3117,12 @@ static void link_print(struct link *l_ptr, const char *str) | |||
3046 | tipc_printf(buf, "NXI(%u):", mod(l_ptr->next_in_no)); | 3117 | tipc_printf(buf, "NXI(%u):", mod(l_ptr->next_in_no)); |
3047 | tipc_printf(buf, "SQUE"); | 3118 | tipc_printf(buf, "SQUE"); |
3048 | if (l_ptr->first_out) { | 3119 | if (l_ptr->first_out) { |
3049 | tipc_printf(buf, "[%u..", msg_seqno(buf_msg(l_ptr->first_out))); | 3120 | tipc_printf(buf, "[%u..", buf_seqno(l_ptr->first_out)); |
3050 | if (l_ptr->next_out) | 3121 | if (l_ptr->next_out) |
3051 | tipc_printf(buf, "%u..", | 3122 | tipc_printf(buf, "%u..", buf_seqno(l_ptr->next_out)); |
3052 | msg_seqno(buf_msg(l_ptr->next_out))); | 3123 | tipc_printf(buf, "%u]", buf_seqno(l_ptr->last_out)); |
3053 | tipc_printf(buf, "%u]", msg_seqno(buf_msg(l_ptr->last_out))); | 3124 | if ((mod(buf_seqno(l_ptr->last_out) - |
3054 | if ((mod(msg_seqno(buf_msg(l_ptr->last_out)) - | 3125 | buf_seqno(l_ptr->first_out)) |
3055 | msg_seqno(buf_msg(l_ptr->first_out))) | ||
3056 | != (l_ptr->out_queue_size - 1)) || | 3126 | != (l_ptr->out_queue_size - 1)) || |
3057 | (l_ptr->last_out->next != NULL)) { | 3127 | (l_ptr->last_out->next != NULL)) { |
3058 | tipc_printf(buf, "\nSend queue inconsistency\n"); | 3128 | tipc_printf(buf, "\nSend queue inconsistency\n"); |
@@ -3064,8 +3134,8 @@ static void link_print(struct link *l_ptr, const char *str) | |||
3064 | tipc_printf(buf, "[]"); | 3134 | tipc_printf(buf, "[]"); |
3065 | tipc_printf(buf, "SQSIZ(%u)", l_ptr->out_queue_size); | 3135 | tipc_printf(buf, "SQSIZ(%u)", l_ptr->out_queue_size); |
3066 | if (l_ptr->oldest_deferred_in) { | 3136 | if (l_ptr->oldest_deferred_in) { |
3067 | u32 o = msg_seqno(buf_msg(l_ptr->oldest_deferred_in)); | 3137 | u32 o = buf_seqno(l_ptr->oldest_deferred_in); |
3068 | u32 n = msg_seqno(buf_msg(l_ptr->newest_deferred_in)); | 3138 | u32 n = buf_seqno(l_ptr->newest_deferred_in); |
3069 | tipc_printf(buf, ":RQUE[%u..%u]", o, n); | 3139 | tipc_printf(buf, ":RQUE[%u..%u]", o, n); |
3070 | if (l_ptr->deferred_inqueue_sz != mod((n + 1) - o)) { | 3140 | if (l_ptr->deferred_inqueue_sz != mod((n + 1) - o)) { |
3071 | tipc_printf(buf, ":RQSIZ(%u)", | 3141 | tipc_printf(buf, ":RQSIZ(%u)", |