aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/bearer.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc/bearer.c')
-rw-r--r--net/tipc/bearer.c42
1 files changed, 12 insertions, 30 deletions
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 52ae17b2583e..9927d1d56c4f 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -63,7 +63,7 @@ static int media_name_valid(const char *name)
63 len = strlen(name); 63 len = strlen(name);
64 if ((len + 1) > TIPC_MAX_MEDIA_NAME) 64 if ((len + 1) > TIPC_MAX_MEDIA_NAME)
65 return 0; 65 return 0;
66 return (strspn(name, tipc_alphabet) == len); 66 return strspn(name, tipc_alphabet) == len;
67} 67}
68 68
69/** 69/**
@@ -288,9 +288,6 @@ static struct bearer *bearer_find(const char *name)
288 struct bearer *b_ptr; 288 struct bearer *b_ptr;
289 u32 i; 289 u32 i;
290 290
291 if (tipc_mode != TIPC_NET_MODE)
292 return NULL;
293
294 for (i = 0, b_ptr = tipc_bearers; i < MAX_BEARERS; i++, b_ptr++) { 291 for (i = 0, b_ptr = tipc_bearers; i < MAX_BEARERS; i++, b_ptr++) {
295 if (b_ptr->active && (!strcmp(b_ptr->publ.name, name))) 292 if (b_ptr->active && (!strcmp(b_ptr->publ.name, name)))
296 return b_ptr; 293 return b_ptr;
@@ -559,8 +556,6 @@ restart:
559 } 556 }
560 557
561 b_ptr = &tipc_bearers[bearer_id]; 558 b_ptr = &tipc_bearers[bearer_id];
562 memset(b_ptr, 0, sizeof(struct bearer));
563
564 strcpy(b_ptr->publ.name, name); 559 strcpy(b_ptr->publ.name, name);
565 res = m_ptr->enable_bearer(&b_ptr->publ); 560 res = m_ptr->enable_bearer(&b_ptr->publ);
566 if (res) { 561 if (res) {
@@ -630,30 +625,17 @@ int tipc_block_bearer(const char *name)
630 * Note: This routine assumes caller holds tipc_net_lock. 625 * Note: This routine assumes caller holds tipc_net_lock.
631 */ 626 */
632 627
633static int bearer_disable(const char *name) 628static int bearer_disable(struct bearer *b_ptr)
634{ 629{
635 struct bearer *b_ptr;
636 struct link *l_ptr; 630 struct link *l_ptr;
637 struct link *temp_l_ptr; 631 struct link *temp_l_ptr;
638 632
639 b_ptr = bearer_find(name); 633 info("Disabling bearer <%s>\n", b_ptr->publ.name);
640 if (!b_ptr) {
641 warn("Attempt to disable unknown bearer <%s>\n", name);
642 return -EINVAL;
643 }
644
645 info("Disabling bearer <%s>\n", name);
646 tipc_disc_stop_link_req(b_ptr->link_req); 634 tipc_disc_stop_link_req(b_ptr->link_req);
647 spin_lock_bh(&b_ptr->publ.lock); 635 spin_lock_bh(&b_ptr->publ.lock);
648 b_ptr->link_req = NULL; 636 b_ptr->link_req = NULL;
649 b_ptr->publ.blocked = 1; 637 b_ptr->publ.blocked = 1;
650 if (b_ptr->media->disable_bearer) { 638 b_ptr->media->disable_bearer(&b_ptr->publ);
651 spin_unlock_bh(&b_ptr->publ.lock);
652 write_unlock_bh(&tipc_net_lock);
653 b_ptr->media->disable_bearer(&b_ptr->publ);
654 write_lock_bh(&tipc_net_lock);
655 spin_lock_bh(&b_ptr->publ.lock);
656 }
657 list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) { 639 list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) {
658 tipc_link_delete(l_ptr); 640 tipc_link_delete(l_ptr);
659 } 641 }
@@ -664,10 +646,16 @@ static int bearer_disable(const char *name)
664 646
665int tipc_disable_bearer(const char *name) 647int tipc_disable_bearer(const char *name)
666{ 648{
649 struct bearer *b_ptr;
667 int res; 650 int res;
668 651
669 write_lock_bh(&tipc_net_lock); 652 write_lock_bh(&tipc_net_lock);
670 res = bearer_disable(name); 653 b_ptr = bearer_find(name);
654 if (b_ptr == NULL) {
655 warn("Attempt to disable unknown bearer <%s>\n", name);
656 res = -EINVAL;
657 } else
658 res = bearer_disable(b_ptr);
671 write_unlock_bh(&tipc_net_lock); 659 write_unlock_bh(&tipc_net_lock);
672 return res; 660 return res;
673} 661}
@@ -680,13 +668,7 @@ void tipc_bearer_stop(void)
680 668
681 for (i = 0; i < MAX_BEARERS; i++) { 669 for (i = 0; i < MAX_BEARERS; i++) {
682 if (tipc_bearers[i].active) 670 if (tipc_bearers[i].active)
683 tipc_bearers[i].publ.blocked = 1; 671 bearer_disable(&tipc_bearers[i]);
684 }
685 for (i = 0; i < MAX_BEARERS; i++) {
686 if (tipc_bearers[i].active)
687 bearer_disable(tipc_bearers[i].publ.name);
688 } 672 }
689 media_count = 0; 673 media_count = 0;
690} 674}
691
692