tls_main.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. /*
  2. * Copyright (c) 2016-2017, Mellanox Technologies. All rights reserved.
  3. * Copyright (c) 2016-2017, Dave Watson <davejwatson@fb.com>. All rights reserved.
  4. *
  5. * This software is available to you under a choice of one of two
  6. * licenses. You may choose to be licensed under the terms of the GNU
  7. * General Public License (GPL) Version 2, available from the file
  8. * COPYING in the main directory of this source tree, or the
  9. * OpenIB.org BSD license below:
  10. *
  11. * Redistribution and use in source and binary forms, with or
  12. * without modification, are permitted provided that the following
  13. * conditions are met:
  14. *
  15. * - Redistributions of source code must retain the above
  16. * copyright notice, this list of conditions and the following
  17. * disclaimer.
  18. *
  19. * - Redistributions in binary form must reproduce the above
  20. * copyright notice, this list of conditions and the following
  21. * disclaimer in the documentation and/or other materials
  22. * provided with the distribution.
  23. *
  24. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  28. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  29. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  30. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  31. * SOFTWARE.
  32. */
  33. #include <linux/module.h>
  34. #include <net/tcp.h>
  35. #include <net/inet_common.h>
  36. #include <linux/highmem.h>
  37. #include <linux/netdevice.h>
  38. #include <linux/sched/signal.h>
  39. #include <linux/inetdevice.h>
  40. #include <net/tls.h>
  41. MODULE_AUTHOR("Mellanox Technologies");
  42. MODULE_DESCRIPTION("Transport Layer Security Support");
  43. MODULE_LICENSE("Dual BSD/GPL");
  44. enum {
  45. TLSV4,
  46. TLSV6,
  47. TLS_NUM_PROTS,
  48. };
  49. enum {
  50. TLS_BASE,
  51. TLS_SW_TX,
  52. TLS_SW_RX,
  53. TLS_SW_RXTX,
  54. TLS_HW_RECORD,
  55. TLS_NUM_CONFIG,
  56. };
  57. static struct proto *saved_tcpv6_prot;
  58. static DEFINE_MUTEX(tcpv6_prot_mutex);
  59. static LIST_HEAD(device_list);
  60. static DEFINE_MUTEX(device_mutex);
  61. static struct proto tls_prots[TLS_NUM_PROTS][TLS_NUM_CONFIG];
  62. static struct proto_ops tls_sw_proto_ops;
  63. static inline void update_sk_prot(struct sock *sk, struct tls_context *ctx)
  64. {
  65. int ip_ver = sk->sk_family == AF_INET6 ? TLSV6 : TLSV4;
  66. sk->sk_prot = &tls_prots[ip_ver][ctx->conf];
  67. }
  68. int wait_on_pending_writer(struct sock *sk, long *timeo)
  69. {
  70. int rc = 0;
  71. DEFINE_WAIT_FUNC(wait, woken_wake_function);
  72. add_wait_queue(sk_sleep(sk), &wait);
  73. while (1) {
  74. if (!*timeo) {
  75. rc = -EAGAIN;
  76. break;
  77. }
  78. if (signal_pending(current)) {
  79. rc = sock_intr_errno(*timeo);
  80. break;
  81. }
  82. if (sk_wait_event(sk, timeo, !sk->sk_write_pending, &wait))
  83. break;
  84. }
  85. remove_wait_queue(sk_sleep(sk), &wait);
  86. return rc;
  87. }
  88. int tls_push_sg(struct sock *sk,
  89. struct tls_context *ctx,
  90. struct scatterlist *sg,
  91. u16 first_offset,
  92. int flags)
  93. {
  94. int sendpage_flags = flags | MSG_SENDPAGE_NOTLAST;
  95. int ret = 0;
  96. struct page *p;
  97. size_t size;
  98. int offset = first_offset;
  99. size = sg->length - offset;
  100. offset += sg->offset;
  101. while (1) {
  102. if (sg_is_last(sg))
  103. sendpage_flags = flags;
  104. /* is sending application-limited? */
  105. tcp_rate_check_app_limited(sk);
  106. p = sg_page(sg);
  107. retry:
  108. ret = do_tcp_sendpages(sk, p, offset, size, sendpage_flags);
  109. if (ret != size) {
  110. if (ret > 0) {
  111. offset += ret;
  112. size -= ret;
  113. goto retry;
  114. }
  115. offset -= sg->offset;
  116. ctx->partially_sent_offset = offset;
  117. ctx->partially_sent_record = (void *)sg;
  118. return ret;
  119. }
  120. put_page(p);
  121. sk_mem_uncharge(sk, sg->length);
  122. sg = sg_next(sg);
  123. if (!sg)
  124. break;
  125. offset = sg->offset;
  126. size = sg->length;
  127. }
  128. clear_bit(TLS_PENDING_CLOSED_RECORD, &ctx->flags);
  129. return 0;
  130. }
  131. static int tls_handle_open_record(struct sock *sk, int flags)
  132. {
  133. struct tls_context *ctx = tls_get_ctx(sk);
  134. if (tls_is_pending_open_record(ctx))
  135. return ctx->push_pending_record(sk, flags);
  136. return 0;
  137. }
  138. int tls_proccess_cmsg(struct sock *sk, struct msghdr *msg,
  139. unsigned char *record_type)
  140. {
  141. struct cmsghdr *cmsg;
  142. int rc = -EINVAL;
  143. for_each_cmsghdr(cmsg, msg) {
  144. if (!CMSG_OK(msg, cmsg))
  145. return -EINVAL;
  146. if (cmsg->cmsg_level != SOL_TLS)
  147. continue;
  148. switch (cmsg->cmsg_type) {
  149. case TLS_SET_RECORD_TYPE:
  150. if (cmsg->cmsg_len < CMSG_LEN(sizeof(*record_type)))
  151. return -EINVAL;
  152. if (msg->msg_flags & MSG_MORE)
  153. return -EINVAL;
  154. rc = tls_handle_open_record(sk, msg->msg_flags);
  155. if (rc)
  156. return rc;
  157. *record_type = *(unsigned char *)CMSG_DATA(cmsg);
  158. rc = 0;
  159. break;
  160. default:
  161. return -EINVAL;
  162. }
  163. }
  164. return rc;
  165. }
  166. int tls_push_pending_closed_record(struct sock *sk, struct tls_context *ctx,
  167. int flags, long *timeo)
  168. {
  169. struct scatterlist *sg;
  170. u16 offset;
  171. if (!tls_is_partially_sent_record(ctx))
  172. return ctx->push_pending_record(sk, flags);
  173. sg = ctx->partially_sent_record;
  174. offset = ctx->partially_sent_offset;
  175. ctx->partially_sent_record = NULL;
  176. return tls_push_sg(sk, ctx, sg, offset, flags);
  177. }
  178. static void tls_write_space(struct sock *sk)
  179. {
  180. struct tls_context *ctx = tls_get_ctx(sk);
  181. if (!sk->sk_write_pending && tls_is_pending_closed_record(ctx)) {
  182. gfp_t sk_allocation = sk->sk_allocation;
  183. int rc;
  184. long timeo = 0;
  185. sk->sk_allocation = GFP_ATOMIC;
  186. rc = tls_push_pending_closed_record(sk, ctx,
  187. MSG_DONTWAIT |
  188. MSG_NOSIGNAL,
  189. &timeo);
  190. sk->sk_allocation = sk_allocation;
  191. if (rc < 0)
  192. return;
  193. }
  194. ctx->sk_write_space(sk);
  195. }
  196. static void tls_sk_proto_close(struct sock *sk, long timeout)
  197. {
  198. struct tls_context *ctx = tls_get_ctx(sk);
  199. long timeo = sock_sndtimeo(sk, 0);
  200. void (*sk_proto_close)(struct sock *sk, long timeout);
  201. lock_sock(sk);
  202. sk_proto_close = ctx->sk_proto_close;
  203. if (ctx->conf == TLS_HW_RECORD)
  204. goto skip_tx_cleanup;
  205. if (ctx->conf == TLS_BASE) {
  206. kfree(ctx);
  207. ctx = NULL;
  208. goto skip_tx_cleanup;
  209. }
  210. if (!tls_complete_pending_work(sk, ctx, 0, &timeo))
  211. tls_handle_open_record(sk, 0);
  212. if (ctx->partially_sent_record) {
  213. struct scatterlist *sg = ctx->partially_sent_record;
  214. while (1) {
  215. put_page(sg_page(sg));
  216. sk_mem_uncharge(sk, sg->length);
  217. if (sg_is_last(sg))
  218. break;
  219. sg++;
  220. }
  221. }
  222. kfree(ctx->tx.rec_seq);
  223. kfree(ctx->tx.iv);
  224. kfree(ctx->rx.rec_seq);
  225. kfree(ctx->rx.iv);
  226. if (ctx->conf == TLS_SW_TX ||
  227. ctx->conf == TLS_SW_RX ||
  228. ctx->conf == TLS_SW_RXTX) {
  229. tls_sw_free_resources(sk);
  230. }
  231. skip_tx_cleanup:
  232. release_sock(sk);
  233. sk_proto_close(sk, timeout);
  234. /* free ctx for TLS_HW_RECORD, used by tcp_set_state
  235. * for sk->sk_prot->unhash [tls_hw_unhash]
  236. */
  237. if (ctx && ctx->conf == TLS_HW_RECORD)
  238. kfree(ctx);
  239. }
  240. static int do_tls_getsockopt_tx(struct sock *sk, char __user *optval,
  241. int __user *optlen)
  242. {
  243. int rc = 0;
  244. struct tls_context *ctx = tls_get_ctx(sk);
  245. struct tls_crypto_info *crypto_info;
  246. int len;
  247. if (get_user(len, optlen))
  248. return -EFAULT;
  249. if (!optval || (len < sizeof(*crypto_info))) {
  250. rc = -EINVAL;
  251. goto out;
  252. }
  253. if (!ctx) {
  254. rc = -EBUSY;
  255. goto out;
  256. }
  257. /* get user crypto info */
  258. crypto_info = &ctx->crypto_send;
  259. if (!TLS_CRYPTO_INFO_READY(crypto_info)) {
  260. rc = -EBUSY;
  261. goto out;
  262. }
  263. if (len == sizeof(*crypto_info)) {
  264. if (copy_to_user(optval, crypto_info, sizeof(*crypto_info)))
  265. rc = -EFAULT;
  266. goto out;
  267. }
  268. switch (crypto_info->cipher_type) {
  269. case TLS_CIPHER_AES_GCM_128: {
  270. struct tls12_crypto_info_aes_gcm_128 *
  271. crypto_info_aes_gcm_128 =
  272. container_of(crypto_info,
  273. struct tls12_crypto_info_aes_gcm_128,
  274. info);
  275. if (len != sizeof(*crypto_info_aes_gcm_128)) {
  276. rc = -EINVAL;
  277. goto out;
  278. }
  279. lock_sock(sk);
  280. memcpy(crypto_info_aes_gcm_128->iv,
  281. ctx->tx.iv + TLS_CIPHER_AES_GCM_128_SALT_SIZE,
  282. TLS_CIPHER_AES_GCM_128_IV_SIZE);
  283. memcpy(crypto_info_aes_gcm_128->rec_seq, ctx->tx.rec_seq,
  284. TLS_CIPHER_AES_GCM_128_REC_SEQ_SIZE);
  285. release_sock(sk);
  286. if (copy_to_user(optval,
  287. crypto_info_aes_gcm_128,
  288. sizeof(*crypto_info_aes_gcm_128)))
  289. rc = -EFAULT;
  290. break;
  291. }
  292. default:
  293. rc = -EINVAL;
  294. }
  295. out:
  296. return rc;
  297. }
  298. static int do_tls_getsockopt(struct sock *sk, int optname,
  299. char __user *optval, int __user *optlen)
  300. {
  301. int rc = 0;
  302. switch (optname) {
  303. case TLS_TX:
  304. rc = do_tls_getsockopt_tx(sk, optval, optlen);
  305. break;
  306. default:
  307. rc = -ENOPROTOOPT;
  308. break;
  309. }
  310. return rc;
  311. }
  312. static int tls_getsockopt(struct sock *sk, int level, int optname,
  313. char __user *optval, int __user *optlen)
  314. {
  315. struct tls_context *ctx = tls_get_ctx(sk);
  316. if (level != SOL_TLS)
  317. return ctx->getsockopt(sk, level, optname, optval, optlen);
  318. return do_tls_getsockopt(sk, optname, optval, optlen);
  319. }
  320. static int do_tls_setsockopt_conf(struct sock *sk, char __user *optval,
  321. unsigned int optlen, int tx)
  322. {
  323. struct tls_crypto_info *crypto_info;
  324. struct tls_context *ctx = tls_get_ctx(sk);
  325. int rc = 0;
  326. int conf;
  327. if (!optval || (optlen < sizeof(*crypto_info))) {
  328. rc = -EINVAL;
  329. goto out;
  330. }
  331. if (tx)
  332. crypto_info = &ctx->crypto_send;
  333. else
  334. crypto_info = &ctx->crypto_recv;
  335. /* Currently we don't support set crypto info more than one time */
  336. if (TLS_CRYPTO_INFO_READY(crypto_info)) {
  337. rc = -EBUSY;
  338. goto out;
  339. }
  340. rc = copy_from_user(crypto_info, optval, sizeof(*crypto_info));
  341. if (rc) {
  342. rc = -EFAULT;
  343. goto err_crypto_info;
  344. }
  345. /* check version */
  346. if (crypto_info->version != TLS_1_2_VERSION) {
  347. rc = -ENOTSUPP;
  348. goto err_crypto_info;
  349. }
  350. switch (crypto_info->cipher_type) {
  351. case TLS_CIPHER_AES_GCM_128: {
  352. if (optlen != sizeof(struct tls12_crypto_info_aes_gcm_128)) {
  353. rc = -EINVAL;
  354. goto err_crypto_info;
  355. }
  356. rc = copy_from_user(crypto_info + 1, optval + sizeof(*crypto_info),
  357. optlen - sizeof(*crypto_info));
  358. if (rc) {
  359. rc = -EFAULT;
  360. goto err_crypto_info;
  361. }
  362. break;
  363. }
  364. default:
  365. rc = -EINVAL;
  366. goto err_crypto_info;
  367. }
  368. /* currently SW is default, we will have ethtool in future */
  369. if (tx) {
  370. rc = tls_set_sw_offload(sk, ctx, 1);
  371. if (ctx->conf == TLS_SW_RX)
  372. conf = TLS_SW_RXTX;
  373. else
  374. conf = TLS_SW_TX;
  375. } else {
  376. rc = tls_set_sw_offload(sk, ctx, 0);
  377. if (ctx->conf == TLS_SW_TX)
  378. conf = TLS_SW_RXTX;
  379. else
  380. conf = TLS_SW_RX;
  381. }
  382. if (rc)
  383. goto err_crypto_info;
  384. ctx->conf = conf;
  385. update_sk_prot(sk, ctx);
  386. if (tx) {
  387. ctx->sk_write_space = sk->sk_write_space;
  388. sk->sk_write_space = tls_write_space;
  389. } else {
  390. sk->sk_socket->ops = &tls_sw_proto_ops;
  391. }
  392. goto out;
  393. err_crypto_info:
  394. memset(crypto_info, 0, sizeof(*crypto_info));
  395. out:
  396. return rc;
  397. }
  398. static int do_tls_setsockopt(struct sock *sk, int optname,
  399. char __user *optval, unsigned int optlen)
  400. {
  401. int rc = 0;
  402. switch (optname) {
  403. case TLS_TX:
  404. case TLS_RX:
  405. lock_sock(sk);
  406. rc = do_tls_setsockopt_conf(sk, optval, optlen,
  407. optname == TLS_TX);
  408. release_sock(sk);
  409. break;
  410. default:
  411. rc = -ENOPROTOOPT;
  412. break;
  413. }
  414. return rc;
  415. }
  416. static int tls_setsockopt(struct sock *sk, int level, int optname,
  417. char __user *optval, unsigned int optlen)
  418. {
  419. struct tls_context *ctx = tls_get_ctx(sk);
  420. if (level != SOL_TLS)
  421. return ctx->setsockopt(sk, level, optname, optval, optlen);
  422. return do_tls_setsockopt(sk, optname, optval, optlen);
  423. }
  424. static struct tls_context *create_ctx(struct sock *sk)
  425. {
  426. struct inet_connection_sock *icsk = inet_csk(sk);
  427. struct tls_context *ctx;
  428. ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
  429. if (!ctx)
  430. return NULL;
  431. icsk->icsk_ulp_data = ctx;
  432. return ctx;
  433. }
  434. static int tls_hw_prot(struct sock *sk)
  435. {
  436. struct tls_context *ctx;
  437. struct tls_device *dev;
  438. int rc = 0;
  439. mutex_lock(&device_mutex);
  440. list_for_each_entry(dev, &device_list, dev_list) {
  441. if (dev->feature && dev->feature(dev)) {
  442. ctx = create_ctx(sk);
  443. if (!ctx)
  444. goto out;
  445. ctx->hash = sk->sk_prot->hash;
  446. ctx->unhash = sk->sk_prot->unhash;
  447. ctx->sk_proto_close = sk->sk_prot->close;
  448. ctx->conf = TLS_HW_RECORD;
  449. update_sk_prot(sk, ctx);
  450. rc = 1;
  451. break;
  452. }
  453. }
  454. out:
  455. mutex_unlock(&device_mutex);
  456. return rc;
  457. }
  458. static void tls_hw_unhash(struct sock *sk)
  459. {
  460. struct tls_context *ctx = tls_get_ctx(sk);
  461. struct tls_device *dev;
  462. mutex_lock(&device_mutex);
  463. list_for_each_entry(dev, &device_list, dev_list) {
  464. if (dev->unhash)
  465. dev->unhash(dev, sk);
  466. }
  467. mutex_unlock(&device_mutex);
  468. ctx->unhash(sk);
  469. }
  470. static int tls_hw_hash(struct sock *sk)
  471. {
  472. struct tls_context *ctx = tls_get_ctx(sk);
  473. struct tls_device *dev;
  474. int err;
  475. err = ctx->hash(sk);
  476. mutex_lock(&device_mutex);
  477. list_for_each_entry(dev, &device_list, dev_list) {
  478. if (dev->hash)
  479. err |= dev->hash(dev, sk);
  480. }
  481. mutex_unlock(&device_mutex);
  482. if (err)
  483. tls_hw_unhash(sk);
  484. return err;
  485. }
  486. static void build_protos(struct proto *prot, struct proto *base)
  487. {
  488. prot[TLS_BASE] = *base;
  489. prot[TLS_BASE].setsockopt = tls_setsockopt;
  490. prot[TLS_BASE].getsockopt = tls_getsockopt;
  491. prot[TLS_BASE].close = tls_sk_proto_close;
  492. prot[TLS_SW_TX] = prot[TLS_BASE];
  493. prot[TLS_SW_TX].sendmsg = tls_sw_sendmsg;
  494. prot[TLS_SW_TX].sendpage = tls_sw_sendpage;
  495. prot[TLS_SW_RX] = prot[TLS_BASE];
  496. prot[TLS_SW_RX].recvmsg = tls_sw_recvmsg;
  497. prot[TLS_SW_RX].close = tls_sk_proto_close;
  498. prot[TLS_SW_RXTX] = prot[TLS_SW_TX];
  499. prot[TLS_SW_RXTX].recvmsg = tls_sw_recvmsg;
  500. prot[TLS_SW_RXTX].close = tls_sk_proto_close;
  501. prot[TLS_HW_RECORD] = *base;
  502. prot[TLS_HW_RECORD].hash = tls_hw_hash;
  503. prot[TLS_HW_RECORD].unhash = tls_hw_unhash;
  504. prot[TLS_HW_RECORD].close = tls_sk_proto_close;
  505. }
  506. static int tls_init(struct sock *sk)
  507. {
  508. int ip_ver = sk->sk_family == AF_INET6 ? TLSV6 : TLSV4;
  509. struct tls_context *ctx;
  510. int rc = 0;
  511. if (tls_hw_prot(sk))
  512. goto out;
  513. /* The TLS ulp is currently supported only for TCP sockets
  514. * in ESTABLISHED state.
  515. * Supporting sockets in LISTEN state will require us
  516. * to modify the accept implementation to clone rather then
  517. * share the ulp context.
  518. */
  519. if (sk->sk_state != TCP_ESTABLISHED)
  520. return -ENOTSUPP;
  521. /* allocate tls context */
  522. ctx = create_ctx(sk);
  523. if (!ctx) {
  524. rc = -ENOMEM;
  525. goto out;
  526. }
  527. ctx->setsockopt = sk->sk_prot->setsockopt;
  528. ctx->getsockopt = sk->sk_prot->getsockopt;
  529. ctx->sk_proto_close = sk->sk_prot->close;
  530. /* Build IPv6 TLS whenever the address of tcpv6_prot changes */
  531. if (ip_ver == TLSV6 &&
  532. unlikely(sk->sk_prot != smp_load_acquire(&saved_tcpv6_prot))) {
  533. mutex_lock(&tcpv6_prot_mutex);
  534. if (likely(sk->sk_prot != saved_tcpv6_prot)) {
  535. build_protos(tls_prots[TLSV6], sk->sk_prot);
  536. smp_store_release(&saved_tcpv6_prot, sk->sk_prot);
  537. }
  538. mutex_unlock(&tcpv6_prot_mutex);
  539. }
  540. ctx->conf = TLS_BASE;
  541. update_sk_prot(sk, ctx);
  542. out:
  543. return rc;
  544. }
  545. void tls_register_device(struct tls_device *device)
  546. {
  547. mutex_lock(&device_mutex);
  548. list_add_tail(&device->dev_list, &device_list);
  549. mutex_unlock(&device_mutex);
  550. }
  551. EXPORT_SYMBOL(tls_register_device);
  552. void tls_unregister_device(struct tls_device *device)
  553. {
  554. mutex_lock(&device_mutex);
  555. list_del(&device->dev_list);
  556. mutex_unlock(&device_mutex);
  557. }
  558. EXPORT_SYMBOL(tls_unregister_device);
  559. static struct tcp_ulp_ops tcp_tls_ulp_ops __read_mostly = {
  560. .name = "tls",
  561. .uid = TCP_ULP_TLS,
  562. .user_visible = true,
  563. .owner = THIS_MODULE,
  564. .init = tls_init,
  565. };
  566. static int __init tls_register(void)
  567. {
  568. build_protos(tls_prots[TLSV4], &tcp_prot);
  569. tls_sw_proto_ops = inet_stream_ops;
  570. tls_sw_proto_ops.poll = tls_sw_poll;
  571. tls_sw_proto_ops.splice_read = tls_sw_splice_read;
  572. tcp_register_ulp(&tcp_tls_ulp_ops);
  573. return 0;
  574. }
  575. static void __exit tls_unregister(void)
  576. {
  577. tcp_unregister_ulp(&tcp_tls_ulp_ops);
  578. }
  579. module_init(tls_register);
  580. module_exit(tls_unregister);