diff options
Diffstat (limited to 'net/tipc/bearer.c')
| -rw-r--r-- | net/tipc/bearer.c | 69 |
1 files changed, 37 insertions, 32 deletions
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index a297e3a2e3e7..09e71241265d 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c | |||
| @@ -123,28 +123,30 @@ int tipc_register_media(struct tipc_media *m_ptr) | |||
| 123 | exit: | 123 | exit: |
| 124 | write_unlock_bh(&tipc_net_lock); | 124 | write_unlock_bh(&tipc_net_lock); |
| 125 | if (res) | 125 | if (res) |
| 126 | warn("Media <%s> registration error\n", m_ptr->name); | 126 | pr_warn("Media <%s> registration error\n", m_ptr->name); |
| 127 | return res; | 127 | return res; |
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | /** | 130 | /** |
| 131 | * tipc_media_addr_printf - record media address in print buffer | 131 | * tipc_media_addr_printf - record media address in print buffer |
| 132 | */ | 132 | */ |
| 133 | void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a) | 133 | void tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a) |
| 134 | { | 134 | { |
| 135 | char addr_str[MAX_ADDR_STR]; | 135 | char addr_str[MAX_ADDR_STR]; |
| 136 | struct tipc_media *m_ptr; | 136 | struct tipc_media *m_ptr; |
| 137 | int ret; | ||
| 137 | 138 | ||
| 138 | m_ptr = media_find_id(a->media_id); | 139 | m_ptr = media_find_id(a->media_id); |
| 139 | 140 | ||
| 140 | if (m_ptr && !m_ptr->addr2str(a, addr_str, sizeof(addr_str))) | 141 | if (m_ptr && !m_ptr->addr2str(a, addr_str, sizeof(addr_str))) |
| 141 | tipc_printf(pb, "%s(%s)", m_ptr->name, addr_str); | 142 | ret = tipc_snprintf(buf, len, "%s(%s)", m_ptr->name, addr_str); |
| 142 | else { | 143 | else { |
| 143 | u32 i; | 144 | u32 i; |
| 144 | 145 | ||
| 145 | tipc_printf(pb, "UNKNOWN(%u)", a->media_id); | 146 | ret = tipc_snprintf(buf, len, "UNKNOWN(%u)", a->media_id); |
| 146 | for (i = 0; i < sizeof(a->value); i++) | 147 | for (i = 0; i < sizeof(a->value); i++) |
| 147 | tipc_printf(pb, "-%02x", a->value[i]); | 148 | ret += tipc_snprintf(buf - ret, len + ret, |
| 149 | "-%02x", a->value[i]); | ||
| 148 | } | 150 | } |
| 149 | } | 151 | } |
| 150 | 152 | ||
| @@ -172,8 +174,8 @@ struct sk_buff *tipc_media_get_names(void) | |||
| 172 | 174 | ||
| 173 | /** | 175 | /** |
| 174 | * bearer_name_validate - validate & (optionally) deconstruct bearer name | 176 | * bearer_name_validate - validate & (optionally) deconstruct bearer name |
| 175 | * @name - ptr to bearer name string | 177 | * @name: ptr to bearer name string |
| 176 | * @name_parts - ptr to area for bearer name components (or NULL if not needed) | 178 | * @name_parts: ptr to area for bearer name components (or NULL if not needed) |
| 177 | * | 179 | * |
| 178 | * Returns 1 if bearer name is valid, otherwise 0. | 180 | * Returns 1 if bearer name is valid, otherwise 0. |
| 179 | */ | 181 | */ |
| @@ -418,12 +420,12 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority) | |||
| 418 | int res = -EINVAL; | 420 | int res = -EINVAL; |
| 419 | 421 | ||
| 420 | if (!tipc_own_addr) { | 422 | if (!tipc_own_addr) { |
| 421 | warn("Bearer <%s> rejected, not supported in standalone mode\n", | 423 | pr_warn("Bearer <%s> rejected, not supported in standalone mode\n", |
| 422 | name); | 424 | name); |
| 423 | return -ENOPROTOOPT; | 425 | return -ENOPROTOOPT; |
| 424 | } | 426 | } |
| 425 | if (!bearer_name_validate(name, &b_names)) { | 427 | if (!bearer_name_validate(name, &b_names)) { |
| 426 | warn("Bearer <%s> rejected, illegal name\n", name); | 428 | pr_warn("Bearer <%s> rejected, illegal name\n", name); |
| 427 | return -EINVAL; | 429 | return -EINVAL; |
| 428 | } | 430 | } |
| 429 | if (tipc_addr_domain_valid(disc_domain) && | 431 | if (tipc_addr_domain_valid(disc_domain) && |
| @@ -435,12 +437,13 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority) | |||
| 435 | res = 0; /* accept specified node in own cluster */ | 437 | res = 0; /* accept specified node in own cluster */ |
| 436 | } | 438 | } |
| 437 | if (res) { | 439 | if (res) { |
| 438 | warn("Bearer <%s> rejected, illegal discovery domain\n", name); | 440 | pr_warn("Bearer <%s> rejected, illegal discovery domain\n", |
| 441 | name); | ||
| 439 | return -EINVAL; | 442 | return -EINVAL; |
| 440 | } | 443 | } |
| 441 | if ((priority > TIPC_MAX_LINK_PRI) && | 444 | if ((priority > TIPC_MAX_LINK_PRI) && |
| 442 | (priority != TIPC_MEDIA_LINK_PRI)) { | 445 | (priority != TIPC_MEDIA_LINK_PRI)) { |
| 443 | warn("Bearer <%s> rejected, illegal priority\n", name); | 446 | pr_warn("Bearer <%s> rejected, illegal priority\n", name); |
| 444 | return -EINVAL; | 447 | return -EINVAL; |
| 445 | } | 448 | } |
| 446 | 449 | ||
| @@ -448,8 +451,8 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority) | |||
| 448 | 451 | ||
| 449 | m_ptr = tipc_media_find(b_names.media_name); | 452 | m_ptr = tipc_media_find(b_names.media_name); |
| 450 | if (!m_ptr) { | 453 | if (!m_ptr) { |
| 451 | warn("Bearer <%s> rejected, media <%s> not registered\n", name, | 454 | pr_warn("Bearer <%s> rejected, media <%s> not registered\n", |
| 452 | b_names.media_name); | 455 | name, b_names.media_name); |
| 453 | goto exit; | 456 | goto exit; |
| 454 | } | 457 | } |
| 455 | 458 | ||
| @@ -465,24 +468,25 @@ restart: | |||
| 465 | continue; | 468 | continue; |
| 466 | } | 469 | } |
| 467 | if (!strcmp(name, tipc_bearers[i].name)) { | 470 | if (!strcmp(name, tipc_bearers[i].name)) { |
| 468 | warn("Bearer <%s> rejected, already enabled\n", name); | 471 | pr_warn("Bearer <%s> rejected, already enabled\n", |
| 472 | name); | ||
| 469 | goto exit; | 473 | goto exit; |
| 470 | } | 474 | } |
| 471 | if ((tipc_bearers[i].priority == priority) && | 475 | if ((tipc_bearers[i].priority == priority) && |
| 472 | (++with_this_prio > 2)) { | 476 | (++with_this_prio > 2)) { |
| 473 | if (priority-- == 0) { | 477 | if (priority-- == 0) { |
| 474 | warn("Bearer <%s> rejected, duplicate priority\n", | 478 | pr_warn("Bearer <%s> rejected, duplicate priority\n", |
| 475 | name); | 479 | name); |
| 476 | goto exit; | 480 | goto exit; |
| 477 | } | 481 | } |
| 478 | warn("Bearer <%s> priority adjustment required %u->%u\n", | 482 | pr_warn("Bearer <%s> priority adjustment required %u->%u\n", |
| 479 | name, priority + 1, priority); | 483 | name, priority + 1, priority); |
| 480 | goto restart; | 484 | goto restart; |
| 481 | } | 485 | } |
| 482 | } | 486 | } |
| 483 | if (bearer_id >= MAX_BEARERS) { | 487 | if (bearer_id >= MAX_BEARERS) { |
| 484 | warn("Bearer <%s> rejected, bearer limit reached (%u)\n", | 488 | pr_warn("Bearer <%s> rejected, bearer limit reached (%u)\n", |
| 485 | name, MAX_BEARERS); | 489 | name, MAX_BEARERS); |
| 486 | goto exit; | 490 | goto exit; |
| 487 | } | 491 | } |
| 488 | 492 | ||
| @@ -490,7 +494,8 @@ restart: | |||
| 490 | strcpy(b_ptr->name, name); | 494 | strcpy(b_ptr->name, name); |
| 491 | res = m_ptr->enable_bearer(b_ptr); | 495 | res = m_ptr->enable_bearer(b_ptr); |
| 492 | if (res) { | 496 | if (res) { |
| 493 | warn("Bearer <%s> rejected, enable failure (%d)\n", name, -res); | 497 | pr_warn("Bearer <%s> rejected, enable failure (%d)\n", |
| 498 | name, -res); | ||
| 494 | goto exit; | 499 | goto exit; |
| 495 | } | 500 | } |
| 496 | 501 | ||
| @@ -508,20 +513,20 @@ restart: | |||
| 508 | res = tipc_disc_create(b_ptr, &m_ptr->bcast_addr, disc_domain); | 513 | res = tipc_disc_create(b_ptr, &m_ptr->bcast_addr, disc_domain); |
| 509 | if (res) { | 514 | if (res) { |
| 510 | bearer_disable(b_ptr); | 515 | bearer_disable(b_ptr); |
| 511 | warn("Bearer <%s> rejected, discovery object creation failed\n", | 516 | pr_warn("Bearer <%s> rejected, discovery object creation failed\n", |
| 512 | name); | 517 | name); |
| 513 | goto exit; | 518 | goto exit; |
| 514 | } | 519 | } |
| 515 | info("Enabled bearer <%s>, discovery domain %s, priority %u\n", | 520 | pr_info("Enabled bearer <%s>, discovery domain %s, priority %u\n", |
| 516 | name, tipc_addr_string_fill(addr_string, disc_domain), priority); | 521 | name, |
| 522 | tipc_addr_string_fill(addr_string, disc_domain), priority); | ||
| 517 | exit: | 523 | exit: |
| 518 | write_unlock_bh(&tipc_net_lock); | 524 | write_unlock_bh(&tipc_net_lock); |
| 519 | return res; | 525 | return res; |
| 520 | } | 526 | } |
| 521 | 527 | ||
| 522 | /** | 528 | /** |
| 523 | * tipc_block_bearer(): Block the bearer with the given name, | 529 | * tipc_block_bearer - Block the bearer with the given name, and reset all its links |
| 524 | * and reset all its links | ||
| 525 | */ | 530 | */ |
| 526 | int tipc_block_bearer(const char *name) | 531 | int tipc_block_bearer(const char *name) |
| 527 | { | 532 | { |
| @@ -532,12 +537,12 @@ int tipc_block_bearer(const char *name) | |||
| 532 | read_lock_bh(&tipc_net_lock); | 537 | read_lock_bh(&tipc_net_lock); |
| 533 | b_ptr = tipc_bearer_find(name); | 538 | b_ptr = tipc_bearer_find(name); |
| 534 | if (!b_ptr) { | 539 | if (!b_ptr) { |
| 535 | warn("Attempt to block unknown bearer <%s>\n", name); | 540 | pr_warn("Attempt to block unknown bearer <%s>\n", name); |
| 536 | read_unlock_bh(&tipc_net_lock); | 541 | read_unlock_bh(&tipc_net_lock); |
| 537 | return -EINVAL; | 542 | return -EINVAL; |
| 538 | } | 543 | } |
| 539 | 544 | ||
| 540 | info("Blocking bearer <%s>\n", name); | 545 | pr_info("Blocking bearer <%s>\n", name); |
| 541 | spin_lock_bh(&b_ptr->lock); | 546 | spin_lock_bh(&b_ptr->lock); |
| 542 | b_ptr->blocked = 1; | 547 | b_ptr->blocked = 1; |
| 543 | list_splice_init(&b_ptr->cong_links, &b_ptr->links); | 548 | list_splice_init(&b_ptr->cong_links, &b_ptr->links); |
| @@ -563,7 +568,7 @@ static void bearer_disable(struct tipc_bearer *b_ptr) | |||
| 563 | struct tipc_link *l_ptr; | 568 | struct tipc_link *l_ptr; |
| 564 | struct tipc_link *temp_l_ptr; | 569 | struct tipc_link *temp_l_ptr; |
| 565 | 570 | ||
| 566 | info("Disabling bearer <%s>\n", b_ptr->name); | 571 | pr_info("Disabling bearer <%s>\n", b_ptr->name); |
| 567 | spin_lock_bh(&b_ptr->lock); | 572 | spin_lock_bh(&b_ptr->lock); |
| 568 | b_ptr->blocked = 1; | 573 | b_ptr->blocked = 1; |
| 569 | b_ptr->media->disable_bearer(b_ptr); | 574 | b_ptr->media->disable_bearer(b_ptr); |
| @@ -585,7 +590,7 @@ int tipc_disable_bearer(const char *name) | |||
| 585 | write_lock_bh(&tipc_net_lock); | 590 | write_lock_bh(&tipc_net_lock); |
| 586 | b_ptr = tipc_bearer_find(name); | 591 | b_ptr = tipc_bearer_find(name); |
| 587 | if (b_ptr == NULL) { | 592 | if (b_ptr == NULL) { |
| 588 | warn("Attempt to disable unknown bearer <%s>\n", name); | 593 | pr_warn("Attempt to disable unknown bearer <%s>\n", name); |
| 589 | res = -EINVAL; | 594 | res = -EINVAL; |
| 590 | } else { | 595 | } else { |
| 591 | bearer_disable(b_ptr); | 596 | bearer_disable(b_ptr); |
