af_rds.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. /*
  2. * Copyright (c) 2006 Oracle. All rights reserved.
  3. *
  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:
  9. *
  10. * Redistribution and use in source and binary forms, with or
  11. * without modification, are permitted provided that the following
  12. * conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above
  15. * copyright notice, this list of conditions and the following
  16. * disclaimer.
  17. *
  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.
  22. *
  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
  30. * SOFTWARE.
  31. *
  32. */
  33. #include <linux/module.h>
  34. #include <linux/errno.h>
  35. #include <linux/kernel.h>
  36. #include <linux/gfp.h>
  37. #include <linux/in.h>
  38. #include <linux/poll.h>
  39. #include <net/sock.h>
  40. #include "rds.h"
  41. /* this is just used for stats gathering :/ */
  42. static DEFINE_SPINLOCK(rds_sock_lock);
  43. static unsigned long rds_sock_count;
  44. static LIST_HEAD(rds_sock_list);
  45. DECLARE_WAIT_QUEUE_HEAD(rds_poll_waitq);
  46. /*
  47. * This is called as the final descriptor referencing this socket is closed.
  48. * We have to unbind the socket so that another socket can be bound to the
  49. * address it was using.
  50. *
  51. * We have to be careful about racing with the incoming path. sock_orphan()
  52. * sets SOCK_DEAD and we use that as an indicator to the rx path that new
  53. * messages shouldn't be queued.
  54. */
  55. static int rds_release(struct socket *sock)
  56. {
  57. struct sock *sk = sock->sk;
  58. struct rds_sock *rs;
  59. if (!sk)
  60. goto out;
  61. rs = rds_sk_to_rs(sk);
  62. sock_orphan(sk);
  63. /* Note - rds_clear_recv_queue grabs rs_recv_lock, so
  64. * that ensures the recv path has completed messing
  65. * with the socket. */
  66. rds_clear_recv_queue(rs);
  67. rds_cong_remove_socket(rs);
  68. rds_remove_bound(rs);
  69. rds_send_drop_to(rs, NULL);
  70. rds_rdma_drop_keys(rs);
  71. rds_notify_queue_get(rs, NULL);
  72. spin_lock_bh(&rds_sock_lock);
  73. list_del_init(&rs->rs_item);
  74. rds_sock_count--;
  75. spin_unlock_bh(&rds_sock_lock);
  76. rds_trans_put(rs->rs_transport);
  77. sock->sk = NULL;
  78. sock_put(sk);
  79. out:
  80. return 0;
  81. }
  82. /*
  83. * Careful not to race with rds_release -> sock_orphan which clears sk_sleep.
  84. * _bh() isn't OK here, we're called from interrupt handlers. It's probably OK
  85. * to wake the waitqueue after sk_sleep is clear as we hold a sock ref, but
  86. * this seems more conservative.
  87. * NB - normally, one would use sk_callback_lock for this, but we can
  88. * get here from interrupts, whereas the network code grabs sk_callback_lock
  89. * with _lock_bh only - so relying on sk_callback_lock introduces livelocks.
  90. */
  91. void rds_wake_sk_sleep(struct rds_sock *rs)
  92. {
  93. unsigned long flags;
  94. read_lock_irqsave(&rs->rs_recv_lock, flags);
  95. __rds_wake_sk_sleep(rds_rs_to_sk(rs));
  96. read_unlock_irqrestore(&rs->rs_recv_lock, flags);
  97. }
  98. static int rds_getname(struct socket *sock, struct sockaddr *uaddr,
  99. int *uaddr_len, int peer)
  100. {
  101. struct sockaddr_in *sin = (struct sockaddr_in *)uaddr;
  102. struct rds_sock *rs = rds_sk_to_rs(sock->sk);
  103. memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
  104. /* racey, don't care */
  105. if (peer) {
  106. if (!rs->rs_conn_addr)
  107. return -ENOTCONN;
  108. sin->sin_port = rs->rs_conn_port;
  109. sin->sin_addr.s_addr = rs->rs_conn_addr;
  110. } else {
  111. sin->sin_port = rs->rs_bound_port;
  112. sin->sin_addr.s_addr = rs->rs_bound_addr;
  113. }
  114. sin->sin_family = AF_INET;
  115. *uaddr_len = sizeof(*sin);
  116. return 0;
  117. }
  118. /*
  119. * RDS' poll is without a doubt the least intuitive part of the interface,
  120. * as POLLIN and POLLOUT do not behave entirely as you would expect from
  121. * a network protocol.
  122. *
  123. * POLLIN is asserted if
  124. * - there is data on the receive queue.
  125. * - to signal that a previously congested destination may have become
  126. * uncongested
  127. * - A notification has been queued to the socket (this can be a congestion
  128. * update, or a RDMA completion).
  129. *
  130. * POLLOUT is asserted if there is room on the send queue. This does not mean
  131. * however, that the next sendmsg() call will succeed. If the application tries
  132. * to send to a congested destination, the system call may still fail (and
  133. * return ENOBUFS).
  134. */
  135. static unsigned int rds_poll(struct file *file, struct socket *sock,
  136. poll_table *wait)
  137. {
  138. struct sock *sk = sock->sk;
  139. struct rds_sock *rs = rds_sk_to_rs(sk);
  140. unsigned int mask = 0;
  141. unsigned long flags;
  142. poll_wait(file, sk_sleep(sk), wait);
  143. if (rs->rs_seen_congestion)
  144. poll_wait(file, &rds_poll_waitq, wait);
  145. read_lock_irqsave(&rs->rs_recv_lock, flags);
  146. if (!rs->rs_cong_monitor) {
  147. /* When a congestion map was updated, we signal POLLIN for
  148. * "historical" reasons. Applications can also poll for
  149. * WRBAND instead. */
  150. if (rds_cong_updated_since(&rs->rs_cong_track))
  151. mask |= (POLLIN | POLLRDNORM | POLLWRBAND);
  152. } else {
  153. spin_lock(&rs->rs_lock);
  154. if (rs->rs_cong_notify)
  155. mask |= (POLLIN | POLLRDNORM);
  156. spin_unlock(&rs->rs_lock);
  157. }
  158. if (!list_empty(&rs->rs_recv_queue) ||
  159. !list_empty(&rs->rs_notify_queue))
  160. mask |= (POLLIN | POLLRDNORM);
  161. if (rs->rs_snd_bytes < rds_sk_sndbuf(rs))
  162. mask |= (POLLOUT | POLLWRNORM);
  163. read_unlock_irqrestore(&rs->rs_recv_lock, flags);
  164. /* clear state any time we wake a seen-congested socket */
  165. if (mask)
  166. rs->rs_seen_congestion = 0;
  167. return mask;
  168. }
  169. static int rds_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
  170. {
  171. return -ENOIOCTLCMD;
  172. }
  173. static int rds_cancel_sent_to(struct rds_sock *rs, char __user *optval,
  174. int len)
  175. {
  176. struct sockaddr_in sin;
  177. int ret = 0;
  178. /* racing with another thread binding seems ok here */
  179. if (rs->rs_bound_addr == 0) {
  180. ret = -ENOTCONN; /* XXX not a great errno */
  181. goto out;
  182. }
  183. if (len < sizeof(struct sockaddr_in)) {
  184. ret = -EINVAL;
  185. goto out;
  186. }
  187. if (copy_from_user(&sin, optval, sizeof(sin))) {
  188. ret = -EFAULT;
  189. goto out;
  190. }
  191. rds_send_drop_to(rs, &sin);
  192. out:
  193. return ret;
  194. }
  195. static int rds_set_bool_option(unsigned char *optvar, char __user *optval,
  196. int optlen)
  197. {
  198. int value;
  199. if (optlen < sizeof(int))
  200. return -EINVAL;
  201. if (get_user(value, (int __user *) optval))
  202. return -EFAULT;
  203. *optvar = !!value;
  204. return 0;
  205. }
  206. static int rds_cong_monitor(struct rds_sock *rs, char __user *optval,
  207. int optlen)
  208. {
  209. int ret;
  210. ret = rds_set_bool_option(&rs->rs_cong_monitor, optval, optlen);
  211. if (ret == 0) {
  212. if (rs->rs_cong_monitor) {
  213. rds_cong_add_socket(rs);
  214. } else {
  215. rds_cong_remove_socket(rs);
  216. rs->rs_cong_mask = 0;
  217. rs->rs_cong_notify = 0;
  218. }
  219. }
  220. return ret;
  221. }
  222. static int rds_set_transport(struct rds_sock *rs, char __user *optval,
  223. int optlen)
  224. {
  225. int t_type;
  226. if (rs->rs_transport)
  227. return -EOPNOTSUPP; /* previously attached to transport */
  228. if (optlen != sizeof(int))
  229. return -EINVAL;
  230. if (copy_from_user(&t_type, (int __user *)optval, sizeof(t_type)))
  231. return -EFAULT;
  232. if (t_type < 0 || t_type >= RDS_TRANS_COUNT)
  233. return -EINVAL;
  234. rs->rs_transport = rds_trans_get(t_type);
  235. return rs->rs_transport ? 0 : -ENOPROTOOPT;
  236. }
  237. static int rds_enable_recvtstamp(struct sock *sk, char __user *optval,
  238. int optlen)
  239. {
  240. int val, valbool;
  241. if (optlen != sizeof(int))
  242. return -EFAULT;
  243. if (get_user(val, (int __user *)optval))
  244. return -EFAULT;
  245. valbool = val ? 1 : 0;
  246. if (valbool)
  247. sock_set_flag(sk, SOCK_RCVTSTAMP);
  248. else
  249. sock_reset_flag(sk, SOCK_RCVTSTAMP);
  250. return 0;
  251. }
  252. static int rds_recv_track_latency(struct rds_sock *rs, char __user *optval,
  253. int optlen)
  254. {
  255. struct rds_rx_trace_so trace;
  256. int i;
  257. if (optlen != sizeof(struct rds_rx_trace_so))
  258. return -EFAULT;
  259. if (copy_from_user(&trace, optval, sizeof(trace)))
  260. return -EFAULT;
  261. if (trace.rx_traces > RDS_MSG_RX_DGRAM_TRACE_MAX)
  262. return -EFAULT;
  263. rs->rs_rx_traces = trace.rx_traces;
  264. for (i = 0; i < rs->rs_rx_traces; i++) {
  265. if (trace.rx_trace_pos[i] > RDS_MSG_RX_DGRAM_TRACE_MAX) {
  266. rs->rs_rx_traces = 0;
  267. return -EFAULT;
  268. }
  269. rs->rs_rx_trace[i] = trace.rx_trace_pos[i];
  270. }
  271. return 0;
  272. }
  273. static int rds_setsockopt(struct socket *sock, int level, int optname,
  274. char __user *optval, unsigned int optlen)
  275. {
  276. struct rds_sock *rs = rds_sk_to_rs(sock->sk);
  277. int ret;
  278. if (level != SOL_RDS) {
  279. ret = -ENOPROTOOPT;
  280. goto out;
  281. }
  282. switch (optname) {
  283. case RDS_CANCEL_SENT_TO:
  284. ret = rds_cancel_sent_to(rs, optval, optlen);
  285. break;
  286. case RDS_GET_MR:
  287. ret = rds_get_mr(rs, optval, optlen);
  288. break;
  289. case RDS_GET_MR_FOR_DEST:
  290. ret = rds_get_mr_for_dest(rs, optval, optlen);
  291. break;
  292. case RDS_FREE_MR:
  293. ret = rds_free_mr(rs, optval, optlen);
  294. break;
  295. case RDS_RECVERR:
  296. ret = rds_set_bool_option(&rs->rs_recverr, optval, optlen);
  297. break;
  298. case RDS_CONG_MONITOR:
  299. ret = rds_cong_monitor(rs, optval, optlen);
  300. break;
  301. case SO_RDS_TRANSPORT:
  302. lock_sock(sock->sk);
  303. ret = rds_set_transport(rs, optval, optlen);
  304. release_sock(sock->sk);
  305. break;
  306. case SO_TIMESTAMP:
  307. lock_sock(sock->sk);
  308. ret = rds_enable_recvtstamp(sock->sk, optval, optlen);
  309. release_sock(sock->sk);
  310. break;
  311. case SO_RDS_MSG_RXPATH_LATENCY:
  312. ret = rds_recv_track_latency(rs, optval, optlen);
  313. break;
  314. default:
  315. ret = -ENOPROTOOPT;
  316. }
  317. out:
  318. return ret;
  319. }
  320. static int rds_getsockopt(struct socket *sock, int level, int optname,
  321. char __user *optval, int __user *optlen)
  322. {
  323. struct rds_sock *rs = rds_sk_to_rs(sock->sk);
  324. int ret = -ENOPROTOOPT, len;
  325. int trans;
  326. if (level != SOL_RDS)
  327. goto out;
  328. if (get_user(len, optlen)) {
  329. ret = -EFAULT;
  330. goto out;
  331. }
  332. switch (optname) {
  333. case RDS_INFO_FIRST ... RDS_INFO_LAST:
  334. ret = rds_info_getsockopt(sock, optname, optval,
  335. optlen);
  336. break;
  337. case RDS_RECVERR:
  338. if (len < sizeof(int))
  339. ret = -EINVAL;
  340. else
  341. if (put_user(rs->rs_recverr, (int __user *) optval) ||
  342. put_user(sizeof(int), optlen))
  343. ret = -EFAULT;
  344. else
  345. ret = 0;
  346. break;
  347. case SO_RDS_TRANSPORT:
  348. if (len < sizeof(int)) {
  349. ret = -EINVAL;
  350. break;
  351. }
  352. trans = (rs->rs_transport ? rs->rs_transport->t_type :
  353. RDS_TRANS_NONE); /* unbound */
  354. if (put_user(trans, (int __user *)optval) ||
  355. put_user(sizeof(int), optlen))
  356. ret = -EFAULT;
  357. else
  358. ret = 0;
  359. break;
  360. default:
  361. break;
  362. }
  363. out:
  364. return ret;
  365. }
  366. static int rds_connect(struct socket *sock, struct sockaddr *uaddr,
  367. int addr_len, int flags)
  368. {
  369. struct sock *sk = sock->sk;
  370. struct sockaddr_in *sin = (struct sockaddr_in *)uaddr;
  371. struct rds_sock *rs = rds_sk_to_rs(sk);
  372. int ret = 0;
  373. lock_sock(sk);
  374. if (addr_len != sizeof(struct sockaddr_in)) {
  375. ret = -EINVAL;
  376. goto out;
  377. }
  378. if (sin->sin_family != AF_INET) {
  379. ret = -EAFNOSUPPORT;
  380. goto out;
  381. }
  382. if (sin->sin_addr.s_addr == htonl(INADDR_ANY)) {
  383. ret = -EDESTADDRREQ;
  384. goto out;
  385. }
  386. rs->rs_conn_addr = sin->sin_addr.s_addr;
  387. rs->rs_conn_port = sin->sin_port;
  388. out:
  389. release_sock(sk);
  390. return ret;
  391. }
  392. static struct proto rds_proto = {
  393. .name = "RDS",
  394. .owner = THIS_MODULE,
  395. .obj_size = sizeof(struct rds_sock),
  396. };
  397. static const struct proto_ops rds_proto_ops = {
  398. .family = AF_RDS,
  399. .owner = THIS_MODULE,
  400. .release = rds_release,
  401. .bind = rds_bind,
  402. .connect = rds_connect,
  403. .socketpair = sock_no_socketpair,
  404. .accept = sock_no_accept,
  405. .getname = rds_getname,
  406. .poll = rds_poll,
  407. .ioctl = rds_ioctl,
  408. .listen = sock_no_listen,
  409. .shutdown = sock_no_shutdown,
  410. .setsockopt = rds_setsockopt,
  411. .getsockopt = rds_getsockopt,
  412. .sendmsg = rds_sendmsg,
  413. .recvmsg = rds_recvmsg,
  414. .mmap = sock_no_mmap,
  415. .sendpage = sock_no_sendpage,
  416. };
  417. static void rds_sock_destruct(struct sock *sk)
  418. {
  419. struct rds_sock *rs = rds_sk_to_rs(sk);
  420. WARN_ON((&rs->rs_item != rs->rs_item.next ||
  421. &rs->rs_item != rs->rs_item.prev));
  422. }
  423. static int __rds_create(struct socket *sock, struct sock *sk, int protocol)
  424. {
  425. struct rds_sock *rs;
  426. sock_init_data(sock, sk);
  427. sock->ops = &rds_proto_ops;
  428. sk->sk_protocol = protocol;
  429. sk->sk_destruct = rds_sock_destruct;
  430. rs = rds_sk_to_rs(sk);
  431. spin_lock_init(&rs->rs_lock);
  432. rwlock_init(&rs->rs_recv_lock);
  433. INIT_LIST_HEAD(&rs->rs_send_queue);
  434. INIT_LIST_HEAD(&rs->rs_recv_queue);
  435. INIT_LIST_HEAD(&rs->rs_notify_queue);
  436. INIT_LIST_HEAD(&rs->rs_cong_list);
  437. spin_lock_init(&rs->rs_rdma_lock);
  438. rs->rs_rdma_keys = RB_ROOT;
  439. rs->rs_rx_traces = 0;
  440. spin_lock_bh(&rds_sock_lock);
  441. list_add_tail(&rs->rs_item, &rds_sock_list);
  442. rds_sock_count++;
  443. spin_unlock_bh(&rds_sock_lock);
  444. return 0;
  445. }
  446. static int rds_create(struct net *net, struct socket *sock, int protocol,
  447. int kern)
  448. {
  449. struct sock *sk;
  450. if (sock->type != SOCK_SEQPACKET || protocol)
  451. return -ESOCKTNOSUPPORT;
  452. sk = sk_alloc(net, AF_RDS, GFP_ATOMIC, &rds_proto, kern);
  453. if (!sk)
  454. return -ENOMEM;
  455. return __rds_create(sock, sk, protocol);
  456. }
  457. void rds_sock_addref(struct rds_sock *rs)
  458. {
  459. sock_hold(rds_rs_to_sk(rs));
  460. }
  461. void rds_sock_put(struct rds_sock *rs)
  462. {
  463. sock_put(rds_rs_to_sk(rs));
  464. }
  465. static const struct net_proto_family rds_family_ops = {
  466. .family = AF_RDS,
  467. .create = rds_create,
  468. .owner = THIS_MODULE,
  469. };
  470. static void rds_sock_inc_info(struct socket *sock, unsigned int len,
  471. struct rds_info_iterator *iter,
  472. struct rds_info_lengths *lens)
  473. {
  474. struct rds_sock *rs;
  475. struct rds_incoming *inc;
  476. unsigned int total = 0;
  477. len /= sizeof(struct rds_info_message);
  478. spin_lock_bh(&rds_sock_lock);
  479. list_for_each_entry(rs, &rds_sock_list, rs_item) {
  480. read_lock(&rs->rs_recv_lock);
  481. /* XXX too lazy to maintain counts.. */
  482. list_for_each_entry(inc, &rs->rs_recv_queue, i_item) {
  483. total++;
  484. if (total <= len)
  485. rds_inc_info_copy(inc, iter, inc->i_saddr,
  486. rs->rs_bound_addr, 1);
  487. }
  488. read_unlock(&rs->rs_recv_lock);
  489. }
  490. spin_unlock_bh(&rds_sock_lock);
  491. lens->nr = total;
  492. lens->each = sizeof(struct rds_info_message);
  493. }
  494. static void rds_sock_info(struct socket *sock, unsigned int len,
  495. struct rds_info_iterator *iter,
  496. struct rds_info_lengths *lens)
  497. {
  498. struct rds_info_socket sinfo;
  499. struct rds_sock *rs;
  500. len /= sizeof(struct rds_info_socket);
  501. spin_lock_bh(&rds_sock_lock);
  502. if (len < rds_sock_count)
  503. goto out;
  504. list_for_each_entry(rs, &rds_sock_list, rs_item) {
  505. sinfo.sndbuf = rds_sk_sndbuf(rs);
  506. sinfo.rcvbuf = rds_sk_rcvbuf(rs);
  507. sinfo.bound_addr = rs->rs_bound_addr;
  508. sinfo.connected_addr = rs->rs_conn_addr;
  509. sinfo.bound_port = rs->rs_bound_port;
  510. sinfo.connected_port = rs->rs_conn_port;
  511. sinfo.inum = sock_i_ino(rds_rs_to_sk(rs));
  512. rds_info_copy(iter, &sinfo, sizeof(sinfo));
  513. }
  514. out:
  515. lens->nr = rds_sock_count;
  516. lens->each = sizeof(struct rds_info_socket);
  517. spin_unlock_bh(&rds_sock_lock);
  518. }
  519. static void rds_exit(void)
  520. {
  521. sock_unregister(rds_family_ops.family);
  522. proto_unregister(&rds_proto);
  523. rds_conn_exit();
  524. rds_cong_exit();
  525. rds_sysctl_exit();
  526. rds_threads_exit();
  527. rds_stats_exit();
  528. rds_page_exit();
  529. rds_bind_lock_destroy();
  530. rds_info_deregister_func(RDS_INFO_SOCKETS, rds_sock_info);
  531. rds_info_deregister_func(RDS_INFO_RECV_MESSAGES, rds_sock_inc_info);
  532. }
  533. module_exit(rds_exit);
  534. u32 rds_gen_num;
  535. static int rds_init(void)
  536. {
  537. int ret;
  538. net_get_random_once(&rds_gen_num, sizeof(rds_gen_num));
  539. ret = rds_bind_lock_init();
  540. if (ret)
  541. goto out;
  542. ret = rds_conn_init();
  543. if (ret)
  544. goto out_bind;
  545. ret = rds_threads_init();
  546. if (ret)
  547. goto out_conn;
  548. ret = rds_sysctl_init();
  549. if (ret)
  550. goto out_threads;
  551. ret = rds_stats_init();
  552. if (ret)
  553. goto out_sysctl;
  554. ret = proto_register(&rds_proto, 1);
  555. if (ret)
  556. goto out_stats;
  557. ret = sock_register(&rds_family_ops);
  558. if (ret)
  559. goto out_proto;
  560. rds_info_register_func(RDS_INFO_SOCKETS, rds_sock_info);
  561. rds_info_register_func(RDS_INFO_RECV_MESSAGES, rds_sock_inc_info);
  562. goto out;
  563. out_proto:
  564. proto_unregister(&rds_proto);
  565. out_stats:
  566. rds_stats_exit();
  567. out_sysctl:
  568. rds_sysctl_exit();
  569. out_threads:
  570. rds_threads_exit();
  571. out_conn:
  572. rds_conn_exit();
  573. rds_cong_exit();
  574. rds_page_exit();
  575. out_bind:
  576. rds_bind_lock_destroy();
  577. out:
  578. return ret;
  579. }
  580. module_init(rds_init);
  581. #define DRV_VERSION "4.0"
  582. #define DRV_RELDATE "Feb 12, 2009"
  583. MODULE_AUTHOR("Oracle Corporation <rds-devel@oss.oracle.com>");
  584. MODULE_DESCRIPTION("RDS: Reliable Datagram Sockets"
  585. " v" DRV_VERSION " (" DRV_RELDATE ")");
  586. MODULE_VERSION(DRV_VERSION);
  587. MODULE_LICENSE("Dual BSD/GPL");
  588. MODULE_ALIAS_NETPROTO(PF_RDS);