diff options
Diffstat (limited to 'net/tipc/link.c')
-rw-r--r-- | net/tipc/link.c | 881 |
1 files changed, 283 insertions, 598 deletions
diff --git a/net/tipc/link.c b/net/tipc/link.c index 23bcc1132365..a4cf364316de 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
@@ -40,7 +40,6 @@ | |||
40 | #include "socket.h" | 40 | #include "socket.h" |
41 | #include "name_distr.h" | 41 | #include "name_distr.h" |
42 | #include "discover.h" | 42 | #include "discover.h" |
43 | #include "config.h" | ||
44 | #include "netlink.h" | 43 | #include "netlink.h" |
45 | 44 | ||
46 | #include <linux/pkt_sched.h> | 45 | #include <linux/pkt_sched.h> |
@@ -101,19 +100,20 @@ static const struct nla_policy tipc_nl_prop_policy[TIPC_NLA_PROP_MAX + 1] = { | |||
101 | */ | 100 | */ |
102 | #define START_CHANGEOVER 100000u | 101 | #define START_CHANGEOVER 100000u |
103 | 102 | ||
104 | static void link_handle_out_of_seq_msg(struct tipc_link *l_ptr, | 103 | static void link_handle_out_of_seq_msg(struct tipc_link *link, |
105 | struct sk_buff *buf); | 104 | struct sk_buff *skb); |
106 | static void tipc_link_proto_rcv(struct tipc_link *l_ptr, struct sk_buff *buf); | 105 | static void tipc_link_proto_rcv(struct tipc_link *link, |
107 | static int tipc_link_tunnel_rcv(struct tipc_node *n_ptr, | 106 | struct sk_buff *skb); |
108 | struct sk_buff **buf); | 107 | static int tipc_link_tunnel_rcv(struct tipc_node *node, |
109 | static void link_set_supervision_props(struct tipc_link *l_ptr, u32 tolerance); | 108 | struct sk_buff **skb); |
109 | static void link_set_supervision_props(struct tipc_link *l_ptr, u32 tol); | ||
110 | static void link_state_event(struct tipc_link *l_ptr, u32 event); | 110 | static void link_state_event(struct tipc_link *l_ptr, u32 event); |
111 | static void link_reset_statistics(struct tipc_link *l_ptr); | 111 | static void link_reset_statistics(struct tipc_link *l_ptr); |
112 | static void link_print(struct tipc_link *l_ptr, const char *str); | 112 | static void link_print(struct tipc_link *l_ptr, const char *str); |
113 | static void tipc_link_sync_xmit(struct tipc_link *l); | 113 | static void tipc_link_sync_xmit(struct tipc_link *l); |
114 | static void tipc_link_sync_rcv(struct tipc_node *n, struct sk_buff *buf); | 114 | static void tipc_link_sync_rcv(struct tipc_node *n, struct sk_buff *buf); |
115 | static int tipc_link_input(struct tipc_link *l, struct sk_buff *buf); | 115 | static void tipc_link_input(struct tipc_link *l, struct sk_buff *skb); |
116 | static int tipc_link_prepare_input(struct tipc_link *l, struct sk_buff **buf); | 116 | static bool tipc_data_input(struct tipc_link *l, struct sk_buff *skb); |
117 | 117 | ||
118 | /* | 118 | /* |
119 | * Simple link routines | 119 | * Simple link routines |
@@ -123,13 +123,30 @@ static unsigned int align(unsigned int i) | |||
123 | return (i + 3) & ~3u; | 123 | return (i + 3) & ~3u; |
124 | } | 124 | } |
125 | 125 | ||
126 | static void tipc_link_release(struct kref *kref) | ||
127 | { | ||
128 | kfree(container_of(kref, struct tipc_link, ref)); | ||
129 | } | ||
130 | |||
131 | static void tipc_link_get(struct tipc_link *l_ptr) | ||
132 | { | ||
133 | kref_get(&l_ptr->ref); | ||
134 | } | ||
135 | |||
136 | static void tipc_link_put(struct tipc_link *l_ptr) | ||
137 | { | ||
138 | kref_put(&l_ptr->ref, tipc_link_release); | ||
139 | } | ||
140 | |||
126 | static void link_init_max_pkt(struct tipc_link *l_ptr) | 141 | static void link_init_max_pkt(struct tipc_link *l_ptr) |
127 | { | 142 | { |
143 | struct tipc_node *node = l_ptr->owner; | ||
144 | struct tipc_net *tn = net_generic(node->net, tipc_net_id); | ||
128 | struct tipc_bearer *b_ptr; | 145 | struct tipc_bearer *b_ptr; |
129 | u32 max_pkt; | 146 | u32 max_pkt; |
130 | 147 | ||
131 | rcu_read_lock(); | 148 | rcu_read_lock(); |
132 | b_ptr = rcu_dereference_rtnl(bearer_list[l_ptr->bearer_id]); | 149 | b_ptr = rcu_dereference_rtnl(tn->bearer_list[l_ptr->bearer_id]); |
133 | if (!b_ptr) { | 150 | if (!b_ptr) { |
134 | rcu_read_unlock(); | 151 | rcu_read_unlock(); |
135 | return; | 152 | return; |
@@ -169,8 +186,9 @@ int tipc_link_is_active(struct tipc_link *l_ptr) | |||
169 | * link_timeout - handle expiration of link timer | 186 | * link_timeout - handle expiration of link timer |
170 | * @l_ptr: pointer to link | 187 | * @l_ptr: pointer to link |
171 | */ | 188 | */ |
172 | static void link_timeout(struct tipc_link *l_ptr) | 189 | static void link_timeout(unsigned long data) |
173 | { | 190 | { |
191 | struct tipc_link *l_ptr = (struct tipc_link *)data; | ||
174 | struct sk_buff *skb; | 192 | struct sk_buff *skb; |
175 | 193 | ||
176 | tipc_node_lock(l_ptr->owner); | 194 | tipc_node_lock(l_ptr->owner); |
@@ -215,11 +233,13 @@ static void link_timeout(struct tipc_link *l_ptr) | |||
215 | tipc_link_push_packets(l_ptr); | 233 | tipc_link_push_packets(l_ptr); |
216 | 234 | ||
217 | tipc_node_unlock(l_ptr->owner); | 235 | tipc_node_unlock(l_ptr->owner); |
236 | tipc_link_put(l_ptr); | ||
218 | } | 237 | } |
219 | 238 | ||
220 | static void link_set_timer(struct tipc_link *l_ptr, u32 time) | 239 | static void link_set_timer(struct tipc_link *link, unsigned long time) |
221 | { | 240 | { |
222 | k_start_timer(&l_ptr->timer, time); | 241 | if (!mod_timer(&link->timer, jiffies + time)) |
242 | tipc_link_get(link); | ||
223 | } | 243 | } |
224 | 244 | ||
225 | /** | 245 | /** |
@@ -234,6 +254,7 @@ struct tipc_link *tipc_link_create(struct tipc_node *n_ptr, | |||
234 | struct tipc_bearer *b_ptr, | 254 | struct tipc_bearer *b_ptr, |
235 | const struct tipc_media_addr *media_addr) | 255 | const struct tipc_media_addr *media_addr) |
236 | { | 256 | { |
257 | struct tipc_net *tn = net_generic(n_ptr->net, tipc_net_id); | ||
237 | struct tipc_link *l_ptr; | 258 | struct tipc_link *l_ptr; |
238 | struct tipc_msg *msg; | 259 | struct tipc_msg *msg; |
239 | char *if_name; | 260 | char *if_name; |
@@ -259,12 +280,12 @@ struct tipc_link *tipc_link_create(struct tipc_node *n_ptr, | |||
259 | pr_warn("Link creation failed, no memory\n"); | 280 | pr_warn("Link creation failed, no memory\n"); |
260 | return NULL; | 281 | return NULL; |
261 | } | 282 | } |
262 | 283 | kref_init(&l_ptr->ref); | |
263 | l_ptr->addr = peer; | 284 | l_ptr->addr = peer; |
264 | if_name = strchr(b_ptr->name, ':') + 1; | 285 | if_name = strchr(b_ptr->name, ':') + 1; |
265 | sprintf(l_ptr->name, "%u.%u.%u:%s-%u.%u.%u:unknown", | 286 | sprintf(l_ptr->name, "%u.%u.%u:%s-%u.%u.%u:unknown", |
266 | tipc_zone(tipc_own_addr), tipc_cluster(tipc_own_addr), | 287 | tipc_zone(tn->own_addr), tipc_cluster(tn->own_addr), |
267 | tipc_node(tipc_own_addr), | 288 | tipc_node(tn->own_addr), |
268 | if_name, | 289 | if_name, |
269 | tipc_zone(peer), tipc_cluster(peer), tipc_node(peer)); | 290 | tipc_zone(peer), tipc_cluster(peer), tipc_node(peer)); |
270 | /* note: peer i/f name is updated by reset/activate message */ | 291 | /* note: peer i/f name is updated by reset/activate message */ |
@@ -278,9 +299,10 @@ struct tipc_link *tipc_link_create(struct tipc_node *n_ptr, | |||
278 | 299 | ||
279 | l_ptr->pmsg = (struct tipc_msg *)&l_ptr->proto_msg; | 300 | l_ptr->pmsg = (struct tipc_msg *)&l_ptr->proto_msg; |
280 | msg = l_ptr->pmsg; | 301 | msg = l_ptr->pmsg; |
281 | tipc_msg_init(msg, LINK_PROTOCOL, RESET_MSG, INT_H_SIZE, l_ptr->addr); | 302 | tipc_msg_init(tn->own_addr, msg, LINK_PROTOCOL, RESET_MSG, INT_H_SIZE, |
303 | l_ptr->addr); | ||
282 | msg_set_size(msg, sizeof(l_ptr->proto_msg)); | 304 | msg_set_size(msg, sizeof(l_ptr->proto_msg)); |
283 | msg_set_session(msg, (tipc_random & 0xffff)); | 305 | msg_set_session(msg, (tn->random & 0xffff)); |
284 | msg_set_bearer_id(msg, b_ptr->identity); | 306 | msg_set_bearer_id(msg, b_ptr->identity); |
285 | strcpy((char *)msg_data(msg), if_name); | 307 | strcpy((char *)msg_data(msg), if_name); |
286 | 308 | ||
@@ -293,48 +315,52 @@ struct tipc_link *tipc_link_create(struct tipc_node *n_ptr, | |||
293 | l_ptr->next_out_no = 1; | 315 | l_ptr->next_out_no = 1; |
294 | __skb_queue_head_init(&l_ptr->outqueue); | 316 | __skb_queue_head_init(&l_ptr->outqueue); |
295 | __skb_queue_head_init(&l_ptr->deferred_queue); | 317 | __skb_queue_head_init(&l_ptr->deferred_queue); |
296 | skb_queue_head_init(&l_ptr->waiting_sks); | 318 | skb_queue_head_init(&l_ptr->wakeupq); |
297 | 319 | skb_queue_head_init(&l_ptr->inputq); | |
320 | skb_queue_head_init(&l_ptr->namedq); | ||
298 | link_reset_statistics(l_ptr); | 321 | link_reset_statistics(l_ptr); |
299 | |||
300 | tipc_node_attach_link(n_ptr, l_ptr); | 322 | tipc_node_attach_link(n_ptr, l_ptr); |
301 | 323 | setup_timer(&l_ptr->timer, link_timeout, (unsigned long)l_ptr); | |
302 | k_init_timer(&l_ptr->timer, (Handler)link_timeout, | ||
303 | (unsigned long)l_ptr); | ||
304 | |||
305 | link_state_event(l_ptr, STARTING_EVT); | 324 | link_state_event(l_ptr, STARTING_EVT); |
306 | 325 | ||
307 | return l_ptr; | 326 | return l_ptr; |
308 | } | 327 | } |
309 | 328 | ||
310 | void tipc_link_delete_list(unsigned int bearer_id, bool shutting_down) | 329 | /** |
330 | * link_delete - Conditional deletion of link. | ||
331 | * If timer still running, real delete is done when it expires | ||
332 | * @link: link to be deleted | ||
333 | */ | ||
334 | void tipc_link_delete(struct tipc_link *link) | ||
335 | { | ||
336 | tipc_link_reset_fragments(link); | ||
337 | tipc_node_detach_link(link->owner, link); | ||
338 | tipc_link_put(link); | ||
339 | } | ||
340 | |||
341 | void tipc_link_delete_list(struct net *net, unsigned int bearer_id, | ||
342 | bool shutting_down) | ||
311 | { | 343 | { |
312 | struct tipc_link *l_ptr; | 344 | struct tipc_net *tn = net_generic(net, tipc_net_id); |
313 | struct tipc_node *n_ptr; | 345 | struct tipc_link *link; |
346 | struct tipc_node *node; | ||
314 | 347 | ||
315 | rcu_read_lock(); | 348 | rcu_read_lock(); |
316 | list_for_each_entry_rcu(n_ptr, &tipc_node_list, list) { | 349 | list_for_each_entry_rcu(node, &tn->node_list, list) { |
317 | tipc_node_lock(n_ptr); | 350 | tipc_node_lock(node); |
318 | l_ptr = n_ptr->links[bearer_id]; | 351 | link = node->links[bearer_id]; |
319 | if (l_ptr) { | 352 | if (!link) { |
320 | tipc_link_reset(l_ptr); | 353 | tipc_node_unlock(node); |
321 | if (shutting_down || !tipc_node_is_up(n_ptr)) { | ||
322 | tipc_node_detach_link(l_ptr->owner, l_ptr); | ||
323 | tipc_link_reset_fragments(l_ptr); | ||
324 | tipc_node_unlock(n_ptr); | ||
325 | |||
326 | /* Nobody else can access this link now: */ | ||
327 | del_timer_sync(&l_ptr->timer); | ||
328 | kfree(l_ptr); | ||
329 | } else { | ||
330 | /* Detach/delete when failover is finished: */ | ||
331 | l_ptr->flags |= LINK_STOPPED; | ||
332 | tipc_node_unlock(n_ptr); | ||
333 | del_timer_sync(&l_ptr->timer); | ||
334 | } | ||
335 | continue; | 354 | continue; |
336 | } | 355 | } |
337 | tipc_node_unlock(n_ptr); | 356 | tipc_link_reset(link); |
357 | if (del_timer(&link->timer)) | ||
358 | tipc_link_put(link); | ||
359 | link->flags |= LINK_STOPPED; | ||
360 | /* Delete link now, or when failover is finished: */ | ||
361 | if (shutting_down || !tipc_node_is_up(node)) | ||
362 | tipc_link_delete(link); | ||
363 | tipc_node_unlock(node); | ||
338 | } | 364 | } |
339 | rcu_read_unlock(); | 365 | rcu_read_unlock(); |
340 | } | 366 | } |
@@ -352,13 +378,14 @@ static bool link_schedule_user(struct tipc_link *link, u32 oport, | |||
352 | { | 378 | { |
353 | struct sk_buff *buf; | 379 | struct sk_buff *buf; |
354 | 380 | ||
355 | buf = tipc_msg_create(SOCK_WAKEUP, 0, INT_H_SIZE, 0, tipc_own_addr, | 381 | buf = tipc_msg_create(SOCK_WAKEUP, 0, INT_H_SIZE, 0, |
356 | tipc_own_addr, oport, 0, 0); | 382 | link_own_addr(link), link_own_addr(link), |
383 | oport, 0, 0); | ||
357 | if (!buf) | 384 | if (!buf) |
358 | return false; | 385 | return false; |
359 | TIPC_SKB_CB(buf)->chain_sz = chain_sz; | 386 | TIPC_SKB_CB(buf)->chain_sz = chain_sz; |
360 | TIPC_SKB_CB(buf)->chain_imp = imp; | 387 | TIPC_SKB_CB(buf)->chain_imp = imp; |
361 | skb_queue_tail(&link->waiting_sks, buf); | 388 | skb_queue_tail(&link->wakeupq, buf); |
362 | link->stats.link_congs++; | 389 | link->stats.link_congs++; |
363 | return true; | 390 | return true; |
364 | } | 391 | } |
@@ -369,17 +396,19 @@ static bool link_schedule_user(struct tipc_link *link, u32 oport, | |||
369 | * Move a number of waiting users, as permitted by available space in | 396 | * Move a number of waiting users, as permitted by available space in |
370 | * the send queue, from link wait queue to node wait queue for wakeup | 397 | * the send queue, from link wait queue to node wait queue for wakeup |
371 | */ | 398 | */ |
372 | static void link_prepare_wakeup(struct tipc_link *link) | 399 | void link_prepare_wakeup(struct tipc_link *link) |
373 | { | 400 | { |
374 | uint pend_qsz = skb_queue_len(&link->outqueue); | 401 | uint pend_qsz = skb_queue_len(&link->outqueue); |
375 | struct sk_buff *skb, *tmp; | 402 | struct sk_buff *skb, *tmp; |
376 | 403 | ||
377 | skb_queue_walk_safe(&link->waiting_sks, skb, tmp) { | 404 | skb_queue_walk_safe(&link->wakeupq, skb, tmp) { |
378 | if (pend_qsz >= link->queue_limit[TIPC_SKB_CB(skb)->chain_imp]) | 405 | if (pend_qsz >= link->queue_limit[TIPC_SKB_CB(skb)->chain_imp]) |
379 | break; | 406 | break; |
380 | pend_qsz += TIPC_SKB_CB(skb)->chain_sz; | 407 | pend_qsz += TIPC_SKB_CB(skb)->chain_sz; |
381 | skb_unlink(skb, &link->waiting_sks); | 408 | skb_unlink(skb, &link->wakeupq); |
382 | skb_queue_tail(&link->owner->waiting_sks, skb); | 409 | skb_queue_tail(&link->inputq, skb); |
410 | link->owner->inputq = &link->inputq; | ||
411 | link->owner->action_flags |= TIPC_MSG_EVT; | ||
383 | } | 412 | } |
384 | } | 413 | } |
385 | 414 | ||
@@ -425,20 +454,20 @@ void tipc_link_reset(struct tipc_link *l_ptr) | |||
425 | return; | 454 | return; |
426 | 455 | ||
427 | tipc_node_link_down(l_ptr->owner, l_ptr); | 456 | tipc_node_link_down(l_ptr->owner, l_ptr); |
428 | tipc_bearer_remove_dest(l_ptr->bearer_id, l_ptr->addr); | 457 | tipc_bearer_remove_dest(owner->net, l_ptr->bearer_id, l_ptr->addr); |
429 | 458 | ||
430 | if (was_active_link && tipc_node_active_links(l_ptr->owner)) { | 459 | if (was_active_link && tipc_node_active_links(l_ptr->owner)) { |
431 | l_ptr->reset_checkpoint = checkpoint; | 460 | l_ptr->reset_checkpoint = checkpoint; |
432 | l_ptr->exp_msg_count = START_CHANGEOVER; | 461 | l_ptr->exp_msg_count = START_CHANGEOVER; |
433 | } | 462 | } |
434 | 463 | ||
435 | /* Clean up all queues: */ | 464 | /* Clean up all queues, except inputq: */ |
436 | __skb_queue_purge(&l_ptr->outqueue); | 465 | __skb_queue_purge(&l_ptr->outqueue); |
437 | __skb_queue_purge(&l_ptr->deferred_queue); | 466 | __skb_queue_purge(&l_ptr->deferred_queue); |
438 | if (!skb_queue_empty(&l_ptr->waiting_sks)) { | 467 | skb_queue_splice_init(&l_ptr->wakeupq, &l_ptr->inputq); |
439 | skb_queue_splice_init(&l_ptr->waiting_sks, &owner->waiting_sks); | 468 | if (!skb_queue_empty(&l_ptr->inputq)) |
440 | owner->action_flags |= TIPC_WAKEUP_USERS; | 469 | owner->action_flags |= TIPC_MSG_EVT; |
441 | } | 470 | owner->inputq = &l_ptr->inputq; |
442 | l_ptr->next_out = NULL; | 471 | l_ptr->next_out = NULL; |
443 | l_ptr->unacked_window = 0; | 472 | l_ptr->unacked_window = 0; |
444 | l_ptr->checkpoint = 1; | 473 | l_ptr->checkpoint = 1; |
@@ -448,13 +477,14 @@ void tipc_link_reset(struct tipc_link *l_ptr) | |||
448 | link_reset_statistics(l_ptr); | 477 | link_reset_statistics(l_ptr); |
449 | } | 478 | } |
450 | 479 | ||
451 | void tipc_link_reset_list(unsigned int bearer_id) | 480 | void tipc_link_reset_list(struct net *net, unsigned int bearer_id) |
452 | { | 481 | { |
482 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
453 | struct tipc_link *l_ptr; | 483 | struct tipc_link *l_ptr; |
454 | struct tipc_node *n_ptr; | 484 | struct tipc_node *n_ptr; |
455 | 485 | ||
456 | rcu_read_lock(); | 486 | rcu_read_lock(); |
457 | list_for_each_entry_rcu(n_ptr, &tipc_node_list, list) { | 487 | list_for_each_entry_rcu(n_ptr, &tn->node_list, list) { |
458 | tipc_node_lock(n_ptr); | 488 | tipc_node_lock(n_ptr); |
459 | l_ptr = n_ptr->links[bearer_id]; | 489 | l_ptr = n_ptr->links[bearer_id]; |
460 | if (l_ptr) | 490 | if (l_ptr) |
@@ -464,11 +494,14 @@ void tipc_link_reset_list(unsigned int bearer_id) | |||
464 | rcu_read_unlock(); | 494 | rcu_read_unlock(); |
465 | } | 495 | } |
466 | 496 | ||
467 | static void link_activate(struct tipc_link *l_ptr) | 497 | static void link_activate(struct tipc_link *link) |
468 | { | 498 | { |
469 | l_ptr->next_in_no = l_ptr->stats.recv_info = 1; | 499 | struct tipc_node *node = link->owner; |
470 | tipc_node_link_up(l_ptr->owner, l_ptr); | 500 | |
471 | tipc_bearer_add_dest(l_ptr->bearer_id, l_ptr->addr); | 501 | link->next_in_no = 1; |
502 | link->stats.recv_info = 1; | ||
503 | tipc_node_link_up(node, link); | ||
504 | tipc_bearer_add_dest(node->net, link->bearer_id, link->addr); | ||
472 | } | 505 | } |
473 | 506 | ||
474 | /** | 507 | /** |
@@ -479,7 +512,7 @@ static void link_activate(struct tipc_link *l_ptr) | |||
479 | static void link_state_event(struct tipc_link *l_ptr, unsigned int event) | 512 | static void link_state_event(struct tipc_link *l_ptr, unsigned int event) |
480 | { | 513 | { |
481 | struct tipc_link *other; | 514 | struct tipc_link *other; |
482 | u32 cont_intv = l_ptr->continuity_interval; | 515 | unsigned long cont_intv = l_ptr->cont_intv; |
483 | 516 | ||
484 | if (l_ptr->flags & LINK_STOPPED) | 517 | if (l_ptr->flags & LINK_STOPPED) |
485 | return; | 518 | return; |
@@ -522,8 +555,8 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event) | |||
522 | link_set_timer(l_ptr, cont_intv / 4); | 555 | link_set_timer(l_ptr, cont_intv / 4); |
523 | break; | 556 | break; |
524 | case RESET_MSG: | 557 | case RESET_MSG: |
525 | pr_info("%s<%s>, requested by peer\n", link_rst_msg, | 558 | pr_debug("%s<%s>, requested by peer\n", |
526 | l_ptr->name); | 559 | link_rst_msg, l_ptr->name); |
527 | tipc_link_reset(l_ptr); | 560 | tipc_link_reset(l_ptr); |
528 | l_ptr->state = RESET_RESET; | 561 | l_ptr->state = RESET_RESET; |
529 | l_ptr->fsm_msg_cnt = 0; | 562 | l_ptr->fsm_msg_cnt = 0; |
@@ -533,7 +566,7 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event) | |||
533 | link_set_timer(l_ptr, cont_intv); | 566 | link_set_timer(l_ptr, cont_intv); |
534 | break; | 567 | break; |
535 | default: | 568 | default: |
536 | pr_err("%s%u in WW state\n", link_unk_evt, event); | 569 | pr_debug("%s%u in WW state\n", link_unk_evt, event); |
537 | } | 570 | } |
538 | break; | 571 | break; |
539 | case WORKING_UNKNOWN: | 572 | case WORKING_UNKNOWN: |
@@ -545,8 +578,8 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event) | |||
545 | link_set_timer(l_ptr, cont_intv); | 578 | link_set_timer(l_ptr, cont_intv); |
546 | break; | 579 | break; |
547 | case RESET_MSG: | 580 | case RESET_MSG: |
548 | pr_info("%s<%s>, requested by peer while probing\n", | 581 | pr_debug("%s<%s>, requested by peer while probing\n", |
549 | link_rst_msg, l_ptr->name); | 582 | link_rst_msg, l_ptr->name); |
550 | tipc_link_reset(l_ptr); | 583 | tipc_link_reset(l_ptr); |
551 | l_ptr->state = RESET_RESET; | 584 | l_ptr->state = RESET_RESET; |
552 | l_ptr->fsm_msg_cnt = 0; | 585 | l_ptr->fsm_msg_cnt = 0; |
@@ -572,8 +605,8 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event) | |||
572 | l_ptr->fsm_msg_cnt++; | 605 | l_ptr->fsm_msg_cnt++; |
573 | link_set_timer(l_ptr, cont_intv / 4); | 606 | link_set_timer(l_ptr, cont_intv / 4); |
574 | } else { /* Link has failed */ | 607 | } else { /* Link has failed */ |
575 | pr_warn("%s<%s>, peer not responding\n", | 608 | pr_debug("%s<%s>, peer not responding\n", |
576 | link_rst_msg, l_ptr->name); | 609 | link_rst_msg, l_ptr->name); |
577 | tipc_link_reset(l_ptr); | 610 | tipc_link_reset(l_ptr); |
578 | l_ptr->state = RESET_UNKNOWN; | 611 | l_ptr->state = RESET_UNKNOWN; |
579 | l_ptr->fsm_msg_cnt = 0; | 612 | l_ptr->fsm_msg_cnt = 0; |
@@ -614,7 +647,9 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event) | |||
614 | break; | 647 | break; |
615 | case STARTING_EVT: | 648 | case STARTING_EVT: |
616 | l_ptr->flags |= LINK_STARTED; | 649 | l_ptr->flags |= LINK_STARTED; |
617 | /* fall through */ | 650 | l_ptr->fsm_msg_cnt++; |
651 | link_set_timer(l_ptr, cont_intv); | ||
652 | break; | ||
618 | case TIMEOUT_EVT: | 653 | case TIMEOUT_EVT: |
619 | tipc_link_proto_xmit(l_ptr, RESET_MSG, 0, 0, 0, 0, 0); | 654 | tipc_link_proto_xmit(l_ptr, RESET_MSG, 0, 0, 0, 0, 0); |
620 | l_ptr->fsm_msg_cnt++; | 655 | l_ptr->fsm_msg_cnt++; |
@@ -700,7 +735,8 @@ drop: | |||
700 | * Only the socket functions tipc_send_stream() and tipc_send_packet() need | 735 | * Only the socket functions tipc_send_stream() and tipc_send_packet() need |
701 | * to act on the return value, since they may need to do more send attempts. | 736 | * to act on the return value, since they may need to do more send attempts. |
702 | */ | 737 | */ |
703 | int __tipc_link_xmit(struct tipc_link *link, struct sk_buff_head *list) | 738 | int __tipc_link_xmit(struct net *net, struct tipc_link *link, |
739 | struct sk_buff_head *list) | ||
704 | { | 740 | { |
705 | struct tipc_msg *msg = buf_msg(skb_peek(list)); | 741 | struct tipc_msg *msg = buf_msg(skb_peek(list)); |
706 | uint psz = msg_size(msg); | 742 | uint psz = msg_size(msg); |
@@ -733,7 +769,8 @@ int __tipc_link_xmit(struct tipc_link *link, struct sk_buff_head *list) | |||
733 | 769 | ||
734 | if (skb_queue_len(outqueue) < sndlim) { | 770 | if (skb_queue_len(outqueue) < sndlim) { |
735 | __skb_queue_tail(outqueue, skb); | 771 | __skb_queue_tail(outqueue, skb); |
736 | tipc_bearer_send(link->bearer_id, skb, addr); | 772 | tipc_bearer_send(net, link->bearer_id, |
773 | skb, addr); | ||
737 | link->next_out = NULL; | 774 | link->next_out = NULL; |
738 | link->unacked_window = 0; | 775 | link->unacked_window = 0; |
739 | } else if (tipc_msg_bundle(outqueue, skb, mtu)) { | 776 | } else if (tipc_msg_bundle(outqueue, skb, mtu)) { |
@@ -758,7 +795,7 @@ int __tipc_link_xmit(struct tipc_link *link, struct sk_buff_head *list) | |||
758 | 795 | ||
759 | static void skb2list(struct sk_buff *skb, struct sk_buff_head *list) | 796 | static void skb2list(struct sk_buff *skb, struct sk_buff_head *list) |
760 | { | 797 | { |
761 | __skb_queue_head_init(list); | 798 | skb_queue_head_init(list); |
762 | __skb_queue_tail(list, skb); | 799 | __skb_queue_tail(list, skb); |
763 | } | 800 | } |
764 | 801 | ||
@@ -767,19 +804,21 @@ static int __tipc_link_xmit_skb(struct tipc_link *link, struct sk_buff *skb) | |||
767 | struct sk_buff_head head; | 804 | struct sk_buff_head head; |
768 | 805 | ||
769 | skb2list(skb, &head); | 806 | skb2list(skb, &head); |
770 | return __tipc_link_xmit(link, &head); | 807 | return __tipc_link_xmit(link->owner->net, link, &head); |
771 | } | 808 | } |
772 | 809 | ||
773 | int tipc_link_xmit_skb(struct sk_buff *skb, u32 dnode, u32 selector) | 810 | int tipc_link_xmit_skb(struct net *net, struct sk_buff *skb, u32 dnode, |
811 | u32 selector) | ||
774 | { | 812 | { |
775 | struct sk_buff_head head; | 813 | struct sk_buff_head head; |
776 | 814 | ||
777 | skb2list(skb, &head); | 815 | skb2list(skb, &head); |
778 | return tipc_link_xmit(&head, dnode, selector); | 816 | return tipc_link_xmit(net, &head, dnode, selector); |
779 | } | 817 | } |
780 | 818 | ||
781 | /** | 819 | /** |
782 | * tipc_link_xmit() is the general link level function for message sending | 820 | * tipc_link_xmit() is the general link level function for message sending |
821 | * @net: the applicable net namespace | ||
783 | * @list: chain of buffers containing message | 822 | * @list: chain of buffers containing message |
784 | * @dsz: amount of user data to be sent | 823 | * @dsz: amount of user data to be sent |
785 | * @dnode: address of destination node | 824 | * @dnode: address of destination node |
@@ -787,33 +826,28 @@ int tipc_link_xmit_skb(struct sk_buff *skb, u32 dnode, u32 selector) | |||
787 | * Consumes the buffer chain, except when returning -ELINKCONG | 826 | * Consumes the buffer chain, except when returning -ELINKCONG |
788 | * Returns 0 if success, otherwise errno: -ELINKCONG,-EHOSTUNREACH,-EMSGSIZE | 827 | * Returns 0 if success, otherwise errno: -ELINKCONG,-EHOSTUNREACH,-EMSGSIZE |
789 | */ | 828 | */ |
790 | int tipc_link_xmit(struct sk_buff_head *list, u32 dnode, u32 selector) | 829 | int tipc_link_xmit(struct net *net, struct sk_buff_head *list, u32 dnode, |
830 | u32 selector) | ||
791 | { | 831 | { |
792 | struct tipc_link *link = NULL; | 832 | struct tipc_link *link = NULL; |
793 | struct tipc_node *node; | 833 | struct tipc_node *node; |
794 | int rc = -EHOSTUNREACH; | 834 | int rc = -EHOSTUNREACH; |
795 | 835 | ||
796 | node = tipc_node_find(dnode); | 836 | node = tipc_node_find(net, dnode); |
797 | if (node) { | 837 | if (node) { |
798 | tipc_node_lock(node); | 838 | tipc_node_lock(node); |
799 | link = node->active_links[selector & 1]; | 839 | link = node->active_links[selector & 1]; |
800 | if (link) | 840 | if (link) |
801 | rc = __tipc_link_xmit(link, list); | 841 | rc = __tipc_link_xmit(net, link, list); |
802 | tipc_node_unlock(node); | 842 | tipc_node_unlock(node); |
803 | } | 843 | } |
804 | |||
805 | if (link) | 844 | if (link) |
806 | return rc; | 845 | return rc; |
807 | 846 | ||
808 | if (likely(in_own_node(dnode))) { | 847 | if (likely(in_own_node(net, dnode))) |
809 | /* As a node local message chain never contains more than one | 848 | return tipc_sk_rcv(net, list); |
810 | * buffer, we just need to dequeue one SKB buffer from the | ||
811 | * head list. | ||
812 | */ | ||
813 | return tipc_sk_rcv(__skb_dequeue(list)); | ||
814 | } | ||
815 | __skb_queue_purge(list); | ||
816 | 849 | ||
850 | __skb_queue_purge(list); | ||
817 | return rc; | 851 | return rc; |
818 | } | 852 | } |
819 | 853 | ||
@@ -835,7 +869,8 @@ static void tipc_link_sync_xmit(struct tipc_link *link) | |||
835 | return; | 869 | return; |
836 | 870 | ||
837 | msg = buf_msg(skb); | 871 | msg = buf_msg(skb); |
838 | tipc_msg_init(msg, BCAST_PROTOCOL, STATE_MSG, INT_H_SIZE, link->addr); | 872 | tipc_msg_init(link_own_addr(link), msg, BCAST_PROTOCOL, STATE_MSG, |
873 | INT_H_SIZE, link->addr); | ||
839 | msg_set_last_bcast(msg, link->owner->bclink.acked); | 874 | msg_set_last_bcast(msg, link->owner->bclink.acked); |
840 | __tipc_link_xmit_skb(link, skb); | 875 | __tipc_link_xmit_skb(link, skb); |
841 | } | 876 | } |
@@ -890,7 +925,8 @@ void tipc_link_push_packets(struct tipc_link *l_ptr) | |||
890 | msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); | 925 | msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); |
891 | if (msg_user(msg) == MSG_BUNDLER) | 926 | if (msg_user(msg) == MSG_BUNDLER) |
892 | TIPC_SKB_CB(skb)->bundling = false; | 927 | TIPC_SKB_CB(skb)->bundling = false; |
893 | tipc_bearer_send(l_ptr->bearer_id, skb, | 928 | tipc_bearer_send(l_ptr->owner->net, |
929 | l_ptr->bearer_id, skb, | ||
894 | &l_ptr->media_addr); | 930 | &l_ptr->media_addr); |
895 | l_ptr->next_out = tipc_skb_queue_next(outqueue, skb); | 931 | l_ptr->next_out = tipc_skb_queue_next(outqueue, skb); |
896 | } else { | 932 | } else { |
@@ -923,6 +959,7 @@ static void link_retransmit_failure(struct tipc_link *l_ptr, | |||
923 | struct sk_buff *buf) | 959 | struct sk_buff *buf) |
924 | { | 960 | { |
925 | struct tipc_msg *msg = buf_msg(buf); | 961 | struct tipc_msg *msg = buf_msg(buf); |
962 | struct net *net = l_ptr->owner->net; | ||
926 | 963 | ||
927 | pr_warn("Retransmission failure on link <%s>\n", l_ptr->name); | 964 | pr_warn("Retransmission failure on link <%s>\n", l_ptr->name); |
928 | 965 | ||
@@ -940,7 +977,7 @@ static void link_retransmit_failure(struct tipc_link *l_ptr, | |||
940 | pr_cont("Outstanding acks: %lu\n", | 977 | pr_cont("Outstanding acks: %lu\n", |
941 | (unsigned long) TIPC_SKB_CB(buf)->handle); | 978 | (unsigned long) TIPC_SKB_CB(buf)->handle); |
942 | 979 | ||
943 | n_ptr = tipc_bclink_retransmit_to(); | 980 | n_ptr = tipc_bclink_retransmit_to(net); |
944 | tipc_node_lock(n_ptr); | 981 | tipc_node_lock(n_ptr); |
945 | 982 | ||
946 | tipc_addr_string_fill(addr_string, n_ptr->addr); | 983 | tipc_addr_string_fill(addr_string, n_ptr->addr); |
@@ -955,7 +992,7 @@ static void link_retransmit_failure(struct tipc_link *l_ptr, | |||
955 | 992 | ||
956 | tipc_node_unlock(n_ptr); | 993 | tipc_node_unlock(n_ptr); |
957 | 994 | ||
958 | tipc_bclink_set_flags(TIPC_BCLINK_RESET); | 995 | tipc_bclink_set_flags(net, TIPC_BCLINK_RESET); |
959 | l_ptr->stale_count = 0; | 996 | l_ptr->stale_count = 0; |
960 | } | 997 | } |
961 | } | 998 | } |
@@ -987,7 +1024,8 @@ void tipc_link_retransmit(struct tipc_link *l_ptr, struct sk_buff *skb, | |||
987 | msg = buf_msg(skb); | 1024 | msg = buf_msg(skb); |
988 | msg_set_ack(msg, mod(l_ptr->next_in_no - 1)); | 1025 | msg_set_ack(msg, mod(l_ptr->next_in_no - 1)); |
989 | msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); | 1026 | msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); |
990 | tipc_bearer_send(l_ptr->bearer_id, skb, &l_ptr->media_addr); | 1027 | tipc_bearer_send(l_ptr->owner->net, l_ptr->bearer_id, skb, |
1028 | &l_ptr->media_addr); | ||
991 | retransmits--; | 1029 | retransmits--; |
992 | l_ptr->stats.retransmitted++; | 1030 | l_ptr->stats.retransmitted++; |
993 | } | 1031 | } |
@@ -1063,14 +1101,16 @@ static int link_recv_buf_validate(struct sk_buff *buf) | |||
1063 | 1101 | ||
1064 | /** | 1102 | /** |
1065 | * tipc_rcv - process TIPC packets/messages arriving from off-node | 1103 | * tipc_rcv - process TIPC packets/messages arriving from off-node |
1104 | * @net: the applicable net namespace | ||
1066 | * @skb: TIPC packet | 1105 | * @skb: TIPC packet |
1067 | * @b_ptr: pointer to bearer message arrived on | 1106 | * @b_ptr: pointer to bearer message arrived on |
1068 | * | 1107 | * |
1069 | * Invoked with no locks held. Bearer pointer must point to a valid bearer | 1108 | * Invoked with no locks held. Bearer pointer must point to a valid bearer |
1070 | * structure (i.e. cannot be NULL), but bearer can be inactive. | 1109 | * structure (i.e. cannot be NULL), but bearer can be inactive. |
1071 | */ | 1110 | */ |
1072 | void tipc_rcv(struct sk_buff *skb, struct tipc_bearer *b_ptr) | 1111 | void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b_ptr) |
1073 | { | 1112 | { |
1113 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
1074 | struct sk_buff_head head; | 1114 | struct sk_buff_head head; |
1075 | struct tipc_node *n_ptr; | 1115 | struct tipc_node *n_ptr; |
1076 | struct tipc_link *l_ptr; | 1116 | struct tipc_link *l_ptr; |
@@ -1096,19 +1136,19 @@ void tipc_rcv(struct sk_buff *skb, struct tipc_bearer *b_ptr) | |||
1096 | 1136 | ||
1097 | if (unlikely(msg_non_seq(msg))) { | 1137 | if (unlikely(msg_non_seq(msg))) { |
1098 | if (msg_user(msg) == LINK_CONFIG) | 1138 | if (msg_user(msg) == LINK_CONFIG) |
1099 | tipc_disc_rcv(skb, b_ptr); | 1139 | tipc_disc_rcv(net, skb, b_ptr); |
1100 | else | 1140 | else |
1101 | tipc_bclink_rcv(skb); | 1141 | tipc_bclink_rcv(net, skb); |
1102 | continue; | 1142 | continue; |
1103 | } | 1143 | } |
1104 | 1144 | ||
1105 | /* Discard unicast link messages destined for another node */ | 1145 | /* Discard unicast link messages destined for another node */ |
1106 | if (unlikely(!msg_short(msg) && | 1146 | if (unlikely(!msg_short(msg) && |
1107 | (msg_destnode(msg) != tipc_own_addr))) | 1147 | (msg_destnode(msg) != tn->own_addr))) |
1108 | goto discard; | 1148 | goto discard; |
1109 | 1149 | ||
1110 | /* Locate neighboring node that sent message */ | 1150 | /* Locate neighboring node that sent message */ |
1111 | n_ptr = tipc_node_find(msg_prevnode(msg)); | 1151 | n_ptr = tipc_node_find(net, msg_prevnode(msg)); |
1112 | if (unlikely(!n_ptr)) | 1152 | if (unlikely(!n_ptr)) |
1113 | goto discard; | 1153 | goto discard; |
1114 | tipc_node_lock(n_ptr); | 1154 | tipc_node_lock(n_ptr); |
@@ -1116,7 +1156,7 @@ void tipc_rcv(struct sk_buff *skb, struct tipc_bearer *b_ptr) | |||
1116 | /* Locate unicast link endpoint that should handle message */ | 1156 | /* Locate unicast link endpoint that should handle message */ |
1117 | l_ptr = n_ptr->links[b_ptr->identity]; | 1157 | l_ptr = n_ptr->links[b_ptr->identity]; |
1118 | if (unlikely(!l_ptr)) | 1158 | if (unlikely(!l_ptr)) |
1119 | goto unlock_discard; | 1159 | goto unlock; |
1120 | 1160 | ||
1121 | /* Verify that communication with node is currently allowed */ | 1161 | /* Verify that communication with node is currently allowed */ |
1122 | if ((n_ptr->action_flags & TIPC_WAIT_PEER_LINKS_DOWN) && | 1162 | if ((n_ptr->action_flags & TIPC_WAIT_PEER_LINKS_DOWN) && |
@@ -1127,7 +1167,7 @@ void tipc_rcv(struct sk_buff *skb, struct tipc_bearer *b_ptr) | |||
1127 | n_ptr->action_flags &= ~TIPC_WAIT_PEER_LINKS_DOWN; | 1167 | n_ptr->action_flags &= ~TIPC_WAIT_PEER_LINKS_DOWN; |
1128 | 1168 | ||
1129 | if (tipc_node_blocked(n_ptr)) | 1169 | if (tipc_node_blocked(n_ptr)) |
1130 | goto unlock_discard; | 1170 | goto unlock; |
1131 | 1171 | ||
1132 | /* Validate message sequence number info */ | 1172 | /* Validate message sequence number info */ |
1133 | seq_no = msg_seqno(msg); | 1173 | seq_no = msg_seqno(msg); |
@@ -1151,18 +1191,16 @@ void tipc_rcv(struct sk_buff *skb, struct tipc_bearer *b_ptr) | |||
1151 | if (unlikely(l_ptr->next_out)) | 1191 | if (unlikely(l_ptr->next_out)) |
1152 | tipc_link_push_packets(l_ptr); | 1192 | tipc_link_push_packets(l_ptr); |
1153 | 1193 | ||
1154 | if (released && !skb_queue_empty(&l_ptr->waiting_sks)) { | 1194 | if (released && !skb_queue_empty(&l_ptr->wakeupq)) |
1155 | link_prepare_wakeup(l_ptr); | 1195 | link_prepare_wakeup(l_ptr); |
1156 | l_ptr->owner->action_flags |= TIPC_WAKEUP_USERS; | ||
1157 | } | ||
1158 | 1196 | ||
1159 | /* Process the incoming packet */ | 1197 | /* Process the incoming packet */ |
1160 | if (unlikely(!link_working_working(l_ptr))) { | 1198 | if (unlikely(!link_working_working(l_ptr))) { |
1161 | if (msg_user(msg) == LINK_PROTOCOL) { | 1199 | if (msg_user(msg) == LINK_PROTOCOL) { |
1162 | tipc_link_proto_rcv(l_ptr, skb); | 1200 | tipc_link_proto_rcv(l_ptr, skb); |
1163 | link_retrieve_defq(l_ptr, &head); | 1201 | link_retrieve_defq(l_ptr, &head); |
1164 | tipc_node_unlock(n_ptr); | 1202 | skb = NULL; |
1165 | continue; | 1203 | goto unlock; |
1166 | } | 1204 | } |
1167 | 1205 | ||
1168 | /* Traffic message. Conditionally activate link */ | 1206 | /* Traffic message. Conditionally activate link */ |
@@ -1171,18 +1209,18 @@ void tipc_rcv(struct sk_buff *skb, struct tipc_bearer *b_ptr) | |||
1171 | if (link_working_working(l_ptr)) { | 1209 | if (link_working_working(l_ptr)) { |
1172 | /* Re-insert buffer in front of queue */ | 1210 | /* Re-insert buffer in front of queue */ |
1173 | __skb_queue_head(&head, skb); | 1211 | __skb_queue_head(&head, skb); |
1174 | tipc_node_unlock(n_ptr); | 1212 | skb = NULL; |
1175 | continue; | 1213 | goto unlock; |
1176 | } | 1214 | } |
1177 | goto unlock_discard; | 1215 | goto unlock; |
1178 | } | 1216 | } |
1179 | 1217 | ||
1180 | /* Link is now in state WORKING_WORKING */ | 1218 | /* Link is now in state WORKING_WORKING */ |
1181 | if (unlikely(seq_no != mod(l_ptr->next_in_no))) { | 1219 | if (unlikely(seq_no != mod(l_ptr->next_in_no))) { |
1182 | link_handle_out_of_seq_msg(l_ptr, skb); | 1220 | link_handle_out_of_seq_msg(l_ptr, skb); |
1183 | link_retrieve_defq(l_ptr, &head); | 1221 | link_retrieve_defq(l_ptr, &head); |
1184 | tipc_node_unlock(n_ptr); | 1222 | skb = NULL; |
1185 | continue; | 1223 | goto unlock; |
1186 | } | 1224 | } |
1187 | l_ptr->next_in_no++; | 1225 | l_ptr->next_in_no++; |
1188 | if (unlikely(!skb_queue_empty(&l_ptr->deferred_queue))) | 1226 | if (unlikely(!skb_queue_empty(&l_ptr->deferred_queue))) |
@@ -1192,95 +1230,102 @@ void tipc_rcv(struct sk_buff *skb, struct tipc_bearer *b_ptr) | |||
1192 | l_ptr->stats.sent_acks++; | 1230 | l_ptr->stats.sent_acks++; |
1193 | tipc_link_proto_xmit(l_ptr, STATE_MSG, 0, 0, 0, 0, 0); | 1231 | tipc_link_proto_xmit(l_ptr, STATE_MSG, 0, 0, 0, 0, 0); |
1194 | } | 1232 | } |
1195 | 1233 | tipc_link_input(l_ptr, skb); | |
1196 | if (tipc_link_prepare_input(l_ptr, &skb)) { | 1234 | skb = NULL; |
1197 | tipc_node_unlock(n_ptr); | 1235 | unlock: |
1198 | continue; | ||
1199 | } | ||
1200 | tipc_node_unlock(n_ptr); | ||
1201 | |||
1202 | if (tipc_link_input(l_ptr, skb) != 0) | ||
1203 | goto discard; | ||
1204 | continue; | ||
1205 | unlock_discard: | ||
1206 | tipc_node_unlock(n_ptr); | 1236 | tipc_node_unlock(n_ptr); |
1207 | discard: | 1237 | discard: |
1208 | kfree_skb(skb); | 1238 | if (unlikely(skb)) |
1239 | kfree_skb(skb); | ||
1209 | } | 1240 | } |
1210 | } | 1241 | } |
1211 | 1242 | ||
1212 | /** | 1243 | /* tipc_data_input - deliver data and name distr msgs to upper layer |
1213 | * tipc_link_prepare_input - process TIPC link messages | ||
1214 | * | ||
1215 | * returns nonzero if the message was consumed | ||
1216 | * | 1244 | * |
1245 | * Consumes buffer if message is of right type | ||
1217 | * Node lock must be held | 1246 | * Node lock must be held |
1218 | */ | 1247 | */ |
1219 | static int tipc_link_prepare_input(struct tipc_link *l, struct sk_buff **buf) | 1248 | static bool tipc_data_input(struct tipc_link *link, struct sk_buff *skb) |
1220 | { | 1249 | { |
1221 | struct tipc_node *n; | 1250 | struct tipc_node *node = link->owner; |
1222 | struct tipc_msg *msg; | 1251 | struct tipc_msg *msg = buf_msg(skb); |
1223 | int res = -EINVAL; | 1252 | u32 dport = msg_destport(msg); |
1224 | 1253 | ||
1225 | n = l->owner; | ||
1226 | msg = buf_msg(*buf); | ||
1227 | switch (msg_user(msg)) { | 1254 | switch (msg_user(msg)) { |
1228 | case CHANGEOVER_PROTOCOL: | 1255 | case TIPC_LOW_IMPORTANCE: |
1229 | if (tipc_link_tunnel_rcv(n, buf)) | 1256 | case TIPC_MEDIUM_IMPORTANCE: |
1230 | res = 0; | 1257 | case TIPC_HIGH_IMPORTANCE: |
1231 | break; | 1258 | case TIPC_CRITICAL_IMPORTANCE: |
1232 | case MSG_FRAGMENTER: | 1259 | case CONN_MANAGER: |
1233 | l->stats.recv_fragments++; | 1260 | if (tipc_skb_queue_tail(&link->inputq, skb, dport)) { |
1234 | if (tipc_buf_append(&l->reasm_buf, buf)) { | 1261 | node->inputq = &link->inputq; |
1235 | l->stats.recv_fragmented++; | 1262 | node->action_flags |= TIPC_MSG_EVT; |
1236 | res = 0; | ||
1237 | } else if (!l->reasm_buf) { | ||
1238 | tipc_link_reset(l); | ||
1239 | } | 1263 | } |
1240 | break; | 1264 | return true; |
1241 | case MSG_BUNDLER: | ||
1242 | l->stats.recv_bundles++; | ||
1243 | l->stats.recv_bundled += msg_msgcnt(msg); | ||
1244 | res = 0; | ||
1245 | break; | ||
1246 | case NAME_DISTRIBUTOR: | 1265 | case NAME_DISTRIBUTOR: |
1247 | n->bclink.recv_permitted = true; | 1266 | node->bclink.recv_permitted = true; |
1248 | res = 0; | 1267 | node->namedq = &link->namedq; |
1249 | break; | 1268 | skb_queue_tail(&link->namedq, skb); |
1269 | if (skb_queue_len(&link->namedq) == 1) | ||
1270 | node->action_flags |= TIPC_NAMED_MSG_EVT; | ||
1271 | return true; | ||
1272 | case MSG_BUNDLER: | ||
1273 | case CHANGEOVER_PROTOCOL: | ||
1274 | case MSG_FRAGMENTER: | ||
1250 | case BCAST_PROTOCOL: | 1275 | case BCAST_PROTOCOL: |
1251 | tipc_link_sync_rcv(n, *buf); | 1276 | return false; |
1252 | break; | ||
1253 | default: | 1277 | default: |
1254 | res = 0; | 1278 | pr_warn("Dropping received illegal msg type\n"); |
1255 | } | 1279 | kfree_skb(skb); |
1256 | return res; | 1280 | return false; |
1281 | }; | ||
1257 | } | 1282 | } |
1258 | /** | 1283 | |
1259 | * tipc_link_input - Deliver message too higher layers | 1284 | /* tipc_link_input - process packet that has passed link protocol check |
1285 | * | ||
1286 | * Consumes buffer | ||
1287 | * Node lock must be held | ||
1260 | */ | 1288 | */ |
1261 | static int tipc_link_input(struct tipc_link *l, struct sk_buff *buf) | 1289 | static void tipc_link_input(struct tipc_link *link, struct sk_buff *skb) |
1262 | { | 1290 | { |
1263 | struct tipc_msg *msg = buf_msg(buf); | 1291 | struct tipc_node *node = link->owner; |
1264 | int res = 0; | 1292 | struct tipc_msg *msg = buf_msg(skb); |
1293 | struct sk_buff *iskb; | ||
1294 | int pos = 0; | ||
1295 | |||
1296 | if (likely(tipc_data_input(link, skb))) | ||
1297 | return; | ||
1265 | 1298 | ||
1266 | switch (msg_user(msg)) { | 1299 | switch (msg_user(msg)) { |
1267 | case TIPC_LOW_IMPORTANCE: | 1300 | case CHANGEOVER_PROTOCOL: |
1268 | case TIPC_MEDIUM_IMPORTANCE: | 1301 | if (!tipc_link_tunnel_rcv(node, &skb)) |
1269 | case TIPC_HIGH_IMPORTANCE: | 1302 | break; |
1270 | case TIPC_CRITICAL_IMPORTANCE: | 1303 | if (msg_user(buf_msg(skb)) != MSG_BUNDLER) { |
1271 | case CONN_MANAGER: | 1304 | tipc_data_input(link, skb); |
1272 | tipc_sk_rcv(buf); | 1305 | break; |
1306 | } | ||
1307 | case MSG_BUNDLER: | ||
1308 | link->stats.recv_bundles++; | ||
1309 | link->stats.recv_bundled += msg_msgcnt(msg); | ||
1310 | |||
1311 | while (tipc_msg_extract(skb, &iskb, &pos)) | ||
1312 | tipc_data_input(link, iskb); | ||
1273 | break; | 1313 | break; |
1274 | case NAME_DISTRIBUTOR: | 1314 | case MSG_FRAGMENTER: |
1275 | tipc_named_rcv(buf); | 1315 | link->stats.recv_fragments++; |
1316 | if (tipc_buf_append(&link->reasm_buf, &skb)) { | ||
1317 | link->stats.recv_fragmented++; | ||
1318 | tipc_data_input(link, skb); | ||
1319 | } else if (!link->reasm_buf) { | ||
1320 | tipc_link_reset(link); | ||
1321 | } | ||
1276 | break; | 1322 | break; |
1277 | case MSG_BUNDLER: | 1323 | case BCAST_PROTOCOL: |
1278 | tipc_link_bundle_rcv(buf); | 1324 | tipc_link_sync_rcv(node, skb); |
1279 | break; | 1325 | break; |
1280 | default: | 1326 | default: |
1281 | res = -EINVAL; | 1327 | break; |
1282 | } | 1328 | }; |
1283 | return res; | ||
1284 | } | 1329 | } |
1285 | 1330 | ||
1286 | /** | 1331 | /** |
@@ -1381,7 +1426,7 @@ void tipc_link_proto_xmit(struct tipc_link *l_ptr, u32 msg_typ, int probe_msg, | |||
1381 | msg_set_type(msg, msg_typ); | 1426 | msg_set_type(msg, msg_typ); |
1382 | msg_set_net_plane(msg, l_ptr->net_plane); | 1427 | msg_set_net_plane(msg, l_ptr->net_plane); |
1383 | msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); | 1428 | msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); |
1384 | msg_set_last_bcast(msg, tipc_bclink_get_last_sent()); | 1429 | msg_set_last_bcast(msg, tipc_bclink_get_last_sent(l_ptr->owner->net)); |
1385 | 1430 | ||
1386 | if (msg_typ == STATE_MSG) { | 1431 | if (msg_typ == STATE_MSG) { |
1387 | u32 next_sent = mod(l_ptr->next_out_no); | 1432 | u32 next_sent = mod(l_ptr->next_out_no); |
@@ -1445,7 +1490,8 @@ void tipc_link_proto_xmit(struct tipc_link *l_ptr, u32 msg_typ, int probe_msg, | |||
1445 | skb_copy_to_linear_data(buf, msg, sizeof(l_ptr->proto_msg)); | 1490 | skb_copy_to_linear_data(buf, msg, sizeof(l_ptr->proto_msg)); |
1446 | buf->priority = TC_PRIO_CONTROL; | 1491 | buf->priority = TC_PRIO_CONTROL; |
1447 | 1492 | ||
1448 | tipc_bearer_send(l_ptr->bearer_id, buf, &l_ptr->media_addr); | 1493 | tipc_bearer_send(l_ptr->owner->net, l_ptr->bearer_id, buf, |
1494 | &l_ptr->media_addr); | ||
1449 | l_ptr->unacked_window = 0; | 1495 | l_ptr->unacked_window = 0; |
1450 | kfree_skb(buf); | 1496 | kfree_skb(buf); |
1451 | } | 1497 | } |
@@ -1455,7 +1501,8 @@ void tipc_link_proto_xmit(struct tipc_link *l_ptr, u32 msg_typ, int probe_msg, | |||
1455 | * Note that network plane id propagates through the network, and may | 1501 | * Note that network plane id propagates through the network, and may |
1456 | * change at any time. The node with lowest address rules | 1502 | * change at any time. The node with lowest address rules |
1457 | */ | 1503 | */ |
1458 | static void tipc_link_proto_rcv(struct tipc_link *l_ptr, struct sk_buff *buf) | 1504 | static void tipc_link_proto_rcv(struct tipc_link *l_ptr, |
1505 | struct sk_buff *buf) | ||
1459 | { | 1506 | { |
1460 | u32 rec_gap = 0; | 1507 | u32 rec_gap = 0; |
1461 | u32 max_pkt_info; | 1508 | u32 max_pkt_info; |
@@ -1468,7 +1515,7 @@ static void tipc_link_proto_rcv(struct tipc_link *l_ptr, struct sk_buff *buf) | |||
1468 | goto exit; | 1515 | goto exit; |
1469 | 1516 | ||
1470 | if (l_ptr->net_plane != msg_net_plane(msg)) | 1517 | if (l_ptr->net_plane != msg_net_plane(msg)) |
1471 | if (tipc_own_addr > msg_prevnode(msg)) | 1518 | if (link_own_addr(l_ptr) > msg_prevnode(msg)) |
1472 | l_ptr->net_plane = msg_net_plane(msg); | 1519 | l_ptr->net_plane = msg_net_plane(msg); |
1473 | 1520 | ||
1474 | switch (msg_type(msg)) { | 1521 | switch (msg_type(msg)) { |
@@ -1535,9 +1582,9 @@ static void tipc_link_proto_rcv(struct tipc_link *l_ptr, struct sk_buff *buf) | |||
1535 | 1582 | ||
1536 | if (msg_linkprio(msg) && | 1583 | if (msg_linkprio(msg) && |
1537 | (msg_linkprio(msg) != l_ptr->priority)) { | 1584 | (msg_linkprio(msg) != l_ptr->priority)) { |
1538 | pr_warn("%s<%s>, priority change %u->%u\n", | 1585 | pr_debug("%s<%s>, priority change %u->%u\n", |
1539 | link_rst_msg, l_ptr->name, l_ptr->priority, | 1586 | link_rst_msg, l_ptr->name, |
1540 | msg_linkprio(msg)); | 1587 | l_ptr->priority, msg_linkprio(msg)); |
1541 | l_ptr->priority = msg_linkprio(msg); | 1588 | l_ptr->priority = msg_linkprio(msg); |
1542 | tipc_link_reset(l_ptr); /* Enforce change to take effect */ | 1589 | tipc_link_reset(l_ptr); /* Enforce change to take effect */ |
1543 | break; | 1590 | break; |
@@ -1636,8 +1683,8 @@ void tipc_link_failover_send_queue(struct tipc_link *l_ptr) | |||
1636 | if (!tunnel) | 1683 | if (!tunnel) |
1637 | return; | 1684 | return; |
1638 | 1685 | ||
1639 | tipc_msg_init(&tunnel_hdr, CHANGEOVER_PROTOCOL, | 1686 | tipc_msg_init(link_own_addr(l_ptr), &tunnel_hdr, CHANGEOVER_PROTOCOL, |
1640 | ORIGINAL_MSG, INT_H_SIZE, l_ptr->addr); | 1687 | ORIGINAL_MSG, INT_H_SIZE, l_ptr->addr); |
1641 | msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id); | 1688 | msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id); |
1642 | msg_set_msgcnt(&tunnel_hdr, msgcount); | 1689 | msg_set_msgcnt(&tunnel_hdr, msgcount); |
1643 | 1690 | ||
@@ -1694,8 +1741,8 @@ void tipc_link_dup_queue_xmit(struct tipc_link *l_ptr, | |||
1694 | struct sk_buff *skb; | 1741 | struct sk_buff *skb; |
1695 | struct tipc_msg tunnel_hdr; | 1742 | struct tipc_msg tunnel_hdr; |
1696 | 1743 | ||
1697 | tipc_msg_init(&tunnel_hdr, CHANGEOVER_PROTOCOL, | 1744 | tipc_msg_init(link_own_addr(l_ptr), &tunnel_hdr, CHANGEOVER_PROTOCOL, |
1698 | DUPLICATE_MSG, INT_H_SIZE, l_ptr->addr); | 1745 | DUPLICATE_MSG, INT_H_SIZE, l_ptr->addr); |
1699 | msg_set_msgcnt(&tunnel_hdr, skb_queue_len(&l_ptr->outqueue)); | 1746 | msg_set_msgcnt(&tunnel_hdr, skb_queue_len(&l_ptr->outqueue)); |
1700 | msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id); | 1747 | msg_set_bearer_id(&tunnel_hdr, l_ptr->peer_bearer_id); |
1701 | skb_queue_walk(&l_ptr->outqueue, skb) { | 1748 | skb_queue_walk(&l_ptr->outqueue, skb) { |
@@ -1729,7 +1776,7 @@ void tipc_link_dup_queue_xmit(struct tipc_link *l_ptr, | |||
1729 | * @from_pos: offset to extract from | 1776 | * @from_pos: offset to extract from |
1730 | * | 1777 | * |
1731 | * Returns a new message buffer containing an embedded message. The | 1778 | * Returns a new message buffer containing an embedded message. The |
1732 | * encapsulating message itself is left unchanged. | 1779 | * encapsulating buffer is left unchanged. |
1733 | */ | 1780 | */ |
1734 | static struct sk_buff *buf_extract(struct sk_buff *skb, u32 from_pos) | 1781 | static struct sk_buff *buf_extract(struct sk_buff *skb, u32 from_pos) |
1735 | { | 1782 | { |
@@ -1743,8 +1790,6 @@ static struct sk_buff *buf_extract(struct sk_buff *skb, u32 from_pos) | |||
1743 | return eb; | 1790 | return eb; |
1744 | } | 1791 | } |
1745 | 1792 | ||
1746 | |||
1747 | |||
1748 | /* tipc_link_dup_rcv(): Receive a tunnelled DUPLICATE_MSG packet. | 1793 | /* tipc_link_dup_rcv(): Receive a tunnelled DUPLICATE_MSG packet. |
1749 | * Owner node is locked. | 1794 | * Owner node is locked. |
1750 | */ | 1795 | */ |
@@ -1804,10 +1849,8 @@ static struct sk_buff *tipc_link_failover_rcv(struct tipc_link *l_ptr, | |||
1804 | } | 1849 | } |
1805 | } | 1850 | } |
1806 | exit: | 1851 | exit: |
1807 | if ((l_ptr->exp_msg_count == 0) && (l_ptr->flags & LINK_STOPPED)) { | 1852 | if ((!l_ptr->exp_msg_count) && (l_ptr->flags & LINK_STOPPED)) |
1808 | tipc_node_detach_link(l_ptr->owner, l_ptr); | 1853 | tipc_link_delete(l_ptr); |
1809 | kfree(l_ptr); | ||
1810 | } | ||
1811 | return buf; | 1854 | return buf; |
1812 | } | 1855 | } |
1813 | 1856 | ||
@@ -1845,50 +1888,16 @@ exit: | |||
1845 | return *buf != NULL; | 1888 | return *buf != NULL; |
1846 | } | 1889 | } |
1847 | 1890 | ||
1848 | /* | 1891 | static void link_set_supervision_props(struct tipc_link *l_ptr, u32 tol) |
1849 | * Bundler functionality: | ||
1850 | */ | ||
1851 | void tipc_link_bundle_rcv(struct sk_buff *buf) | ||
1852 | { | 1892 | { |
1853 | u32 msgcount = msg_msgcnt(buf_msg(buf)); | 1893 | unsigned long intv = ((tol / 4) > 500) ? 500 : tol / 4; |
1854 | u32 pos = INT_H_SIZE; | ||
1855 | struct sk_buff *obuf; | ||
1856 | struct tipc_msg *omsg; | ||
1857 | |||
1858 | while (msgcount--) { | ||
1859 | obuf = buf_extract(buf, pos); | ||
1860 | if (obuf == NULL) { | ||
1861 | pr_warn("Link unable to unbundle message(s)\n"); | ||
1862 | break; | ||
1863 | } | ||
1864 | omsg = buf_msg(obuf); | ||
1865 | pos += align(msg_size(omsg)); | ||
1866 | if (msg_isdata(omsg)) { | ||
1867 | if (unlikely(msg_type(omsg) == TIPC_MCAST_MSG)) | ||
1868 | tipc_sk_mcast_rcv(obuf); | ||
1869 | else | ||
1870 | tipc_sk_rcv(obuf); | ||
1871 | } else if (msg_user(omsg) == CONN_MANAGER) { | ||
1872 | tipc_sk_rcv(obuf); | ||
1873 | } else if (msg_user(omsg) == NAME_DISTRIBUTOR) { | ||
1874 | tipc_named_rcv(obuf); | ||
1875 | } else { | ||
1876 | pr_warn("Illegal bundled msg: %u\n", msg_user(omsg)); | ||
1877 | kfree_skb(obuf); | ||
1878 | } | ||
1879 | } | ||
1880 | kfree_skb(buf); | ||
1881 | } | ||
1882 | 1894 | ||
1883 | static void link_set_supervision_props(struct tipc_link *l_ptr, u32 tolerance) | 1895 | if ((tol < TIPC_MIN_LINK_TOL) || (tol > TIPC_MAX_LINK_TOL)) |
1884 | { | ||
1885 | if ((tolerance < TIPC_MIN_LINK_TOL) || (tolerance > TIPC_MAX_LINK_TOL)) | ||
1886 | return; | 1896 | return; |
1887 | 1897 | ||
1888 | l_ptr->tolerance = tolerance; | 1898 | l_ptr->tolerance = tol; |
1889 | l_ptr->continuity_interval = | 1899 | l_ptr->cont_intv = msecs_to_jiffies(intv); |
1890 | ((tolerance / 4) > 500) ? 500 : tolerance / 4; | 1900 | l_ptr->abort_limit = tol / (jiffies_to_msecs(l_ptr->cont_intv) / 4); |
1891 | l_ptr->abort_limit = tolerance / (l_ptr->continuity_interval / 4); | ||
1892 | } | 1901 | } |
1893 | 1902 | ||
1894 | void tipc_link_set_queue_limits(struct tipc_link *l_ptr, u32 window) | 1903 | void tipc_link_set_queue_limits(struct tipc_link *l_ptr, u32 window) |
@@ -1911,22 +1920,25 @@ void tipc_link_set_queue_limits(struct tipc_link *l_ptr, u32 window) | |||
1911 | } | 1920 | } |
1912 | 1921 | ||
1913 | /* tipc_link_find_owner - locate owner node of link by link's name | 1922 | /* tipc_link_find_owner - locate owner node of link by link's name |
1923 | * @net: the applicable net namespace | ||
1914 | * @name: pointer to link name string | 1924 | * @name: pointer to link name string |
1915 | * @bearer_id: pointer to index in 'node->links' array where the link was found. | 1925 | * @bearer_id: pointer to index in 'node->links' array where the link was found. |
1916 | * | 1926 | * |
1917 | * Returns pointer to node owning the link, or 0 if no matching link is found. | 1927 | * Returns pointer to node owning the link, or 0 if no matching link is found. |
1918 | */ | 1928 | */ |
1919 | static struct tipc_node *tipc_link_find_owner(const char *link_name, | 1929 | static struct tipc_node *tipc_link_find_owner(struct net *net, |
1930 | const char *link_name, | ||
1920 | unsigned int *bearer_id) | 1931 | unsigned int *bearer_id) |
1921 | { | 1932 | { |
1933 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
1922 | struct tipc_link *l_ptr; | 1934 | struct tipc_link *l_ptr; |
1923 | struct tipc_node *n_ptr; | 1935 | struct tipc_node *n_ptr; |
1924 | struct tipc_node *found_node = 0; | 1936 | struct tipc_node *found_node = NULL; |
1925 | int i; | 1937 | int i; |
1926 | 1938 | ||
1927 | *bearer_id = 0; | 1939 | *bearer_id = 0; |
1928 | rcu_read_lock(); | 1940 | rcu_read_lock(); |
1929 | list_for_each_entry_rcu(n_ptr, &tipc_node_list, list) { | 1941 | list_for_each_entry_rcu(n_ptr, &tn->node_list, list) { |
1930 | tipc_node_lock(n_ptr); | 1942 | tipc_node_lock(n_ptr); |
1931 | for (i = 0; i < MAX_BEARERS; i++) { | 1943 | for (i = 0; i < MAX_BEARERS; i++) { |
1932 | l_ptr = n_ptr->links[i]; | 1944 | l_ptr = n_ptr->links[i]; |
@@ -1946,148 +1958,6 @@ static struct tipc_node *tipc_link_find_owner(const char *link_name, | |||
1946 | } | 1958 | } |
1947 | 1959 | ||
1948 | /** | 1960 | /** |
1949 | * link_value_is_valid -- validate proposed link tolerance/priority/window | ||
1950 | * | ||
1951 | * @cmd: value type (TIPC_CMD_SET_LINK_*) | ||
1952 | * @new_value: the new value | ||
1953 | * | ||
1954 | * Returns 1 if value is within range, 0 if not. | ||
1955 | */ | ||
1956 | static int link_value_is_valid(u16 cmd, u32 new_value) | ||
1957 | { | ||
1958 | switch (cmd) { | ||
1959 | case TIPC_CMD_SET_LINK_TOL: | ||
1960 | return (new_value >= TIPC_MIN_LINK_TOL) && | ||
1961 | (new_value <= TIPC_MAX_LINK_TOL); | ||
1962 | case TIPC_CMD_SET_LINK_PRI: | ||
1963 | return (new_value <= TIPC_MAX_LINK_PRI); | ||
1964 | case TIPC_CMD_SET_LINK_WINDOW: | ||
1965 | return (new_value >= TIPC_MIN_LINK_WIN) && | ||
1966 | (new_value <= TIPC_MAX_LINK_WIN); | ||
1967 | } | ||
1968 | return 0; | ||
1969 | } | ||
1970 | |||
1971 | /** | ||
1972 | * link_cmd_set_value - change priority/tolerance/window for link/bearer/media | ||
1973 | * @name: ptr to link, bearer, or media name | ||
1974 | * @new_value: new value of link, bearer, or media setting | ||
1975 | * @cmd: which link, bearer, or media attribute to set (TIPC_CMD_SET_LINK_*) | ||
1976 | * | ||
1977 | * Caller must hold RTNL lock to ensure link/bearer/media is not deleted. | ||
1978 | * | ||
1979 | * Returns 0 if value updated and negative value on error. | ||
1980 | */ | ||
1981 | static int link_cmd_set_value(const char *name, u32 new_value, u16 cmd) | ||
1982 | { | ||
1983 | struct tipc_node *node; | ||
1984 | struct tipc_link *l_ptr; | ||
1985 | struct tipc_bearer *b_ptr; | ||
1986 | struct tipc_media *m_ptr; | ||
1987 | int bearer_id; | ||
1988 | int res = 0; | ||
1989 | |||
1990 | node = tipc_link_find_owner(name, &bearer_id); | ||
1991 | if (node) { | ||
1992 | tipc_node_lock(node); | ||
1993 | l_ptr = node->links[bearer_id]; | ||
1994 | |||
1995 | if (l_ptr) { | ||
1996 | switch (cmd) { | ||
1997 | case TIPC_CMD_SET_LINK_TOL: | ||
1998 | link_set_supervision_props(l_ptr, new_value); | ||
1999 | tipc_link_proto_xmit(l_ptr, STATE_MSG, 0, 0, | ||
2000 | new_value, 0, 0); | ||
2001 | break; | ||
2002 | case TIPC_CMD_SET_LINK_PRI: | ||
2003 | l_ptr->priority = new_value; | ||
2004 | tipc_link_proto_xmit(l_ptr, STATE_MSG, 0, 0, | ||
2005 | 0, new_value, 0); | ||
2006 | break; | ||
2007 | case TIPC_CMD_SET_LINK_WINDOW: | ||
2008 | tipc_link_set_queue_limits(l_ptr, new_value); | ||
2009 | break; | ||
2010 | default: | ||
2011 | res = -EINVAL; | ||
2012 | break; | ||
2013 | } | ||
2014 | } | ||
2015 | tipc_node_unlock(node); | ||
2016 | return res; | ||
2017 | } | ||
2018 | |||
2019 | b_ptr = tipc_bearer_find(name); | ||
2020 | if (b_ptr) { | ||
2021 | switch (cmd) { | ||
2022 | case TIPC_CMD_SET_LINK_TOL: | ||
2023 | b_ptr->tolerance = new_value; | ||
2024 | break; | ||
2025 | case TIPC_CMD_SET_LINK_PRI: | ||
2026 | b_ptr->priority = new_value; | ||
2027 | break; | ||
2028 | case TIPC_CMD_SET_LINK_WINDOW: | ||
2029 | b_ptr->window = new_value; | ||
2030 | break; | ||
2031 | default: | ||
2032 | res = -EINVAL; | ||
2033 | break; | ||
2034 | } | ||
2035 | return res; | ||
2036 | } | ||
2037 | |||
2038 | m_ptr = tipc_media_find(name); | ||
2039 | if (!m_ptr) | ||
2040 | return -ENODEV; | ||
2041 | switch (cmd) { | ||
2042 | case TIPC_CMD_SET_LINK_TOL: | ||
2043 | m_ptr->tolerance = new_value; | ||
2044 | break; | ||
2045 | case TIPC_CMD_SET_LINK_PRI: | ||
2046 | m_ptr->priority = new_value; | ||
2047 | break; | ||
2048 | case TIPC_CMD_SET_LINK_WINDOW: | ||
2049 | m_ptr->window = new_value; | ||
2050 | break; | ||
2051 | default: | ||
2052 | res = -EINVAL; | ||
2053 | break; | ||
2054 | } | ||
2055 | return res; | ||
2056 | } | ||
2057 | |||
2058 | struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space, | ||
2059 | u16 cmd) | ||
2060 | { | ||
2061 | struct tipc_link_config *args; | ||
2062 | u32 new_value; | ||
2063 | int res; | ||
2064 | |||
2065 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_CONFIG)) | ||
2066 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | ||
2067 | |||
2068 | args = (struct tipc_link_config *)TLV_DATA(req_tlv_area); | ||
2069 | new_value = ntohl(args->value); | ||
2070 | |||
2071 | if (!link_value_is_valid(cmd, new_value)) | ||
2072 | return tipc_cfg_reply_error_string( | ||
2073 | "cannot change, value invalid"); | ||
2074 | |||
2075 | if (!strcmp(args->name, tipc_bclink_name)) { | ||
2076 | if ((cmd == TIPC_CMD_SET_LINK_WINDOW) && | ||
2077 | (tipc_bclink_set_queue_limits(new_value) == 0)) | ||
2078 | return tipc_cfg_reply_none(); | ||
2079 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | ||
2080 | " (cannot change setting on broadcast link)"); | ||
2081 | } | ||
2082 | |||
2083 | res = link_cmd_set_value(args->name, new_value, cmd); | ||
2084 | if (res) | ||
2085 | return tipc_cfg_reply_error_string("cannot change link setting"); | ||
2086 | |||
2087 | return tipc_cfg_reply_none(); | ||
2088 | } | ||
2089 | |||
2090 | /** | ||
2091 | * link_reset_statistics - reset link statistics | 1961 | * link_reset_statistics - reset link statistics |
2092 | * @l_ptr: pointer to link | 1962 | * @l_ptr: pointer to link |
2093 | */ | 1963 | */ |
@@ -2098,207 +1968,13 @@ static void link_reset_statistics(struct tipc_link *l_ptr) | |||
2098 | l_ptr->stats.recv_info = l_ptr->next_in_no; | 1968 | l_ptr->stats.recv_info = l_ptr->next_in_no; |
2099 | } | 1969 | } |
2100 | 1970 | ||
2101 | struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area, int req_tlv_space) | ||
2102 | { | ||
2103 | char *link_name; | ||
2104 | struct tipc_link *l_ptr; | ||
2105 | struct tipc_node *node; | ||
2106 | unsigned int bearer_id; | ||
2107 | |||
2108 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_NAME)) | ||
2109 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | ||
2110 | |||
2111 | link_name = (char *)TLV_DATA(req_tlv_area); | ||
2112 | if (!strcmp(link_name, tipc_bclink_name)) { | ||
2113 | if (tipc_bclink_reset_stats()) | ||
2114 | return tipc_cfg_reply_error_string("link not found"); | ||
2115 | return tipc_cfg_reply_none(); | ||
2116 | } | ||
2117 | node = tipc_link_find_owner(link_name, &bearer_id); | ||
2118 | if (!node) | ||
2119 | return tipc_cfg_reply_error_string("link not found"); | ||
2120 | |||
2121 | tipc_node_lock(node); | ||
2122 | l_ptr = node->links[bearer_id]; | ||
2123 | if (!l_ptr) { | ||
2124 | tipc_node_unlock(node); | ||
2125 | return tipc_cfg_reply_error_string("link not found"); | ||
2126 | } | ||
2127 | link_reset_statistics(l_ptr); | ||
2128 | tipc_node_unlock(node); | ||
2129 | return tipc_cfg_reply_none(); | ||
2130 | } | ||
2131 | |||
2132 | /** | ||
2133 | * percent - convert count to a percentage of total (rounding up or down) | ||
2134 | */ | ||
2135 | static u32 percent(u32 count, u32 total) | ||
2136 | { | ||
2137 | return (count * 100 + (total / 2)) / total; | ||
2138 | } | ||
2139 | |||
2140 | /** | ||
2141 | * tipc_link_stats - print link statistics | ||
2142 | * @name: link name | ||
2143 | * @buf: print buffer area | ||
2144 | * @buf_size: size of print buffer area | ||
2145 | * | ||
2146 | * Returns length of print buffer data string (or 0 if error) | ||
2147 | */ | ||
2148 | static int tipc_link_stats(const char *name, char *buf, const u32 buf_size) | ||
2149 | { | ||
2150 | struct tipc_link *l; | ||
2151 | struct tipc_stats *s; | ||
2152 | struct tipc_node *node; | ||
2153 | char *status; | ||
2154 | u32 profile_total = 0; | ||
2155 | unsigned int bearer_id; | ||
2156 | int ret; | ||
2157 | |||
2158 | if (!strcmp(name, tipc_bclink_name)) | ||
2159 | return tipc_bclink_stats(buf, buf_size); | ||
2160 | |||
2161 | node = tipc_link_find_owner(name, &bearer_id); | ||
2162 | if (!node) | ||
2163 | return 0; | ||
2164 | |||
2165 | tipc_node_lock(node); | ||
2166 | |||
2167 | l = node->links[bearer_id]; | ||
2168 | if (!l) { | ||
2169 | tipc_node_unlock(node); | ||
2170 | return 0; | ||
2171 | } | ||
2172 | |||
2173 | s = &l->stats; | ||
2174 | |||
2175 | if (tipc_link_is_active(l)) | ||
2176 | status = "ACTIVE"; | ||
2177 | else if (tipc_link_is_up(l)) | ||
2178 | status = "STANDBY"; | ||
2179 | else | ||
2180 | status = "DEFUNCT"; | ||
2181 | |||
2182 | ret = tipc_snprintf(buf, buf_size, "Link <%s>\n" | ||
2183 | " %s MTU:%u Priority:%u Tolerance:%u ms" | ||
2184 | " Window:%u packets\n", | ||
2185 | l->name, status, l->max_pkt, l->priority, | ||
2186 | l->tolerance, l->queue_limit[0]); | ||
2187 | |||
2188 | ret += tipc_snprintf(buf + ret, buf_size - ret, | ||
2189 | " RX packets:%u fragments:%u/%u bundles:%u/%u\n", | ||
2190 | l->next_in_no - s->recv_info, s->recv_fragments, | ||
2191 | s->recv_fragmented, s->recv_bundles, | ||
2192 | s->recv_bundled); | ||
2193 | |||
2194 | ret += tipc_snprintf(buf + ret, buf_size - ret, | ||
2195 | " TX packets:%u fragments:%u/%u bundles:%u/%u\n", | ||
2196 | l->next_out_no - s->sent_info, s->sent_fragments, | ||
2197 | s->sent_fragmented, s->sent_bundles, | ||
2198 | s->sent_bundled); | ||
2199 | |||
2200 | profile_total = s->msg_length_counts; | ||
2201 | if (!profile_total) | ||
2202 | profile_total = 1; | ||
2203 | |||
2204 | ret += tipc_snprintf(buf + ret, buf_size - ret, | ||
2205 | " TX profile sample:%u packets average:%u octets\n" | ||
2206 | " 0-64:%u%% -256:%u%% -1024:%u%% -4096:%u%% " | ||
2207 | "-16384:%u%% -32768:%u%% -66000:%u%%\n", | ||
2208 | s->msg_length_counts, | ||
2209 | s->msg_lengths_total / profile_total, | ||
2210 | percent(s->msg_length_profile[0], profile_total), | ||
2211 | percent(s->msg_length_profile[1], profile_total), | ||
2212 | percent(s->msg_length_profile[2], profile_total), | ||
2213 | percent(s->msg_length_profile[3], profile_total), | ||
2214 | percent(s->msg_length_profile[4], profile_total), | ||
2215 | percent(s->msg_length_profile[5], profile_total), | ||
2216 | percent(s->msg_length_profile[6], profile_total)); | ||
2217 | |||
2218 | ret += tipc_snprintf(buf + ret, buf_size - ret, | ||
2219 | " RX states:%u probes:%u naks:%u defs:%u" | ||
2220 | " dups:%u\n", s->recv_states, s->recv_probes, | ||
2221 | s->recv_nacks, s->deferred_recv, s->duplicates); | ||
2222 | |||
2223 | ret += tipc_snprintf(buf + ret, buf_size - ret, | ||
2224 | " TX states:%u probes:%u naks:%u acks:%u" | ||
2225 | " dups:%u\n", s->sent_states, s->sent_probes, | ||
2226 | s->sent_nacks, s->sent_acks, s->retransmitted); | ||
2227 | |||
2228 | ret += tipc_snprintf(buf + ret, buf_size - ret, | ||
2229 | " Congestion link:%u Send queue" | ||
2230 | " max:%u avg:%u\n", s->link_congs, | ||
2231 | s->max_queue_sz, s->queue_sz_counts ? | ||
2232 | (s->accu_queue_sz / s->queue_sz_counts) : 0); | ||
2233 | |||
2234 | tipc_node_unlock(node); | ||
2235 | return ret; | ||
2236 | } | ||
2237 | |||
2238 | struct sk_buff *tipc_link_cmd_show_stats(const void *req_tlv_area, int req_tlv_space) | ||
2239 | { | ||
2240 | struct sk_buff *buf; | ||
2241 | struct tlv_desc *rep_tlv; | ||
2242 | int str_len; | ||
2243 | int pb_len; | ||
2244 | char *pb; | ||
2245 | |||
2246 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_NAME)) | ||
2247 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | ||
2248 | |||
2249 | buf = tipc_cfg_reply_alloc(TLV_SPACE(ULTRA_STRING_MAX_LEN)); | ||
2250 | if (!buf) | ||
2251 | return NULL; | ||
2252 | |||
2253 | rep_tlv = (struct tlv_desc *)buf->data; | ||
2254 | pb = TLV_DATA(rep_tlv); | ||
2255 | pb_len = ULTRA_STRING_MAX_LEN; | ||
2256 | str_len = tipc_link_stats((char *)TLV_DATA(req_tlv_area), | ||
2257 | pb, pb_len); | ||
2258 | if (!str_len) { | ||
2259 | kfree_skb(buf); | ||
2260 | return tipc_cfg_reply_error_string("link not found"); | ||
2261 | } | ||
2262 | str_len += 1; /* for "\0" */ | ||
2263 | skb_put(buf, TLV_SPACE(str_len)); | ||
2264 | TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len); | ||
2265 | |||
2266 | return buf; | ||
2267 | } | ||
2268 | |||
2269 | /** | ||
2270 | * tipc_link_get_max_pkt - get maximum packet size to use when sending to destination | ||
2271 | * @dest: network address of destination node | ||
2272 | * @selector: used to select from set of active links | ||
2273 | * | ||
2274 | * If no active link can be found, uses default maximum packet size. | ||
2275 | */ | ||
2276 | u32 tipc_link_get_max_pkt(u32 dest, u32 selector) | ||
2277 | { | ||
2278 | struct tipc_node *n_ptr; | ||
2279 | struct tipc_link *l_ptr; | ||
2280 | u32 res = MAX_PKT_DEFAULT; | ||
2281 | |||
2282 | if (dest == tipc_own_addr) | ||
2283 | return MAX_MSG_SIZE; | ||
2284 | |||
2285 | n_ptr = tipc_node_find(dest); | ||
2286 | if (n_ptr) { | ||
2287 | tipc_node_lock(n_ptr); | ||
2288 | l_ptr = n_ptr->active_links[selector & 1]; | ||
2289 | if (l_ptr) | ||
2290 | res = l_ptr->max_pkt; | ||
2291 | tipc_node_unlock(n_ptr); | ||
2292 | } | ||
2293 | return res; | ||
2294 | } | ||
2295 | |||
2296 | static void link_print(struct tipc_link *l_ptr, const char *str) | 1971 | static void link_print(struct tipc_link *l_ptr, const char *str) |
2297 | { | 1972 | { |
1973 | struct tipc_net *tn = net_generic(l_ptr->owner->net, tipc_net_id); | ||
2298 | struct tipc_bearer *b_ptr; | 1974 | struct tipc_bearer *b_ptr; |
2299 | 1975 | ||
2300 | rcu_read_lock(); | 1976 | rcu_read_lock(); |
2301 | b_ptr = rcu_dereference_rtnl(bearer_list[l_ptr->bearer_id]); | 1977 | b_ptr = rcu_dereference_rtnl(tn->bearer_list[l_ptr->bearer_id]); |
2302 | if (b_ptr) | 1978 | if (b_ptr) |
2303 | pr_info("%s Link %x<%s>:", str, l_ptr->addr, b_ptr->name); | 1979 | pr_info("%s Link %x<%s>:", str, l_ptr->addr, b_ptr->name); |
2304 | rcu_read_unlock(); | 1980 | rcu_read_unlock(); |
@@ -2362,6 +2038,7 @@ int tipc_nl_link_set(struct sk_buff *skb, struct genl_info *info) | |||
2362 | struct tipc_link *link; | 2038 | struct tipc_link *link; |
2363 | struct tipc_node *node; | 2039 | struct tipc_node *node; |
2364 | struct nlattr *attrs[TIPC_NLA_LINK_MAX + 1]; | 2040 | struct nlattr *attrs[TIPC_NLA_LINK_MAX + 1]; |
2041 | struct net *net = sock_net(skb->sk); | ||
2365 | 2042 | ||
2366 | if (!info->attrs[TIPC_NLA_LINK]) | 2043 | if (!info->attrs[TIPC_NLA_LINK]) |
2367 | return -EINVAL; | 2044 | return -EINVAL; |
@@ -2377,7 +2054,7 @@ int tipc_nl_link_set(struct sk_buff *skb, struct genl_info *info) | |||
2377 | 2054 | ||
2378 | name = nla_data(attrs[TIPC_NLA_LINK_NAME]); | 2055 | name = nla_data(attrs[TIPC_NLA_LINK_NAME]); |
2379 | 2056 | ||
2380 | node = tipc_link_find_owner(name, &bearer_id); | 2057 | node = tipc_link_find_owner(net, name, &bearer_id); |
2381 | if (!node) | 2058 | if (!node) |
2382 | return -EINVAL; | 2059 | return -EINVAL; |
2383 | 2060 | ||
@@ -2493,14 +2170,16 @@ msg_full: | |||
2493 | } | 2170 | } |
2494 | 2171 | ||
2495 | /* Caller should hold appropriate locks to protect the link */ | 2172 | /* Caller should hold appropriate locks to protect the link */ |
2496 | static int __tipc_nl_add_link(struct tipc_nl_msg *msg, struct tipc_link *link) | 2173 | static int __tipc_nl_add_link(struct net *net, struct tipc_nl_msg *msg, |
2174 | struct tipc_link *link) | ||
2497 | { | 2175 | { |
2498 | int err; | 2176 | int err; |
2499 | void *hdr; | 2177 | void *hdr; |
2500 | struct nlattr *attrs; | 2178 | struct nlattr *attrs; |
2501 | struct nlattr *prop; | 2179 | struct nlattr *prop; |
2180 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
2502 | 2181 | ||
2503 | hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_v2_family, | 2182 | hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family, |
2504 | NLM_F_MULTI, TIPC_NL_LINK_GET); | 2183 | NLM_F_MULTI, TIPC_NL_LINK_GET); |
2505 | if (!hdr) | 2184 | if (!hdr) |
2506 | return -EMSGSIZE; | 2185 | return -EMSGSIZE; |
@@ -2512,7 +2191,7 @@ static int __tipc_nl_add_link(struct tipc_nl_msg *msg, struct tipc_link *link) | |||
2512 | if (nla_put_string(msg->skb, TIPC_NLA_LINK_NAME, link->name)) | 2191 | if (nla_put_string(msg->skb, TIPC_NLA_LINK_NAME, link->name)) |
2513 | goto attr_msg_full; | 2192 | goto attr_msg_full; |
2514 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_DEST, | 2193 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_DEST, |
2515 | tipc_cluster_mask(tipc_own_addr))) | 2194 | tipc_cluster_mask(tn->own_addr))) |
2516 | goto attr_msg_full; | 2195 | goto attr_msg_full; |
2517 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_MTU, link->max_pkt)) | 2196 | if (nla_put_u32(msg->skb, TIPC_NLA_LINK_MTU, link->max_pkt)) |
2518 | goto attr_msg_full; | 2197 | goto attr_msg_full; |
@@ -2562,9 +2241,8 @@ msg_full: | |||
2562 | } | 2241 | } |
2563 | 2242 | ||
2564 | /* Caller should hold node lock */ | 2243 | /* Caller should hold node lock */ |
2565 | static int __tipc_nl_add_node_links(struct tipc_nl_msg *msg, | 2244 | static int __tipc_nl_add_node_links(struct net *net, struct tipc_nl_msg *msg, |
2566 | struct tipc_node *node, | 2245 | struct tipc_node *node, u32 *prev_link) |
2567 | u32 *prev_link) | ||
2568 | { | 2246 | { |
2569 | u32 i; | 2247 | u32 i; |
2570 | int err; | 2248 | int err; |
@@ -2575,7 +2253,7 @@ static int __tipc_nl_add_node_links(struct tipc_nl_msg *msg, | |||
2575 | if (!node->links[i]) | 2253 | if (!node->links[i]) |
2576 | continue; | 2254 | continue; |
2577 | 2255 | ||
2578 | err = __tipc_nl_add_link(msg, node->links[i]); | 2256 | err = __tipc_nl_add_link(net, msg, node->links[i]); |
2579 | if (err) | 2257 | if (err) |
2580 | return err; | 2258 | return err; |
2581 | } | 2259 | } |
@@ -2586,6 +2264,8 @@ static int __tipc_nl_add_node_links(struct tipc_nl_msg *msg, | |||
2586 | 2264 | ||
2587 | int tipc_nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb) | 2265 | int tipc_nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb) |
2588 | { | 2266 | { |
2267 | struct net *net = sock_net(skb->sk); | ||
2268 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
2589 | struct tipc_node *node; | 2269 | struct tipc_node *node; |
2590 | struct tipc_nl_msg msg; | 2270 | struct tipc_nl_msg msg; |
2591 | u32 prev_node = cb->args[0]; | 2271 | u32 prev_node = cb->args[0]; |
@@ -2603,7 +2283,7 @@ int tipc_nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb) | |||
2603 | rcu_read_lock(); | 2283 | rcu_read_lock(); |
2604 | 2284 | ||
2605 | if (prev_node) { | 2285 | if (prev_node) { |
2606 | node = tipc_node_find(prev_node); | 2286 | node = tipc_node_find(net, prev_node); |
2607 | if (!node) { | 2287 | if (!node) { |
2608 | /* We never set seq or call nl_dump_check_consistent() | 2288 | /* We never set seq or call nl_dump_check_consistent() |
2609 | * this means that setting prev_seq here will cause the | 2289 | * this means that setting prev_seq here will cause the |
@@ -2615,9 +2295,11 @@ int tipc_nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb) | |||
2615 | goto out; | 2295 | goto out; |
2616 | } | 2296 | } |
2617 | 2297 | ||
2618 | list_for_each_entry_continue_rcu(node, &tipc_node_list, list) { | 2298 | list_for_each_entry_continue_rcu(node, &tn->node_list, |
2299 | list) { | ||
2619 | tipc_node_lock(node); | 2300 | tipc_node_lock(node); |
2620 | err = __tipc_nl_add_node_links(&msg, node, &prev_link); | 2301 | err = __tipc_nl_add_node_links(net, &msg, node, |
2302 | &prev_link); | ||
2621 | tipc_node_unlock(node); | 2303 | tipc_node_unlock(node); |
2622 | if (err) | 2304 | if (err) |
2623 | goto out; | 2305 | goto out; |
@@ -2625,13 +2307,14 @@ int tipc_nl_link_dump(struct sk_buff *skb, struct netlink_callback *cb) | |||
2625 | prev_node = node->addr; | 2307 | prev_node = node->addr; |
2626 | } | 2308 | } |
2627 | } else { | 2309 | } else { |
2628 | err = tipc_nl_add_bc_link(&msg); | 2310 | err = tipc_nl_add_bc_link(net, &msg); |
2629 | if (err) | 2311 | if (err) |
2630 | goto out; | 2312 | goto out; |
2631 | 2313 | ||
2632 | list_for_each_entry_rcu(node, &tipc_node_list, list) { | 2314 | list_for_each_entry_rcu(node, &tn->node_list, list) { |
2633 | tipc_node_lock(node); | 2315 | tipc_node_lock(node); |
2634 | err = __tipc_nl_add_node_links(&msg, node, &prev_link); | 2316 | err = __tipc_nl_add_node_links(net, &msg, node, |
2317 | &prev_link); | ||
2635 | tipc_node_unlock(node); | 2318 | tipc_node_unlock(node); |
2636 | if (err) | 2319 | if (err) |
2637 | goto out; | 2320 | goto out; |
@@ -2652,6 +2335,7 @@ out: | |||
2652 | 2335 | ||
2653 | int tipc_nl_link_get(struct sk_buff *skb, struct genl_info *info) | 2336 | int tipc_nl_link_get(struct sk_buff *skb, struct genl_info *info) |
2654 | { | 2337 | { |
2338 | struct net *net = genl_info_net(info); | ||
2655 | struct sk_buff *ans_skb; | 2339 | struct sk_buff *ans_skb; |
2656 | struct tipc_nl_msg msg; | 2340 | struct tipc_nl_msg msg; |
2657 | struct tipc_link *link; | 2341 | struct tipc_link *link; |
@@ -2664,7 +2348,7 @@ int tipc_nl_link_get(struct sk_buff *skb, struct genl_info *info) | |||
2664 | return -EINVAL; | 2348 | return -EINVAL; |
2665 | 2349 | ||
2666 | name = nla_data(info->attrs[TIPC_NLA_LINK_NAME]); | 2350 | name = nla_data(info->attrs[TIPC_NLA_LINK_NAME]); |
2667 | node = tipc_link_find_owner(name, &bearer_id); | 2351 | node = tipc_link_find_owner(net, name, &bearer_id); |
2668 | if (!node) | 2352 | if (!node) |
2669 | return -EINVAL; | 2353 | return -EINVAL; |
2670 | 2354 | ||
@@ -2683,7 +2367,7 @@ int tipc_nl_link_get(struct sk_buff *skb, struct genl_info *info) | |||
2683 | goto err_out; | 2367 | goto err_out; |
2684 | } | 2368 | } |
2685 | 2369 | ||
2686 | err = __tipc_nl_add_link(&msg, link); | 2370 | err = __tipc_nl_add_link(net, &msg, link); |
2687 | if (err) | 2371 | if (err) |
2688 | goto err_out; | 2372 | goto err_out; |
2689 | 2373 | ||
@@ -2706,6 +2390,7 @@ int tipc_nl_link_reset_stats(struct sk_buff *skb, struct genl_info *info) | |||
2706 | struct tipc_link *link; | 2390 | struct tipc_link *link; |
2707 | struct tipc_node *node; | 2391 | struct tipc_node *node; |
2708 | struct nlattr *attrs[TIPC_NLA_LINK_MAX + 1]; | 2392 | struct nlattr *attrs[TIPC_NLA_LINK_MAX + 1]; |
2393 | struct net *net = sock_net(skb->sk); | ||
2709 | 2394 | ||
2710 | if (!info->attrs[TIPC_NLA_LINK]) | 2395 | if (!info->attrs[TIPC_NLA_LINK]) |
2711 | return -EINVAL; | 2396 | return -EINVAL; |
@@ -2722,13 +2407,13 @@ int tipc_nl_link_reset_stats(struct sk_buff *skb, struct genl_info *info) | |||
2722 | link_name = nla_data(attrs[TIPC_NLA_LINK_NAME]); | 2407 | link_name = nla_data(attrs[TIPC_NLA_LINK_NAME]); |
2723 | 2408 | ||
2724 | if (strcmp(link_name, tipc_bclink_name) == 0) { | 2409 | if (strcmp(link_name, tipc_bclink_name) == 0) { |
2725 | err = tipc_bclink_reset_stats(); | 2410 | err = tipc_bclink_reset_stats(net); |
2726 | if (err) | 2411 | if (err) |
2727 | return err; | 2412 | return err; |
2728 | return 0; | 2413 | return 0; |
2729 | } | 2414 | } |
2730 | 2415 | ||
2731 | node = tipc_link_find_owner(link_name, &bearer_id); | 2416 | node = tipc_link_find_owner(net, link_name, &bearer_id); |
2732 | if (!node) | 2417 | if (!node) |
2733 | return -EINVAL; | 2418 | return -EINVAL; |
2734 | 2419 | ||