bearer.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. /*
  2. * net/tipc/bearer.c: TIPC bearer code
  3. *
  4. * Copyright (c) 1996-2006, 2013, Ericsson AB
  5. * Copyright (c) 2004-2006, 2010-2013, 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 60
  41. static struct tipc_media * const media_info_array[] = {
  42. &eth_media_info,
  43. #ifdef CONFIG_TIPC_MEDIA_IB
  44. &ib_media_info,
  45. #endif
  46. NULL
  47. };
  48. struct tipc_bearer __rcu *bearer_list[MAX_BEARERS + 1];
  49. static void bearer_disable(struct tipc_bearer *b_ptr, bool shutting_down);
  50. /**
  51. * tipc_media_find - locates specified media object by name
  52. */
  53. struct tipc_media *tipc_media_find(const char *name)
  54. {
  55. u32 i;
  56. for (i = 0; media_info_array[i] != NULL; i++) {
  57. if (!strcmp(media_info_array[i]->name, name))
  58. break;
  59. }
  60. return media_info_array[i];
  61. }
  62. /**
  63. * media_find_id - locates specified media object by type identifier
  64. */
  65. static struct tipc_media *media_find_id(u8 type)
  66. {
  67. u32 i;
  68. for (i = 0; media_info_array[i] != NULL; i++) {
  69. if (media_info_array[i]->type_id == type)
  70. break;
  71. }
  72. return media_info_array[i];
  73. }
  74. /**
  75. * tipc_media_addr_printf - record media address in print buffer
  76. */
  77. void tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a)
  78. {
  79. char addr_str[MAX_ADDR_STR];
  80. struct tipc_media *m_ptr;
  81. int ret;
  82. m_ptr = media_find_id(a->media_id);
  83. if (m_ptr && !m_ptr->addr2str(a, addr_str, sizeof(addr_str)))
  84. ret = tipc_snprintf(buf, len, "%s(%s)", m_ptr->name, addr_str);
  85. else {
  86. u32 i;
  87. ret = tipc_snprintf(buf, len, "UNKNOWN(%u)", a->media_id);
  88. for (i = 0; i < sizeof(a->value); i++)
  89. ret += tipc_snprintf(buf - ret, len + ret,
  90. "-%02x", a->value[i]);
  91. }
  92. }
  93. /**
  94. * tipc_media_get_names - record names of registered media in buffer
  95. */
  96. struct sk_buff *tipc_media_get_names(void)
  97. {
  98. struct sk_buff *buf;
  99. int i;
  100. buf = tipc_cfg_reply_alloc(MAX_MEDIA * TLV_SPACE(TIPC_MAX_MEDIA_NAME));
  101. if (!buf)
  102. return NULL;
  103. for (i = 0; media_info_array[i] != NULL; i++) {
  104. tipc_cfg_append_tlv(buf, TIPC_TLV_MEDIA_NAME,
  105. media_info_array[i]->name,
  106. strlen(media_info_array[i]->name) + 1);
  107. }
  108. return buf;
  109. }
  110. /**
  111. * bearer_name_validate - validate & (optionally) deconstruct bearer name
  112. * @name: ptr to bearer name string
  113. * @name_parts: ptr to area for bearer name components (or NULL if not needed)
  114. *
  115. * Returns 1 if bearer name is valid, otherwise 0.
  116. */
  117. static int bearer_name_validate(const char *name,
  118. struct tipc_bearer_names *name_parts)
  119. {
  120. char name_copy[TIPC_MAX_BEARER_NAME];
  121. char *media_name;
  122. char *if_name;
  123. u32 media_len;
  124. u32 if_len;
  125. /* copy bearer name & ensure length is OK */
  126. name_copy[TIPC_MAX_BEARER_NAME - 1] = 0;
  127. /* need above in case non-Posix strncpy() doesn't pad with nulls */
  128. strncpy(name_copy, name, TIPC_MAX_BEARER_NAME);
  129. if (name_copy[TIPC_MAX_BEARER_NAME - 1] != 0)
  130. return 0;
  131. /* ensure all component parts of bearer name are present */
  132. media_name = name_copy;
  133. if_name = strchr(media_name, ':');
  134. if (if_name == NULL)
  135. return 0;
  136. *(if_name++) = 0;
  137. media_len = if_name - media_name;
  138. if_len = strlen(if_name) + 1;
  139. /* validate component parts of bearer name */
  140. if ((media_len <= 1) || (media_len > TIPC_MAX_MEDIA_NAME) ||
  141. (if_len <= 1) || (if_len > TIPC_MAX_IF_NAME))
  142. return 0;
  143. /* return bearer name components, if necessary */
  144. if (name_parts) {
  145. strcpy(name_parts->media_name, media_name);
  146. strcpy(name_parts->if_name, if_name);
  147. }
  148. return 1;
  149. }
  150. /**
  151. * tipc_bearer_find - locates bearer object with matching bearer name
  152. */
  153. struct tipc_bearer *tipc_bearer_find(const char *name)
  154. {
  155. struct tipc_bearer *b_ptr;
  156. u32 i;
  157. for (i = 0; i < MAX_BEARERS; i++) {
  158. b_ptr = rtnl_dereference(bearer_list[i]);
  159. if (b_ptr && (!strcmp(b_ptr->name, name)))
  160. return b_ptr;
  161. }
  162. return NULL;
  163. }
  164. /**
  165. * tipc_bearer_get_names - record names of bearers in buffer
  166. */
  167. struct sk_buff *tipc_bearer_get_names(void)
  168. {
  169. struct sk_buff *buf;
  170. struct tipc_bearer *b;
  171. int i, j;
  172. buf = tipc_cfg_reply_alloc(MAX_BEARERS * TLV_SPACE(TIPC_MAX_BEARER_NAME));
  173. if (!buf)
  174. return NULL;
  175. for (i = 0; media_info_array[i] != NULL; i++) {
  176. for (j = 0; j < MAX_BEARERS; j++) {
  177. b = rtnl_dereference(bearer_list[j]);
  178. if (!b)
  179. continue;
  180. if (b->media == media_info_array[i]) {
  181. tipc_cfg_append_tlv(buf, TIPC_TLV_BEARER_NAME,
  182. b->name,
  183. strlen(b->name) + 1);
  184. }
  185. }
  186. }
  187. return buf;
  188. }
  189. void tipc_bearer_add_dest(u32 bearer_id, u32 dest)
  190. {
  191. struct tipc_bearer *b_ptr;
  192. rcu_read_lock();
  193. b_ptr = rcu_dereference_rtnl(bearer_list[bearer_id]);
  194. if (b_ptr) {
  195. tipc_bcbearer_sort(&b_ptr->nodes, dest, true);
  196. tipc_disc_add_dest(b_ptr->link_req);
  197. }
  198. rcu_read_unlock();
  199. }
  200. void tipc_bearer_remove_dest(u32 bearer_id, u32 dest)
  201. {
  202. struct tipc_bearer *b_ptr;
  203. rcu_read_lock();
  204. b_ptr = rcu_dereference_rtnl(bearer_list[bearer_id]);
  205. if (b_ptr) {
  206. tipc_bcbearer_sort(&b_ptr->nodes, dest, false);
  207. tipc_disc_remove_dest(b_ptr->link_req);
  208. }
  209. rcu_read_unlock();
  210. }
  211. /**
  212. * tipc_enable_bearer - enable bearer with the given name
  213. */
  214. int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
  215. {
  216. struct tipc_bearer *b_ptr;
  217. struct tipc_media *m_ptr;
  218. struct tipc_bearer_names b_names;
  219. char addr_string[16];
  220. u32 bearer_id;
  221. u32 with_this_prio;
  222. u32 i;
  223. int res = -EINVAL;
  224. if (!tipc_own_addr) {
  225. pr_warn("Bearer <%s> rejected, not supported in standalone mode\n",
  226. name);
  227. return -ENOPROTOOPT;
  228. }
  229. if (!bearer_name_validate(name, &b_names)) {
  230. pr_warn("Bearer <%s> rejected, illegal name\n", name);
  231. return -EINVAL;
  232. }
  233. if (tipc_addr_domain_valid(disc_domain) &&
  234. (disc_domain != tipc_own_addr)) {
  235. if (tipc_in_scope(disc_domain, tipc_own_addr)) {
  236. disc_domain = tipc_own_addr & TIPC_CLUSTER_MASK;
  237. res = 0; /* accept any node in own cluster */
  238. } else if (in_own_cluster_exact(disc_domain))
  239. res = 0; /* accept specified node in own cluster */
  240. }
  241. if (res) {
  242. pr_warn("Bearer <%s> rejected, illegal discovery domain\n",
  243. name);
  244. return -EINVAL;
  245. }
  246. if ((priority > TIPC_MAX_LINK_PRI) &&
  247. (priority != TIPC_MEDIA_LINK_PRI)) {
  248. pr_warn("Bearer <%s> rejected, illegal priority\n", name);
  249. return -EINVAL;
  250. }
  251. m_ptr = tipc_media_find(b_names.media_name);
  252. if (!m_ptr) {
  253. pr_warn("Bearer <%s> rejected, media <%s> not registered\n",
  254. name, b_names.media_name);
  255. return -EINVAL;
  256. }
  257. if (priority == TIPC_MEDIA_LINK_PRI)
  258. priority = m_ptr->priority;
  259. restart:
  260. bearer_id = MAX_BEARERS;
  261. with_this_prio = 1;
  262. for (i = MAX_BEARERS; i-- != 0; ) {
  263. b_ptr = rtnl_dereference(bearer_list[i]);
  264. if (!b_ptr) {
  265. bearer_id = i;
  266. continue;
  267. }
  268. if (!strcmp(name, b_ptr->name)) {
  269. pr_warn("Bearer <%s> rejected, already enabled\n",
  270. name);
  271. return -EINVAL;
  272. }
  273. if ((b_ptr->priority == priority) &&
  274. (++with_this_prio > 2)) {
  275. if (priority-- == 0) {
  276. pr_warn("Bearer <%s> rejected, duplicate priority\n",
  277. name);
  278. return -EINVAL;
  279. }
  280. pr_warn("Bearer <%s> priority adjustment required %u->%u\n",
  281. name, priority + 1, priority);
  282. goto restart;
  283. }
  284. }
  285. if (bearer_id >= MAX_BEARERS) {
  286. pr_warn("Bearer <%s> rejected, bearer limit reached (%u)\n",
  287. name, MAX_BEARERS);
  288. return -EINVAL;
  289. }
  290. b_ptr = kzalloc(sizeof(*b_ptr), GFP_ATOMIC);
  291. if (!b_ptr)
  292. return -ENOMEM;
  293. strcpy(b_ptr->name, name);
  294. b_ptr->media = m_ptr;
  295. res = m_ptr->enable_media(b_ptr);
  296. if (res) {
  297. pr_warn("Bearer <%s> rejected, enable failure (%d)\n",
  298. name, -res);
  299. return -EINVAL;
  300. }
  301. b_ptr->identity = bearer_id;
  302. b_ptr->tolerance = m_ptr->tolerance;
  303. b_ptr->window = m_ptr->window;
  304. b_ptr->domain = disc_domain;
  305. b_ptr->net_plane = bearer_id + 'A';
  306. b_ptr->priority = priority;
  307. res = tipc_disc_create(b_ptr, &b_ptr->bcast_addr);
  308. if (res) {
  309. bearer_disable(b_ptr, false);
  310. pr_warn("Bearer <%s> rejected, discovery object creation failed\n",
  311. name);
  312. return -EINVAL;
  313. }
  314. rcu_assign_pointer(bearer_list[bearer_id], b_ptr);
  315. pr_info("Enabled bearer <%s>, discovery domain %s, priority %u\n",
  316. name,
  317. tipc_addr_string_fill(addr_string, disc_domain), priority);
  318. return res;
  319. }
  320. /**
  321. * tipc_reset_bearer - Reset all links established over this bearer
  322. */
  323. static int tipc_reset_bearer(struct tipc_bearer *b_ptr)
  324. {
  325. pr_info("Resetting bearer <%s>\n", b_ptr->name);
  326. tipc_link_reset_list(b_ptr->identity);
  327. tipc_disc_reset(b_ptr);
  328. return 0;
  329. }
  330. /**
  331. * bearer_disable
  332. *
  333. * Note: This routine assumes caller holds RTNL lock.
  334. */
  335. static void bearer_disable(struct tipc_bearer *b_ptr, bool shutting_down)
  336. {
  337. u32 i;
  338. pr_info("Disabling bearer <%s>\n", b_ptr->name);
  339. b_ptr->media->disable_media(b_ptr);
  340. tipc_link_delete_list(b_ptr->identity, shutting_down);
  341. if (b_ptr->link_req)
  342. tipc_disc_delete(b_ptr->link_req);
  343. for (i = 0; i < MAX_BEARERS; i++) {
  344. if (b_ptr == rtnl_dereference(bearer_list[i])) {
  345. RCU_INIT_POINTER(bearer_list[i], NULL);
  346. break;
  347. }
  348. }
  349. kfree_rcu(b_ptr, rcu);
  350. }
  351. int tipc_disable_bearer(const char *name)
  352. {
  353. struct tipc_bearer *b_ptr;
  354. int res;
  355. b_ptr = tipc_bearer_find(name);
  356. if (b_ptr == NULL) {
  357. pr_warn("Attempt to disable unknown bearer <%s>\n", name);
  358. res = -EINVAL;
  359. } else {
  360. bearer_disable(b_ptr, false);
  361. res = 0;
  362. }
  363. return res;
  364. }
  365. int tipc_enable_l2_media(struct tipc_bearer *b)
  366. {
  367. struct net_device *dev;
  368. char *driver_name = strchr((const char *)b->name, ':') + 1;
  369. /* Find device with specified name */
  370. dev = dev_get_by_name(&init_net, driver_name);
  371. if (!dev)
  372. return -ENODEV;
  373. /* Associate TIPC bearer with L2 bearer */
  374. rcu_assign_pointer(b->media_ptr, dev);
  375. memset(&b->bcast_addr, 0, sizeof(b->bcast_addr));
  376. memcpy(b->bcast_addr.value, dev->broadcast, b->media->hwaddr_len);
  377. b->bcast_addr.media_id = b->media->type_id;
  378. b->bcast_addr.broadcast = 1;
  379. b->mtu = dev->mtu;
  380. b->media->raw2addr(b, &b->addr, (char *)dev->dev_addr);
  381. rcu_assign_pointer(dev->tipc_ptr, b);
  382. return 0;
  383. }
  384. /* tipc_disable_l2_media - detach TIPC bearer from an L2 interface
  385. *
  386. * Mark L2 bearer as inactive so that incoming buffers are thrown away,
  387. * then get worker thread to complete bearer cleanup. (Can't do cleanup
  388. * here because cleanup code needs to sleep and caller holds spinlocks.)
  389. */
  390. void tipc_disable_l2_media(struct tipc_bearer *b)
  391. {
  392. struct net_device *dev;
  393. dev = (struct net_device *)rtnl_dereference(b->media_ptr);
  394. RCU_INIT_POINTER(b->media_ptr, NULL);
  395. RCU_INIT_POINTER(dev->tipc_ptr, NULL);
  396. synchronize_net();
  397. dev_put(dev);
  398. }
  399. /**
  400. * tipc_l2_send_msg - send a TIPC packet out over an L2 interface
  401. * @buf: the packet to be sent
  402. * @b_ptr: the bearer through which the packet is to be sent
  403. * @dest: peer destination address
  404. */
  405. int tipc_l2_send_msg(struct sk_buff *buf, struct tipc_bearer *b,
  406. struct tipc_media_addr *dest)
  407. {
  408. struct sk_buff *clone;
  409. struct net_device *dev;
  410. int delta;
  411. dev = (struct net_device *)rcu_dereference_rtnl(b->media_ptr);
  412. if (!dev)
  413. return 0;
  414. clone = skb_clone(buf, GFP_ATOMIC);
  415. if (!clone)
  416. return 0;
  417. delta = dev->hard_header_len - skb_headroom(buf);
  418. if ((delta > 0) &&
  419. pskb_expand_head(clone, SKB_DATA_ALIGN(delta), 0, GFP_ATOMIC)) {
  420. kfree_skb(clone);
  421. return 0;
  422. }
  423. skb_reset_network_header(clone);
  424. clone->dev = dev;
  425. clone->protocol = htons(ETH_P_TIPC);
  426. dev_hard_header(clone, dev, ETH_P_TIPC, dest->value,
  427. dev->dev_addr, clone->len);
  428. dev_queue_xmit(clone);
  429. return 0;
  430. }
  431. /* tipc_bearer_send- sends buffer to destination over bearer
  432. *
  433. * IMPORTANT:
  434. * The media send routine must not alter the buffer being passed in
  435. * as it may be needed for later retransmission!
  436. */
  437. void tipc_bearer_send(u32 bearer_id, struct sk_buff *buf,
  438. struct tipc_media_addr *dest)
  439. {
  440. struct tipc_bearer *b_ptr;
  441. rcu_read_lock();
  442. b_ptr = rcu_dereference_rtnl(bearer_list[bearer_id]);
  443. if (likely(b_ptr))
  444. b_ptr->media->send_msg(buf, b_ptr, dest);
  445. rcu_read_unlock();
  446. }
  447. /**
  448. * tipc_l2_rcv_msg - handle incoming TIPC message from an interface
  449. * @buf: the received packet
  450. * @dev: the net device that the packet was received on
  451. * @pt: the packet_type structure which was used to register this handler
  452. * @orig_dev: the original receive net device in case the device is a bond
  453. *
  454. * Accept only packets explicitly sent to this node, or broadcast packets;
  455. * ignores packets sent using interface multicast, and traffic sent to other
  456. * nodes (which can happen if interface is running in promiscuous mode).
  457. */
  458. static int tipc_l2_rcv_msg(struct sk_buff *buf, struct net_device *dev,
  459. struct packet_type *pt, struct net_device *orig_dev)
  460. {
  461. struct tipc_bearer *b_ptr;
  462. if (!net_eq(dev_net(dev), &init_net)) {
  463. kfree_skb(buf);
  464. return NET_RX_DROP;
  465. }
  466. rcu_read_lock();
  467. b_ptr = rcu_dereference_rtnl(dev->tipc_ptr);
  468. if (likely(b_ptr)) {
  469. if (likely(buf->pkt_type <= PACKET_BROADCAST)) {
  470. buf->next = NULL;
  471. tipc_rcv(buf, b_ptr);
  472. rcu_read_unlock();
  473. return NET_RX_SUCCESS;
  474. }
  475. }
  476. rcu_read_unlock();
  477. kfree_skb(buf);
  478. return NET_RX_DROP;
  479. }
  480. /**
  481. * tipc_l2_device_event - handle device events from network device
  482. * @nb: the context of the notification
  483. * @evt: the type of event
  484. * @ptr: the net device that the event was on
  485. *
  486. * This function is called by the Ethernet driver in case of link
  487. * change event.
  488. */
  489. static int tipc_l2_device_event(struct notifier_block *nb, unsigned long evt,
  490. void *ptr)
  491. {
  492. struct tipc_bearer *b_ptr;
  493. struct net_device *dev = netdev_notifier_info_to_dev(ptr);
  494. if (!net_eq(dev_net(dev), &init_net))
  495. return NOTIFY_DONE;
  496. b_ptr = rtnl_dereference(dev->tipc_ptr);
  497. if (!b_ptr)
  498. return NOTIFY_DONE;
  499. b_ptr->mtu = dev->mtu;
  500. switch (evt) {
  501. case NETDEV_CHANGE:
  502. if (netif_carrier_ok(dev))
  503. break;
  504. case NETDEV_DOWN:
  505. case NETDEV_CHANGEMTU:
  506. tipc_reset_bearer(b_ptr);
  507. break;
  508. case NETDEV_CHANGEADDR:
  509. b_ptr->media->raw2addr(b_ptr, &b_ptr->addr,
  510. (char *)dev->dev_addr);
  511. tipc_reset_bearer(b_ptr);
  512. break;
  513. case NETDEV_UNREGISTER:
  514. case NETDEV_CHANGENAME:
  515. bearer_disable(b_ptr, false);
  516. break;
  517. }
  518. return NOTIFY_OK;
  519. }
  520. static struct packet_type tipc_packet_type __read_mostly = {
  521. .type = htons(ETH_P_TIPC),
  522. .func = tipc_l2_rcv_msg,
  523. };
  524. static struct notifier_block notifier = {
  525. .notifier_call = tipc_l2_device_event,
  526. .priority = 0,
  527. };
  528. int tipc_bearer_setup(void)
  529. {
  530. int err;
  531. err = register_netdevice_notifier(&notifier);
  532. if (err)
  533. return err;
  534. dev_add_pack(&tipc_packet_type);
  535. return 0;
  536. }
  537. void tipc_bearer_cleanup(void)
  538. {
  539. unregister_netdevice_notifier(&notifier);
  540. dev_remove_pack(&tipc_packet_type);
  541. }
  542. void tipc_bearer_stop(void)
  543. {
  544. struct tipc_bearer *b_ptr;
  545. u32 i;
  546. for (i = 0; i < MAX_BEARERS; i++) {
  547. b_ptr = rtnl_dereference(bearer_list[i]);
  548. if (b_ptr) {
  549. bearer_disable(b_ptr, true);
  550. bearer_list[i] = NULL;
  551. }
  552. }
  553. }