msg.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. /*
  2. * net/tipc/msg.c: TIPC message header routines
  3. *
  4. * Copyright (c) 2000-2006, 2014-2015, Ericsson AB
  5. * Copyright (c) 2005, 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 <net/sock.h>
  37. #include "core.h"
  38. #include "msg.h"
  39. #include "addr.h"
  40. #include "name_table.h"
  41. #define MAX_FORWARD_SIZE 1024
  42. static unsigned int align(unsigned int i)
  43. {
  44. return (i + 3) & ~3u;
  45. }
  46. /**
  47. * tipc_buf_acquire - creates a TIPC message buffer
  48. * @size: message size (including TIPC header)
  49. *
  50. * Returns a new buffer with data pointers set to the specified size.
  51. *
  52. * NOTE: Headroom is reserved to allow prepending of a data link header.
  53. * There may also be unrequested tailroom present at the buffer's end.
  54. */
  55. struct sk_buff *tipc_buf_acquire(u32 size)
  56. {
  57. struct sk_buff *skb;
  58. unsigned int buf_size = (BUF_HEADROOM + size + 3) & ~3u;
  59. skb = alloc_skb_fclone(buf_size, GFP_ATOMIC);
  60. if (skb) {
  61. skb_reserve(skb, BUF_HEADROOM);
  62. skb_put(skb, size);
  63. skb->next = NULL;
  64. }
  65. return skb;
  66. }
  67. void tipc_msg_init(u32 own_node, struct tipc_msg *m, u32 user, u32 type,
  68. u32 hsize, u32 dnode)
  69. {
  70. memset(m, 0, hsize);
  71. msg_set_version(m);
  72. msg_set_user(m, user);
  73. msg_set_hdr_sz(m, hsize);
  74. msg_set_size(m, hsize);
  75. msg_set_prevnode(m, own_node);
  76. msg_set_type(m, type);
  77. if (hsize > SHORT_H_SIZE) {
  78. msg_set_orignode(m, own_node);
  79. msg_set_destnode(m, dnode);
  80. }
  81. }
  82. struct sk_buff *tipc_msg_create(uint user, uint type,
  83. uint hdr_sz, uint data_sz, u32 dnode,
  84. u32 onode, u32 dport, u32 oport, int errcode)
  85. {
  86. struct tipc_msg *msg;
  87. struct sk_buff *buf;
  88. buf = tipc_buf_acquire(hdr_sz + data_sz);
  89. if (unlikely(!buf))
  90. return NULL;
  91. msg = buf_msg(buf);
  92. tipc_msg_init(onode, msg, user, type, hdr_sz, dnode);
  93. msg_set_size(msg, hdr_sz + data_sz);
  94. msg_set_origport(msg, oport);
  95. msg_set_destport(msg, dport);
  96. msg_set_errcode(msg, errcode);
  97. if (hdr_sz > SHORT_H_SIZE) {
  98. msg_set_orignode(msg, onode);
  99. msg_set_destnode(msg, dnode);
  100. }
  101. return buf;
  102. }
  103. /* tipc_buf_append(): Append a buffer to the fragment list of another buffer
  104. * @*headbuf: in: NULL for first frag, otherwise value returned from prev call
  105. * out: set when successful non-complete reassembly, otherwise NULL
  106. * @*buf: in: the buffer to append. Always defined
  107. * out: head buf after successful complete reassembly, otherwise NULL
  108. * Returns 1 when reassembly complete, otherwise 0
  109. */
  110. int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf)
  111. {
  112. struct sk_buff *head = *headbuf;
  113. struct sk_buff *frag = *buf;
  114. struct sk_buff *tail = NULL;
  115. struct tipc_msg *msg;
  116. u32 fragid;
  117. int delta;
  118. bool headstolen;
  119. if (!frag)
  120. goto err;
  121. msg = buf_msg(frag);
  122. fragid = msg_type(msg);
  123. frag->next = NULL;
  124. skb_pull(frag, msg_hdr_sz(msg));
  125. if (fragid == FIRST_FRAGMENT) {
  126. if (unlikely(head))
  127. goto err;
  128. if (unlikely(skb_unclone(frag, GFP_ATOMIC)))
  129. goto err;
  130. head = *headbuf = frag;
  131. *buf = NULL;
  132. TIPC_SKB_CB(head)->tail = NULL;
  133. if (skb_is_nonlinear(head)) {
  134. skb_walk_frags(head, tail) {
  135. TIPC_SKB_CB(head)->tail = tail;
  136. }
  137. } else {
  138. skb_frag_list_init(head);
  139. }
  140. return 0;
  141. }
  142. if (!head)
  143. goto err;
  144. if (skb_try_coalesce(head, frag, &headstolen, &delta)) {
  145. kfree_skb_partial(frag, headstolen);
  146. } else {
  147. tail = TIPC_SKB_CB(head)->tail;
  148. if (!skb_has_frag_list(head))
  149. skb_shinfo(head)->frag_list = frag;
  150. else
  151. tail->next = frag;
  152. head->truesize += frag->truesize;
  153. head->data_len += frag->len;
  154. head->len += frag->len;
  155. TIPC_SKB_CB(head)->tail = frag;
  156. }
  157. if (fragid == LAST_FRAGMENT) {
  158. TIPC_SKB_CB(head)->validated = false;
  159. if (unlikely(!tipc_msg_validate(head)))
  160. goto err;
  161. *buf = head;
  162. TIPC_SKB_CB(head)->tail = NULL;
  163. *headbuf = NULL;
  164. return 1;
  165. }
  166. *buf = NULL;
  167. return 0;
  168. err:
  169. pr_warn_ratelimited("Unable to build fragment list\n");
  170. kfree_skb(*buf);
  171. kfree_skb(*headbuf);
  172. *buf = *headbuf = NULL;
  173. return 0;
  174. }
  175. /* tipc_msg_validate - validate basic format of received message
  176. *
  177. * This routine ensures a TIPC message has an acceptable header, and at least
  178. * as much data as the header indicates it should. The routine also ensures
  179. * that the entire message header is stored in the main fragment of the message
  180. * buffer, to simplify future access to message header fields.
  181. *
  182. * Note: Having extra info present in the message header or data areas is OK.
  183. * TIPC will ignore the excess, under the assumption that it is optional info
  184. * introduced by a later release of the protocol.
  185. */
  186. bool tipc_msg_validate(struct sk_buff *skb)
  187. {
  188. struct tipc_msg *msg;
  189. int msz, hsz;
  190. if (unlikely(TIPC_SKB_CB(skb)->validated))
  191. return true;
  192. if (unlikely(!pskb_may_pull(skb, MIN_H_SIZE)))
  193. return false;
  194. hsz = msg_hdr_sz(buf_msg(skb));
  195. if (unlikely(hsz < MIN_H_SIZE) || (hsz > MAX_H_SIZE))
  196. return false;
  197. if (unlikely(!pskb_may_pull(skb, hsz)))
  198. return false;
  199. msg = buf_msg(skb);
  200. if (unlikely(msg_version(msg) != TIPC_VERSION))
  201. return false;
  202. msz = msg_size(msg);
  203. if (unlikely(msz < hsz))
  204. return false;
  205. if (unlikely((msz - hsz) > TIPC_MAX_USER_MSG_SIZE))
  206. return false;
  207. if (unlikely(skb->len < msz))
  208. return false;
  209. TIPC_SKB_CB(skb)->validated = true;
  210. return true;
  211. }
  212. /**
  213. * tipc_msg_build - create buffer chain containing specified header and data
  214. * @mhdr: Message header, to be prepended to data
  215. * @m: User message
  216. * @dsz: Total length of user data
  217. * @pktmax: Max packet size that can be used
  218. * @list: Buffer or chain of buffers to be returned to caller
  219. *
  220. * Returns message data size or errno: -ENOMEM, -EFAULT
  221. */
  222. int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m,
  223. int offset, int dsz, int pktmax, struct sk_buff_head *list)
  224. {
  225. int mhsz = msg_hdr_sz(mhdr);
  226. int msz = mhsz + dsz;
  227. int pktno = 1;
  228. int pktsz;
  229. int pktrem = pktmax;
  230. int drem = dsz;
  231. struct tipc_msg pkthdr;
  232. struct sk_buff *skb;
  233. char *pktpos;
  234. int rc;
  235. msg_set_size(mhdr, msz);
  236. /* No fragmentation needed? */
  237. if (likely(msz <= pktmax)) {
  238. skb = tipc_buf_acquire(msz);
  239. if (unlikely(!skb))
  240. return -ENOMEM;
  241. skb_orphan(skb);
  242. __skb_queue_tail(list, skb);
  243. skb_copy_to_linear_data(skb, mhdr, mhsz);
  244. pktpos = skb->data + mhsz;
  245. if (copy_from_iter(pktpos, dsz, &m->msg_iter) == dsz)
  246. return dsz;
  247. rc = -EFAULT;
  248. goto error;
  249. }
  250. /* Prepare reusable fragment header */
  251. tipc_msg_init(msg_prevnode(mhdr), &pkthdr, MSG_FRAGMENTER,
  252. FIRST_FRAGMENT, INT_H_SIZE, msg_destnode(mhdr));
  253. msg_set_size(&pkthdr, pktmax);
  254. msg_set_fragm_no(&pkthdr, pktno);
  255. msg_set_importance(&pkthdr, msg_importance(mhdr));
  256. /* Prepare first fragment */
  257. skb = tipc_buf_acquire(pktmax);
  258. if (!skb)
  259. return -ENOMEM;
  260. skb_orphan(skb);
  261. __skb_queue_tail(list, skb);
  262. pktpos = skb->data;
  263. skb_copy_to_linear_data(skb, &pkthdr, INT_H_SIZE);
  264. pktpos += INT_H_SIZE;
  265. pktrem -= INT_H_SIZE;
  266. skb_copy_to_linear_data_offset(skb, INT_H_SIZE, mhdr, mhsz);
  267. pktpos += mhsz;
  268. pktrem -= mhsz;
  269. do {
  270. if (drem < pktrem)
  271. pktrem = drem;
  272. if (copy_from_iter(pktpos, pktrem, &m->msg_iter) != pktrem) {
  273. rc = -EFAULT;
  274. goto error;
  275. }
  276. drem -= pktrem;
  277. if (!drem)
  278. break;
  279. /* Prepare new fragment: */
  280. if (drem < (pktmax - INT_H_SIZE))
  281. pktsz = drem + INT_H_SIZE;
  282. else
  283. pktsz = pktmax;
  284. skb = tipc_buf_acquire(pktsz);
  285. if (!skb) {
  286. rc = -ENOMEM;
  287. goto error;
  288. }
  289. skb_orphan(skb);
  290. __skb_queue_tail(list, skb);
  291. msg_set_type(&pkthdr, FRAGMENT);
  292. msg_set_size(&pkthdr, pktsz);
  293. msg_set_fragm_no(&pkthdr, ++pktno);
  294. skb_copy_to_linear_data(skb, &pkthdr, INT_H_SIZE);
  295. pktpos = skb->data + INT_H_SIZE;
  296. pktrem = pktsz - INT_H_SIZE;
  297. } while (1);
  298. msg_set_type(buf_msg(skb), LAST_FRAGMENT);
  299. return dsz;
  300. error:
  301. __skb_queue_purge(list);
  302. __skb_queue_head_init(list);
  303. return rc;
  304. }
  305. /**
  306. * tipc_msg_bundle(): Append contents of a buffer to tail of an existing one
  307. * @skb: the buffer to append to ("bundle")
  308. * @msg: message to be appended
  309. * @mtu: max allowable size for the bundle buffer
  310. * Consumes buffer if successful
  311. * Returns true if bundling could be performed, otherwise false
  312. */
  313. bool tipc_msg_bundle(struct sk_buff *skb, struct tipc_msg *msg, u32 mtu)
  314. {
  315. struct tipc_msg *bmsg;
  316. unsigned int bsz;
  317. unsigned int msz = msg_size(msg);
  318. u32 start, pad;
  319. u32 max = mtu - INT_H_SIZE;
  320. if (likely(msg_user(msg) == MSG_FRAGMENTER))
  321. return false;
  322. if (!skb)
  323. return false;
  324. bmsg = buf_msg(skb);
  325. bsz = msg_size(bmsg);
  326. start = align(bsz);
  327. pad = start - bsz;
  328. if (unlikely(msg_user(msg) == TUNNEL_PROTOCOL))
  329. return false;
  330. if (unlikely(msg_user(msg) == BCAST_PROTOCOL))
  331. return false;
  332. if (unlikely(msg_user(bmsg) != MSG_BUNDLER))
  333. return false;
  334. if (unlikely(skb_tailroom(skb) < (pad + msz)))
  335. return false;
  336. if (unlikely(max < (start + msz)))
  337. return false;
  338. if ((msg_importance(msg) < TIPC_SYSTEM_IMPORTANCE) &&
  339. (msg_importance(bmsg) == TIPC_SYSTEM_IMPORTANCE))
  340. return false;
  341. skb_put(skb, pad + msz);
  342. skb_copy_to_linear_data_offset(skb, start, msg, msz);
  343. msg_set_size(bmsg, start + msz);
  344. msg_set_msgcnt(bmsg, msg_msgcnt(bmsg) + 1);
  345. return true;
  346. }
  347. /**
  348. * tipc_msg_extract(): extract bundled inner packet from buffer
  349. * @skb: buffer to be extracted from.
  350. * @iskb: extracted inner buffer, to be returned
  351. * @pos: position in outer message of msg to be extracted.
  352. * Returns position of next msg
  353. * Consumes outer buffer when last packet extracted
  354. * Returns true when when there is an extracted buffer, otherwise false
  355. */
  356. bool tipc_msg_extract(struct sk_buff *skb, struct sk_buff **iskb, int *pos)
  357. {
  358. struct tipc_msg *msg;
  359. int imsz, offset;
  360. *iskb = NULL;
  361. if (unlikely(skb_linearize(skb)))
  362. goto none;
  363. msg = buf_msg(skb);
  364. offset = msg_hdr_sz(msg) + *pos;
  365. if (unlikely(offset > (msg_size(msg) - MIN_H_SIZE)))
  366. goto none;
  367. *iskb = skb_clone(skb, GFP_ATOMIC);
  368. if (unlikely(!*iskb))
  369. goto none;
  370. skb_pull(*iskb, offset);
  371. imsz = msg_size(buf_msg(*iskb));
  372. skb_trim(*iskb, imsz);
  373. if (unlikely(!tipc_msg_validate(*iskb)))
  374. goto none;
  375. *pos += align(imsz);
  376. return true;
  377. none:
  378. kfree_skb(skb);
  379. kfree_skb(*iskb);
  380. *iskb = NULL;
  381. return false;
  382. }
  383. /**
  384. * tipc_msg_make_bundle(): Create bundle buf and append message to its tail
  385. * @list: the buffer chain, where head is the buffer to replace/append
  386. * @skb: buffer to be created, appended to and returned in case of success
  387. * @msg: message to be appended
  388. * @mtu: max allowable size for the bundle buffer, inclusive header
  389. * @dnode: destination node for message. (Not always present in header)
  390. * Returns true if success, otherwise false
  391. */
  392. bool tipc_msg_make_bundle(struct sk_buff **skb, struct tipc_msg *msg,
  393. u32 mtu, u32 dnode)
  394. {
  395. struct sk_buff *_skb;
  396. struct tipc_msg *bmsg;
  397. u32 msz = msg_size(msg);
  398. u32 max = mtu - INT_H_SIZE;
  399. if (msg_user(msg) == MSG_FRAGMENTER)
  400. return false;
  401. if (msg_user(msg) == TUNNEL_PROTOCOL)
  402. return false;
  403. if (msg_user(msg) == BCAST_PROTOCOL)
  404. return false;
  405. if (msz > (max / 2))
  406. return false;
  407. _skb = tipc_buf_acquire(max);
  408. if (!_skb)
  409. return false;
  410. skb_trim(_skb, INT_H_SIZE);
  411. bmsg = buf_msg(_skb);
  412. tipc_msg_init(msg_prevnode(msg), bmsg, MSG_BUNDLER, 0,
  413. INT_H_SIZE, dnode);
  414. if (msg_isdata(msg))
  415. msg_set_importance(bmsg, TIPC_CRITICAL_IMPORTANCE);
  416. else
  417. msg_set_importance(bmsg, TIPC_SYSTEM_IMPORTANCE);
  418. msg_set_seqno(bmsg, msg_seqno(msg));
  419. msg_set_ack(bmsg, msg_ack(msg));
  420. msg_set_bcast_ack(bmsg, msg_bcast_ack(msg));
  421. tipc_msg_bundle(_skb, msg, mtu);
  422. *skb = _skb;
  423. return true;
  424. }
  425. /**
  426. * tipc_msg_reverse(): swap source and destination addresses and add error code
  427. * @own_node: originating node id for reversed message
  428. * @skb: buffer containing message to be reversed; may be replaced.
  429. * @err: error code to be set in message, if any
  430. * Consumes buffer at failure
  431. * Returns true if success, otherwise false
  432. */
  433. bool tipc_msg_reverse(u32 own_node, struct sk_buff **skb, int err)
  434. {
  435. struct sk_buff *_skb = *skb;
  436. struct tipc_msg *hdr = buf_msg(_skb);
  437. struct tipc_msg ohdr;
  438. int dlen = min_t(uint, msg_data_sz(hdr), MAX_FORWARD_SIZE);
  439. if (skb_linearize(_skb))
  440. goto exit;
  441. hdr = buf_msg(_skb);
  442. if (msg_dest_droppable(hdr))
  443. goto exit;
  444. if (msg_errcode(hdr))
  445. goto exit;
  446. /* Take a copy of original header before altering message */
  447. memcpy(&ohdr, hdr, msg_hdr_sz(hdr));
  448. /* Never return SHORT header; expand by replacing buffer if necessary */
  449. if (msg_short(hdr)) {
  450. *skb = tipc_buf_acquire(BASIC_H_SIZE + dlen);
  451. if (!*skb)
  452. goto exit;
  453. memcpy((*skb)->data + BASIC_H_SIZE, msg_data(hdr), dlen);
  454. kfree_skb(_skb);
  455. _skb = *skb;
  456. hdr = buf_msg(_skb);
  457. memcpy(hdr, &ohdr, BASIC_H_SIZE);
  458. msg_set_hdr_sz(hdr, BASIC_H_SIZE);
  459. }
  460. /* Now reverse the concerned fields */
  461. msg_set_errcode(hdr, err);
  462. msg_set_origport(hdr, msg_destport(&ohdr));
  463. msg_set_destport(hdr, msg_origport(&ohdr));
  464. msg_set_destnode(hdr, msg_prevnode(&ohdr));
  465. msg_set_prevnode(hdr, own_node);
  466. msg_set_orignode(hdr, own_node);
  467. msg_set_size(hdr, msg_hdr_sz(hdr) + dlen);
  468. skb_trim(_skb, msg_size(hdr));
  469. skb_orphan(_skb);
  470. return true;
  471. exit:
  472. kfree_skb(_skb);
  473. *skb = NULL;
  474. return false;
  475. }
  476. /**
  477. * tipc_msg_lookup_dest(): try to find new destination for named message
  478. * @skb: the buffer containing the message.
  479. * @err: error code to be used by caller if lookup fails
  480. * Does not consume buffer
  481. * Returns true if a destination is found, false otherwise
  482. */
  483. bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb, int *err)
  484. {
  485. struct tipc_msg *msg = buf_msg(skb);
  486. u32 dport, dnode;
  487. u32 onode = tipc_own_addr(net);
  488. if (!msg_isdata(msg))
  489. return false;
  490. if (!msg_named(msg))
  491. return false;
  492. if (msg_errcode(msg))
  493. return false;
  494. *err = -TIPC_ERR_NO_NAME;
  495. if (skb_linearize(skb))
  496. return false;
  497. msg = buf_msg(skb);
  498. if (msg_reroute_cnt(msg))
  499. return false;
  500. dnode = addr_domain(net, msg_lookup_scope(msg));
  501. dport = tipc_nametbl_translate(net, msg_nametype(msg),
  502. msg_nameinst(msg), &dnode);
  503. if (!dport)
  504. return false;
  505. msg_incr_reroute_cnt(msg);
  506. if (dnode != onode)
  507. msg_set_prevnode(msg, onode);
  508. msg_set_destnode(msg, dnode);
  509. msg_set_destport(msg, dport);
  510. *err = TIPC_OK;
  511. return true;
  512. }
  513. /* tipc_msg_reassemble() - clone a buffer chain of fragments and
  514. * reassemble the clones into one message
  515. */
  516. struct sk_buff *tipc_msg_reassemble(struct sk_buff_head *list)
  517. {
  518. struct sk_buff *skb;
  519. struct sk_buff *frag = NULL;
  520. struct sk_buff *head = NULL;
  521. int hdr_sz;
  522. /* Copy header if single buffer */
  523. if (skb_queue_len(list) == 1) {
  524. skb = skb_peek(list);
  525. hdr_sz = skb_headroom(skb) + msg_hdr_sz(buf_msg(skb));
  526. return __pskb_copy(skb, hdr_sz, GFP_ATOMIC);
  527. }
  528. /* Clone all fragments and reassemble */
  529. skb_queue_walk(list, skb) {
  530. frag = skb_clone(skb, GFP_ATOMIC);
  531. if (!frag)
  532. goto error;
  533. frag->next = NULL;
  534. if (tipc_buf_append(&head, &frag))
  535. break;
  536. if (!head)
  537. goto error;
  538. }
  539. return frag;
  540. error:
  541. pr_warn("Failed do clone local mcast rcv buffer\n");
  542. kfree_skb(head);
  543. return NULL;
  544. }