diff options
Diffstat (limited to 'net/tipc/link.c')
| -rw-r--r-- | net/tipc/link.c | 627 |
1 files changed, 345 insertions, 282 deletions
diff --git a/net/tipc/link.c b/net/tipc/link.c index d4b5de41b682..c5190ab75290 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
| @@ -77,19 +77,19 @@ static const char *link_unk_evt = "Unknown link event "; | |||
| 77 | 77 | ||
| 78 | static void link_handle_out_of_seq_msg(struct tipc_link *l_ptr, | 78 | static void link_handle_out_of_seq_msg(struct tipc_link *l_ptr, |
| 79 | struct sk_buff *buf); | 79 | struct sk_buff *buf); |
| 80 | static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf); | 80 | static void tipc_link_proto_rcv(struct tipc_link *l_ptr, struct sk_buff *buf); |
| 81 | static int tipc_link_tunnel_rcv(struct tipc_link **l_ptr, | 81 | static int tipc_link_tunnel_rcv(struct tipc_node *n_ptr, |
| 82 | struct sk_buff **buf); | 82 | struct sk_buff **buf); |
| 83 | static void link_set_supervision_props(struct tipc_link *l_ptr, u32 tolerance); | 83 | static void link_set_supervision_props(struct tipc_link *l_ptr, u32 tolerance); |
| 84 | static int link_send_sections_long(struct tipc_port *sender, | 84 | static int tipc_link_iovec_long_xmit(struct tipc_port *sender, |
| 85 | struct iovec const *msg_sect, | 85 | struct iovec const *msg_sect, |
| 86 | unsigned int len, u32 destnode); | 86 | unsigned int len, u32 destnode); |
| 87 | static void link_state_event(struct tipc_link *l_ptr, u32 event); | 87 | static void link_state_event(struct tipc_link *l_ptr, u32 event); |
| 88 | static void link_reset_statistics(struct tipc_link *l_ptr); | 88 | static void link_reset_statistics(struct tipc_link *l_ptr); |
| 89 | static void link_print(struct tipc_link *l_ptr, const char *str); | 89 | static void link_print(struct tipc_link *l_ptr, const char *str); |
| 90 | static int link_send_long_buf(struct tipc_link *l_ptr, struct sk_buff *buf); | 90 | static int tipc_link_frag_xmit(struct tipc_link *l_ptr, struct sk_buff *buf); |
| 91 | static void tipc_link_send_sync(struct tipc_link *l); | 91 | static void tipc_link_sync_xmit(struct tipc_link *l); |
| 92 | static void tipc_link_recv_sync(struct tipc_node *n, struct sk_buff *buf); | 92 | static void tipc_link_sync_rcv(struct tipc_node *n, struct sk_buff *buf); |
| 93 | 93 | ||
| 94 | /* | 94 | /* |
| 95 | * Simple link routines | 95 | * Simple link routines |
| @@ -147,11 +147,6 @@ int tipc_link_is_active(struct tipc_link *l_ptr) | |||
| 147 | /** | 147 | /** |
| 148 | * link_timeout - handle expiration of link timer | 148 | * link_timeout - handle expiration of link timer |
| 149 | * @l_ptr: pointer to link | 149 | * @l_ptr: pointer to link |
| 150 | * | ||
| 151 | * This routine must not grab "tipc_net_lock" to avoid a potential deadlock conflict | ||
| 152 | * with tipc_link_delete(). (There is no risk that the node will be deleted by | ||
| 153 | * another thread because tipc_link_delete() always cancels the link timer before | ||
| 154 | * tipc_node_delete() is called.) | ||
| 155 | */ | 150 | */ |
| 156 | static void link_timeout(struct tipc_link *l_ptr) | 151 | static void link_timeout(struct tipc_link *l_ptr) |
| 157 | { | 152 | { |
| @@ -213,8 +208,8 @@ static void link_set_timer(struct tipc_link *l_ptr, u32 time) | |||
| 213 | * Returns pointer to link. | 208 | * Returns pointer to link. |
| 214 | */ | 209 | */ |
| 215 | struct tipc_link *tipc_link_create(struct tipc_node *n_ptr, | 210 | struct tipc_link *tipc_link_create(struct tipc_node *n_ptr, |
| 216 | struct tipc_bearer *b_ptr, | 211 | struct tipc_bearer *b_ptr, |
| 217 | const struct tipc_media_addr *media_addr) | 212 | const struct tipc_media_addr *media_addr) |
| 218 | { | 213 | { |
| 219 | struct tipc_link *l_ptr; | 214 | struct tipc_link *l_ptr; |
| 220 | struct tipc_msg *msg; | 215 | struct tipc_msg *msg; |
| @@ -279,41 +274,44 @@ struct tipc_link *tipc_link_create(struct tipc_node *n_ptr, | |||
| 279 | 274 | ||
| 280 | k_init_timer(&l_ptr->timer, (Handler)link_timeout, | 275 | k_init_timer(&l_ptr->timer, (Handler)link_timeout, |
| 281 | (unsigned long)l_ptr); | 276 | (unsigned long)l_ptr); |
| 282 | list_add_tail(&l_ptr->link_list, &b_ptr->links); | ||
| 283 | 277 | ||
| 284 | link_state_event(l_ptr, STARTING_EVT); | 278 | link_state_event(l_ptr, STARTING_EVT); |
| 285 | 279 | ||
| 286 | return l_ptr; | 280 | return l_ptr; |
| 287 | } | 281 | } |
| 288 | 282 | ||
| 289 | /** | 283 | void tipc_link_delete_list(unsigned int bearer_id, bool shutting_down) |
| 290 | * tipc_link_delete - delete a link | ||
| 291 | * @l_ptr: pointer to link | ||
| 292 | * | ||
| 293 | * Note: 'tipc_net_lock' is write_locked, bearer is locked. | ||
| 294 | * This routine must not grab the node lock until after link timer cancellation | ||
| 295 | * to avoid a potential deadlock situation. | ||
| 296 | */ | ||
| 297 | void tipc_link_delete(struct tipc_link *l_ptr) | ||
| 298 | { | 284 | { |
| 299 | if (!l_ptr) { | 285 | struct tipc_link *l_ptr; |
| 300 | pr_err("Attempt to delete non-existent link\n"); | 286 | struct tipc_node *n_ptr; |
| 301 | return; | ||
| 302 | } | ||
| 303 | |||
| 304 | k_cancel_timer(&l_ptr->timer); | ||
| 305 | 287 | ||
| 306 | tipc_node_lock(l_ptr->owner); | 288 | rcu_read_lock(); |
| 307 | tipc_link_reset(l_ptr); | 289 | list_for_each_entry_rcu(n_ptr, &tipc_node_list, list) { |
| 308 | tipc_node_detach_link(l_ptr->owner, l_ptr); | 290 | spin_lock_bh(&n_ptr->lock); |
| 309 | tipc_link_purge_queues(l_ptr); | 291 | l_ptr = n_ptr->links[bearer_id]; |
| 310 | list_del_init(&l_ptr->link_list); | 292 | if (l_ptr) { |
| 311 | tipc_node_unlock(l_ptr->owner); | 293 | tipc_link_reset(l_ptr); |
| 312 | k_term_timer(&l_ptr->timer); | 294 | if (shutting_down || !tipc_node_is_up(n_ptr)) { |
| 313 | kfree(l_ptr); | 295 | tipc_node_detach_link(l_ptr->owner, l_ptr); |
| 296 | tipc_link_reset_fragments(l_ptr); | ||
| 297 | spin_unlock_bh(&n_ptr->lock); | ||
| 298 | |||
| 299 | /* Nobody else can access this link now: */ | ||
| 300 | del_timer_sync(&l_ptr->timer); | ||
| 301 | kfree(l_ptr); | ||
| 302 | } else { | ||
| 303 | /* Detach/delete when failover is finished: */ | ||
| 304 | l_ptr->flags |= LINK_STOPPED; | ||
| 305 | spin_unlock_bh(&n_ptr->lock); | ||
| 306 | del_timer_sync(&l_ptr->timer); | ||
| 307 | } | ||
| 308 | continue; | ||
| 309 | } | ||
| 310 | spin_unlock_bh(&n_ptr->lock); | ||
| 311 | } | ||
| 312 | rcu_read_unlock(); | ||
| 314 | } | 313 | } |
| 315 | 314 | ||
| 316 | |||
| 317 | /** | 315 | /** |
| 318 | * link_schedule_port - schedule port for deferred sending | 316 | * link_schedule_port - schedule port for deferred sending |
| 319 | * @l_ptr: pointer to link | 317 | * @l_ptr: pointer to link |
| @@ -330,8 +328,6 @@ static int link_schedule_port(struct tipc_link *l_ptr, u32 origport, u32 sz) | |||
| 330 | spin_lock_bh(&tipc_port_list_lock); | 328 | spin_lock_bh(&tipc_port_list_lock); |
| 331 | p_ptr = tipc_port_lock(origport); | 329 | p_ptr = tipc_port_lock(origport); |
| 332 | if (p_ptr) { | 330 | if (p_ptr) { |
| 333 | if (!p_ptr->wakeup) | ||
| 334 | goto exit; | ||
| 335 | if (!list_empty(&p_ptr->wait_list)) | 331 | if (!list_empty(&p_ptr->wait_list)) |
| 336 | goto exit; | 332 | goto exit; |
| 337 | p_ptr->congested = 1; | 333 | p_ptr->congested = 1; |
| @@ -366,7 +362,7 @@ void tipc_link_wakeup_ports(struct tipc_link *l_ptr, int all) | |||
| 366 | list_del_init(&p_ptr->wait_list); | 362 | list_del_init(&p_ptr->wait_list); |
| 367 | spin_lock_bh(p_ptr->lock); | 363 | spin_lock_bh(p_ptr->lock); |
| 368 | p_ptr->congested = 0; | 364 | p_ptr->congested = 0; |
| 369 | p_ptr->wakeup(p_ptr); | 365 | tipc_port_wakeup(p_ptr); |
| 370 | win -= p_ptr->waiting_pkts; | 366 | win -= p_ptr->waiting_pkts; |
| 371 | spin_unlock_bh(p_ptr->lock); | 367 | spin_unlock_bh(p_ptr->lock); |
| 372 | } | 368 | } |
| @@ -461,6 +457,21 @@ void tipc_link_reset(struct tipc_link *l_ptr) | |||
| 461 | link_reset_statistics(l_ptr); | 457 | link_reset_statistics(l_ptr); |
| 462 | } | 458 | } |
| 463 | 459 | ||
| 460 | void tipc_link_reset_list(unsigned int bearer_id) | ||
| 461 | { | ||
| 462 | struct tipc_link *l_ptr; | ||
| 463 | struct tipc_node *n_ptr; | ||
| 464 | |||
| 465 | rcu_read_lock(); | ||
| 466 | list_for_each_entry_rcu(n_ptr, &tipc_node_list, list) { | ||
| 467 | spin_lock_bh(&n_ptr->lock); | ||
| 468 | l_ptr = n_ptr->links[bearer_id]; | ||
| 469 | if (l_ptr) | ||
| 470 | tipc_link_reset(l_ptr); | ||
| 471 | spin_unlock_bh(&n_ptr->lock); | ||
| 472 | } | ||
| 473 | rcu_read_unlock(); | ||
| 474 | } | ||
| 464 | 475 | ||
| 465 | static void link_activate(struct tipc_link *l_ptr) | 476 | static void link_activate(struct tipc_link *l_ptr) |
| 466 | { | 477 | { |
| @@ -479,7 +490,10 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event) | |||
| 479 | struct tipc_link *other; | 490 | struct tipc_link *other; |
| 480 | u32 cont_intv = l_ptr->continuity_interval; | 491 | u32 cont_intv = l_ptr->continuity_interval; |
| 481 | 492 | ||
| 482 | if (!l_ptr->started && (event != STARTING_EVT)) | 493 | if (l_ptr->flags & LINK_STOPPED) |
| 494 | return; | ||
| 495 | |||
| 496 | if (!(l_ptr->flags & LINK_STARTED) && (event != STARTING_EVT)) | ||
| 483 | return; /* Not yet. */ | 497 | return; /* Not yet. */ |
| 484 | 498 | ||
| 485 | /* Check whether changeover is going on */ | 499 | /* Check whether changeover is going on */ |
| @@ -499,12 +513,12 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event) | |||
| 499 | if (l_ptr->next_in_no != l_ptr->checkpoint) { | 513 | if (l_ptr->next_in_no != l_ptr->checkpoint) { |
| 500 | l_ptr->checkpoint = l_ptr->next_in_no; | 514 | l_ptr->checkpoint = l_ptr->next_in_no; |
| 501 | if (tipc_bclink_acks_missing(l_ptr->owner)) { | 515 | if (tipc_bclink_acks_missing(l_ptr->owner)) { |
| 502 | tipc_link_send_proto_msg(l_ptr, STATE_MSG, | 516 | tipc_link_proto_xmit(l_ptr, STATE_MSG, |
| 503 | 0, 0, 0, 0, 0); | 517 | 0, 0, 0, 0, 0); |
| 504 | l_ptr->fsm_msg_cnt++; | 518 | l_ptr->fsm_msg_cnt++; |
| 505 | } else if (l_ptr->max_pkt < l_ptr->max_pkt_target) { | 519 | } else if (l_ptr->max_pkt < l_ptr->max_pkt_target) { |
| 506 | tipc_link_send_proto_msg(l_ptr, STATE_MSG, | 520 | tipc_link_proto_xmit(l_ptr, STATE_MSG, |
| 507 | 1, 0, 0, 0, 0); | 521 | 1, 0, 0, 0, 0); |
| 508 | l_ptr->fsm_msg_cnt++; | 522 | l_ptr->fsm_msg_cnt++; |
| 509 | } | 523 | } |
| 510 | link_set_timer(l_ptr, cont_intv); | 524 | link_set_timer(l_ptr, cont_intv); |
| @@ -512,7 +526,7 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event) | |||
| 512 | } | 526 | } |
| 513 | l_ptr->state = WORKING_UNKNOWN; | 527 | l_ptr->state = WORKING_UNKNOWN; |
| 514 | l_ptr->fsm_msg_cnt = 0; | 528 | l_ptr->fsm_msg_cnt = 0; |
| 515 | tipc_link_send_proto_msg(l_ptr, STATE_MSG, 1, 0, 0, 0, 0); | 529 | tipc_link_proto_xmit(l_ptr, STATE_MSG, 1, 0, 0, 0, 0); |
| 516 | l_ptr->fsm_msg_cnt++; | 530 | l_ptr->fsm_msg_cnt++; |
| 517 | link_set_timer(l_ptr, cont_intv / 4); | 531 | link_set_timer(l_ptr, cont_intv / 4); |
| 518 | break; | 532 | break; |
| @@ -522,7 +536,8 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event) | |||
| 522 | tipc_link_reset(l_ptr); | 536 | tipc_link_reset(l_ptr); |
| 523 | l_ptr->state = RESET_RESET; | 537 | l_ptr->state = RESET_RESET; |
| 524 | l_ptr->fsm_msg_cnt = 0; | 538 | l_ptr->fsm_msg_cnt = 0; |
| 525 | tipc_link_send_proto_msg(l_ptr, ACTIVATE_MSG, 0, 0, 0, 0, 0); | 539 | tipc_link_proto_xmit(l_ptr, ACTIVATE_MSG, |
| 540 | 0, 0, 0, 0, 0); | ||
| 526 | l_ptr->fsm_msg_cnt++; | 541 | l_ptr->fsm_msg_cnt++; |
| 527 | link_set_timer(l_ptr, cont_intv); | 542 | link_set_timer(l_ptr, cont_intv); |
| 528 | break; | 543 | break; |
| @@ -544,7 +559,8 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event) | |||
| 544 | tipc_link_reset(l_ptr); | 559 | tipc_link_reset(l_ptr); |
| 545 | l_ptr->state = RESET_RESET; | 560 | l_ptr->state = RESET_RESET; |
| 546 | l_ptr->fsm_msg_cnt = 0; | 561 | l_ptr->fsm_msg_cnt = 0; |
| 547 | tipc_link_send_proto_msg(l_ptr, ACTIVATE_MSG, 0, 0, 0, 0, 0); | 562 | tipc_link_proto_xmit(l_ptr, ACTIVATE_MSG, |
| 563 | 0, 0, 0, 0, 0); | ||
| 548 | l_ptr->fsm_msg_cnt++; | 564 | l_ptr->fsm_msg_cnt++; |
| 549 | link_set_timer(l_ptr, cont_intv); | 565 | link_set_timer(l_ptr, cont_intv); |
| 550 | break; | 566 | break; |
| @@ -554,14 +570,14 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event) | |||
| 554 | l_ptr->fsm_msg_cnt = 0; | 570 | l_ptr->fsm_msg_cnt = 0; |
| 555 | l_ptr->checkpoint = l_ptr->next_in_no; | 571 | l_ptr->checkpoint = l_ptr->next_in_no; |
| 556 | if (tipc_bclink_acks_missing(l_ptr->owner)) { | 572 | if (tipc_bclink_acks_missing(l_ptr->owner)) { |
| 557 | tipc_link_send_proto_msg(l_ptr, STATE_MSG, | 573 | tipc_link_proto_xmit(l_ptr, STATE_MSG, |
| 558 | 0, 0, 0, 0, 0); | 574 | 0, 0, 0, 0, 0); |
| 559 | l_ptr->fsm_msg_cnt++; | 575 | l_ptr->fsm_msg_cnt++; |
| 560 | } | 576 | } |
| 561 | link_set_timer(l_ptr, cont_intv); | 577 | link_set_timer(l_ptr, cont_intv); |
| 562 | } else if (l_ptr->fsm_msg_cnt < l_ptr->abort_limit) { | 578 | } else if (l_ptr->fsm_msg_cnt < l_ptr->abort_limit) { |
| 563 | tipc_link_send_proto_msg(l_ptr, STATE_MSG, | 579 | tipc_link_proto_xmit(l_ptr, STATE_MSG, |
| 564 | 1, 0, 0, 0, 0); | 580 | 1, 0, 0, 0, 0); |
| 565 | l_ptr->fsm_msg_cnt++; | 581 | l_ptr->fsm_msg_cnt++; |
| 566 | link_set_timer(l_ptr, cont_intv / 4); | 582 | link_set_timer(l_ptr, cont_intv / 4); |
| 567 | } else { /* Link has failed */ | 583 | } else { /* Link has failed */ |
| @@ -570,8 +586,8 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event) | |||
| 570 | tipc_link_reset(l_ptr); | 586 | tipc_link_reset(l_ptr); |
| 571 | l_ptr->state = RESET_UNKNOWN; | 587 | l_ptr->state = RESET_UNKNOWN; |
| 572 | l_ptr->fsm_msg_cnt = 0; | 588 | l_ptr->fsm_msg_cnt = 0; |
| 573 | tipc_link_send_proto_msg(l_ptr, RESET_MSG, | 589 | tipc_link_proto_xmit(l_ptr, RESET_MSG, |
| 574 | 0, 0, 0, 0, 0); | 590 | 0, 0, 0, 0, 0); |
| 575 | l_ptr->fsm_msg_cnt++; | 591 | l_ptr->fsm_msg_cnt++; |
| 576 | link_set_timer(l_ptr, cont_intv); | 592 | link_set_timer(l_ptr, cont_intv); |
| 577 | } | 593 | } |
| @@ -591,24 +607,25 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event) | |||
| 591 | l_ptr->state = WORKING_WORKING; | 607 | l_ptr->state = WORKING_WORKING; |
| 592 | l_ptr->fsm_msg_cnt = 0; | 608 | l_ptr->fsm_msg_cnt = 0; |
| 593 | link_activate(l_ptr); | 609 | link_activate(l_ptr); |
| 594 | tipc_link_send_proto_msg(l_ptr, STATE_MSG, 1, 0, 0, 0, 0); | 610 | tipc_link_proto_xmit(l_ptr, STATE_MSG, 1, 0, 0, 0, 0); |
| 595 | l_ptr->fsm_msg_cnt++; | 611 | l_ptr->fsm_msg_cnt++; |
| 596 | if (l_ptr->owner->working_links == 1) | 612 | if (l_ptr->owner->working_links == 1) |
| 597 | tipc_link_send_sync(l_ptr); | 613 | tipc_link_sync_xmit(l_ptr); |
| 598 | link_set_timer(l_ptr, cont_intv); | 614 | link_set_timer(l_ptr, cont_intv); |
| 599 | break; | 615 | break; |
| 600 | case RESET_MSG: | 616 | case RESET_MSG: |
| 601 | l_ptr->state = RESET_RESET; | 617 | l_ptr->state = RESET_RESET; |
| 602 | l_ptr->fsm_msg_cnt = 0; | 618 | l_ptr->fsm_msg_cnt = 0; |
| 603 | tipc_link_send_proto_msg(l_ptr, ACTIVATE_MSG, 1, 0, 0, 0, 0); | 619 | tipc_link_proto_xmit(l_ptr, ACTIVATE_MSG, |
| 620 | 1, 0, 0, 0, 0); | ||
| 604 | l_ptr->fsm_msg_cnt++; | 621 | l_ptr->fsm_msg_cnt++; |
| 605 | link_set_timer(l_ptr, cont_intv); | 622 | link_set_timer(l_ptr, cont_intv); |
| 606 | break; | 623 | break; |
| 607 | case STARTING_EVT: | 624 | case STARTING_EVT: |
| 608 | l_ptr->started = 1; | 625 | l_ptr->flags |= LINK_STARTED; |
| 609 | /* fall through */ | 626 | /* fall through */ |
| 610 | case TIMEOUT_EVT: | 627 | case TIMEOUT_EVT: |
| 611 | tipc_link_send_proto_msg(l_ptr, RESET_MSG, 0, 0, 0, 0, 0); | 628 | tipc_link_proto_xmit(l_ptr, RESET_MSG, 0, 0, 0, 0, 0); |
| 612 | l_ptr->fsm_msg_cnt++; | 629 | l_ptr->fsm_msg_cnt++; |
| 613 | link_set_timer(l_ptr, cont_intv); | 630 | link_set_timer(l_ptr, cont_intv); |
| 614 | break; | 631 | break; |
| @@ -626,16 +643,17 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event) | |||
| 626 | l_ptr->state = WORKING_WORKING; | 643 | l_ptr->state = WORKING_WORKING; |
| 627 | l_ptr->fsm_msg_cnt = 0; | 644 | l_ptr->fsm_msg_cnt = 0; |
| 628 | link_activate(l_ptr); | 645 | link_activate(l_ptr); |
| 629 | tipc_link_send_proto_msg(l_ptr, STATE_MSG, 1, 0, 0, 0, 0); | 646 | tipc_link_proto_xmit(l_ptr, STATE_MSG, 1, 0, 0, 0, 0); |
| 630 | l_ptr->fsm_msg_cnt++; | 647 | l_ptr->fsm_msg_cnt++; |
| 631 | if (l_ptr->owner->working_links == 1) | 648 | if (l_ptr->owner->working_links == 1) |
| 632 | tipc_link_send_sync(l_ptr); | 649 | tipc_link_sync_xmit(l_ptr); |
| 633 | link_set_timer(l_ptr, cont_intv); | 650 | link_set_timer(l_ptr, cont_intv); |
| 634 | break; | 651 | break; |
| 635 | case RESET_MSG: | 652 | case RESET_MSG: |
| 636 | break; | 653 | break; |
| 637 | case TIMEOUT_EVT: | 654 | case TIMEOUT_EVT: |
| 638 | tipc_link_send_proto_msg(l_ptr, ACTIVATE_MSG, 0, 0, 0, 0, 0); | 655 | tipc_link_proto_xmit(l_ptr, ACTIVATE_MSG, |
| 656 | 0, 0, 0, 0, 0); | ||
| 639 | l_ptr->fsm_msg_cnt++; | 657 | l_ptr->fsm_msg_cnt++; |
| 640 | link_set_timer(l_ptr, cont_intv); | 658 | link_set_timer(l_ptr, cont_intv); |
| 641 | break; | 659 | break; |
| @@ -721,11 +739,11 @@ static void link_add_chain_to_outqueue(struct tipc_link *l_ptr, | |||
| 721 | } | 739 | } |
| 722 | 740 | ||
| 723 | /* | 741 | /* |
| 724 | * tipc_link_send_buf() is the 'full path' for messages, called from | 742 | * tipc_link_xmit() is the 'full path' for messages, called from |
| 725 | * inside TIPC when the 'fast path' in tipc_send_buf | 743 | * inside TIPC when the 'fast path' in tipc_send_xmit |
| 726 | * has failed, and from link_send() | 744 | * has failed, and from link_send() |
| 727 | */ | 745 | */ |
| 728 | int tipc_link_send_buf(struct tipc_link *l_ptr, struct sk_buff *buf) | 746 | int __tipc_link_xmit(struct tipc_link *l_ptr, struct sk_buff *buf) |
| 729 | { | 747 | { |
| 730 | struct tipc_msg *msg = buf_msg(buf); | 748 | struct tipc_msg *msg = buf_msg(buf); |
| 731 | u32 size = msg_size(msg); | 749 | u32 size = msg_size(msg); |
| @@ -753,7 +771,7 @@ int tipc_link_send_buf(struct tipc_link *l_ptr, struct sk_buff *buf) | |||
| 753 | 771 | ||
| 754 | /* Fragmentation needed ? */ | 772 | /* Fragmentation needed ? */ |
| 755 | if (size > max_packet) | 773 | if (size > max_packet) |
| 756 | return link_send_long_buf(l_ptr, buf); | 774 | return tipc_link_frag_xmit(l_ptr, buf); |
| 757 | 775 | ||
| 758 | /* Packet can be queued or sent. */ | 776 | /* Packet can be queued or sent. */ |
| 759 | if (likely(!link_congested(l_ptr))) { | 777 | if (likely(!link_congested(l_ptr))) { |
| @@ -797,11 +815,11 @@ int tipc_link_send_buf(struct tipc_link *l_ptr, struct sk_buff *buf) | |||
| 797 | } | 815 | } |
| 798 | 816 | ||
| 799 | /* | 817 | /* |
| 800 | * tipc_link_send(): same as tipc_link_send_buf(), but the link to use has | 818 | * tipc_link_xmit(): same as __tipc_link_xmit(), but the link to use |
| 801 | * not been selected yet, and the the owner node is not locked | 819 | * has not been selected yet, and the the owner node is not locked |
| 802 | * Called by TIPC internal users, e.g. the name distributor | 820 | * Called by TIPC internal users, e.g. the name distributor |
| 803 | */ | 821 | */ |
| 804 | int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector) | 822 | int tipc_link_xmit(struct sk_buff *buf, u32 dest, u32 selector) |
| 805 | { | 823 | { |
| 806 | struct tipc_link *l_ptr; | 824 | struct tipc_link *l_ptr; |
| 807 | struct tipc_node *n_ptr; | 825 | struct tipc_node *n_ptr; |
| @@ -813,7 +831,7 @@ int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector) | |||
| 813 | tipc_node_lock(n_ptr); | 831 | tipc_node_lock(n_ptr); |
| 814 | l_ptr = n_ptr->active_links[selector & 1]; | 832 | l_ptr = n_ptr->active_links[selector & 1]; |
| 815 | if (l_ptr) | 833 | if (l_ptr) |
| 816 | res = tipc_link_send_buf(l_ptr, buf); | 834 | res = __tipc_link_xmit(l_ptr, buf); |
| 817 | else | 835 | else |
| 818 | kfree_skb(buf); | 836 | kfree_skb(buf); |
| 819 | tipc_node_unlock(n_ptr); | 837 | tipc_node_unlock(n_ptr); |
| @@ -825,14 +843,14 @@ int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector) | |||
| 825 | } | 843 | } |
| 826 | 844 | ||
| 827 | /* | 845 | /* |
| 828 | * tipc_link_send_sync - synchronize broadcast link endpoints. | 846 | * tipc_link_sync_xmit - synchronize broadcast link endpoints. |
| 829 | * | 847 | * |
| 830 | * Give a newly added peer node the sequence number where it should | 848 | * Give a newly added peer node the sequence number where it should |
| 831 | * start receiving and acking broadcast packets. | 849 | * start receiving and acking broadcast packets. |
| 832 | * | 850 | * |
| 833 | * Called with node locked | 851 | * Called with node locked |
| 834 | */ | 852 | */ |
| 835 | static void tipc_link_send_sync(struct tipc_link *l) | 853 | static void tipc_link_sync_xmit(struct tipc_link *l) |
| 836 | { | 854 | { |
| 837 | struct sk_buff *buf; | 855 | struct sk_buff *buf; |
| 838 | struct tipc_msg *msg; | 856 | struct tipc_msg *msg; |
| @@ -849,14 +867,14 @@ static void tipc_link_send_sync(struct tipc_link *l) | |||
| 849 | } | 867 | } |
| 850 | 868 | ||
| 851 | /* | 869 | /* |
| 852 | * tipc_link_recv_sync - synchronize broadcast link endpoints. | 870 | * tipc_link_sync_rcv - synchronize broadcast link endpoints. |
| 853 | * Receive the sequence number where we should start receiving and | 871 | * Receive the sequence number where we should start receiving and |
| 854 | * acking broadcast packets from a newly added peer node, and open | 872 | * acking broadcast packets from a newly added peer node, and open |
| 855 | * up for reception of such packets. | 873 | * up for reception of such packets. |
| 856 | * | 874 | * |
| 857 | * Called with node locked | 875 | * Called with node locked |
| 858 | */ | 876 | */ |
| 859 | static void tipc_link_recv_sync(struct tipc_node *n, struct sk_buff *buf) | 877 | static void tipc_link_sync_rcv(struct tipc_node *n, struct sk_buff *buf) |
| 860 | { | 878 | { |
| 861 | struct tipc_msg *msg = buf_msg(buf); | 879 | struct tipc_msg *msg = buf_msg(buf); |
| 862 | 880 | ||
| @@ -866,7 +884,7 @@ static void tipc_link_recv_sync(struct tipc_node *n, struct sk_buff *buf) | |||
| 866 | } | 884 | } |
| 867 | 885 | ||
| 868 | /* | 886 | /* |
| 869 | * tipc_link_send_names - send name table entries to new neighbor | 887 | * tipc_link_names_xmit - send name table entries to new neighbor |
| 870 | * | 888 | * |
| 871 | * Send routine for bulk delivery of name table messages when contact | 889 | * Send routine for bulk delivery of name table messages when contact |
| 872 | * with a new neighbor occurs. No link congestion checking is performed | 890 | * with a new neighbor occurs. No link congestion checking is performed |
| @@ -874,7 +892,7 @@ static void tipc_link_recv_sync(struct tipc_node *n, struct sk_buff *buf) | |||
| 874 | * small enough not to require fragmentation. | 892 | * small enough not to require fragmentation. |
| 875 | * Called without any locks held. | 893 | * Called without any locks held. |
| 876 | */ | 894 | */ |
| 877 | void tipc_link_send_names(struct list_head *message_list, u32 dest) | 895 | void tipc_link_names_xmit(struct list_head *message_list, u32 dest) |
| 878 | { | 896 | { |
| 879 | struct tipc_node *n_ptr; | 897 | struct tipc_node *n_ptr; |
| 880 | struct tipc_link *l_ptr; | 898 | struct tipc_link *l_ptr; |
| @@ -909,13 +927,13 @@ void tipc_link_send_names(struct list_head *message_list, u32 dest) | |||
| 909 | } | 927 | } |
| 910 | 928 | ||
| 911 | /* | 929 | /* |
| 912 | * link_send_buf_fast: Entry for data messages where the | 930 | * tipc_link_xmit_fast: Entry for data messages where the |
| 913 | * destination link is known and the header is complete, | 931 | * destination link is known and the header is complete, |
| 914 | * inclusive total message length. Very time critical. | 932 | * inclusive total message length. Very time critical. |
| 915 | * Link is locked. Returns user data length. | 933 | * Link is locked. Returns user data length. |
| 916 | */ | 934 | */ |
| 917 | static int link_send_buf_fast(struct tipc_link *l_ptr, struct sk_buff *buf, | 935 | static int tipc_link_xmit_fast(struct tipc_link *l_ptr, struct sk_buff *buf, |
| 918 | u32 *used_max_pkt) | 936 | u32 *used_max_pkt) |
| 919 | { | 937 | { |
| 920 | struct tipc_msg *msg = buf_msg(buf); | 938 | struct tipc_msg *msg = buf_msg(buf); |
| 921 | int res = msg_data_sz(msg); | 939 | int res = msg_data_sz(msg); |
| @@ -931,18 +949,18 @@ static int link_send_buf_fast(struct tipc_link *l_ptr, struct sk_buff *buf, | |||
| 931 | else | 949 | else |
| 932 | *used_max_pkt = l_ptr->max_pkt; | 950 | *used_max_pkt = l_ptr->max_pkt; |
| 933 | } | 951 | } |
| 934 | return tipc_link_send_buf(l_ptr, buf); /* All other cases */ | 952 | return __tipc_link_xmit(l_ptr, buf); /* All other cases */ |
| 935 | } | 953 | } |
| 936 | 954 | ||
| 937 | /* | 955 | /* |
| 938 | * tipc_link_send_sections_fast: Entry for messages where the | 956 | * tipc_link_iovec_xmit_fast: Entry for messages where the |
| 939 | * destination processor is known and the header is complete, | 957 | * destination processor is known and the header is complete, |
| 940 | * except for total message length. | 958 | * except for total message length. |
| 941 | * Returns user data length or errno. | 959 | * Returns user data length or errno. |
| 942 | */ | 960 | */ |
| 943 | int tipc_link_send_sections_fast(struct tipc_port *sender, | 961 | int tipc_link_iovec_xmit_fast(struct tipc_port *sender, |
| 944 | struct iovec const *msg_sect, | 962 | struct iovec const *msg_sect, |
| 945 | unsigned int len, u32 destaddr) | 963 | unsigned int len, u32 destaddr) |
| 946 | { | 964 | { |
| 947 | struct tipc_msg *hdr = &sender->phdr; | 965 | struct tipc_msg *hdr = &sender->phdr; |
| 948 | struct tipc_link *l_ptr; | 966 | struct tipc_link *l_ptr; |
| @@ -968,8 +986,8 @@ again: | |||
| 968 | l_ptr = node->active_links[selector]; | 986 | l_ptr = node->active_links[selector]; |
| 969 | if (likely(l_ptr)) { | 987 | if (likely(l_ptr)) { |
| 970 | if (likely(buf)) { | 988 | if (likely(buf)) { |
| 971 | res = link_send_buf_fast(l_ptr, buf, | 989 | res = tipc_link_xmit_fast(l_ptr, buf, |
| 972 | &sender->max_pkt); | 990 | &sender->max_pkt); |
| 973 | exit: | 991 | exit: |
| 974 | tipc_node_unlock(node); | 992 | tipc_node_unlock(node); |
| 975 | read_unlock_bh(&tipc_net_lock); | 993 | read_unlock_bh(&tipc_net_lock); |
| @@ -995,24 +1013,21 @@ exit: | |||
| 995 | if ((msg_hdr_sz(hdr) + res) <= sender->max_pkt) | 1013 | if ((msg_hdr_sz(hdr) + res) <= sender->max_pkt) |
| 996 | goto again; | 1014 | goto again; |
| 997 | 1015 | ||
| 998 | return link_send_sections_long(sender, msg_sect, len, | 1016 | return tipc_link_iovec_long_xmit(sender, msg_sect, |
| 999 | destaddr); | 1017 | len, destaddr); |
| 1000 | } | 1018 | } |
| 1001 | tipc_node_unlock(node); | 1019 | tipc_node_unlock(node); |
| 1002 | } | 1020 | } |
| 1003 | read_unlock_bh(&tipc_net_lock); | 1021 | read_unlock_bh(&tipc_net_lock); |
| 1004 | 1022 | ||
| 1005 | /* Couldn't find a link to the destination node */ | 1023 | /* Couldn't find a link to the destination node */ |
| 1006 | if (buf) | 1024 | kfree_skb(buf); |
| 1007 | return tipc_reject_msg(buf, TIPC_ERR_NO_NODE); | 1025 | tipc_port_iovec_reject(sender, hdr, msg_sect, len, TIPC_ERR_NO_NODE); |
| 1008 | if (res >= 0) | 1026 | return -ENETUNREACH; |
| 1009 | return tipc_port_reject_sections(sender, hdr, msg_sect, | ||
| 1010 | len, TIPC_ERR_NO_NODE); | ||
| 1011 | return res; | ||
| 1012 | } | 1027 | } |
| 1013 | 1028 | ||
| 1014 | /* | 1029 | /* |
| 1015 | * link_send_sections_long(): Entry for long messages where the | 1030 | * tipc_link_iovec_long_xmit(): Entry for long messages where the |
| 1016 | * destination node is known and the header is complete, | 1031 | * destination node is known and the header is complete, |
| 1017 | * inclusive total message length. | 1032 | * inclusive total message length. |
| 1018 | * Link and bearer congestion status have been checked to be ok, | 1033 | * Link and bearer congestion status have been checked to be ok, |
| @@ -1025,9 +1040,9 @@ exit: | |||
| 1025 | * | 1040 | * |
| 1026 | * Returns user data length or errno. | 1041 | * Returns user data length or errno. |
| 1027 | */ | 1042 | */ |
| 1028 | static int link_send_sections_long(struct tipc_port *sender, | 1043 | static int tipc_link_iovec_long_xmit(struct tipc_port *sender, |
| 1029 | struct iovec const *msg_sect, | 1044 | struct iovec const *msg_sect, |
| 1030 | unsigned int len, u32 destaddr) | 1045 | unsigned int len, u32 destaddr) |
| 1031 | { | 1046 | { |
| 1032 | struct tipc_link *l_ptr; | 1047 | struct tipc_link *l_ptr; |
| 1033 | struct tipc_node *node; | 1048 | struct tipc_node *node; |
| @@ -1146,8 +1161,9 @@ error: | |||
| 1146 | } else { | 1161 | } else { |
| 1147 | reject: | 1162 | reject: |
| 1148 | kfree_skb_list(buf_chain); | 1163 | kfree_skb_list(buf_chain); |
| 1149 | return tipc_port_reject_sections(sender, hdr, msg_sect, | 1164 | tipc_port_iovec_reject(sender, hdr, msg_sect, len, |
| 1150 | len, TIPC_ERR_NO_NODE); | 1165 | TIPC_ERR_NO_NODE); |
| 1166 | return -ENETUNREACH; | ||
| 1151 | } | 1167 | } |
| 1152 | 1168 | ||
| 1153 | /* Append chain of fragments to send queue & send them */ | 1169 | /* Append chain of fragments to send queue & send them */ |
| @@ -1391,6 +1407,12 @@ static int link_recv_buf_validate(struct sk_buff *buf) | |||
| 1391 | u32 hdr_size; | 1407 | u32 hdr_size; |
| 1392 | u32 min_hdr_size; | 1408 | u32 min_hdr_size; |
| 1393 | 1409 | ||
| 1410 | /* If this packet comes from the defer queue, the skb has already | ||
| 1411 | * been validated | ||
| 1412 | */ | ||
| 1413 | if (unlikely(TIPC_SKB_CB(buf)->deferred)) | ||
| 1414 | return 1; | ||
| 1415 | |||
| 1394 | if (unlikely(buf->len < MIN_H_SIZE)) | 1416 | if (unlikely(buf->len < MIN_H_SIZE)) |
| 1395 | return 0; | 1417 | return 0; |
| 1396 | 1418 | ||
| @@ -1435,15 +1457,10 @@ void tipc_rcv(struct sk_buff *head, struct tipc_bearer *b_ptr) | |||
| 1435 | u32 seq_no; | 1457 | u32 seq_no; |
| 1436 | u32 ackd; | 1458 | u32 ackd; |
| 1437 | u32 released = 0; | 1459 | u32 released = 0; |
| 1438 | int type; | ||
| 1439 | 1460 | ||
| 1440 | head = head->next; | 1461 | head = head->next; |
| 1441 | buf->next = NULL; | 1462 | buf->next = NULL; |
| 1442 | 1463 | ||
| 1443 | /* Ensure bearer is still enabled */ | ||
| 1444 | if (unlikely(!b_ptr->active)) | ||
| 1445 | goto discard; | ||
| 1446 | |||
| 1447 | /* Ensure message is well-formed */ | 1464 | /* Ensure message is well-formed */ |
| 1448 | if (unlikely(!link_recv_buf_validate(buf))) | 1465 | if (unlikely(!link_recv_buf_validate(buf))) |
| 1449 | goto discard; | 1466 | goto discard; |
| @@ -1457,9 +1474,9 @@ void tipc_rcv(struct sk_buff *head, struct tipc_bearer *b_ptr) | |||
| 1457 | 1474 | ||
| 1458 | if (unlikely(msg_non_seq(msg))) { | 1475 | if (unlikely(msg_non_seq(msg))) { |
| 1459 | if (msg_user(msg) == LINK_CONFIG) | 1476 | if (msg_user(msg) == LINK_CONFIG) |
| 1460 | tipc_disc_recv_msg(buf, b_ptr); | 1477 | tipc_disc_rcv(buf, b_ptr); |
| 1461 | else | 1478 | else |
| 1462 | tipc_bclink_recv_pkt(buf); | 1479 | tipc_bclink_rcv(buf); |
| 1463 | continue; | 1480 | continue; |
| 1464 | } | 1481 | } |
| 1465 | 1482 | ||
| @@ -1483,7 +1500,7 @@ void tipc_rcv(struct sk_buff *head, struct tipc_bearer *b_ptr) | |||
| 1483 | if ((n_ptr->block_setup & WAIT_PEER_DOWN) && | 1500 | if ((n_ptr->block_setup & WAIT_PEER_DOWN) && |
| 1484 | msg_user(msg) == LINK_PROTOCOL && | 1501 | msg_user(msg) == LINK_PROTOCOL && |
| 1485 | (msg_type(msg) == RESET_MSG || | 1502 | (msg_type(msg) == RESET_MSG || |
| 1486 | msg_type(msg) == ACTIVATE_MSG) && | 1503 | msg_type(msg) == ACTIVATE_MSG) && |
| 1487 | !msg_redundant_link(msg)) | 1504 | !msg_redundant_link(msg)) |
| 1488 | n_ptr->block_setup &= ~WAIT_PEER_DOWN; | 1505 | n_ptr->block_setup &= ~WAIT_PEER_DOWN; |
| 1489 | 1506 | ||
| @@ -1502,7 +1519,6 @@ void tipc_rcv(struct sk_buff *head, struct tipc_bearer *b_ptr) | |||
| 1502 | while ((crs != l_ptr->next_out) && | 1519 | while ((crs != l_ptr->next_out) && |
| 1503 | less_eq(buf_seqno(crs), ackd)) { | 1520 | less_eq(buf_seqno(crs), ackd)) { |
| 1504 | struct sk_buff *next = crs->next; | 1521 | struct sk_buff *next = crs->next; |
| 1505 | |||
| 1506 | kfree_skb(crs); | 1522 | kfree_skb(crs); |
| 1507 | crs = next; | 1523 | crs = next; |
| 1508 | released++; | 1524 | released++; |
| @@ -1515,18 +1531,19 @@ void tipc_rcv(struct sk_buff *head, struct tipc_bearer *b_ptr) | |||
| 1515 | /* Try sending any messages link endpoint has pending */ | 1531 | /* Try sending any messages link endpoint has pending */ |
| 1516 | if (unlikely(l_ptr->next_out)) | 1532 | if (unlikely(l_ptr->next_out)) |
| 1517 | tipc_link_push_queue(l_ptr); | 1533 | tipc_link_push_queue(l_ptr); |
| 1534 | |||
| 1518 | if (unlikely(!list_empty(&l_ptr->waiting_ports))) | 1535 | if (unlikely(!list_empty(&l_ptr->waiting_ports))) |
| 1519 | tipc_link_wakeup_ports(l_ptr, 0); | 1536 | tipc_link_wakeup_ports(l_ptr, 0); |
| 1537 | |||
| 1520 | if (unlikely(++l_ptr->unacked_window >= TIPC_MIN_LINK_WIN)) { | 1538 | if (unlikely(++l_ptr->unacked_window >= TIPC_MIN_LINK_WIN)) { |
| 1521 | l_ptr->stats.sent_acks++; | 1539 | l_ptr->stats.sent_acks++; |
| 1522 | tipc_link_send_proto_msg(l_ptr, STATE_MSG, 0, 0, 0, 0, 0); | 1540 | tipc_link_proto_xmit(l_ptr, STATE_MSG, 0, 0, 0, 0, 0); |
| 1523 | } | 1541 | } |
| 1524 | 1542 | ||
| 1525 | /* Now (finally!) process the incoming message */ | 1543 | /* Process the incoming packet */ |
| 1526 | protocol_check: | ||
| 1527 | if (unlikely(!link_working_working(l_ptr))) { | 1544 | if (unlikely(!link_working_working(l_ptr))) { |
| 1528 | if (msg_user(msg) == LINK_PROTOCOL) { | 1545 | if (msg_user(msg) == LINK_PROTOCOL) { |
| 1529 | link_recv_proto_msg(l_ptr, buf); | 1546 | tipc_link_proto_rcv(l_ptr, buf); |
| 1530 | head = link_insert_deferred_queue(l_ptr, head); | 1547 | head = link_insert_deferred_queue(l_ptr, head); |
| 1531 | tipc_node_unlock(n_ptr); | 1548 | tipc_node_unlock(n_ptr); |
| 1532 | continue; | 1549 | continue; |
| @@ -1555,67 +1572,65 @@ protocol_check: | |||
| 1555 | l_ptr->next_in_no++; | 1572 | l_ptr->next_in_no++; |
| 1556 | if (unlikely(l_ptr->oldest_deferred_in)) | 1573 | if (unlikely(l_ptr->oldest_deferred_in)) |
| 1557 | head = link_insert_deferred_queue(l_ptr, head); | 1574 | head = link_insert_deferred_queue(l_ptr, head); |
| 1558 | deliver: | 1575 | |
| 1559 | if (likely(msg_isdata(msg))) { | 1576 | /* Deliver packet/message to correct user: */ |
| 1560 | tipc_node_unlock(n_ptr); | 1577 | if (unlikely(msg_user(msg) == CHANGEOVER_PROTOCOL)) { |
| 1561 | tipc_port_recv_msg(buf); | 1578 | if (!tipc_link_tunnel_rcv(n_ptr, &buf)) { |
| 1562 | continue; | 1579 | tipc_node_unlock(n_ptr); |
| 1580 | continue; | ||
| 1581 | } | ||
| 1582 | msg = buf_msg(buf); | ||
| 1583 | } else if (msg_user(msg) == MSG_FRAGMENTER) { | ||
| 1584 | int rc; | ||
| 1585 | |||
| 1586 | l_ptr->stats.recv_fragments++; | ||
| 1587 | rc = tipc_link_frag_rcv(&l_ptr->reasm_head, | ||
| 1588 | &l_ptr->reasm_tail, | ||
| 1589 | &buf); | ||
| 1590 | if (rc == LINK_REASM_COMPLETE) { | ||
| 1591 | l_ptr->stats.recv_fragmented++; | ||
| 1592 | msg = buf_msg(buf); | ||
| 1593 | } else { | ||
| 1594 | if (rc == LINK_REASM_ERROR) | ||
| 1595 | tipc_link_reset(l_ptr); | ||
| 1596 | tipc_node_unlock(n_ptr); | ||
| 1597 | continue; | ||
| 1598 | } | ||
| 1563 | } | 1599 | } |
| 1600 | |||
| 1564 | switch (msg_user(msg)) { | 1601 | switch (msg_user(msg)) { |
| 1565 | int ret; | 1602 | case TIPC_LOW_IMPORTANCE: |
| 1603 | case TIPC_MEDIUM_IMPORTANCE: | ||
| 1604 | case TIPC_HIGH_IMPORTANCE: | ||
| 1605 | case TIPC_CRITICAL_IMPORTANCE: | ||
| 1606 | tipc_node_unlock(n_ptr); | ||
| 1607 | tipc_port_rcv(buf); | ||
| 1608 | continue; | ||
| 1566 | case MSG_BUNDLER: | 1609 | case MSG_BUNDLER: |
| 1567 | l_ptr->stats.recv_bundles++; | 1610 | l_ptr->stats.recv_bundles++; |
| 1568 | l_ptr->stats.recv_bundled += msg_msgcnt(msg); | 1611 | l_ptr->stats.recv_bundled += msg_msgcnt(msg); |
| 1569 | tipc_node_unlock(n_ptr); | 1612 | tipc_node_unlock(n_ptr); |
| 1570 | tipc_link_recv_bundle(buf); | 1613 | tipc_link_bundle_rcv(buf); |
| 1571 | continue; | 1614 | continue; |
| 1572 | case NAME_DISTRIBUTOR: | 1615 | case NAME_DISTRIBUTOR: |
| 1573 | n_ptr->bclink.recv_permitted = true; | 1616 | n_ptr->bclink.recv_permitted = true; |
| 1574 | tipc_node_unlock(n_ptr); | 1617 | tipc_node_unlock(n_ptr); |
| 1575 | tipc_named_recv(buf); | 1618 | tipc_named_rcv(buf); |
| 1576 | continue; | ||
| 1577 | case BCAST_PROTOCOL: | ||
| 1578 | tipc_link_recv_sync(n_ptr, buf); | ||
| 1579 | tipc_node_unlock(n_ptr); | ||
| 1580 | continue; | 1619 | continue; |
| 1581 | case CONN_MANAGER: | 1620 | case CONN_MANAGER: |
| 1582 | tipc_node_unlock(n_ptr); | 1621 | tipc_node_unlock(n_ptr); |
| 1583 | tipc_port_recv_proto_msg(buf); | 1622 | tipc_port_proto_rcv(buf); |
| 1584 | continue; | ||
| 1585 | case MSG_FRAGMENTER: | ||
| 1586 | l_ptr->stats.recv_fragments++; | ||
| 1587 | ret = tipc_link_recv_fragment(&l_ptr->reasm_head, | ||
| 1588 | &l_ptr->reasm_tail, | ||
| 1589 | &buf); | ||
| 1590 | if (ret == LINK_REASM_COMPLETE) { | ||
| 1591 | l_ptr->stats.recv_fragmented++; | ||
| 1592 | msg = buf_msg(buf); | ||
| 1593 | goto deliver; | ||
| 1594 | } | ||
| 1595 | if (ret == LINK_REASM_ERROR) | ||
| 1596 | tipc_link_reset(l_ptr); | ||
| 1597 | tipc_node_unlock(n_ptr); | ||
| 1598 | continue; | 1623 | continue; |
| 1599 | case CHANGEOVER_PROTOCOL: | 1624 | case BCAST_PROTOCOL: |
| 1600 | type = msg_type(msg); | 1625 | tipc_link_sync_rcv(n_ptr, buf); |
| 1601 | if (tipc_link_tunnel_rcv(&l_ptr, &buf)) { | ||
| 1602 | msg = buf_msg(buf); | ||
| 1603 | seq_no = msg_seqno(msg); | ||
| 1604 | if (type == ORIGINAL_MSG) | ||
| 1605 | goto deliver; | ||
| 1606 | goto protocol_check; | ||
| 1607 | } | ||
| 1608 | break; | 1626 | break; |
| 1609 | default: | 1627 | default: |
| 1610 | kfree_skb(buf); | 1628 | kfree_skb(buf); |
| 1611 | buf = NULL; | ||
| 1612 | break; | 1629 | break; |
| 1613 | } | 1630 | } |
| 1614 | tipc_node_unlock(n_ptr); | 1631 | tipc_node_unlock(n_ptr); |
| 1615 | tipc_net_route_msg(buf); | ||
| 1616 | continue; | 1632 | continue; |
| 1617 | unlock_discard: | 1633 | unlock_discard: |
| 1618 | |||
| 1619 | tipc_node_unlock(n_ptr); | 1634 | tipc_node_unlock(n_ptr); |
| 1620 | discard: | 1635 | discard: |
| 1621 | kfree_skb(buf); | 1636 | kfree_skb(buf); |
| @@ -1682,7 +1697,7 @@ static void link_handle_out_of_seq_msg(struct tipc_link *l_ptr, | |||
| 1682 | u32 seq_no = buf_seqno(buf); | 1697 | u32 seq_no = buf_seqno(buf); |
| 1683 | 1698 | ||
| 1684 | if (likely(msg_user(buf_msg(buf)) == LINK_PROTOCOL)) { | 1699 | if (likely(msg_user(buf_msg(buf)) == LINK_PROTOCOL)) { |
| 1685 | link_recv_proto_msg(l_ptr, buf); | 1700 | tipc_link_proto_rcv(l_ptr, buf); |
| 1686 | return; | 1701 | return; |
| 1687 | } | 1702 | } |
| 1688 | 1703 | ||
| @@ -1703,8 +1718,9 @@ static void link_handle_out_of_seq_msg(struct tipc_link *l_ptr, | |||
| 1703 | &l_ptr->newest_deferred_in, buf)) { | 1718 | &l_ptr->newest_deferred_in, buf)) { |
| 1704 | l_ptr->deferred_inqueue_sz++; | 1719 | l_ptr->deferred_inqueue_sz++; |
| 1705 | l_ptr->stats.deferred_recv++; | 1720 | l_ptr->stats.deferred_recv++; |
| 1721 | TIPC_SKB_CB(buf)->deferred = true; | ||
| 1706 | if ((l_ptr->deferred_inqueue_sz % 16) == 1) | 1722 | if ((l_ptr->deferred_inqueue_sz % 16) == 1) |
| 1707 | tipc_link_send_proto_msg(l_ptr, STATE_MSG, 0, 0, 0, 0, 0); | 1723 | tipc_link_proto_xmit(l_ptr, STATE_MSG, 0, 0, 0, 0, 0); |
| 1708 | } else | 1724 | } else |
| 1709 | l_ptr->stats.duplicates++; | 1725 | l_ptr->stats.duplicates++; |
| 1710 | } | 1726 | } |
| @@ -1712,9 +1728,8 @@ static void link_handle_out_of_seq_msg(struct tipc_link *l_ptr, | |||
| 1712 | /* | 1728 | /* |
| 1713 | * Send protocol message to the other endpoint. | 1729 | * Send protocol message to the other endpoint. |
| 1714 | */ | 1730 | */ |
| 1715 | void tipc_link_send_proto_msg(struct tipc_link *l_ptr, u32 msg_typ, | 1731 | void tipc_link_proto_xmit(struct tipc_link *l_ptr, u32 msg_typ, int probe_msg, |
| 1716 | int probe_msg, u32 gap, u32 tolerance, | 1732 | u32 gap, u32 tolerance, u32 priority, u32 ack_mtu) |
| 1717 | u32 priority, u32 ack_mtu) | ||
| 1718 | { | 1733 | { |
| 1719 | struct sk_buff *buf = NULL; | 1734 | struct sk_buff *buf = NULL; |
| 1720 | struct tipc_msg *msg = l_ptr->pmsg; | 1735 | struct tipc_msg *msg = l_ptr->pmsg; |
| @@ -1813,7 +1828,7 @@ void tipc_link_send_proto_msg(struct tipc_link *l_ptr, u32 msg_typ, | |||
| 1813 | * Note that network plane id propagates through the network, and may | 1828 | * Note that network plane id propagates through the network, and may |
| 1814 | * change at any time. The node with lowest address rules | 1829 | * change at any time. The node with lowest address rules |
| 1815 | */ | 1830 | */ |
| 1816 | static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf) | 1831 | static void tipc_link_proto_rcv(struct tipc_link *l_ptr, struct sk_buff *buf) |
| 1817 | { | 1832 | { |
| 1818 | u32 rec_gap = 0; | 1833 | u32 rec_gap = 0; |
| 1819 | u32 max_pkt_info; | 1834 | u32 max_pkt_info; |
| @@ -1932,8 +1947,8 @@ static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf) | |||
| 1932 | msg_last_bcast(msg)); | 1947 | msg_last_bcast(msg)); |
| 1933 | 1948 | ||
| 1934 | if (rec_gap || (msg_probe(msg))) { | 1949 | if (rec_gap || (msg_probe(msg))) { |
| 1935 | tipc_link_send_proto_msg(l_ptr, STATE_MSG, | 1950 | tipc_link_proto_xmit(l_ptr, STATE_MSG, 0, rec_gap, 0, |
| 1936 | 0, rec_gap, 0, 0, max_pkt_ack); | 1951 | 0, max_pkt_ack); |
| 1937 | } | 1952 | } |
| 1938 | if (msg_seq_gap(msg)) { | 1953 | if (msg_seq_gap(msg)) { |
| 1939 | l_ptr->stats.recv_nacks++; | 1954 | l_ptr->stats.recv_nacks++; |
| @@ -1972,7 +1987,7 @@ static void tipc_link_tunnel_xmit(struct tipc_link *l_ptr, | |||
| 1972 | } | 1987 | } |
| 1973 | skb_copy_to_linear_data(buf, tunnel_hdr, INT_H_SIZE); | 1988 | skb_copy_to_linear_data(buf, tunnel_hdr, INT_H_SIZE); |
| 1974 | skb_copy_to_linear_data_offset(buf, INT_H_SIZE, msg, length); | 1989 | skb_copy_to_linear_data_offset(buf, INT_H_SIZE, msg, length); |
| 1975 | tipc_link_send_buf(tunnel, buf); | 1990 | __tipc_link_xmit(tunnel, buf); |
| 1976 | } | 1991 | } |
| 1977 | 1992 | ||
| 1978 | 1993 | ||
| @@ -2005,7 +2020,7 @@ void tipc_link_failover_send_queue(struct tipc_link *l_ptr) | |||
| 2005 | if (buf) { | 2020 | if (buf) { |
| 2006 | skb_copy_to_linear_data(buf, &tunnel_hdr, INT_H_SIZE); | 2021 | skb_copy_to_linear_data(buf, &tunnel_hdr, INT_H_SIZE); |
| 2007 | msg_set_size(&tunnel_hdr, INT_H_SIZE); | 2022 | msg_set_size(&tunnel_hdr, INT_H_SIZE); |
| 2008 | tipc_link_send_buf(tunnel, buf); | 2023 | __tipc_link_xmit(tunnel, buf); |
| 2009 | } else { | 2024 | } else { |
| 2010 | pr_warn("%sunable to send changeover msg\n", | 2025 | pr_warn("%sunable to send changeover msg\n", |
| 2011 | link_co_err); | 2026 | link_co_err); |
| @@ -2039,7 +2054,7 @@ void tipc_link_failover_send_queue(struct tipc_link *l_ptr) | |||
| 2039 | } | 2054 | } |
| 2040 | } | 2055 | } |
| 2041 | 2056 | ||
| 2042 | /* tipc_link_dup_send_queue(): A second link has become active. Tunnel a | 2057 | /* tipc_link_dup_queue_xmit(): A second link has become active. Tunnel a |
| 2043 | * duplicate of the first link's send queue via the new link. This way, we | 2058 | * duplicate of the first link's send queue via the new link. This way, we |
| 2044 | * are guaranteed that currently queued packets from a socket are delivered | 2059 | * are guaranteed that currently queued packets from a socket are delivered |
| 2045 | * before future traffic from the same socket, even if this is using the | 2060 | * before future traffic from the same socket, even if this is using the |
| @@ -2048,7 +2063,7 @@ void tipc_link_failover_send_queue(struct tipc_link *l_ptr) | |||
| 2048 | * and sequence order is preserved per sender/receiver socket pair. | 2063 | * and sequence order is preserved per sender/receiver socket pair. |
| 2049 | * Owner node is locked. | 2064 | * Owner node is locked. |
| 2050 | */ | 2065 | */ |
| 2051 | void tipc_link_dup_send_queue(struct tipc_link *l_ptr, | 2066 | void tipc_link_dup_queue_xmit(struct tipc_link *l_ptr, |
| 2052 | struct tipc_link *tunnel) | 2067 | struct tipc_link *tunnel) |
| 2053 | { | 2068 | { |
| 2054 | struct sk_buff *iter; | 2069 | struct sk_buff *iter; |
| @@ -2078,7 +2093,7 @@ void tipc_link_dup_send_queue(struct tipc_link *l_ptr, | |||
| 2078 | skb_copy_to_linear_data(outbuf, &tunnel_hdr, INT_H_SIZE); | 2093 | skb_copy_to_linear_data(outbuf, &tunnel_hdr, INT_H_SIZE); |
| 2079 | skb_copy_to_linear_data_offset(outbuf, INT_H_SIZE, iter->data, | 2094 | skb_copy_to_linear_data_offset(outbuf, INT_H_SIZE, iter->data, |
| 2080 | length); | 2095 | length); |
| 2081 | tipc_link_send_buf(tunnel, outbuf); | 2096 | __tipc_link_xmit(tunnel, outbuf); |
| 2082 | if (!tipc_link_is_up(l_ptr)) | 2097 | if (!tipc_link_is_up(l_ptr)) |
| 2083 | return; | 2098 | return; |
| 2084 | iter = iter->next; | 2099 | iter = iter->next; |
| @@ -2105,89 +2120,114 @@ static struct sk_buff *buf_extract(struct sk_buff *skb, u32 from_pos) | |||
| 2105 | return eb; | 2120 | return eb; |
| 2106 | } | 2121 | } |
| 2107 | 2122 | ||
| 2108 | /* tipc_link_tunnel_rcv(): Receive a tunneled packet, sent | 2123 | |
| 2109 | * via other link as result of a failover (ORIGINAL_MSG) or | 2124 | |
| 2110 | * a new active link (DUPLICATE_MSG). Failover packets are | 2125 | /* tipc_link_dup_rcv(): Receive a tunnelled DUPLICATE_MSG packet. |
| 2111 | * returned to the active link for delivery upwards. | 2126 | * Owner node is locked. |
| 2127 | */ | ||
| 2128 | static void tipc_link_dup_rcv(struct tipc_link *l_ptr, | ||
| 2129 | struct sk_buff *t_buf) | ||
| 2130 | { | ||
| 2131 | struct sk_buff *buf; | ||
| 2132 | |||
| 2133 | if (!tipc_link_is_up(l_ptr)) | ||
| 2134 | return; | ||
| 2135 | |||
| 2136 | buf = buf_extract(t_buf, INT_H_SIZE); | ||
| 2137 | if (buf == NULL) { | ||
| 2138 | pr_warn("%sfailed to extract inner dup pkt\n", link_co_err); | ||
| 2139 | return; | ||
| 2140 | } | ||
| 2141 | |||
| 2142 | /* Add buffer to deferred queue, if applicable: */ | ||
| 2143 | link_handle_out_of_seq_msg(l_ptr, buf); | ||
| 2144 | } | ||
| 2145 | |||
| 2146 | /* tipc_link_failover_rcv(): Receive a tunnelled ORIGINAL_MSG packet | ||
| 2112 | * Owner node is locked. | 2147 | * Owner node is locked. |
| 2113 | */ | 2148 | */ |
| 2114 | static int tipc_link_tunnel_rcv(struct tipc_link **l_ptr, | 2149 | static struct sk_buff *tipc_link_failover_rcv(struct tipc_link *l_ptr, |
| 2115 | struct sk_buff **buf) | 2150 | struct sk_buff *t_buf) |
| 2116 | { | 2151 | { |
| 2117 | struct sk_buff *tunnel_buf = *buf; | 2152 | struct tipc_msg *t_msg = buf_msg(t_buf); |
| 2118 | struct tipc_link *dest_link; | 2153 | struct sk_buff *buf = NULL; |
| 2119 | struct tipc_msg *msg; | 2154 | struct tipc_msg *msg; |
| 2120 | struct tipc_msg *tunnel_msg = buf_msg(tunnel_buf); | ||
| 2121 | u32 msg_typ = msg_type(tunnel_msg); | ||
| 2122 | u32 msg_count = msg_msgcnt(tunnel_msg); | ||
| 2123 | u32 bearer_id = msg_bearer_id(tunnel_msg); | ||
| 2124 | 2155 | ||
| 2125 | if (bearer_id >= MAX_BEARERS) | 2156 | if (tipc_link_is_up(l_ptr)) |
| 2126 | goto exit; | 2157 | tipc_link_reset(l_ptr); |
| 2127 | dest_link = (*l_ptr)->owner->links[bearer_id]; | ||
| 2128 | if (!dest_link) | ||
| 2129 | goto exit; | ||
| 2130 | if (dest_link == *l_ptr) { | ||
| 2131 | pr_err("Unexpected changeover message on link <%s>\n", | ||
| 2132 | (*l_ptr)->name); | ||
| 2133 | goto exit; | ||
| 2134 | } | ||
| 2135 | *l_ptr = dest_link; | ||
| 2136 | msg = msg_get_wrapped(tunnel_msg); | ||
| 2137 | 2158 | ||
| 2138 | if (msg_typ == DUPLICATE_MSG) { | 2159 | /* First failover packet? */ |
| 2139 | if (less(msg_seqno(msg), mod(dest_link->next_in_no))) | 2160 | if (l_ptr->exp_msg_count == START_CHANGEOVER) |
| 2140 | goto exit; | 2161 | l_ptr->exp_msg_count = msg_msgcnt(t_msg); |
| 2141 | *buf = buf_extract(tunnel_buf, INT_H_SIZE); | 2162 | |
| 2142 | if (*buf == NULL) { | 2163 | /* Should there be an inner packet? */ |
| 2143 | pr_warn("%sduplicate msg dropped\n", link_co_err); | 2164 | if (l_ptr->exp_msg_count) { |
| 2165 | l_ptr->exp_msg_count--; | ||
| 2166 | buf = buf_extract(t_buf, INT_H_SIZE); | ||
| 2167 | if (buf == NULL) { | ||
| 2168 | pr_warn("%sno inner failover pkt\n", link_co_err); | ||
| 2144 | goto exit; | 2169 | goto exit; |
| 2145 | } | 2170 | } |
| 2146 | kfree_skb(tunnel_buf); | 2171 | msg = buf_msg(buf); |
| 2147 | return 1; | ||
| 2148 | } | ||
| 2149 | 2172 | ||
| 2150 | /* First original message ?: */ | 2173 | if (less(msg_seqno(msg), l_ptr->reset_checkpoint)) { |
| 2151 | if (tipc_link_is_up(dest_link)) { | 2174 | kfree_skb(buf); |
| 2152 | pr_info("%s<%s>, changeover initiated by peer\n", link_rst_msg, | 2175 | buf = NULL; |
| 2153 | dest_link->name); | ||
| 2154 | tipc_link_reset(dest_link); | ||
| 2155 | dest_link->exp_msg_count = msg_count; | ||
| 2156 | if (!msg_count) | ||
| 2157 | goto exit; | ||
| 2158 | } else if (dest_link->exp_msg_count == START_CHANGEOVER) { | ||
| 2159 | dest_link->exp_msg_count = msg_count; | ||
| 2160 | if (!msg_count) | ||
| 2161 | goto exit; | 2176 | goto exit; |
| 2177 | } | ||
| 2178 | if (msg_user(msg) == MSG_FRAGMENTER) { | ||
| 2179 | l_ptr->stats.recv_fragments++; | ||
| 2180 | tipc_link_frag_rcv(&l_ptr->reasm_head, | ||
| 2181 | &l_ptr->reasm_tail, | ||
| 2182 | &buf); | ||
| 2183 | } | ||
| 2162 | } | 2184 | } |
| 2185 | exit: | ||
| 2186 | if ((l_ptr->exp_msg_count == 0) && (l_ptr->flags & LINK_STOPPED)) { | ||
| 2187 | tipc_node_detach_link(l_ptr->owner, l_ptr); | ||
| 2188 | kfree(l_ptr); | ||
| 2189 | } | ||
| 2190 | return buf; | ||
| 2191 | } | ||
| 2192 | |||
| 2193 | /* tipc_link_tunnel_rcv(): Receive a tunnelled packet, sent | ||
| 2194 | * via other link as result of a failover (ORIGINAL_MSG) or | ||
| 2195 | * a new active link (DUPLICATE_MSG). Failover packets are | ||
| 2196 | * returned to the active link for delivery upwards. | ||
| 2197 | * Owner node is locked. | ||
| 2198 | */ | ||
| 2199 | static int tipc_link_tunnel_rcv(struct tipc_node *n_ptr, | ||
| 2200 | struct sk_buff **buf) | ||
| 2201 | { | ||
| 2202 | struct sk_buff *t_buf = *buf; | ||
| 2203 | struct tipc_link *l_ptr; | ||
| 2204 | struct tipc_msg *t_msg = buf_msg(t_buf); | ||
| 2205 | u32 bearer_id = msg_bearer_id(t_msg); | ||
| 2206 | |||
| 2207 | *buf = NULL; | ||
| 2163 | 2208 | ||
| 2164 | /* Receive original message */ | 2209 | if (bearer_id >= MAX_BEARERS) |
| 2165 | if (dest_link->exp_msg_count == 0) { | ||
| 2166 | pr_warn("%sgot too many tunnelled messages\n", link_co_err); | ||
| 2167 | goto exit; | 2210 | goto exit; |
| 2168 | } | 2211 | |
| 2169 | dest_link->exp_msg_count--; | 2212 | l_ptr = n_ptr->links[bearer_id]; |
| 2170 | if (less(msg_seqno(msg), dest_link->reset_checkpoint)) { | 2213 | if (!l_ptr) |
| 2171 | goto exit; | 2214 | goto exit; |
| 2172 | } else { | 2215 | |
| 2173 | *buf = buf_extract(tunnel_buf, INT_H_SIZE); | 2216 | if (msg_type(t_msg) == DUPLICATE_MSG) |
| 2174 | if (*buf != NULL) { | 2217 | tipc_link_dup_rcv(l_ptr, t_buf); |
| 2175 | kfree_skb(tunnel_buf); | 2218 | else if (msg_type(t_msg) == ORIGINAL_MSG) |
| 2176 | return 1; | 2219 | *buf = tipc_link_failover_rcv(l_ptr, t_buf); |
| 2177 | } else { | 2220 | else |
| 2178 | pr_warn("%soriginal msg dropped\n", link_co_err); | 2221 | pr_warn("%sunknown tunnel pkt received\n", link_co_err); |
| 2179 | } | ||
| 2180 | } | ||
| 2181 | exit: | 2222 | exit: |
| 2182 | *buf = NULL; | 2223 | kfree_skb(t_buf); |
| 2183 | kfree_skb(tunnel_buf); | 2224 | return *buf != NULL; |
| 2184 | return 0; | ||
| 2185 | } | 2225 | } |
| 2186 | 2226 | ||
| 2187 | /* | 2227 | /* |
| 2188 | * Bundler functionality: | 2228 | * Bundler functionality: |
| 2189 | */ | 2229 | */ |
| 2190 | void tipc_link_recv_bundle(struct sk_buff *buf) | 2230 | void tipc_link_bundle_rcv(struct sk_buff *buf) |
| 2191 | { | 2231 | { |
| 2192 | u32 msgcount = msg_msgcnt(buf_msg(buf)); | 2232 | u32 msgcount = msg_msgcnt(buf_msg(buf)); |
| 2193 | u32 pos = INT_H_SIZE; | 2233 | u32 pos = INT_H_SIZE; |
| @@ -2210,11 +2250,11 @@ void tipc_link_recv_bundle(struct sk_buff *buf) | |||
| 2210 | */ | 2250 | */ |
| 2211 | 2251 | ||
| 2212 | /* | 2252 | /* |
| 2213 | * link_send_long_buf: Entry for buffers needing fragmentation. | 2253 | * tipc_link_frag_xmit: Entry for buffers needing fragmentation. |
| 2214 | * The buffer is complete, inclusive total message length. | 2254 | * The buffer is complete, inclusive total message length. |
| 2215 | * Returns user data length. | 2255 | * Returns user data length. |
| 2216 | */ | 2256 | */ |
| 2217 | static int link_send_long_buf(struct tipc_link *l_ptr, struct sk_buff *buf) | 2257 | static int tipc_link_frag_xmit(struct tipc_link *l_ptr, struct sk_buff *buf) |
| 2218 | { | 2258 | { |
| 2219 | struct sk_buff *buf_chain = NULL; | 2259 | struct sk_buff *buf_chain = NULL; |
| 2220 | struct sk_buff *buf_chain_tail = (struct sk_buff *)&buf_chain; | 2260 | struct sk_buff *buf_chain_tail = (struct sk_buff *)&buf_chain; |
| @@ -2277,12 +2317,11 @@ static int link_send_long_buf(struct tipc_link *l_ptr, struct sk_buff *buf) | |||
| 2277 | return dsz; | 2317 | return dsz; |
| 2278 | } | 2318 | } |
| 2279 | 2319 | ||
| 2280 | /* | 2320 | /* tipc_link_frag_rcv(): Called with node lock on. Returns |
| 2281 | * tipc_link_recv_fragment(): Called with node lock on. Returns | ||
| 2282 | * the reassembled buffer if message is complete. | 2321 | * the reassembled buffer if message is complete. |
| 2283 | */ | 2322 | */ |
| 2284 | int tipc_link_recv_fragment(struct sk_buff **head, struct sk_buff **tail, | 2323 | int tipc_link_frag_rcv(struct sk_buff **head, struct sk_buff **tail, |
| 2285 | struct sk_buff **fbuf) | 2324 | struct sk_buff **fbuf) |
| 2286 | { | 2325 | { |
| 2287 | struct sk_buff *frag = *fbuf; | 2326 | struct sk_buff *frag = *fbuf; |
| 2288 | struct tipc_msg *msg = buf_msg(frag); | 2327 | struct tipc_msg *msg = buf_msg(frag); |
| @@ -2296,6 +2335,7 @@ int tipc_link_recv_fragment(struct sk_buff **head, struct sk_buff **tail, | |||
| 2296 | goto out_free; | 2335 | goto out_free; |
| 2297 | *head = frag; | 2336 | *head = frag; |
| 2298 | skb_frag_list_init(*head); | 2337 | skb_frag_list_init(*head); |
| 2338 | *fbuf = NULL; | ||
| 2299 | return 0; | 2339 | return 0; |
| 2300 | } else if (*head && | 2340 | } else if (*head && |
| 2301 | skb_try_coalesce(*head, frag, &headstolen, &delta)) { | 2341 | skb_try_coalesce(*head, frag, &headstolen, &delta)) { |
| @@ -2315,10 +2355,12 @@ int tipc_link_recv_fragment(struct sk_buff **head, struct sk_buff **tail, | |||
| 2315 | *tail = *head = NULL; | 2355 | *tail = *head = NULL; |
| 2316 | return LINK_REASM_COMPLETE; | 2356 | return LINK_REASM_COMPLETE; |
| 2317 | } | 2357 | } |
| 2358 | *fbuf = NULL; | ||
| 2318 | return 0; | 2359 | return 0; |
| 2319 | out_free: | 2360 | out_free: |
| 2320 | pr_warn_ratelimited("Link unable to reassemble fragmented message\n"); | 2361 | pr_warn_ratelimited("Link unable to reassemble fragmented message\n"); |
| 2321 | kfree_skb(*fbuf); | 2362 | kfree_skb(*fbuf); |
| 2363 | *fbuf = NULL; | ||
| 2322 | return LINK_REASM_ERROR; | 2364 | return LINK_REASM_ERROR; |
| 2323 | } | 2365 | } |
| 2324 | 2366 | ||
| @@ -2352,35 +2394,41 @@ void tipc_link_set_queue_limits(struct tipc_link *l_ptr, u32 window) | |||
| 2352 | l_ptr->queue_limit[MSG_FRAGMENTER] = 4000; | 2394 | l_ptr->queue_limit[MSG_FRAGMENTER] = 4000; |
| 2353 | } | 2395 | } |
| 2354 | 2396 | ||
| 2355 | /** | 2397 | /* tipc_link_find_owner - locate owner node of link by link's name |
| 2356 | * link_find_link - locate link by name | 2398 | * @name: pointer to link name string |
| 2357 | * @name: ptr to link name string | 2399 | * @bearer_id: pointer to index in 'node->links' array where the link was found. |
| 2358 | * @node: ptr to area to be filled with ptr to associated node | ||
| 2359 | * | ||
| 2360 | * Caller must hold 'tipc_net_lock' to ensure node and bearer are not deleted; | 2400 | * Caller must hold 'tipc_net_lock' to ensure node and bearer are not deleted; |
| 2361 | * this also prevents link deletion. | 2401 | * this also prevents link deletion. |
| 2362 | * | 2402 | * |
| 2363 | * Returns pointer to link (or 0 if invalid link name). | 2403 | * Returns pointer to node owning the link, or 0 if no matching link is found. |
| 2364 | */ | 2404 | */ |
| 2365 | static struct tipc_link *link_find_link(const char *name, | 2405 | static struct tipc_node *tipc_link_find_owner(const char *link_name, |
| 2366 | struct tipc_node **node) | 2406 | unsigned int *bearer_id) |
| 2367 | { | 2407 | { |
| 2368 | struct tipc_link *l_ptr; | 2408 | struct tipc_link *l_ptr; |
| 2369 | struct tipc_node *n_ptr; | 2409 | struct tipc_node *n_ptr; |
| 2410 | struct tipc_node *found_node = 0; | ||
| 2370 | int i; | 2411 | int i; |
| 2371 | 2412 | ||
| 2372 | list_for_each_entry(n_ptr, &tipc_node_list, list) { | 2413 | *bearer_id = 0; |
| 2414 | rcu_read_lock(); | ||
| 2415 | list_for_each_entry_rcu(n_ptr, &tipc_node_list, list) { | ||
| 2416 | tipc_node_lock(n_ptr); | ||
| 2373 | for (i = 0; i < MAX_BEARERS; i++) { | 2417 | for (i = 0; i < MAX_BEARERS; i++) { |
| 2374 | l_ptr = n_ptr->links[i]; | 2418 | l_ptr = n_ptr->links[i]; |
| 2375 | if (l_ptr && !strcmp(l_ptr->name, name)) | 2419 | if (l_ptr && !strcmp(l_ptr->name, link_name)) { |
| 2376 | goto found; | 2420 | *bearer_id = i; |
| 2421 | found_node = n_ptr; | ||
| 2422 | break; | ||
| 2423 | } | ||
| 2377 | } | 2424 | } |
| 2425 | tipc_node_unlock(n_ptr); | ||
| 2426 | if (found_node) | ||
| 2427 | break; | ||
| 2378 | } | 2428 | } |
| 2379 | l_ptr = NULL; | 2429 | rcu_read_unlock(); |
| 2380 | n_ptr = NULL; | 2430 | |
| 2381 | found: | 2431 | return found_node; |
| 2382 | *node = n_ptr; | ||
| 2383 | return l_ptr; | ||
| 2384 | } | 2432 | } |
| 2385 | 2433 | ||
| 2386 | /** | 2434 | /** |
| @@ -2422,32 +2470,33 @@ static int link_cmd_set_value(const char *name, u32 new_value, u16 cmd) | |||
| 2422 | struct tipc_link *l_ptr; | 2470 | struct tipc_link *l_ptr; |
| 2423 | struct tipc_bearer *b_ptr; | 2471 | struct tipc_bearer *b_ptr; |
| 2424 | struct tipc_media *m_ptr; | 2472 | struct tipc_media *m_ptr; |
| 2473 | int bearer_id; | ||
| 2425 | int res = 0; | 2474 | int res = 0; |
| 2426 | 2475 | ||
| 2427 | l_ptr = link_find_link(name, &node); | 2476 | node = tipc_link_find_owner(name, &bearer_id); |
| 2428 | if (l_ptr) { | 2477 | if (node) { |
| 2429 | /* | ||
| 2430 | * acquire node lock for tipc_link_send_proto_msg(). | ||
| 2431 | * see "TIPC locking policy" in net.c. | ||
| 2432 | */ | ||
| 2433 | tipc_node_lock(node); | 2478 | tipc_node_lock(node); |
| 2434 | switch (cmd) { | 2479 | l_ptr = node->links[bearer_id]; |
| 2435 | case TIPC_CMD_SET_LINK_TOL: | 2480 | |
| 2436 | link_set_supervision_props(l_ptr, new_value); | 2481 | if (l_ptr) { |
| 2437 | tipc_link_send_proto_msg(l_ptr, | 2482 | switch (cmd) { |
| 2438 | STATE_MSG, 0, 0, new_value, 0, 0); | 2483 | case TIPC_CMD_SET_LINK_TOL: |
| 2439 | break; | 2484 | link_set_supervision_props(l_ptr, new_value); |
| 2440 | case TIPC_CMD_SET_LINK_PRI: | 2485 | tipc_link_proto_xmit(l_ptr, STATE_MSG, 0, 0, |
| 2441 | l_ptr->priority = new_value; | 2486 | new_value, 0, 0); |
| 2442 | tipc_link_send_proto_msg(l_ptr, | 2487 | break; |
| 2443 | STATE_MSG, 0, 0, 0, new_value, 0); | 2488 | case TIPC_CMD_SET_LINK_PRI: |
| 2444 | break; | 2489 | l_ptr->priority = new_value; |
| 2445 | case TIPC_CMD_SET_LINK_WINDOW: | 2490 | tipc_link_proto_xmit(l_ptr, STATE_MSG, 0, 0, |
| 2446 | tipc_link_set_queue_limits(l_ptr, new_value); | 2491 | 0, new_value, 0); |
| 2447 | break; | 2492 | break; |
| 2448 | default: | 2493 | case TIPC_CMD_SET_LINK_WINDOW: |
| 2449 | res = -EINVAL; | 2494 | tipc_link_set_queue_limits(l_ptr, new_value); |
| 2450 | break; | 2495 | break; |
| 2496 | default: | ||
| 2497 | res = -EINVAL; | ||
| 2498 | break; | ||
| 2499 | } | ||
| 2451 | } | 2500 | } |
| 2452 | tipc_node_unlock(node); | 2501 | tipc_node_unlock(node); |
| 2453 | return res; | 2502 | return res; |
| @@ -2542,6 +2591,7 @@ struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area, int req_tlv_ | |||
| 2542 | char *link_name; | 2591 | char *link_name; |
| 2543 | struct tipc_link *l_ptr; | 2592 | struct tipc_link *l_ptr; |
| 2544 | struct tipc_node *node; | 2593 | struct tipc_node *node; |
| 2594 | unsigned int bearer_id; | ||
| 2545 | 2595 | ||
| 2546 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_NAME)) | 2596 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_NAME)) |
| 2547 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | 2597 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); |
| @@ -2552,15 +2602,19 @@ struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area, int req_tlv_ | |||
| 2552 | return tipc_cfg_reply_error_string("link not found"); | 2602 | return tipc_cfg_reply_error_string("link not found"); |
| 2553 | return tipc_cfg_reply_none(); | 2603 | return tipc_cfg_reply_none(); |
| 2554 | } | 2604 | } |
| 2555 | |||
| 2556 | read_lock_bh(&tipc_net_lock); | 2605 | read_lock_bh(&tipc_net_lock); |
| 2557 | l_ptr = link_find_link(link_name, &node); | 2606 | node = tipc_link_find_owner(link_name, &bearer_id); |
| 2558 | if (!l_ptr) { | 2607 | if (!node) { |
| 2559 | read_unlock_bh(&tipc_net_lock); | 2608 | read_unlock_bh(&tipc_net_lock); |
| 2560 | return tipc_cfg_reply_error_string("link not found"); | 2609 | return tipc_cfg_reply_error_string("link not found"); |
| 2561 | } | 2610 | } |
| 2562 | |||
| 2563 | tipc_node_lock(node); | 2611 | tipc_node_lock(node); |
| 2612 | l_ptr = node->links[bearer_id]; | ||
| 2613 | if (!l_ptr) { | ||
| 2614 | tipc_node_unlock(node); | ||
| 2615 | read_unlock_bh(&tipc_net_lock); | ||
| 2616 | return tipc_cfg_reply_error_string("link not found"); | ||
| 2617 | } | ||
| 2564 | link_reset_statistics(l_ptr); | 2618 | link_reset_statistics(l_ptr); |
| 2565 | tipc_node_unlock(node); | 2619 | tipc_node_unlock(node); |
| 2566 | read_unlock_bh(&tipc_net_lock); | 2620 | read_unlock_bh(&tipc_net_lock); |
| @@ -2590,18 +2644,27 @@ static int tipc_link_stats(const char *name, char *buf, const u32 buf_size) | |||
| 2590 | struct tipc_node *node; | 2644 | struct tipc_node *node; |
| 2591 | char *status; | 2645 | char *status; |
| 2592 | u32 profile_total = 0; | 2646 | u32 profile_total = 0; |
| 2647 | unsigned int bearer_id; | ||
| 2593 | int ret; | 2648 | int ret; |
| 2594 | 2649 | ||
| 2595 | if (!strcmp(name, tipc_bclink_name)) | 2650 | if (!strcmp(name, tipc_bclink_name)) |
| 2596 | return tipc_bclink_stats(buf, buf_size); | 2651 | return tipc_bclink_stats(buf, buf_size); |
| 2597 | 2652 | ||
| 2598 | read_lock_bh(&tipc_net_lock); | 2653 | read_lock_bh(&tipc_net_lock); |
| 2599 | l = link_find_link(name, &node); | 2654 | node = tipc_link_find_owner(name, &bearer_id); |
| 2600 | if (!l) { | 2655 | if (!node) { |
| 2601 | read_unlock_bh(&tipc_net_lock); | 2656 | read_unlock_bh(&tipc_net_lock); |
| 2602 | return 0; | 2657 | return 0; |
| 2603 | } | 2658 | } |
| 2604 | tipc_node_lock(node); | 2659 | tipc_node_lock(node); |
| 2660 | |||
| 2661 | l = node->links[bearer_id]; | ||
| 2662 | if (!l) { | ||
| 2663 | tipc_node_unlock(node); | ||
| 2664 | read_unlock_bh(&tipc_net_lock); | ||
| 2665 | return 0; | ||
| 2666 | } | ||
| 2667 | |||
| 2605 | s = &l->stats; | 2668 | s = &l->stats; |
| 2606 | 2669 | ||
| 2607 | if (tipc_link_is_active(l)) | 2670 | if (tipc_link_is_active(l)) |
