33 #include <linux/kernel.h>
34 #include <linux/slab.h>
36 #include <linux/module.h>
45 static unsigned int rds_tcp_tc_count;
53 #define RDS_TCP_DEFAULT_BUFSIZE (128 * 1024)
69 struct sock *
sk = sock->
sk;
86 return tcp_sk(tc->
t_sock->sk)->snd_nxt;
91 return tcp_sk(tc->
t_sock->sk)->snd_una;
97 rdsdebug(
"restoring sock %p callbacks from tc %p\n", sock, tc);
101 spin_lock(&rds_tcp_tc_list_lock);
104 spin_unlock(&rds_tcp_tc_list_lock);
111 sock->
sk->sk_user_data =
NULL;
125 rdsdebug(
"setting sock %p callbacks to tc %p\n", sock, tc);
129 spin_lock(&rds_tcp_tc_list_lock);
132 spin_unlock(&rds_tcp_tc_list_lock);
136 sock->
sk->sk_data_ready = sock->
sk->sk_user_data;
144 sock->
sk->sk_user_data =
conn;
152 static void rds_tcp_tc_info(
struct socket *
sock,
unsigned int len,
164 if (len /
sizeof(tsinfo) < rds_tcp_tc_count)
169 sock->
ops->getname(sock, (
struct sockaddr *)&sin, &sinlen, 0);
170 tsinfo.local_addr = sin.sin_addr.s_addr;
171 tsinfo.local_port = sin.sin_port;
172 sock->
ops->getname(sock, (
struct sockaddr *)&sin, &sinlen, 1);
173 tsinfo.peer_addr = sin.sin_addr.s_addr;
174 tsinfo.peer_port = sin.sin_port;
186 lens->
nr = rds_tcp_tc_count;
187 lens->
each =
sizeof(tsinfo);
189 spin_unlock_irqrestore(&rds_tcp_tc_list_lock, flags);
214 spin_lock_irq(&rds_tcp_conn_lock);
216 spin_unlock_irq(&rds_tcp_conn_lock);
222 static void rds_tcp_conn_free(
void *
arg)
226 rdsdebug(
"freeing tc %p\n", tc);
230 spin_unlock_irqrestore(&rds_tcp_conn_lock, flags);
235 static void rds_tcp_destroy_conns(
void)
241 spin_lock_irq(&rds_tcp_conn_lock);
242 list_splice(&rds_tcp_conn_list, &tmp_list);
243 INIT_LIST_HEAD(&rds_tcp_conn_list);
244 spin_unlock_irq(&rds_tcp_conn_lock);
247 if (tc->
conn->c_passive)
253 static void rds_tcp_exit(
void)
257 rds_tcp_destroy_conns();
265 .laddr_check = rds_tcp_laddr_check,
270 .conn_alloc = rds_tcp_conn_alloc,
271 .conn_free = rds_tcp_conn_free,
277 .exit = rds_tcp_exit,
281 .t_prefer_loopback = 1,
284 static int rds_tcp_init(
void)
291 if (!rds_tcp_conn_slab) {