bearer.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. /*
  2. * net/tipc/bearer.c: TIPC bearer code
  3. *
  4. * Copyright (c) 1996-2006, Ericsson AB
  5. * Copyright (c) 2004-2006, 2010-2011, Wind River Systems
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the distribution.
  16. * 3. Neither the names of the copyright holders nor the names of its
  17. * contributors may be used to endorse or promote products derived from
  18. * this software without specific prior written permission.
  19. *
  20. * Alternatively, this software may be distributed under the terms of the
  21. * GNU General Public License ("GPL") version 2 as published by the Free
  22. * Software Foundation.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  27. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  28. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  29. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  30. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  31. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  32. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  33. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  34. * POSSIBILITY OF SUCH DAMAGE.
  35. */
  36. #include "core.h"
  37. #include "config.h"
  38. #include "bearer.h"
  39. #include "discover.h"
  40. #define MAX_ADDR_STR 32
  41. static struct tipc_media *media_list[MAX_MEDIA];
  42. static u32 media_count;
  43. struct tipc_bearer tipc_bearers[MAX_BEARERS];
  44. static void bearer_disable(struct tipc_bearer *b_ptr);
  45. /**
  46. * media_name_valid - validate media name
  47. *
  48. * Returns 1 if media name is valid, otherwise 0.
  49. */
  50. static int media_name_valid(const char *name)
  51. {
  52. u32 len;
  53. len = strlen(name);
  54. if ((len + 1) > TIPC_MAX_MEDIA_NAME)
  55. return 0;
  56. return strspn(name, tipc_alphabet) == len;
  57. }
  58. /**
  59. * tipc_media_find - locates specified media object by name
  60. */
  61. struct tipc_media *tipc_media_find(const char *name)
  62. {
  63. u32 i;
  64. for (i = 0; i < media_count; i++) {
  65. if (!strcmp(media_list[i]->name, name))
  66. return media_list[i];
  67. }
  68. return NULL;
  69. }
  70. /**
  71. * media_find_id - locates specified media object by type identifier
  72. */
  73. static struct tipc_media *media_find_id(u8 type)
  74. {
  75. u32 i;
  76. for (i = 0; i < media_count; i++) {
  77. if (media_list[i]->type_id == type)
  78. return media_list[i];
  79. }
  80. return NULL;
  81. }
  82. /**
  83. * tipc_register_media - register a media type
  84. *
  85. * Bearers for this media type must be activated separately at a later stage.
  86. */
  87. int tipc_register_media(struct tipc_media *m_ptr)
  88. {
  89. int res = -EINVAL;
  90. write_lock_bh(&tipc_net_lock);
  91. if (!media_name_valid(m_ptr->name))
  92. goto exit;
  93. if ((m_ptr->bcast_addr.media_id != m_ptr->type_id) ||
  94. !m_ptr->bcast_addr.broadcast)
  95. goto exit;
  96. if (m_ptr->priority > TIPC_MAX_LINK_PRI)
  97. goto exit;
  98. if ((m_ptr->tolerance < TIPC_MIN_LINK_TOL) ||
  99. (m_ptr->tolerance > TIPC_MAX_LINK_TOL))
  100. goto exit;
  101. if (media_count >= MAX_MEDIA)
  102. goto exit;
  103. if (tipc_media_find(m_ptr->name) || media_find_id(m_ptr->type_id))
  104. goto exit;
  105. media_list[media_count] = m_ptr;
  106. media_count++;
  107. res = 0;
  108. exit:
  109. write_unlock_bh(&tipc_net_lock);
  110. if (res)
  111. pr_warn("Media <%s> registration error\n", m_ptr->name);
  112. return res;
  113. }
  114. /**
  115. * tipc_media_addr_printf - record media address in print buffer
  116. */
  117. void tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a)
  118. {
  119. char addr_str[MAX_ADDR_STR];
  120. struct tipc_media *m_ptr;
  121. int ret;
  122. m_ptr = media_find_id(a->media_id);
  123. if (m_ptr && !m_ptr->addr2str(a, addr_str, sizeof(addr_str)))
  124. ret = tipc_snprintf(buf, len, "%s(%s)", m_ptr->name, addr_str);
  125. else {
  126. u32 i;
  127. ret = tipc_snprintf(buf, len, "UNKNOWN(%u)", a->media_id);
  128. for (i = 0; i < sizeof(a->value); i++)
  129. ret += tipc_snprintf(buf - ret, len + ret,
  130. "-%02x", a->value[i]);
  131. }
  132. }
  133. /**
  134. * tipc_media_get_names - record names of registered media in buffer
  135. */
  136. struct sk_buff *tipc_media_get_names(void)
  137. {
  138. struct sk_buff *buf;
  139. int i;
  140. buf = tipc_cfg_reply_alloc(MAX_MEDIA * TLV_SPACE(TIPC_MAX_MEDIA_NAME));
  141. if (!buf)
  142. return NULL;
  143. read_lock_bh(&tipc_net_lock);
  144. for (i = 0; i < media_count; i++) {
  145. tipc_cfg_append_tlv(buf, TIPC_TLV_MEDIA_NAME,
  146. media_list[i]->name,
  147. strlen(media_list[i]->name) + 1);
  148. }
  149. read_unlock_bh(&tipc_net_lock);
  150. return buf;
  151. }
  152. /**
  153. * bearer_name_validate - validate & (optionally) deconstruct bearer name
  154. * @name: ptr to bearer name string
  155. * @name_parts: ptr to area for bearer name components (or NULL if not needed)
  156. *
  157. * Returns 1 if bearer name is valid, otherwise 0.
  158. */
  159. static int bearer_name_validate(const char *name,
  160. struct tipc_bearer_names *name_parts)
  161. {
  162. char name_copy[TIPC_MAX_BEARER_NAME];
  163. char *media_name;
  164. char *if_name;
  165. u32 media_len;
  166. u32 if_len;
  167. /* copy bearer name & ensure length is OK */
  168. name_copy[TIPC_MAX_BEARER_NAME - 1] = 0;
  169. /* need above in case non-Posix strncpy() doesn't pad with nulls */
  170. strncpy(name_copy, name, TIPC_MAX_BEARER_NAME);
  171. if (name_copy[TIPC_MAX_BEARER_NAME - 1] != 0)
  172. return 0;
  173. /* ensure all component parts of bearer name are present */
  174. media_name = name_copy;
  175. if_name = strchr(media_name, ':');
  176. if (if_name == NULL)
  177. return 0;
  178. *(if_name++) = 0;
  179. media_len = if_name - media_name;
  180. if_len = strlen(if_name) + 1;
  181. /* validate component parts of bearer name */
  182. if ((media_len <= 1) || (media_len > TIPC_MAX_MEDIA_NAME) ||
  183. (if_len <= 1) || (if_len > TIPC_MAX_IF_NAME) ||
  184. (strspn(media_name, tipc_alphabet) != (media_len - 1)) ||
  185. (strspn(if_name, tipc_alphabet) != (if_len - 1)))
  186. return 0;
  187. /* return bearer name components, if necessary */
  188. if (name_parts) {
  189. strcpy(name_parts->media_name, media_name);
  190. strcpy(name_parts->if_name, if_name);
  191. }
  192. return 1;
  193. }
  194. /**
  195. * tipc_bearer_find - locates bearer object with matching bearer name
  196. */
  197. struct tipc_bearer *tipc_bearer_find(const char *name)
  198. {
  199. struct tipc_bearer *b_ptr;
  200. u32 i;
  201. for (i = 0, b_ptr = tipc_bearers; i < MAX_BEARERS; i++, b_ptr++) {
  202. if (b_ptr->active && (!strcmp(b_ptr->name, name)))
  203. return b_ptr;
  204. }
  205. return NULL;
  206. }
  207. /**
  208. * tipc_bearer_find_interface - locates bearer object with matching interface name
  209. */
  210. struct tipc_bearer *tipc_bearer_find_interface(const char *if_name)
  211. {
  212. struct tipc_bearer *b_ptr;
  213. char *b_if_name;
  214. u32 i;
  215. for (i = 0, b_ptr = tipc_bearers; i < MAX_BEARERS; i++, b_ptr++) {
  216. if (!b_ptr->active)
  217. continue;
  218. b_if_name = strchr(b_ptr->name, ':') + 1;
  219. if (!strcmp(b_if_name, if_name))
  220. return b_ptr;
  221. }
  222. return NULL;
  223. }
  224. /**
  225. * tipc_bearer_get_names - record names of bearers in buffer
  226. */
  227. struct sk_buff *tipc_bearer_get_names(void)
  228. {
  229. struct sk_buff *buf;
  230. struct tipc_bearer *b_ptr;
  231. int i, j;
  232. buf = tipc_cfg_reply_alloc(MAX_BEARERS * TLV_SPACE(TIPC_MAX_BEARER_NAME));
  233. if (!buf)
  234. return NULL;
  235. read_lock_bh(&tipc_net_lock);
  236. for (i = 0; i < media_count; i++) {
  237. for (j = 0; j < MAX_BEARERS; j++) {
  238. b_ptr = &tipc_bearers[j];
  239. if (b_ptr->active && (b_ptr->media == media_list[i])) {
  240. tipc_cfg_append_tlv(buf, TIPC_TLV_BEARER_NAME,
  241. b_ptr->name,
  242. strlen(b_ptr->name) + 1);
  243. }
  244. }
  245. }
  246. read_unlock_bh(&tipc_net_lock);
  247. return buf;
  248. }
  249. void tipc_bearer_add_dest(struct tipc_bearer *b_ptr, u32 dest)
  250. {
  251. tipc_nmap_add(&b_ptr->nodes, dest);
  252. tipc_bcbearer_sort();
  253. tipc_disc_add_dest(b_ptr->link_req);
  254. }
  255. void tipc_bearer_remove_dest(struct tipc_bearer *b_ptr, u32 dest)
  256. {
  257. tipc_nmap_remove(&b_ptr->nodes, dest);
  258. tipc_bcbearer_sort();
  259. tipc_disc_remove_dest(b_ptr->link_req);
  260. }
  261. /*
  262. * bearer_push(): Resolve bearer congestion. Force the waiting
  263. * links to push out their unsent packets, one packet per link
  264. * per iteration, until all packets are gone or congestion reoccurs.
  265. * 'tipc_net_lock' is read_locked when this function is called
  266. * bearer.lock must be taken before calling
  267. * Returns binary true(1) ore false(0)
  268. */
  269. static int bearer_push(struct tipc_bearer *b_ptr)
  270. {
  271. u32 res = 0;
  272. struct tipc_link *ln, *tln;
  273. if (b_ptr->blocked)
  274. return 0;
  275. while (!list_empty(&b_ptr->cong_links) && (res != PUSH_FAILED)) {
  276. list_for_each_entry_safe(ln, tln, &b_ptr->cong_links, link_list) {
  277. res = tipc_link_push_packet(ln);
  278. if (res == PUSH_FAILED)
  279. break;
  280. if (res == PUSH_FINISHED)
  281. list_move_tail(&ln->link_list, &b_ptr->links);
  282. }
  283. }
  284. return list_empty(&b_ptr->cong_links);
  285. }
  286. void tipc_bearer_lock_push(struct tipc_bearer *b_ptr)
  287. {
  288. spin_lock_bh(&b_ptr->lock);
  289. bearer_push(b_ptr);
  290. spin_unlock_bh(&b_ptr->lock);
  291. }
  292. /*
  293. * Interrupt enabling new requests after bearer congestion or blocking:
  294. * See bearer_send().
  295. */
  296. void tipc_continue(struct tipc_bearer *b_ptr)
  297. {
  298. spin_lock_bh(&b_ptr->lock);
  299. if (!list_empty(&b_ptr->cong_links))
  300. tipc_k_signal((Handler)tipc_bearer_lock_push, (unsigned long)b_ptr);
  301. b_ptr->blocked = 0;
  302. spin_unlock_bh(&b_ptr->lock);
  303. }
  304. /*
  305. * Schedule link for sending of messages after the bearer
  306. * has been deblocked by 'continue()'. This method is called
  307. * when somebody tries to send a message via this link while
  308. * the bearer is congested. 'tipc_net_lock' is in read_lock here
  309. * bearer.lock is busy
  310. */
  311. static void tipc_bearer_schedule_unlocked(struct tipc_bearer *b_ptr,
  312. struct tipc_link *l_ptr)
  313. {
  314. list_move_tail(&l_ptr->link_list, &b_ptr->cong_links);
  315. }
  316. /*
  317. * Schedule link for sending of messages after the bearer
  318. * has been deblocked by 'continue()'. This method is called
  319. * when somebody tries to send a message via this link while
  320. * the bearer is congested. 'tipc_net_lock' is in read_lock here,
  321. * bearer.lock is free
  322. */
  323. void tipc_bearer_schedule(struct tipc_bearer *b_ptr, struct tipc_link *l_ptr)
  324. {
  325. spin_lock_bh(&b_ptr->lock);
  326. tipc_bearer_schedule_unlocked(b_ptr, l_ptr);
  327. spin_unlock_bh(&b_ptr->lock);
  328. }
  329. /*
  330. * tipc_bearer_resolve_congestion(): Check if there is bearer congestion,
  331. * and if there is, try to resolve it before returning.
  332. * 'tipc_net_lock' is read_locked when this function is called
  333. */
  334. int tipc_bearer_resolve_congestion(struct tipc_bearer *b_ptr,
  335. struct tipc_link *l_ptr)
  336. {
  337. int res = 1;
  338. if (list_empty(&b_ptr->cong_links))
  339. return 1;
  340. spin_lock_bh(&b_ptr->lock);
  341. if (!bearer_push(b_ptr)) {
  342. tipc_bearer_schedule_unlocked(b_ptr, l_ptr);
  343. res = 0;
  344. }
  345. spin_unlock_bh(&b_ptr->lock);
  346. return res;
  347. }
  348. /**
  349. * tipc_bearer_congested - determines if bearer is currently congested
  350. */
  351. int tipc_bearer_congested(struct tipc_bearer *b_ptr, struct tipc_link *l_ptr)
  352. {
  353. if (unlikely(b_ptr->blocked))
  354. return 1;
  355. if (likely(list_empty(&b_ptr->cong_links)))
  356. return 0;
  357. return !tipc_bearer_resolve_congestion(b_ptr, l_ptr);
  358. }
  359. /**
  360. * tipc_enable_bearer - enable bearer with the given name
  361. */
  362. int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
  363. {
  364. struct tipc_bearer *b_ptr;
  365. struct tipc_media *m_ptr;
  366. struct tipc_bearer_names b_names;
  367. char addr_string[16];
  368. u32 bearer_id;
  369. u32 with_this_prio;
  370. u32 i;
  371. int res = -EINVAL;
  372. if (!tipc_own_addr) {
  373. pr_warn("Bearer <%s> rejected, not supported in standalone mode\n",
  374. name);
  375. return -ENOPROTOOPT;
  376. }
  377. if (!bearer_name_validate(name, &b_names)) {
  378. pr_warn("Bearer <%s> rejected, illegal name\n", name);
  379. return -EINVAL;
  380. }
  381. if (tipc_addr_domain_valid(disc_domain) &&
  382. (disc_domain != tipc_own_addr)) {
  383. if (tipc_in_scope(disc_domain, tipc_own_addr)) {
  384. disc_domain = tipc_own_addr & TIPC_CLUSTER_MASK;
  385. res = 0; /* accept any node in own cluster */
  386. } else if (in_own_cluster_exact(disc_domain))
  387. res = 0; /* accept specified node in own cluster */
  388. }
  389. if (res) {
  390. pr_warn("Bearer <%s> rejected, illegal discovery domain\n",
  391. name);
  392. return -EINVAL;
  393. }
  394. if ((priority > TIPC_MAX_LINK_PRI) &&
  395. (priority != TIPC_MEDIA_LINK_PRI)) {
  396. pr_warn("Bearer <%s> rejected, illegal priority\n", name);
  397. return -EINVAL;
  398. }
  399. write_lock_bh(&tipc_net_lock);
  400. m_ptr = tipc_media_find(b_names.media_name);
  401. if (!m_ptr) {
  402. pr_warn("Bearer <%s> rejected, media <%s> not registered\n",
  403. name, b_names.media_name);
  404. goto exit;
  405. }
  406. if (priority == TIPC_MEDIA_LINK_PRI)
  407. priority = m_ptr->priority;
  408. restart:
  409. bearer_id = MAX_BEARERS;
  410. with_this_prio = 1;
  411. for (i = MAX_BEARERS; i-- != 0; ) {
  412. if (!tipc_bearers[i].active) {
  413. bearer_id = i;
  414. continue;
  415. }
  416. if (!strcmp(name, tipc_bearers[i].name)) {
  417. pr_warn("Bearer <%s> rejected, already enabled\n",
  418. name);
  419. goto exit;
  420. }
  421. if ((tipc_bearers[i].priority == priority) &&
  422. (++with_this_prio > 2)) {
  423. if (priority-- == 0) {
  424. pr_warn("Bearer <%s> rejected, duplicate priority\n",
  425. name);
  426. goto exit;
  427. }
  428. pr_warn("Bearer <%s> priority adjustment required %u->%u\n",
  429. name, priority + 1, priority);
  430. goto restart;
  431. }
  432. }
  433. if (bearer_id >= MAX_BEARERS) {
  434. pr_warn("Bearer <%s> rejected, bearer limit reached (%u)\n",
  435. name, MAX_BEARERS);
  436. goto exit;
  437. }
  438. b_ptr = &tipc_bearers[bearer_id];
  439. strcpy(b_ptr->name, name);
  440. res = m_ptr->enable_bearer(b_ptr);
  441. if (res) {
  442. pr_warn("Bearer <%s> rejected, enable failure (%d)\n",
  443. name, -res);
  444. goto exit;
  445. }
  446. b_ptr->identity = bearer_id;
  447. b_ptr->media = m_ptr;
  448. b_ptr->tolerance = m_ptr->tolerance;
  449. b_ptr->window = m_ptr->window;
  450. b_ptr->net_plane = bearer_id + 'A';
  451. b_ptr->active = 1;
  452. b_ptr->priority = priority;
  453. INIT_LIST_HEAD(&b_ptr->cong_links);
  454. INIT_LIST_HEAD(&b_ptr->links);
  455. spin_lock_init(&b_ptr->lock);
  456. res = tipc_disc_create(b_ptr, &m_ptr->bcast_addr, disc_domain);
  457. if (res) {
  458. bearer_disable(b_ptr);
  459. pr_warn("Bearer <%s> rejected, discovery object creation failed\n",
  460. name);
  461. goto exit;
  462. }
  463. pr_info("Enabled bearer <%s>, discovery domain %s, priority %u\n",
  464. name,
  465. tipc_addr_string_fill(addr_string, disc_domain), priority);
  466. exit:
  467. write_unlock_bh(&tipc_net_lock);
  468. return res;
  469. }
  470. /**
  471. * tipc_block_bearer - Block the bearer with the given name, and reset all its links
  472. */
  473. int tipc_block_bearer(const char *name)
  474. {
  475. struct tipc_bearer *b_ptr = NULL;
  476. struct tipc_link *l_ptr;
  477. struct tipc_link *temp_l_ptr;
  478. read_lock_bh(&tipc_net_lock);
  479. b_ptr = tipc_bearer_find(name);
  480. if (!b_ptr) {
  481. pr_warn("Attempt to block unknown bearer <%s>\n", name);
  482. read_unlock_bh(&tipc_net_lock);
  483. return -EINVAL;
  484. }
  485. pr_info("Blocking bearer <%s>\n", name);
  486. spin_lock_bh(&b_ptr->lock);
  487. b_ptr->blocked = 1;
  488. list_splice_init(&b_ptr->cong_links, &b_ptr->links);
  489. list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) {
  490. struct tipc_node *n_ptr = l_ptr->owner;
  491. spin_lock_bh(&n_ptr->lock);
  492. tipc_link_reset(l_ptr);
  493. spin_unlock_bh(&n_ptr->lock);
  494. }
  495. spin_unlock_bh(&b_ptr->lock);
  496. read_unlock_bh(&tipc_net_lock);
  497. return 0;
  498. }
  499. /**
  500. * bearer_disable
  501. *
  502. * Note: This routine assumes caller holds tipc_net_lock.
  503. */
  504. static void bearer_disable(struct tipc_bearer *b_ptr)
  505. {
  506. struct tipc_link *l_ptr;
  507. struct tipc_link *temp_l_ptr;
  508. pr_info("Disabling bearer <%s>\n", b_ptr->name);
  509. spin_lock_bh(&b_ptr->lock);
  510. b_ptr->blocked = 1;
  511. b_ptr->media->disable_bearer(b_ptr);
  512. list_splice_init(&b_ptr->cong_links, &b_ptr->links);
  513. list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) {
  514. tipc_link_delete(l_ptr);
  515. }
  516. if (b_ptr->link_req)
  517. tipc_disc_delete(b_ptr->link_req);
  518. spin_unlock_bh(&b_ptr->lock);
  519. memset(b_ptr, 0, sizeof(struct tipc_bearer));
  520. }
  521. int tipc_disable_bearer(const char *name)
  522. {
  523. struct tipc_bearer *b_ptr;
  524. int res;
  525. write_lock_bh(&tipc_net_lock);
  526. b_ptr = tipc_bearer_find(name);
  527. if (b_ptr == NULL) {
  528. pr_warn("Attempt to disable unknown bearer <%s>\n", name);
  529. res = -EINVAL;
  530. } else {
  531. bearer_disable(b_ptr);
  532. res = 0;
  533. }
  534. write_unlock_bh(&tipc_net_lock);
  535. return res;
  536. }
  537. void tipc_bearer_stop(void)
  538. {
  539. u32 i;
  540. for (i = 0; i < MAX_BEARERS; i++) {
  541. if (tipc_bearers[i].active)
  542. bearer_disable(&tipc_bearers[i]);
  543. }
  544. media_count = 0;
  545. }