42 #define MAX_ADDR_STR 32
45 static u32 media_count;
49 static void bearer_disable(
struct tipc_bearer *b_ptr);
58 for (i = 0; i < media_count; i++) {
59 if (!
strcmp(media_list[i]->name, name))
72 for (i = 0; i < media_count; i++) {
73 if (media_list[i]->
type_id == type)
105 media_list[media_count] = m_ptr;
111 pr_warn(
"Media <%s> registration error\n", m_ptr->
name);
126 if (m_ptr && !m_ptr->
addr2str(a, addr_str,
sizeof(addr_str)))
132 for (i = 0; i <
sizeof(a->
value); i++)
134 "-%02x", a->
value[i]);
151 for (i = 0; i < media_count; i++) {
167 static int bearer_name_validate(
const char *
name,
184 media_name = name_copy;
185 if_name =
strchr(media_name,
':');
189 media_len = if_name - media_name;
190 if_len =
strlen(if_name) + 1;
233 if (!
strcmp(b_if_name, if_name))
253 for (i = 0; i < media_count; i++) {
256 if (b_ptr->
active && (b_ptr->
media == media_list[i])) {
311 spin_lock_bh(&b_ptr->
lock);
313 spin_unlock_bh(&b_ptr->
lock);
323 spin_lock_bh(&b_ptr->
lock);
327 spin_unlock_bh(&b_ptr->lock);
337 static void tipc_bearer_schedule_unlocked(
struct tipc_bearer *b_ptr,
352 spin_lock_bh(&b_ptr->
lock);
353 tipc_bearer_schedule_unlocked(b_ptr, l_ptr);
354 spin_unlock_bh(&b_ptr->
lock);
370 spin_lock_bh(&b_ptr->
lock);
371 if (!bearer_push(b_ptr)) {
372 tipc_bearer_schedule_unlocked(b_ptr, l_ptr);
375 spin_unlock_bh(&b_ptr->
lock);
399 char addr_string[16];
405 if (!tipc_own_addr) {
406 pr_warn(
"Bearer <%s> rejected, not supported in standalone mode\n",
410 if (!bearer_name_validate(name, &b_names)) {
411 pr_warn(
"Bearer <%s> rejected, illegal name\n", name);
415 (disc_domain != tipc_own_addr)) {
419 }
else if (in_own_cluster_exact(disc_domain))
423 pr_warn(
"Bearer <%s> rejected, illegal discovery domain\n",
429 pr_warn(
"Bearer <%s> rejected, illegal priority\n", name);
437 pr_warn(
"Bearer <%s> rejected, media <%s> not registered\n",
454 pr_warn(
"Bearer <%s> rejected, already enabled\n",
459 (++with_this_prio > 2)) {
460 if (priority-- == 0) {
461 pr_warn(
"Bearer <%s> rejected, duplicate priority\n",
465 pr_warn(
"Bearer <%s> priority adjustment required %u->%u\n",
466 name, priority + 1, priority);
471 pr_warn(
"Bearer <%s> rejected, bearer limit reached (%u)\n",
480 pr_warn(
"Bearer <%s> rejected, enable failure (%d)\n",
486 b_ptr->
media = m_ptr;
493 INIT_LIST_HEAD(&b_ptr->
links);
498 bearer_disable(b_ptr);
499 pr_warn(
"Bearer <%s> rejected, discovery object creation failed\n",
503 pr_info(
"Enabled bearer <%s>, discovery domain %s, priority %u\n",
523 pr_warn(
"Attempt to block unknown bearer <%s>\n", name);
528 pr_info(
"Blocking bearer <%s>\n", name);
529 spin_lock_bh(&b_ptr->
lock);
535 spin_lock_bh(&n_ptr->
lock);
537 spin_unlock_bh(&n_ptr->
lock);
539 spin_unlock_bh(&b_ptr->
lock);
549 static void bearer_disable(
struct tipc_bearer *b_ptr)
555 spin_lock_bh(&b_ptr->
lock);
557 b_ptr->
media->disable_bearer(b_ptr);
564 spin_unlock_bh(&b_ptr->
lock);
576 pr_warn(
"Attempt to disable unknown bearer <%s>\n", name);
579 bearer_disable(b_ptr);