xfrm_algo.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768
  1. /*
  2. * xfrm algorithm interface
  3. *
  4. * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the Free
  8. * Software Foundation; either version 2 of the License, or (at your option)
  9. * any later version.
  10. */
  11. #include <linux/module.h>
  12. #include <linux/kernel.h>
  13. #include <linux/pfkeyv2.h>
  14. #include <linux/crypto.h>
  15. #include <linux/scatterlist.h>
  16. #include <net/xfrm.h>
  17. #if defined(CONFIG_INET_AH) || defined(CONFIG_INET_AH_MODULE) || defined(CONFIG_INET6_AH) || defined(CONFIG_INET6_AH_MODULE)
  18. #include <net/ah.h>
  19. #endif
  20. #if defined(CONFIG_INET_ESP) || defined(CONFIG_INET_ESP_MODULE) || defined(CONFIG_INET6_ESP) || defined(CONFIG_INET6_ESP_MODULE)
  21. #include <net/esp.h>
  22. #endif
  23. /*
  24. * Algorithms supported by IPsec. These entries contain properties which
  25. * are used in key negotiation and xfrm processing, and are used to verify
  26. * that instantiated crypto transforms have correct parameters for IPsec
  27. * purposes.
  28. */
  29. static struct xfrm_algo_desc aead_list[] = {
  30. {
  31. .name = "rfc4106(gcm(aes))",
  32. .uinfo = {
  33. .aead = {
  34. .icv_truncbits = 64,
  35. }
  36. },
  37. .desc = {
  38. .sadb_alg_id = SADB_X_EALG_AES_GCM_ICV8,
  39. .sadb_alg_ivlen = 8,
  40. .sadb_alg_minbits = 128,
  41. .sadb_alg_maxbits = 256
  42. }
  43. },
  44. {
  45. .name = "rfc4106(gcm(aes))",
  46. .uinfo = {
  47. .aead = {
  48. .icv_truncbits = 96,
  49. }
  50. },
  51. .desc = {
  52. .sadb_alg_id = SADB_X_EALG_AES_GCM_ICV12,
  53. .sadb_alg_ivlen = 8,
  54. .sadb_alg_minbits = 128,
  55. .sadb_alg_maxbits = 256
  56. }
  57. },
  58. {
  59. .name = "rfc4106(gcm(aes))",
  60. .uinfo = {
  61. .aead = {
  62. .icv_truncbits = 128,
  63. }
  64. },
  65. .desc = {
  66. .sadb_alg_id = SADB_X_EALG_AES_GCM_ICV16,
  67. .sadb_alg_ivlen = 8,
  68. .sadb_alg_minbits = 128,
  69. .sadb_alg_maxbits = 256
  70. }
  71. },
  72. {
  73. .name = "rfc4309(ccm(aes))",
  74. .uinfo = {
  75. .aead = {
  76. .icv_truncbits = 64,
  77. }
  78. },
  79. .desc = {
  80. .sadb_alg_id = SADB_X_EALG_AES_CCM_ICV8,
  81. .sadb_alg_ivlen = 8,
  82. .sadb_alg_minbits = 128,
  83. .sadb_alg_maxbits = 256
  84. }
  85. },
  86. {
  87. .name = "rfc4309(ccm(aes))",
  88. .uinfo = {
  89. .aead = {
  90. .icv_truncbits = 96,
  91. }
  92. },
  93. .desc = {
  94. .sadb_alg_id = SADB_X_EALG_AES_CCM_ICV12,
  95. .sadb_alg_ivlen = 8,
  96. .sadb_alg_minbits = 128,
  97. .sadb_alg_maxbits = 256
  98. }
  99. },
  100. {
  101. .name = "rfc4309(ccm(aes))",
  102. .uinfo = {
  103. .aead = {
  104. .icv_truncbits = 128,
  105. }
  106. },
  107. .desc = {
  108. .sadb_alg_id = SADB_X_EALG_AES_CCM_ICV16,
  109. .sadb_alg_ivlen = 8,
  110. .sadb_alg_minbits = 128,
  111. .sadb_alg_maxbits = 256
  112. }
  113. },
  114. };
  115. static struct xfrm_algo_desc aalg_list[] = {
  116. {
  117. .name = "hmac(digest_null)",
  118. .compat = "digest_null",
  119. .uinfo = {
  120. .auth = {
  121. .icv_truncbits = 0,
  122. .icv_fullbits = 0,
  123. }
  124. },
  125. .desc = {
  126. .sadb_alg_id = SADB_X_AALG_NULL,
  127. .sadb_alg_ivlen = 0,
  128. .sadb_alg_minbits = 0,
  129. .sadb_alg_maxbits = 0
  130. }
  131. },
  132. {
  133. .name = "hmac(md5)",
  134. .compat = "md5",
  135. .uinfo = {
  136. .auth = {
  137. .icv_truncbits = 96,
  138. .icv_fullbits = 128,
  139. }
  140. },
  141. .desc = {
  142. .sadb_alg_id = SADB_AALG_MD5HMAC,
  143. .sadb_alg_ivlen = 0,
  144. .sadb_alg_minbits = 128,
  145. .sadb_alg_maxbits = 128
  146. }
  147. },
  148. {
  149. .name = "hmac(sha1)",
  150. .compat = "sha1",
  151. .uinfo = {
  152. .auth = {
  153. .icv_truncbits = 96,
  154. .icv_fullbits = 160,
  155. }
  156. },
  157. .desc = {
  158. .sadb_alg_id = SADB_AALG_SHA1HMAC,
  159. .sadb_alg_ivlen = 0,
  160. .sadb_alg_minbits = 160,
  161. .sadb_alg_maxbits = 160
  162. }
  163. },
  164. {
  165. .name = "hmac(sha256)",
  166. .compat = "sha256",
  167. .uinfo = {
  168. .auth = {
  169. .icv_truncbits = 96,
  170. .icv_fullbits = 256,
  171. }
  172. },
  173. .desc = {
  174. .sadb_alg_id = SADB_X_AALG_SHA2_256HMAC,
  175. .sadb_alg_ivlen = 0,
  176. .sadb_alg_minbits = 256,
  177. .sadb_alg_maxbits = 256
  178. }
  179. },
  180. {
  181. .name = "hmac(ripemd160)",
  182. .compat = "ripemd160",
  183. .uinfo = {
  184. .auth = {
  185. .icv_truncbits = 96,
  186. .icv_fullbits = 160,
  187. }
  188. },
  189. .desc = {
  190. .sadb_alg_id = SADB_X_AALG_RIPEMD160HMAC,
  191. .sadb_alg_ivlen = 0,
  192. .sadb_alg_minbits = 160,
  193. .sadb_alg_maxbits = 160
  194. }
  195. },
  196. {
  197. .name = "xcbc(aes)",
  198. .uinfo = {
  199. .auth = {
  200. .icv_truncbits = 96,
  201. .icv_fullbits = 128,
  202. }
  203. },
  204. .desc = {
  205. .sadb_alg_id = SADB_X_AALG_AES_XCBC_MAC,
  206. .sadb_alg_ivlen = 0,
  207. .sadb_alg_minbits = 128,
  208. .sadb_alg_maxbits = 128
  209. }
  210. },
  211. };
  212. static struct xfrm_algo_desc ealg_list[] = {
  213. {
  214. .name = "ecb(cipher_null)",
  215. .compat = "cipher_null",
  216. .uinfo = {
  217. .encr = {
  218. .blockbits = 8,
  219. .defkeybits = 0,
  220. }
  221. },
  222. .desc = {
  223. .sadb_alg_id = SADB_EALG_NULL,
  224. .sadb_alg_ivlen = 0,
  225. .sadb_alg_minbits = 0,
  226. .sadb_alg_maxbits = 0
  227. }
  228. },
  229. {
  230. .name = "cbc(des)",
  231. .compat = "des",
  232. .uinfo = {
  233. .encr = {
  234. .blockbits = 64,
  235. .defkeybits = 64,
  236. }
  237. },
  238. .desc = {
  239. .sadb_alg_id = SADB_EALG_DESCBC,
  240. .sadb_alg_ivlen = 8,
  241. .sadb_alg_minbits = 64,
  242. .sadb_alg_maxbits = 64
  243. }
  244. },
  245. {
  246. .name = "cbc(des3_ede)",
  247. .compat = "des3_ede",
  248. .uinfo = {
  249. .encr = {
  250. .blockbits = 64,
  251. .defkeybits = 192,
  252. }
  253. },
  254. .desc = {
  255. .sadb_alg_id = SADB_EALG_3DESCBC,
  256. .sadb_alg_ivlen = 8,
  257. .sadb_alg_minbits = 192,
  258. .sadb_alg_maxbits = 192
  259. }
  260. },
  261. {
  262. .name = "cbc(cast128)",
  263. .compat = "cast128",
  264. .uinfo = {
  265. .encr = {
  266. .blockbits = 64,
  267. .defkeybits = 128,
  268. }
  269. },
  270. .desc = {
  271. .sadb_alg_id = SADB_X_EALG_CASTCBC,
  272. .sadb_alg_ivlen = 8,
  273. .sadb_alg_minbits = 40,
  274. .sadb_alg_maxbits = 128
  275. }
  276. },
  277. {
  278. .name = "cbc(blowfish)",
  279. .compat = "blowfish",
  280. .uinfo = {
  281. .encr = {
  282. .blockbits = 64,
  283. .defkeybits = 128,
  284. }
  285. },
  286. .desc = {
  287. .sadb_alg_id = SADB_X_EALG_BLOWFISHCBC,
  288. .sadb_alg_ivlen = 8,
  289. .sadb_alg_minbits = 40,
  290. .sadb_alg_maxbits = 448
  291. }
  292. },
  293. {
  294. .name = "cbc(aes)",
  295. .compat = "aes",
  296. .uinfo = {
  297. .encr = {
  298. .blockbits = 128,
  299. .defkeybits = 128,
  300. }
  301. },
  302. .desc = {
  303. .sadb_alg_id = SADB_X_EALG_AESCBC,
  304. .sadb_alg_ivlen = 8,
  305. .sadb_alg_minbits = 128,
  306. .sadb_alg_maxbits = 256
  307. }
  308. },
  309. {
  310. .name = "cbc(serpent)",
  311. .compat = "serpent",
  312. .uinfo = {
  313. .encr = {
  314. .blockbits = 128,
  315. .defkeybits = 128,
  316. }
  317. },
  318. .desc = {
  319. .sadb_alg_id = SADB_X_EALG_SERPENTCBC,
  320. .sadb_alg_ivlen = 8,
  321. .sadb_alg_minbits = 128,
  322. .sadb_alg_maxbits = 256,
  323. }
  324. },
  325. {
  326. .name = "cbc(camellia)",
  327. .uinfo = {
  328. .encr = {
  329. .blockbits = 128,
  330. .defkeybits = 128,
  331. }
  332. },
  333. .desc = {
  334. .sadb_alg_id = SADB_X_EALG_CAMELLIACBC,
  335. .sadb_alg_ivlen = 8,
  336. .sadb_alg_minbits = 128,
  337. .sadb_alg_maxbits = 256
  338. }
  339. },
  340. {
  341. .name = "cbc(twofish)",
  342. .compat = "twofish",
  343. .uinfo = {
  344. .encr = {
  345. .blockbits = 128,
  346. .defkeybits = 128,
  347. }
  348. },
  349. .desc = {
  350. .sadb_alg_id = SADB_X_EALG_TWOFISHCBC,
  351. .sadb_alg_ivlen = 8,
  352. .sadb_alg_minbits = 128,
  353. .sadb_alg_maxbits = 256
  354. }
  355. },
  356. };
  357. static struct xfrm_algo_desc calg_list[] = {
  358. {
  359. .name = "deflate",
  360. .uinfo = {
  361. .comp = {
  362. .threshold = 90,
  363. }
  364. },
  365. .desc = { .sadb_alg_id = SADB_X_CALG_DEFLATE }
  366. },
  367. {
  368. .name = "lzs",
  369. .uinfo = {
  370. .comp = {
  371. .threshold = 90,
  372. }
  373. },
  374. .desc = { .sadb_alg_id = SADB_X_CALG_LZS }
  375. },
  376. {
  377. .name = "lzjh",
  378. .uinfo = {
  379. .comp = {
  380. .threshold = 50,
  381. }
  382. },
  383. .desc = { .sadb_alg_id = SADB_X_CALG_LZJH }
  384. },
  385. };
  386. static inline int aead_entries(void)
  387. {
  388. return ARRAY_SIZE(aead_list);
  389. }
  390. static inline int aalg_entries(void)
  391. {
  392. return ARRAY_SIZE(aalg_list);
  393. }
  394. static inline int ealg_entries(void)
  395. {
  396. return ARRAY_SIZE(ealg_list);
  397. }
  398. static inline int calg_entries(void)
  399. {
  400. return ARRAY_SIZE(calg_list);
  401. }
  402. struct xfrm_algo_list {
  403. struct xfrm_algo_desc *algs;
  404. int entries;
  405. u32 type;
  406. u32 mask;
  407. };
  408. static const struct xfrm_algo_list xfrm_aead_list = {
  409. .algs = aead_list,
  410. .entries = ARRAY_SIZE(aead_list),
  411. .type = CRYPTO_ALG_TYPE_AEAD,
  412. .mask = CRYPTO_ALG_TYPE_MASK,
  413. };
  414. static const struct xfrm_algo_list xfrm_aalg_list = {
  415. .algs = aalg_list,
  416. .entries = ARRAY_SIZE(aalg_list),
  417. .type = CRYPTO_ALG_TYPE_HASH,
  418. .mask = CRYPTO_ALG_TYPE_HASH_MASK,
  419. };
  420. static const struct xfrm_algo_list xfrm_ealg_list = {
  421. .algs = ealg_list,
  422. .entries = ARRAY_SIZE(ealg_list),
  423. .type = CRYPTO_ALG_TYPE_BLKCIPHER,
  424. .mask = CRYPTO_ALG_TYPE_BLKCIPHER_MASK,
  425. };
  426. static const struct xfrm_algo_list xfrm_calg_list = {
  427. .algs = calg_list,
  428. .entries = ARRAY_SIZE(calg_list),
  429. .type = CRYPTO_ALG_TYPE_COMPRESS,
  430. .mask = CRYPTO_ALG_TYPE_MASK,
  431. };
  432. static struct xfrm_algo_desc *xfrm_find_algo(
  433. const struct xfrm_algo_list *algo_list,
  434. int match(const struct xfrm_algo_desc *entry, const void *data),
  435. const void *data, int probe)
  436. {
  437. struct xfrm_algo_desc *list = algo_list->algs;
  438. int i, status;
  439. for (i = 0; i < algo_list->entries; i++) {
  440. if (!match(list + i, data))
  441. continue;
  442. if (list[i].available)
  443. return &list[i];
  444. if (!probe)
  445. break;
  446. status = crypto_has_alg(list[i].name, algo_list->type,
  447. algo_list->mask);
  448. if (!status)
  449. break;
  450. list[i].available = status;
  451. return &list[i];
  452. }
  453. return NULL;
  454. }
  455. static int xfrm_alg_id_match(const struct xfrm_algo_desc *entry,
  456. const void *data)
  457. {
  458. return entry->desc.sadb_alg_id == (unsigned long)data;
  459. }
  460. struct xfrm_algo_desc *xfrm_aalg_get_byid(int alg_id)
  461. {
  462. return xfrm_find_algo(&xfrm_aalg_list, xfrm_alg_id_match,
  463. (void *)(unsigned long)alg_id, 1);
  464. }
  465. EXPORT_SYMBOL_GPL(xfrm_aalg_get_byid);
  466. struct xfrm_algo_desc *xfrm_ealg_get_byid(int alg_id)
  467. {
  468. return xfrm_find_algo(&xfrm_ealg_list, xfrm_alg_id_match,
  469. (void *)(unsigned long)alg_id, 1);
  470. }
  471. EXPORT_SYMBOL_GPL(xfrm_ealg_get_byid);
  472. struct xfrm_algo_desc *xfrm_calg_get_byid(int alg_id)
  473. {
  474. return xfrm_find_algo(&xfrm_calg_list, xfrm_alg_id_match,
  475. (void *)(unsigned long)alg_id, 1);
  476. }
  477. EXPORT_SYMBOL_GPL(xfrm_calg_get_byid);
  478. static int xfrm_alg_name_match(const struct xfrm_algo_desc *entry,
  479. const void *data)
  480. {
  481. const char *name = data;
  482. return name && (!strcmp(name, entry->name) ||
  483. (entry->compat && !strcmp(name, entry->compat)));
  484. }
  485. struct xfrm_algo_desc *xfrm_aalg_get_byname(char *name, int probe)
  486. {
  487. return xfrm_find_algo(&xfrm_aalg_list, xfrm_alg_name_match, name,
  488. probe);
  489. }
  490. EXPORT_SYMBOL_GPL(xfrm_aalg_get_byname);
  491. struct xfrm_algo_desc *xfrm_ealg_get_byname(char *name, int probe)
  492. {
  493. return xfrm_find_algo(&xfrm_ealg_list, xfrm_alg_name_match, name,
  494. probe);
  495. }
  496. EXPORT_SYMBOL_GPL(xfrm_ealg_get_byname);
  497. struct xfrm_algo_desc *xfrm_calg_get_byname(char *name, int probe)
  498. {
  499. return xfrm_find_algo(&xfrm_calg_list, xfrm_alg_name_match, name,
  500. probe);
  501. }
  502. EXPORT_SYMBOL_GPL(xfrm_calg_get_byname);
  503. struct xfrm_aead_name {
  504. const char *name;
  505. int icvbits;
  506. };
  507. static int xfrm_aead_name_match(const struct xfrm_algo_desc *entry,
  508. const void *data)
  509. {
  510. const struct xfrm_aead_name *aead = data;
  511. const char *name = aead->name;
  512. return aead->icvbits == entry->uinfo.aead.icv_truncbits && name &&
  513. !strcmp(name, entry->name);
  514. }
  515. struct xfrm_algo_desc *xfrm_aead_get_byname(char *name, int icv_len, int probe)
  516. {
  517. struct xfrm_aead_name data = {
  518. .name = name,
  519. .icvbits = icv_len,
  520. };
  521. return xfrm_find_algo(&xfrm_aead_list, xfrm_aead_name_match, &data,
  522. probe);
  523. }
  524. EXPORT_SYMBOL_GPL(xfrm_aead_get_byname);
  525. struct xfrm_algo_desc *xfrm_aalg_get_byidx(unsigned int idx)
  526. {
  527. if (idx >= aalg_entries())
  528. return NULL;
  529. return &aalg_list[idx];
  530. }
  531. EXPORT_SYMBOL_GPL(xfrm_aalg_get_byidx);
  532. struct xfrm_algo_desc *xfrm_ealg_get_byidx(unsigned int idx)
  533. {
  534. if (idx >= ealg_entries())
  535. return NULL;
  536. return &ealg_list[idx];
  537. }
  538. EXPORT_SYMBOL_GPL(xfrm_ealg_get_byidx);
  539. /*
  540. * Probe for the availability of crypto algorithms, and set the available
  541. * flag for any algorithms found on the system. This is typically called by
  542. * pfkey during userspace SA add, update or register.
  543. */
  544. void xfrm_probe_algs(void)
  545. {
  546. int i, status;
  547. BUG_ON(in_softirq());
  548. for (i = 0; i < aalg_entries(); i++) {
  549. status = crypto_has_hash(aalg_list[i].name, 0,
  550. CRYPTO_ALG_ASYNC);
  551. if (aalg_list[i].available != status)
  552. aalg_list[i].available = status;
  553. }
  554. for (i = 0; i < ealg_entries(); i++) {
  555. status = crypto_has_blkcipher(ealg_list[i].name, 0,
  556. CRYPTO_ALG_ASYNC);
  557. if (ealg_list[i].available != status)
  558. ealg_list[i].available = status;
  559. }
  560. for (i = 0; i < calg_entries(); i++) {
  561. status = crypto_has_comp(calg_list[i].name, 0,
  562. CRYPTO_ALG_ASYNC);
  563. if (calg_list[i].available != status)
  564. calg_list[i].available = status;
  565. }
  566. }
  567. EXPORT_SYMBOL_GPL(xfrm_probe_algs);
  568. int xfrm_count_auth_supported(void)
  569. {
  570. int i, n;
  571. for (i = 0, n = 0; i < aalg_entries(); i++)
  572. if (aalg_list[i].available)
  573. n++;
  574. return n;
  575. }
  576. EXPORT_SYMBOL_GPL(xfrm_count_auth_supported);
  577. int xfrm_count_enc_supported(void)
  578. {
  579. int i, n;
  580. for (i = 0, n = 0; i < ealg_entries(); i++)
  581. if (ealg_list[i].available)
  582. n++;
  583. return n;
  584. }
  585. EXPORT_SYMBOL_GPL(xfrm_count_enc_supported);
  586. /* Move to common area: it is shared with AH. */
  587. int skb_icv_walk(const struct sk_buff *skb, struct hash_desc *desc,
  588. int offset, int len, icv_update_fn_t icv_update)
  589. {
  590. int start = skb_headlen(skb);
  591. int i, copy = start - offset;
  592. int err;
  593. struct scatterlist sg;
  594. /* Checksum header. */
  595. if (copy > 0) {
  596. if (copy > len)
  597. copy = len;
  598. sg_init_one(&sg, skb->data + offset, copy);
  599. err = icv_update(desc, &sg, copy);
  600. if (unlikely(err))
  601. return err;
  602. if ((len -= copy) == 0)
  603. return 0;
  604. offset += copy;
  605. }
  606. for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
  607. int end;
  608. BUG_TRAP(start <= offset + len);
  609. end = start + skb_shinfo(skb)->frags[i].size;
  610. if ((copy = end - offset) > 0) {
  611. skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
  612. if (copy > len)
  613. copy = len;
  614. sg_init_table(&sg, 1);
  615. sg_set_page(&sg, frag->page, copy,
  616. frag->page_offset + offset-start);
  617. err = icv_update(desc, &sg, copy);
  618. if (unlikely(err))
  619. return err;
  620. if (!(len -= copy))
  621. return 0;
  622. offset += copy;
  623. }
  624. start = end;
  625. }
  626. if (skb_shinfo(skb)->frag_list) {
  627. struct sk_buff *list = skb_shinfo(skb)->frag_list;
  628. for (; list; list = list->next) {
  629. int end;
  630. BUG_TRAP(start <= offset + len);
  631. end = start + list->len;
  632. if ((copy = end - offset) > 0) {
  633. if (copy > len)
  634. copy = len;
  635. err = skb_icv_walk(list, desc, offset-start,
  636. copy, icv_update);
  637. if (unlikely(err))
  638. return err;
  639. if ((len -= copy) == 0)
  640. return 0;
  641. offset += copy;
  642. }
  643. start = end;
  644. }
  645. }
  646. BUG_ON(len);
  647. return 0;
  648. }
  649. EXPORT_SYMBOL_GPL(skb_icv_walk);
  650. #if defined(CONFIG_INET_ESP) || defined(CONFIG_INET_ESP_MODULE) || defined(CONFIG_INET6_ESP) || defined(CONFIG_INET6_ESP_MODULE)
  651. void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len)
  652. {
  653. if (tail != skb) {
  654. skb->data_len += len;
  655. skb->len += len;
  656. }
  657. return skb_put(tail, len);
  658. }
  659. EXPORT_SYMBOL_GPL(pskb_put);
  660. #endif