2 * Copyright (c) 2006, 2018 Oracle and/or its affiliates. All rights reserved.
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 #include <linux/kernel.h>
34 #include <linux/slab.h>
36 #include <linux/module.h>
38 #include <net/net_namespace.h>
39 #include <net/netns/generic.h>
40 #include <net/addrconf.h>
45 /* only for info exporting */
46 static DEFINE_SPINLOCK(rds_tcp_tc_list_lock);
47 static LIST_HEAD(rds_tcp_tc_list);
49 /* rds_tcp_tc_count counts only IPv4 connections.
50 * rds6_tcp_tc_count counts both IPv4 and IPv6 connections.
52 static unsigned int rds_tcp_tc_count;
53 #if IS_ENABLED(CONFIG_IPV6)
54 static unsigned int rds6_tcp_tc_count;
57 /* Track rds_tcp_connection structs so they can be cleaned up */
58 static DEFINE_SPINLOCK(rds_tcp_conn_lock);
59 static LIST_HEAD(rds_tcp_conn_list);
60 static atomic_t rds_tcp_unloading = ATOMIC_INIT(0);
62 static struct kmem_cache *rds_tcp_conn_slab;
64 static int rds_tcp_skbuf_handler(struct ctl_table *ctl, int write,
65 void *buffer, size_t *lenp, loff_t *fpos);
67 static int rds_tcp_min_sndbuf = SOCK_MIN_SNDBUF;
68 static int rds_tcp_min_rcvbuf = SOCK_MIN_RCVBUF;
70 static struct ctl_table rds_tcp_sysctl_table[] = {
71 #define RDS_TCP_SNDBUF 0
73 .procname = "rds_tcp_sndbuf",
74 /* data is per-net pointer */
75 .maxlen = sizeof(int),
77 .proc_handler = rds_tcp_skbuf_handler,
78 .extra1 = &rds_tcp_min_sndbuf,
80 #define RDS_TCP_RCVBUF 1
82 .procname = "rds_tcp_rcvbuf",
83 /* data is per-net pointer */
84 .maxlen = sizeof(int),
86 .proc_handler = rds_tcp_skbuf_handler,
87 .extra1 = &rds_tcp_min_rcvbuf,
92 u32 rds_tcp_write_seq(struct rds_tcp_connection *tc)
94 /* seq# of the last byte of data in tcp send buffer */
95 return tcp_sk(tc->t_sock->sk)->write_seq;
98 u32 rds_tcp_snd_una(struct rds_tcp_connection *tc)
100 return tcp_sk(tc->t_sock->sk)->snd_una;
103 void rds_tcp_restore_callbacks(struct socket *sock,
104 struct rds_tcp_connection *tc)
106 rdsdebug("restoring sock %p callbacks from tc %p\n", sock, tc);
107 write_lock_bh(&sock->sk->sk_callback_lock);
109 /* done under the callback_lock to serialize with write_space */
110 spin_lock(&rds_tcp_tc_list_lock);
111 list_del_init(&tc->t_list_item);
112 #if IS_ENABLED(CONFIG_IPV6)
115 if (!tc->t_cpath->cp_conn->c_isv6)
117 spin_unlock(&rds_tcp_tc_list_lock);
121 sock->sk->sk_write_space = tc->t_orig_write_space;
122 sock->sk->sk_data_ready = tc->t_orig_data_ready;
123 sock->sk->sk_state_change = tc->t_orig_state_change;
124 sock->sk->sk_user_data = NULL;
126 write_unlock_bh(&sock->sk->sk_callback_lock);
130 * rds_tcp_reset_callbacks() switches the to the new sock and
131 * returns the existing tc->t_sock.
133 * The only functions that set tc->t_sock are rds_tcp_set_callbacks
134 * and rds_tcp_reset_callbacks. Send and receive trust that
135 * it is set. The absence of RDS_CONN_UP bit protects those paths
136 * from being called while it isn't set.
138 void rds_tcp_reset_callbacks(struct socket *sock,
139 struct rds_conn_path *cp)
141 struct rds_tcp_connection *tc = cp->cp_transport_data;
142 struct socket *osock = tc->t_sock;
147 /* Need to resolve a duelling SYN between peers.
148 * We have an outstanding SYN to this peer, which may
149 * potentially have transitioned to the RDS_CONN_UP state,
150 * so we must quiesce any send threads before resetting
151 * cp_transport_data. We quiesce these threads by setting
152 * cp_state to something other than RDS_CONN_UP, and then
153 * waiting for any existing threads in rds_send_xmit to
154 * complete release_in_xmit(). (Subsequent threads entering
155 * rds_send_xmit() will bail on !rds_conn_up().
157 * However an incoming syn-ack at this point would end up
158 * marking the conn as RDS_CONN_UP, and would again permit
159 * rds_send_xmi() threads through, so ideally we would
160 * synchronize on RDS_CONN_UP after lock_sock(), but cannot
161 * do that: waiting on !RDS_IN_XMIT after lock_sock() may
162 * end up deadlocking with tcp_sendmsg(), and the RDS_IN_XMIT
163 * would not get set. As a result, we set c_state to
164 * RDS_CONN_RESETTTING, to ensure that rds_tcp_state_change
165 * cannot mark rds_conn_path_up() in the window before lock_sock()
167 atomic_set(&cp->cp_state, RDS_CONN_RESETTING);
168 wait_event(cp->cp_waitq, !test_bit(RDS_IN_XMIT, &cp->cp_flags));
169 /* reset receive side state for rds_tcp_data_recv() for osock */
170 cancel_delayed_work_sync(&cp->cp_send_w);
171 cancel_delayed_work_sync(&cp->cp_recv_w);
172 lock_sock(osock->sk);
174 rds_inc_put(&tc->t_tinc->ti_inc);
177 tc->t_tinc_hdr_rem = sizeof(struct rds_header);
178 tc->t_tinc_data_rem = 0;
179 rds_tcp_restore_callbacks(osock, tc);
180 release_sock(osock->sk);
183 rds_send_path_reset(cp);
185 rds_tcp_set_callbacks(sock, cp);
186 release_sock(sock->sk);
189 /* Add tc to rds_tcp_tc_list and set tc->t_sock. See comments
190 * above rds_tcp_reset_callbacks for notes about synchronization
193 void rds_tcp_set_callbacks(struct socket *sock, struct rds_conn_path *cp)
195 struct rds_tcp_connection *tc = cp->cp_transport_data;
197 rdsdebug("setting sock %p callbacks to tc %p\n", sock, tc);
198 write_lock_bh(&sock->sk->sk_callback_lock);
200 /* done under the callback_lock to serialize with write_space */
201 spin_lock(&rds_tcp_tc_list_lock);
202 list_add_tail(&tc->t_list_item, &rds_tcp_tc_list);
203 #if IS_ENABLED(CONFIG_IPV6)
206 if (!tc->t_cpath->cp_conn->c_isv6)
208 spin_unlock(&rds_tcp_tc_list_lock);
210 /* accepted sockets need our listen data ready undone */
211 if (sock->sk->sk_data_ready == rds_tcp_listen_data_ready)
212 sock->sk->sk_data_ready = sock->sk->sk_user_data;
216 tc->t_orig_data_ready = sock->sk->sk_data_ready;
217 tc->t_orig_write_space = sock->sk->sk_write_space;
218 tc->t_orig_state_change = sock->sk->sk_state_change;
220 sock->sk->sk_user_data = cp;
221 sock->sk->sk_data_ready = rds_tcp_data_ready;
222 sock->sk->sk_write_space = rds_tcp_write_space;
223 sock->sk->sk_state_change = rds_tcp_state_change;
225 write_unlock_bh(&sock->sk->sk_callback_lock);
228 /* Handle RDS_INFO_TCP_SOCKETS socket option. It only returns IPv4
229 * connections for backward compatibility.
231 static void rds_tcp_tc_info(struct socket *rds_sock, unsigned int len,
232 struct rds_info_iterator *iter,
233 struct rds_info_lengths *lens)
235 struct rds_info_tcp_socket tsinfo;
236 struct rds_tcp_connection *tc;
239 spin_lock_irqsave(&rds_tcp_tc_list_lock, flags);
241 if (len / sizeof(tsinfo) < rds_tcp_tc_count)
244 list_for_each_entry(tc, &rds_tcp_tc_list, t_list_item) {
245 struct inet_sock *inet = inet_sk(tc->t_sock->sk);
247 if (tc->t_cpath->cp_conn->c_isv6)
250 tsinfo.local_addr = inet->inet_saddr;
251 tsinfo.local_port = inet->inet_sport;
252 tsinfo.peer_addr = inet->inet_daddr;
253 tsinfo.peer_port = inet->inet_dport;
255 tsinfo.hdr_rem = tc->t_tinc_hdr_rem;
256 tsinfo.data_rem = tc->t_tinc_data_rem;
257 tsinfo.last_sent_nxt = tc->t_last_sent_nxt;
258 tsinfo.last_expected_una = tc->t_last_expected_una;
259 tsinfo.last_seen_una = tc->t_last_seen_una;
260 tsinfo.tos = tc->t_cpath->cp_conn->c_tos;
262 rds_info_copy(iter, &tsinfo, sizeof(tsinfo));
266 lens->nr = rds_tcp_tc_count;
267 lens->each = sizeof(tsinfo);
269 spin_unlock_irqrestore(&rds_tcp_tc_list_lock, flags);
272 #if IS_ENABLED(CONFIG_IPV6)
273 /* Handle RDS6_INFO_TCP_SOCKETS socket option. It returns both IPv4 and
274 * IPv6 connections. IPv4 connection address is returned in an IPv4 mapped
277 static void rds6_tcp_tc_info(struct socket *sock, unsigned int len,
278 struct rds_info_iterator *iter,
279 struct rds_info_lengths *lens)
281 struct rds6_info_tcp_socket tsinfo6;
282 struct rds_tcp_connection *tc;
285 spin_lock_irqsave(&rds_tcp_tc_list_lock, flags);
287 if (len / sizeof(tsinfo6) < rds6_tcp_tc_count)
290 list_for_each_entry(tc, &rds_tcp_tc_list, t_list_item) {
291 struct sock *sk = tc->t_sock->sk;
292 struct inet_sock *inet = inet_sk(sk);
294 tsinfo6.local_addr = sk->sk_v6_rcv_saddr;
295 tsinfo6.local_port = inet->inet_sport;
296 tsinfo6.peer_addr = sk->sk_v6_daddr;
297 tsinfo6.peer_port = inet->inet_dport;
299 tsinfo6.hdr_rem = tc->t_tinc_hdr_rem;
300 tsinfo6.data_rem = tc->t_tinc_data_rem;
301 tsinfo6.last_sent_nxt = tc->t_last_sent_nxt;
302 tsinfo6.last_expected_una = tc->t_last_expected_una;
303 tsinfo6.last_seen_una = tc->t_last_seen_una;
305 rds_info_copy(iter, &tsinfo6, sizeof(tsinfo6));
309 lens->nr = rds6_tcp_tc_count;
310 lens->each = sizeof(tsinfo6);
312 spin_unlock_irqrestore(&rds_tcp_tc_list_lock, flags);
316 int rds_tcp_laddr_check(struct net *net, const struct in6_addr *addr,
319 struct net_device *dev = NULL;
320 #if IS_ENABLED(CONFIG_IPV6)
324 if (ipv6_addr_v4mapped(addr)) {
325 if (inet_addr_type(net, addr->s6_addr32[3]) == RTN_LOCAL)
327 return -EADDRNOTAVAIL;
330 /* If the scope_id is specified, check only those addresses
331 * hosted on the specified interface.
335 dev = dev_get_by_index_rcu(net, scope_id);
336 /* scope_id is not valid... */
339 return -EADDRNOTAVAIL;
343 #if IS_ENABLED(CONFIG_IPV6)
344 ret = ipv6_chk_addr(net, addr, dev, 0);
348 return -EADDRNOTAVAIL;
351 static void rds_tcp_conn_free(void *arg)
353 struct rds_tcp_connection *tc = arg;
356 rdsdebug("freeing tc %p\n", tc);
358 spin_lock_irqsave(&rds_tcp_conn_lock, flags);
359 if (!tc->t_tcp_node_detached)
360 list_del(&tc->t_tcp_node);
361 spin_unlock_irqrestore(&rds_tcp_conn_lock, flags);
363 kmem_cache_free(rds_tcp_conn_slab, tc);
366 static int rds_tcp_conn_alloc(struct rds_connection *conn, gfp_t gfp)
368 struct rds_tcp_connection *tc;
372 for (i = 0; i < RDS_MPATH_WORKERS; i++) {
373 tc = kmem_cache_alloc(rds_tcp_conn_slab, gfp);
378 mutex_init(&tc->t_conn_path_lock);
381 tc->t_tinc_hdr_rem = sizeof(struct rds_header);
382 tc->t_tinc_data_rem = 0;
384 conn->c_path[i].cp_transport_data = tc;
385 tc->t_cpath = &conn->c_path[i];
386 tc->t_tcp_node_detached = true;
388 rdsdebug("rds_conn_path [%d] tc %p\n", i,
389 conn->c_path[i].cp_transport_data);
391 spin_lock_irq(&rds_tcp_conn_lock);
392 for (i = 0; i < RDS_MPATH_WORKERS; i++) {
393 tc = conn->c_path[i].cp_transport_data;
394 tc->t_tcp_node_detached = false;
395 list_add_tail(&tc->t_tcp_node, &rds_tcp_conn_list);
397 spin_unlock_irq(&rds_tcp_conn_lock);
400 for (j = 0; j < i; j++)
401 rds_tcp_conn_free(conn->c_path[j].cp_transport_data);
406 static bool list_has_conn(struct list_head *list, struct rds_connection *conn)
408 struct rds_tcp_connection *tc, *_tc;
410 list_for_each_entry_safe(tc, _tc, list, t_tcp_node) {
411 if (tc->t_cpath->cp_conn == conn)
417 static void rds_tcp_set_unloading(void)
419 atomic_set(&rds_tcp_unloading, 1);
422 static bool rds_tcp_is_unloading(struct rds_connection *conn)
424 return atomic_read(&rds_tcp_unloading) != 0;
427 static void rds_tcp_destroy_conns(void)
429 struct rds_tcp_connection *tc, *_tc;
432 /* avoid calling conn_destroy with irqs off */
433 spin_lock_irq(&rds_tcp_conn_lock);
434 list_for_each_entry_safe(tc, _tc, &rds_tcp_conn_list, t_tcp_node) {
435 if (!list_has_conn(&tmp_list, tc->t_cpath->cp_conn))
436 list_move_tail(&tc->t_tcp_node, &tmp_list);
438 spin_unlock_irq(&rds_tcp_conn_lock);
440 list_for_each_entry_safe(tc, _tc, &tmp_list, t_tcp_node)
441 rds_conn_destroy(tc->t_cpath->cp_conn);
444 static void rds_tcp_exit(void);
446 static u8 rds_tcp_get_tos_map(u8 tos)
448 /* all user tos mapped to default 0 for TCP transport */
452 struct rds_transport rds_tcp_transport = {
453 .laddr_check = rds_tcp_laddr_check,
454 .xmit_path_prepare = rds_tcp_xmit_path_prepare,
455 .xmit_path_complete = rds_tcp_xmit_path_complete,
456 .xmit = rds_tcp_xmit,
457 .recv_path = rds_tcp_recv_path,
458 .conn_alloc = rds_tcp_conn_alloc,
459 .conn_free = rds_tcp_conn_free,
460 .conn_path_connect = rds_tcp_conn_path_connect,
461 .conn_path_shutdown = rds_tcp_conn_path_shutdown,
462 .inc_copy_to_user = rds_tcp_inc_copy_to_user,
463 .inc_free = rds_tcp_inc_free,
464 .stats_info_copy = rds_tcp_stats_info_copy,
465 .exit = rds_tcp_exit,
466 .get_tos_map = rds_tcp_get_tos_map,
467 .t_owner = THIS_MODULE,
469 .t_type = RDS_TRANS_TCP,
470 .t_prefer_loopback = 1,
472 .t_unloading = rds_tcp_is_unloading,
475 static unsigned int rds_tcp_netid;
477 /* per-network namespace private data for this module */
479 struct socket *rds_tcp_listen_sock;
480 struct work_struct rds_tcp_accept_w;
481 struct ctl_table_header *rds_tcp_sysctl;
482 struct ctl_table *ctl_table;
487 /* All module specific customizations to the RDS-TCP socket should be done in
488 * rds_tcp_tune() and applied after socket creation.
490 bool rds_tcp_tune(struct socket *sock)
492 struct sock *sk = sock->sk;
493 struct net *net = sock_net(sk);
494 struct rds_tcp_net *rtn;
496 tcp_sock_set_nodelay(sock->sk);
498 /* TCP timer functions might access net namespace even after
499 * a process which created this net namespace terminated.
501 if (!sk->sk_net_refcnt) {
502 if (!maybe_get_net(net)) {
506 /* Update ns_tracker to current stack trace and refcounted tracker */
507 __netns_tracker_free(net, &sk->ns_tracker, false);
509 sk->sk_net_refcnt = 1;
510 netns_tracker_alloc(net, &sk->ns_tracker, GFP_KERNEL);
511 sock_inuse_add(net, 1);
513 rtn = net_generic(net, rds_tcp_netid);
514 if (rtn->sndbuf_size > 0) {
515 sk->sk_sndbuf = rtn->sndbuf_size;
516 sk->sk_userlocks |= SOCK_SNDBUF_LOCK;
518 if (rtn->rcvbuf_size > 0) {
519 sk->sk_rcvbuf = rtn->rcvbuf_size;
520 sk->sk_userlocks |= SOCK_RCVBUF_LOCK;
526 static void rds_tcp_accept_worker(struct work_struct *work)
528 struct rds_tcp_net *rtn = container_of(work,
532 while (rds_tcp_accept_one(rtn->rds_tcp_listen_sock) == 0)
536 void rds_tcp_accept_work(struct sock *sk)
538 struct net *net = sock_net(sk);
539 struct rds_tcp_net *rtn = net_generic(net, rds_tcp_netid);
541 queue_work(rds_wq, &rtn->rds_tcp_accept_w);
544 static __net_init int rds_tcp_init_net(struct net *net)
546 struct rds_tcp_net *rtn = net_generic(net, rds_tcp_netid);
547 struct ctl_table *tbl;
550 memset(rtn, 0, sizeof(*rtn));
552 /* {snd, rcv}buf_size default to 0, which implies we let the
553 * stack pick the value, and permit auto-tuning of buffer size.
555 if (net == &init_net) {
556 tbl = rds_tcp_sysctl_table;
558 tbl = kmemdup(rds_tcp_sysctl_table,
559 sizeof(rds_tcp_sysctl_table), GFP_KERNEL);
561 pr_warn("could not set allocate sysctl table\n");
564 rtn->ctl_table = tbl;
566 tbl[RDS_TCP_SNDBUF].data = &rtn->sndbuf_size;
567 tbl[RDS_TCP_RCVBUF].data = &rtn->rcvbuf_size;
568 rtn->rds_tcp_sysctl = register_net_sysctl_sz(net, "net/rds/tcp", tbl,
569 ARRAY_SIZE(rds_tcp_sysctl_table));
570 if (!rtn->rds_tcp_sysctl) {
571 pr_warn("could not register sysctl\n");
576 #if IS_ENABLED(CONFIG_IPV6)
577 rtn->rds_tcp_listen_sock = rds_tcp_listen_init(net, true);
579 rtn->rds_tcp_listen_sock = rds_tcp_listen_init(net, false);
581 if (!rtn->rds_tcp_listen_sock) {
582 pr_warn("could not set up IPv6 listen sock\n");
584 #if IS_ENABLED(CONFIG_IPV6)
585 /* Try IPv4 as some systems disable IPv6 */
586 rtn->rds_tcp_listen_sock = rds_tcp_listen_init(net, false);
587 if (!rtn->rds_tcp_listen_sock) {
589 unregister_net_sysctl_table(rtn->rds_tcp_sysctl);
590 rtn->rds_tcp_sysctl = NULL;
593 #if IS_ENABLED(CONFIG_IPV6)
597 INIT_WORK(&rtn->rds_tcp_accept_w, rds_tcp_accept_worker);
601 if (net != &init_net)
606 static void rds_tcp_kill_sock(struct net *net)
608 struct rds_tcp_connection *tc, *_tc;
610 struct rds_tcp_net *rtn = net_generic(net, rds_tcp_netid);
611 struct socket *lsock = rtn->rds_tcp_listen_sock;
613 rtn->rds_tcp_listen_sock = NULL;
614 rds_tcp_listen_stop(lsock, &rtn->rds_tcp_accept_w);
615 spin_lock_irq(&rds_tcp_conn_lock);
616 list_for_each_entry_safe(tc, _tc, &rds_tcp_conn_list, t_tcp_node) {
617 struct net *c_net = read_pnet(&tc->t_cpath->cp_conn->c_net);
621 if (!list_has_conn(&tmp_list, tc->t_cpath->cp_conn)) {
622 list_move_tail(&tc->t_tcp_node, &tmp_list);
624 list_del(&tc->t_tcp_node);
625 tc->t_tcp_node_detached = true;
628 spin_unlock_irq(&rds_tcp_conn_lock);
629 list_for_each_entry_safe(tc, _tc, &tmp_list, t_tcp_node)
630 rds_conn_destroy(tc->t_cpath->cp_conn);
633 static void __net_exit rds_tcp_exit_net(struct net *net)
635 struct rds_tcp_net *rtn = net_generic(net, rds_tcp_netid);
637 rds_tcp_kill_sock(net);
639 if (rtn->rds_tcp_sysctl)
640 unregister_net_sysctl_table(rtn->rds_tcp_sysctl);
642 if (net != &init_net)
643 kfree(rtn->ctl_table);
646 static struct pernet_operations rds_tcp_net_ops = {
647 .init = rds_tcp_init_net,
648 .exit = rds_tcp_exit_net,
649 .id = &rds_tcp_netid,
650 .size = sizeof(struct rds_tcp_net),
653 void *rds_tcp_listen_sock_def_readable(struct net *net)
655 struct rds_tcp_net *rtn = net_generic(net, rds_tcp_netid);
656 struct socket *lsock = rtn->rds_tcp_listen_sock;
661 return lsock->sk->sk_user_data;
664 /* when sysctl is used to modify some kernel socket parameters,this
665 * function resets the RDS connections in that netns so that we can
666 * restart with new parameters. The assumption is that such reset
667 * events are few and far-between.
669 static void rds_tcp_sysctl_reset(struct net *net)
671 struct rds_tcp_connection *tc, *_tc;
673 spin_lock_irq(&rds_tcp_conn_lock);
674 list_for_each_entry_safe(tc, _tc, &rds_tcp_conn_list, t_tcp_node) {
675 struct net *c_net = read_pnet(&tc->t_cpath->cp_conn->c_net);
677 if (net != c_net || !tc->t_sock)
680 /* reconnect with new parameters */
681 rds_conn_path_drop(tc->t_cpath, false);
683 spin_unlock_irq(&rds_tcp_conn_lock);
686 static int rds_tcp_skbuf_handler(struct ctl_table *ctl, int write,
687 void *buffer, size_t *lenp, loff_t *fpos)
689 struct net *net = current->nsproxy->net_ns;
692 err = proc_dointvec_minmax(ctl, write, buffer, lenp, fpos);
694 pr_warn("Invalid input. Must be >= %d\n",
695 *(int *)(ctl->extra1));
699 rds_tcp_sysctl_reset(net);
703 static void rds_tcp_exit(void)
705 rds_tcp_set_unloading();
707 rds_info_deregister_func(RDS_INFO_TCP_SOCKETS, rds_tcp_tc_info);
708 #if IS_ENABLED(CONFIG_IPV6)
709 rds_info_deregister_func(RDS6_INFO_TCP_SOCKETS, rds6_tcp_tc_info);
711 unregister_pernet_device(&rds_tcp_net_ops);
712 rds_tcp_destroy_conns();
713 rds_trans_unregister(&rds_tcp_transport);
715 kmem_cache_destroy(rds_tcp_conn_slab);
717 module_exit(rds_tcp_exit);
719 static int __init rds_tcp_init(void)
723 rds_tcp_conn_slab = kmem_cache_create("rds_tcp_connection",
724 sizeof(struct rds_tcp_connection),
726 if (!rds_tcp_conn_slab) {
731 ret = rds_tcp_recv_init();
735 ret = register_pernet_device(&rds_tcp_net_ops);
739 rds_trans_register(&rds_tcp_transport);
741 rds_info_register_func(RDS_INFO_TCP_SOCKETS, rds_tcp_tc_info);
742 #if IS_ENABLED(CONFIG_IPV6)
743 rds_info_register_func(RDS6_INFO_TCP_SOCKETS, rds6_tcp_tc_info);
750 kmem_cache_destroy(rds_tcp_conn_slab);
754 module_init(rds_tcp_init);
756 MODULE_AUTHOR("Oracle Corporation <rds-devel@oss.oracle.com>");
757 MODULE_DESCRIPTION("RDS: TCP transport");
758 MODULE_LICENSE("Dual BSD/GPL");