proto.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272
  1. /*
  2. * net/dccp/proto.c
  3. *
  4. * An implementation of the DCCP protocol
  5. * Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/dccp.h>
  12. #include <linux/module.h>
  13. #include <linux/types.h>
  14. #include <linux/sched.h>
  15. #include <linux/kernel.h>
  16. #include <linux/skbuff.h>
  17. #include <linux/netdevice.h>
  18. #include <linux/in.h>
  19. #include <linux/if_arp.h>
  20. #include <linux/init.h>
  21. #include <linux/random.h>
  22. #include <linux/slab.h>
  23. #include <net/checksum.h>
  24. #include <net/inet_sock.h>
  25. #include <net/inet_common.h>
  26. #include <net/sock.h>
  27. #include <net/xfrm.h>
  28. #include <asm/ioctls.h>
  29. #include <linux/spinlock.h>
  30. #include <linux/timer.h>
  31. #include <linux/delay.h>
  32. #include <linux/poll.h>
  33. #include "ccid.h"
  34. #include "dccp.h"
  35. #include "feat.h"
  36. DEFINE_SNMP_STAT(struct dccp_mib, dccp_statistics) __read_mostly;
  37. EXPORT_SYMBOL_GPL(dccp_statistics);
  38. struct percpu_counter dccp_orphan_count;
  39. EXPORT_SYMBOL_GPL(dccp_orphan_count);
  40. struct inet_hashinfo dccp_hashinfo;
  41. EXPORT_SYMBOL_GPL(dccp_hashinfo);
  42. /* the maximum queue length for tx in packets. 0 is no limit */
  43. int sysctl_dccp_tx_qlen __read_mostly = 5;
  44. #ifdef CONFIG_IP_DCCP_DEBUG
  45. static const char *dccp_state_name(const int state)
  46. {
  47. static const char *const dccp_state_names[] = {
  48. [DCCP_OPEN] = "OPEN",
  49. [DCCP_REQUESTING] = "REQUESTING",
  50. [DCCP_PARTOPEN] = "PARTOPEN",
  51. [DCCP_LISTEN] = "LISTEN",
  52. [DCCP_RESPOND] = "RESPOND",
  53. [DCCP_CLOSING] = "CLOSING",
  54. [DCCP_ACTIVE_CLOSEREQ] = "CLOSEREQ",
  55. [DCCP_PASSIVE_CLOSE] = "PASSIVE_CLOSE",
  56. [DCCP_PASSIVE_CLOSEREQ] = "PASSIVE_CLOSEREQ",
  57. [DCCP_TIME_WAIT] = "TIME_WAIT",
  58. [DCCP_CLOSED] = "CLOSED",
  59. };
  60. if (state >= DCCP_MAX_STATES)
  61. return "INVALID STATE!";
  62. else
  63. return dccp_state_names[state];
  64. }
  65. #endif
  66. void dccp_set_state(struct sock *sk, const int state)
  67. {
  68. const int oldstate = sk->sk_state;
  69. dccp_pr_debug("%s(%p) %s --> %s\n", dccp_role(sk), sk,
  70. dccp_state_name(oldstate), dccp_state_name(state));
  71. WARN_ON(state == oldstate);
  72. switch (state) {
  73. case DCCP_OPEN:
  74. if (oldstate != DCCP_OPEN)
  75. DCCP_INC_STATS(DCCP_MIB_CURRESTAB);
  76. /* Client retransmits all Confirm options until entering OPEN */
  77. if (oldstate == DCCP_PARTOPEN)
  78. dccp_feat_list_purge(&dccp_sk(sk)->dccps_featneg);
  79. break;
  80. case DCCP_CLOSED:
  81. if (oldstate == DCCP_OPEN || oldstate == DCCP_ACTIVE_CLOSEREQ ||
  82. oldstate == DCCP_CLOSING)
  83. DCCP_INC_STATS(DCCP_MIB_ESTABRESETS);
  84. sk->sk_prot->unhash(sk);
  85. if (inet_csk(sk)->icsk_bind_hash != NULL &&
  86. !(sk->sk_userlocks & SOCK_BINDPORT_LOCK))
  87. inet_put_port(sk);
  88. /* fall through */
  89. default:
  90. if (oldstate == DCCP_OPEN)
  91. DCCP_DEC_STATS(DCCP_MIB_CURRESTAB);
  92. }
  93. /* Change state AFTER socket is unhashed to avoid closed
  94. * socket sitting in hash tables.
  95. */
  96. sk->sk_state = state;
  97. }
  98. EXPORT_SYMBOL_GPL(dccp_set_state);
  99. static void dccp_finish_passive_close(struct sock *sk)
  100. {
  101. switch (sk->sk_state) {
  102. case DCCP_PASSIVE_CLOSE:
  103. /* Node (client or server) has received Close packet. */
  104. dccp_send_reset(sk, DCCP_RESET_CODE_CLOSED);
  105. dccp_set_state(sk, DCCP_CLOSED);
  106. break;
  107. case DCCP_PASSIVE_CLOSEREQ:
  108. /*
  109. * Client received CloseReq. We set the `active' flag so that
  110. * dccp_send_close() retransmits the Close as per RFC 4340, 8.3.
  111. */
  112. dccp_send_close(sk, 1);
  113. dccp_set_state(sk, DCCP_CLOSING);
  114. }
  115. }
  116. void dccp_done(struct sock *sk)
  117. {
  118. dccp_set_state(sk, DCCP_CLOSED);
  119. dccp_clear_xmit_timers(sk);
  120. sk->sk_shutdown = SHUTDOWN_MASK;
  121. if (!sock_flag(sk, SOCK_DEAD))
  122. sk->sk_state_change(sk);
  123. else
  124. inet_csk_destroy_sock(sk);
  125. }
  126. EXPORT_SYMBOL_GPL(dccp_done);
  127. const char *dccp_packet_name(const int type)
  128. {
  129. static const char *const dccp_packet_names[] = {
  130. [DCCP_PKT_REQUEST] = "REQUEST",
  131. [DCCP_PKT_RESPONSE] = "RESPONSE",
  132. [DCCP_PKT_DATA] = "DATA",
  133. [DCCP_PKT_ACK] = "ACK",
  134. [DCCP_PKT_DATAACK] = "DATAACK",
  135. [DCCP_PKT_CLOSEREQ] = "CLOSEREQ",
  136. [DCCP_PKT_CLOSE] = "CLOSE",
  137. [DCCP_PKT_RESET] = "RESET",
  138. [DCCP_PKT_SYNC] = "SYNC",
  139. [DCCP_PKT_SYNCACK] = "SYNCACK",
  140. };
  141. if (type >= DCCP_NR_PKT_TYPES)
  142. return "INVALID";
  143. else
  144. return dccp_packet_names[type];
  145. }
  146. EXPORT_SYMBOL_GPL(dccp_packet_name);
  147. static void dccp_sk_destruct(struct sock *sk)
  148. {
  149. struct dccp_sock *dp = dccp_sk(sk);
  150. ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk);
  151. dp->dccps_hc_tx_ccid = NULL;
  152. inet_sock_destruct(sk);
  153. }
  154. int dccp_init_sock(struct sock *sk, const __u8 ctl_sock_initialized)
  155. {
  156. struct dccp_sock *dp = dccp_sk(sk);
  157. struct inet_connection_sock *icsk = inet_csk(sk);
  158. icsk->icsk_rto = DCCP_TIMEOUT_INIT;
  159. icsk->icsk_syn_retries = sysctl_dccp_request_retries;
  160. sk->sk_state = DCCP_CLOSED;
  161. sk->sk_write_space = dccp_write_space;
  162. sk->sk_destruct = dccp_sk_destruct;
  163. icsk->icsk_sync_mss = dccp_sync_mss;
  164. dp->dccps_mss_cache = 536;
  165. dp->dccps_rate_last = jiffies;
  166. dp->dccps_role = DCCP_ROLE_UNDEFINED;
  167. dp->dccps_service = DCCP_SERVICE_CODE_IS_ABSENT;
  168. dp->dccps_tx_qlen = sysctl_dccp_tx_qlen;
  169. dccp_init_xmit_timers(sk);
  170. INIT_LIST_HEAD(&dp->dccps_featneg);
  171. /* control socket doesn't need feat nego */
  172. if (likely(ctl_sock_initialized))
  173. return dccp_feat_init(sk);
  174. return 0;
  175. }
  176. EXPORT_SYMBOL_GPL(dccp_init_sock);
  177. void dccp_destroy_sock(struct sock *sk)
  178. {
  179. struct dccp_sock *dp = dccp_sk(sk);
  180. __skb_queue_purge(&sk->sk_write_queue);
  181. if (sk->sk_send_head != NULL) {
  182. kfree_skb(sk->sk_send_head);
  183. sk->sk_send_head = NULL;
  184. }
  185. /* Clean up a referenced DCCP bind bucket. */
  186. if (inet_csk(sk)->icsk_bind_hash != NULL)
  187. inet_put_port(sk);
  188. kfree(dp->dccps_service_list);
  189. dp->dccps_service_list = NULL;
  190. if (dp->dccps_hc_rx_ackvec != NULL) {
  191. dccp_ackvec_free(dp->dccps_hc_rx_ackvec);
  192. dp->dccps_hc_rx_ackvec = NULL;
  193. }
  194. ccid_hc_rx_delete(dp->dccps_hc_rx_ccid, sk);
  195. dp->dccps_hc_rx_ccid = NULL;
  196. /* clean up feature negotiation state */
  197. dccp_feat_list_purge(&dp->dccps_featneg);
  198. }
  199. EXPORT_SYMBOL_GPL(dccp_destroy_sock);
  200. static inline int dccp_listen_start(struct sock *sk, int backlog)
  201. {
  202. struct dccp_sock *dp = dccp_sk(sk);
  203. dp->dccps_role = DCCP_ROLE_LISTEN;
  204. /* do not start to listen if feature negotiation setup fails */
  205. if (dccp_feat_finalise_settings(dp))
  206. return -EPROTO;
  207. return inet_csk_listen_start(sk, backlog);
  208. }
  209. static inline int dccp_need_reset(int state)
  210. {
  211. return state != DCCP_CLOSED && state != DCCP_LISTEN &&
  212. state != DCCP_REQUESTING;
  213. }
  214. int dccp_disconnect(struct sock *sk, int flags)
  215. {
  216. struct inet_connection_sock *icsk = inet_csk(sk);
  217. struct inet_sock *inet = inet_sk(sk);
  218. struct dccp_sock *dp = dccp_sk(sk);
  219. int err = 0;
  220. const int old_state = sk->sk_state;
  221. if (old_state != DCCP_CLOSED)
  222. dccp_set_state(sk, DCCP_CLOSED);
  223. /*
  224. * This corresponds to the ABORT function of RFC793, sec. 3.8
  225. * TCP uses a RST segment, DCCP a Reset packet with Code 2, "Aborted".
  226. */
  227. if (old_state == DCCP_LISTEN) {
  228. inet_csk_listen_stop(sk);
  229. } else if (dccp_need_reset(old_state)) {
  230. dccp_send_reset(sk, DCCP_RESET_CODE_ABORTED);
  231. sk->sk_err = ECONNRESET;
  232. } else if (old_state == DCCP_REQUESTING)
  233. sk->sk_err = ECONNRESET;
  234. dccp_clear_xmit_timers(sk);
  235. ccid_hc_rx_delete(dp->dccps_hc_rx_ccid, sk);
  236. dp->dccps_hc_rx_ccid = NULL;
  237. __skb_queue_purge(&sk->sk_receive_queue);
  238. __skb_queue_purge(&sk->sk_write_queue);
  239. if (sk->sk_send_head != NULL) {
  240. __kfree_skb(sk->sk_send_head);
  241. sk->sk_send_head = NULL;
  242. }
  243. inet->inet_dport = 0;
  244. if (!(sk->sk_userlocks & SOCK_BINDADDR_LOCK))
  245. inet_reset_saddr(sk);
  246. sk->sk_shutdown = 0;
  247. sock_reset_flag(sk, SOCK_DONE);
  248. icsk->icsk_backoff = 0;
  249. inet_csk_delack_init(sk);
  250. __sk_dst_reset(sk);
  251. WARN_ON(inet->inet_num && !icsk->icsk_bind_hash);
  252. sk->sk_error_report(sk);
  253. return err;
  254. }
  255. EXPORT_SYMBOL_GPL(dccp_disconnect);
  256. /*
  257. * Wait for a DCCP event.
  258. *
  259. * Note that we don't need to lock the socket, as the upper poll layers
  260. * take care of normal races (between the test and the event) and we don't
  261. * go look at any of the socket buffers directly.
  262. */
  263. unsigned int dccp_poll(struct file *file, struct socket *sock,
  264. poll_table *wait)
  265. {
  266. unsigned int mask;
  267. struct sock *sk = sock->sk;
  268. sock_poll_wait(file, sk_sleep(sk), wait);
  269. if (sk->sk_state == DCCP_LISTEN)
  270. return inet_csk_listen_poll(sk);
  271. /* Socket is not locked. We are protected from async events
  272. by poll logic and correct handling of state changes
  273. made by another threads is impossible in any case.
  274. */
  275. mask = 0;
  276. if (sk->sk_err)
  277. mask = POLLERR;
  278. if (sk->sk_shutdown == SHUTDOWN_MASK || sk->sk_state == DCCP_CLOSED)
  279. mask |= POLLHUP;
  280. if (sk->sk_shutdown & RCV_SHUTDOWN)
  281. mask |= POLLIN | POLLRDNORM | POLLRDHUP;
  282. /* Connected? */
  283. if ((1 << sk->sk_state) & ~(DCCPF_REQUESTING | DCCPF_RESPOND)) {
  284. if (atomic_read(&sk->sk_rmem_alloc) > 0)
  285. mask |= POLLIN | POLLRDNORM;
  286. if (!(sk->sk_shutdown & SEND_SHUTDOWN)) {
  287. if (sk_stream_is_writeable(sk)) {
  288. mask |= POLLOUT | POLLWRNORM;
  289. } else { /* send SIGIO later */
  290. sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);
  291. set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
  292. /* Race breaker. If space is freed after
  293. * wspace test but before the flags are set,
  294. * IO signal will be lost.
  295. */
  296. if (sk_stream_is_writeable(sk))
  297. mask |= POLLOUT | POLLWRNORM;
  298. }
  299. }
  300. }
  301. return mask;
  302. }
  303. EXPORT_SYMBOL_GPL(dccp_poll);
  304. int dccp_ioctl(struct sock *sk, int cmd, unsigned long arg)
  305. {
  306. int rc = -ENOTCONN;
  307. lock_sock(sk);
  308. if (sk->sk_state == DCCP_LISTEN)
  309. goto out;
  310. switch (cmd) {
  311. case SIOCINQ: {
  312. struct sk_buff *skb;
  313. unsigned long amount = 0;
  314. skb = skb_peek(&sk->sk_receive_queue);
  315. if (skb != NULL) {
  316. /*
  317. * We will only return the amount of this packet since
  318. * that is all that will be read.
  319. */
  320. amount = skb->len;
  321. }
  322. rc = put_user(amount, (int __user *)arg);
  323. }
  324. break;
  325. default:
  326. rc = -ENOIOCTLCMD;
  327. break;
  328. }
  329. out:
  330. release_sock(sk);
  331. return rc;
  332. }
  333. EXPORT_SYMBOL_GPL(dccp_ioctl);
  334. static int dccp_setsockopt_service(struct sock *sk, const __be32 service,
  335. char __user *optval, unsigned int optlen)
  336. {
  337. struct dccp_sock *dp = dccp_sk(sk);
  338. struct dccp_service_list *sl = NULL;
  339. if (service == DCCP_SERVICE_INVALID_VALUE ||
  340. optlen > DCCP_SERVICE_LIST_MAX_LEN * sizeof(u32))
  341. return -EINVAL;
  342. if (optlen > sizeof(service)) {
  343. sl = kmalloc(optlen, GFP_KERNEL);
  344. if (sl == NULL)
  345. return -ENOMEM;
  346. sl->dccpsl_nr = optlen / sizeof(u32) - 1;
  347. if (copy_from_user(sl->dccpsl_list,
  348. optval + sizeof(service),
  349. optlen - sizeof(service)) ||
  350. dccp_list_has_service(sl, DCCP_SERVICE_INVALID_VALUE)) {
  351. kfree(sl);
  352. return -EFAULT;
  353. }
  354. }
  355. lock_sock(sk);
  356. dp->dccps_service = service;
  357. kfree(dp->dccps_service_list);
  358. dp->dccps_service_list = sl;
  359. release_sock(sk);
  360. return 0;
  361. }
  362. static int dccp_setsockopt_cscov(struct sock *sk, int cscov, bool rx)
  363. {
  364. u8 *list, len;
  365. int i, rc;
  366. if (cscov < 0 || cscov > 15)
  367. return -EINVAL;
  368. /*
  369. * Populate a list of permissible values, in the range cscov...15. This
  370. * is necessary since feature negotiation of single values only works if
  371. * both sides incidentally choose the same value. Since the list starts
  372. * lowest-value first, negotiation will pick the smallest shared value.
  373. */
  374. if (cscov == 0)
  375. return 0;
  376. len = 16 - cscov;
  377. list = kmalloc(len, GFP_KERNEL);
  378. if (list == NULL)
  379. return -ENOBUFS;
  380. for (i = 0; i < len; i++)
  381. list[i] = cscov++;
  382. rc = dccp_feat_register_sp(sk, DCCPF_MIN_CSUM_COVER, rx, list, len);
  383. if (rc == 0) {
  384. if (rx)
  385. dccp_sk(sk)->dccps_pcrlen = cscov;
  386. else
  387. dccp_sk(sk)->dccps_pcslen = cscov;
  388. }
  389. kfree(list);
  390. return rc;
  391. }
  392. static int dccp_setsockopt_ccid(struct sock *sk, int type,
  393. char __user *optval, unsigned int optlen)
  394. {
  395. u8 *val;
  396. int rc = 0;
  397. if (optlen < 1 || optlen > DCCP_FEAT_MAX_SP_VALS)
  398. return -EINVAL;
  399. val = memdup_user(optval, optlen);
  400. if (IS_ERR(val))
  401. return PTR_ERR(val);
  402. lock_sock(sk);
  403. if (type == DCCP_SOCKOPT_TX_CCID || type == DCCP_SOCKOPT_CCID)
  404. rc = dccp_feat_register_sp(sk, DCCPF_CCID, 1, val, optlen);
  405. if (!rc && (type == DCCP_SOCKOPT_RX_CCID || type == DCCP_SOCKOPT_CCID))
  406. rc = dccp_feat_register_sp(sk, DCCPF_CCID, 0, val, optlen);
  407. release_sock(sk);
  408. kfree(val);
  409. return rc;
  410. }
  411. static int do_dccp_setsockopt(struct sock *sk, int level, int optname,
  412. char __user *optval, unsigned int optlen)
  413. {
  414. struct dccp_sock *dp = dccp_sk(sk);
  415. int val, err = 0;
  416. switch (optname) {
  417. case DCCP_SOCKOPT_PACKET_SIZE:
  418. DCCP_WARN("sockopt(PACKET_SIZE) is deprecated: fix your app\n");
  419. return 0;
  420. case DCCP_SOCKOPT_CHANGE_L:
  421. case DCCP_SOCKOPT_CHANGE_R:
  422. DCCP_WARN("sockopt(CHANGE_L/R) is deprecated: fix your app\n");
  423. return 0;
  424. case DCCP_SOCKOPT_CCID:
  425. case DCCP_SOCKOPT_RX_CCID:
  426. case DCCP_SOCKOPT_TX_CCID:
  427. return dccp_setsockopt_ccid(sk, optname, optval, optlen);
  428. }
  429. if (optlen < (int)sizeof(int))
  430. return -EINVAL;
  431. if (get_user(val, (int __user *)optval))
  432. return -EFAULT;
  433. if (optname == DCCP_SOCKOPT_SERVICE)
  434. return dccp_setsockopt_service(sk, val, optval, optlen);
  435. lock_sock(sk);
  436. switch (optname) {
  437. case DCCP_SOCKOPT_SERVER_TIMEWAIT:
  438. if (dp->dccps_role != DCCP_ROLE_SERVER)
  439. err = -EOPNOTSUPP;
  440. else
  441. dp->dccps_server_timewait = (val != 0);
  442. break;
  443. case DCCP_SOCKOPT_SEND_CSCOV:
  444. err = dccp_setsockopt_cscov(sk, val, false);
  445. break;
  446. case DCCP_SOCKOPT_RECV_CSCOV:
  447. err = dccp_setsockopt_cscov(sk, val, true);
  448. break;
  449. case DCCP_SOCKOPT_QPOLICY_ID:
  450. if (sk->sk_state != DCCP_CLOSED)
  451. err = -EISCONN;
  452. else if (val < 0 || val >= DCCPQ_POLICY_MAX)
  453. err = -EINVAL;
  454. else
  455. dp->dccps_qpolicy = val;
  456. break;
  457. case DCCP_SOCKOPT_QPOLICY_TXQLEN:
  458. if (val < 0)
  459. err = -EINVAL;
  460. else
  461. dp->dccps_tx_qlen = val;
  462. break;
  463. default:
  464. err = -ENOPROTOOPT;
  465. break;
  466. }
  467. release_sock(sk);
  468. return err;
  469. }
  470. int dccp_setsockopt(struct sock *sk, int level, int optname,
  471. char __user *optval, unsigned int optlen)
  472. {
  473. if (level != SOL_DCCP)
  474. return inet_csk(sk)->icsk_af_ops->setsockopt(sk, level,
  475. optname, optval,
  476. optlen);
  477. return do_dccp_setsockopt(sk, level, optname, optval, optlen);
  478. }
  479. EXPORT_SYMBOL_GPL(dccp_setsockopt);
  480. #ifdef CONFIG_COMPAT
  481. int compat_dccp_setsockopt(struct sock *sk, int level, int optname,
  482. char __user *optval, unsigned int optlen)
  483. {
  484. if (level != SOL_DCCP)
  485. return inet_csk_compat_setsockopt(sk, level, optname,
  486. optval, optlen);
  487. return do_dccp_setsockopt(sk, level, optname, optval, optlen);
  488. }
  489. EXPORT_SYMBOL_GPL(compat_dccp_setsockopt);
  490. #endif
  491. static int dccp_getsockopt_service(struct sock *sk, int len,
  492. __be32 __user *optval,
  493. int __user *optlen)
  494. {
  495. const struct dccp_sock *dp = dccp_sk(sk);
  496. const struct dccp_service_list *sl;
  497. int err = -ENOENT, slen = 0, total_len = sizeof(u32);
  498. lock_sock(sk);
  499. if ((sl = dp->dccps_service_list) != NULL) {
  500. slen = sl->dccpsl_nr * sizeof(u32);
  501. total_len += slen;
  502. }
  503. err = -EINVAL;
  504. if (total_len > len)
  505. goto out;
  506. err = 0;
  507. if (put_user(total_len, optlen) ||
  508. put_user(dp->dccps_service, optval) ||
  509. (sl != NULL && copy_to_user(optval + 1, sl->dccpsl_list, slen)))
  510. err = -EFAULT;
  511. out:
  512. release_sock(sk);
  513. return err;
  514. }
  515. static int do_dccp_getsockopt(struct sock *sk, int level, int optname,
  516. char __user *optval, int __user *optlen)
  517. {
  518. struct dccp_sock *dp;
  519. int val, len;
  520. if (get_user(len, optlen))
  521. return -EFAULT;
  522. if (len < (int)sizeof(int))
  523. return -EINVAL;
  524. dp = dccp_sk(sk);
  525. switch (optname) {
  526. case DCCP_SOCKOPT_PACKET_SIZE:
  527. DCCP_WARN("sockopt(PACKET_SIZE) is deprecated: fix your app\n");
  528. return 0;
  529. case DCCP_SOCKOPT_SERVICE:
  530. return dccp_getsockopt_service(sk, len,
  531. (__be32 __user *)optval, optlen);
  532. case DCCP_SOCKOPT_GET_CUR_MPS:
  533. val = dp->dccps_mss_cache;
  534. break;
  535. case DCCP_SOCKOPT_AVAILABLE_CCIDS:
  536. return ccid_getsockopt_builtin_ccids(sk, len, optval, optlen);
  537. case DCCP_SOCKOPT_TX_CCID:
  538. val = ccid_get_current_tx_ccid(dp);
  539. if (val < 0)
  540. return -ENOPROTOOPT;
  541. break;
  542. case DCCP_SOCKOPT_RX_CCID:
  543. val = ccid_get_current_rx_ccid(dp);
  544. if (val < 0)
  545. return -ENOPROTOOPT;
  546. break;
  547. case DCCP_SOCKOPT_SERVER_TIMEWAIT:
  548. val = dp->dccps_server_timewait;
  549. break;
  550. case DCCP_SOCKOPT_SEND_CSCOV:
  551. val = dp->dccps_pcslen;
  552. break;
  553. case DCCP_SOCKOPT_RECV_CSCOV:
  554. val = dp->dccps_pcrlen;
  555. break;
  556. case DCCP_SOCKOPT_QPOLICY_ID:
  557. val = dp->dccps_qpolicy;
  558. break;
  559. case DCCP_SOCKOPT_QPOLICY_TXQLEN:
  560. val = dp->dccps_tx_qlen;
  561. break;
  562. case 128 ... 191:
  563. return ccid_hc_rx_getsockopt(dp->dccps_hc_rx_ccid, sk, optname,
  564. len, (u32 __user *)optval, optlen);
  565. case 192 ... 255:
  566. return ccid_hc_tx_getsockopt(dp->dccps_hc_tx_ccid, sk, optname,
  567. len, (u32 __user *)optval, optlen);
  568. default:
  569. return -ENOPROTOOPT;
  570. }
  571. len = sizeof(val);
  572. if (put_user(len, optlen) || copy_to_user(optval, &val, len))
  573. return -EFAULT;
  574. return 0;
  575. }
  576. int dccp_getsockopt(struct sock *sk, int level, int optname,
  577. char __user *optval, int __user *optlen)
  578. {
  579. if (level != SOL_DCCP)
  580. return inet_csk(sk)->icsk_af_ops->getsockopt(sk, level,
  581. optname, optval,
  582. optlen);
  583. return do_dccp_getsockopt(sk, level, optname, optval, optlen);
  584. }
  585. EXPORT_SYMBOL_GPL(dccp_getsockopt);
  586. #ifdef CONFIG_COMPAT
  587. int compat_dccp_getsockopt(struct sock *sk, int level, int optname,
  588. char __user *optval, int __user *optlen)
  589. {
  590. if (level != SOL_DCCP)
  591. return inet_csk_compat_getsockopt(sk, level, optname,
  592. optval, optlen);
  593. return do_dccp_getsockopt(sk, level, optname, optval, optlen);
  594. }
  595. EXPORT_SYMBOL_GPL(compat_dccp_getsockopt);
  596. #endif
  597. static int dccp_msghdr_parse(struct msghdr *msg, struct sk_buff *skb)
  598. {
  599. struct cmsghdr *cmsg;
  600. /*
  601. * Assign an (opaque) qpolicy priority value to skb->priority.
  602. *
  603. * We are overloading this skb field for use with the qpolicy subystem.
  604. * The skb->priority is normally used for the SO_PRIORITY option, which
  605. * is initialised from sk_priority. Since the assignment of sk_priority
  606. * to skb->priority happens later (on layer 3), we overload this field
  607. * for use with queueing priorities as long as the skb is on layer 4.
  608. * The default priority value (if nothing is set) is 0.
  609. */
  610. skb->priority = 0;
  611. for_each_cmsghdr(cmsg, msg) {
  612. if (!CMSG_OK(msg, cmsg))
  613. return -EINVAL;
  614. if (cmsg->cmsg_level != SOL_DCCP)
  615. continue;
  616. if (cmsg->cmsg_type <= DCCP_SCM_QPOLICY_MAX &&
  617. !dccp_qpolicy_param_ok(skb->sk, cmsg->cmsg_type))
  618. return -EINVAL;
  619. switch (cmsg->cmsg_type) {
  620. case DCCP_SCM_PRIORITY:
  621. if (cmsg->cmsg_len != CMSG_LEN(sizeof(__u32)))
  622. return -EINVAL;
  623. skb->priority = *(__u32 *)CMSG_DATA(cmsg);
  624. break;
  625. default:
  626. return -EINVAL;
  627. }
  628. }
  629. return 0;
  630. }
  631. int dccp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
  632. {
  633. const struct dccp_sock *dp = dccp_sk(sk);
  634. const int flags = msg->msg_flags;
  635. const int noblock = flags & MSG_DONTWAIT;
  636. struct sk_buff *skb;
  637. int rc, size;
  638. long timeo;
  639. if (len > dp->dccps_mss_cache)
  640. return -EMSGSIZE;
  641. lock_sock(sk);
  642. if (dccp_qpolicy_full(sk)) {
  643. rc = -EAGAIN;
  644. goto out_release;
  645. }
  646. timeo = sock_sndtimeo(sk, noblock);
  647. /*
  648. * We have to use sk_stream_wait_connect here to set sk_write_pending,
  649. * so that the trick in dccp_rcv_request_sent_state_process.
  650. */
  651. /* Wait for a connection to finish. */
  652. if ((1 << sk->sk_state) & ~(DCCPF_OPEN | DCCPF_PARTOPEN))
  653. if ((rc = sk_stream_wait_connect(sk, &timeo)) != 0)
  654. goto out_release;
  655. size = sk->sk_prot->max_header + len;
  656. release_sock(sk);
  657. skb = sock_alloc_send_skb(sk, size, noblock, &rc);
  658. lock_sock(sk);
  659. if (skb == NULL)
  660. goto out_release;
  661. if (sk->sk_state == DCCP_CLOSED) {
  662. rc = -ENOTCONN;
  663. goto out_discard;
  664. }
  665. skb_reserve(skb, sk->sk_prot->max_header);
  666. rc = memcpy_from_msg(skb_put(skb, len), msg, len);
  667. if (rc != 0)
  668. goto out_discard;
  669. rc = dccp_msghdr_parse(msg, skb);
  670. if (rc != 0)
  671. goto out_discard;
  672. dccp_qpolicy_push(sk, skb);
  673. /*
  674. * The xmit_timer is set if the TX CCID is rate-based and will expire
  675. * when congestion control permits to release further packets into the
  676. * network. Window-based CCIDs do not use this timer.
  677. */
  678. if (!timer_pending(&dp->dccps_xmit_timer))
  679. dccp_write_xmit(sk);
  680. out_release:
  681. release_sock(sk);
  682. return rc ? : len;
  683. out_discard:
  684. kfree_skb(skb);
  685. goto out_release;
  686. }
  687. EXPORT_SYMBOL_GPL(dccp_sendmsg);
  688. int dccp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock,
  689. int flags, int *addr_len)
  690. {
  691. const struct dccp_hdr *dh;
  692. long timeo;
  693. lock_sock(sk);
  694. if (sk->sk_state == DCCP_LISTEN) {
  695. len = -ENOTCONN;
  696. goto out;
  697. }
  698. timeo = sock_rcvtimeo(sk, nonblock);
  699. do {
  700. struct sk_buff *skb = skb_peek(&sk->sk_receive_queue);
  701. if (skb == NULL)
  702. goto verify_sock_status;
  703. dh = dccp_hdr(skb);
  704. switch (dh->dccph_type) {
  705. case DCCP_PKT_DATA:
  706. case DCCP_PKT_DATAACK:
  707. goto found_ok_skb;
  708. case DCCP_PKT_CLOSE:
  709. case DCCP_PKT_CLOSEREQ:
  710. if (!(flags & MSG_PEEK))
  711. dccp_finish_passive_close(sk);
  712. /* fall through */
  713. case DCCP_PKT_RESET:
  714. dccp_pr_debug("found fin (%s) ok!\n",
  715. dccp_packet_name(dh->dccph_type));
  716. len = 0;
  717. goto found_fin_ok;
  718. default:
  719. dccp_pr_debug("packet_type=%s\n",
  720. dccp_packet_name(dh->dccph_type));
  721. sk_eat_skb(sk, skb);
  722. }
  723. verify_sock_status:
  724. if (sock_flag(sk, SOCK_DONE)) {
  725. len = 0;
  726. break;
  727. }
  728. if (sk->sk_err) {
  729. len = sock_error(sk);
  730. break;
  731. }
  732. if (sk->sk_shutdown & RCV_SHUTDOWN) {
  733. len = 0;
  734. break;
  735. }
  736. if (sk->sk_state == DCCP_CLOSED) {
  737. if (!sock_flag(sk, SOCK_DONE)) {
  738. /* This occurs when user tries to read
  739. * from never connected socket.
  740. */
  741. len = -ENOTCONN;
  742. break;
  743. }
  744. len = 0;
  745. break;
  746. }
  747. if (!timeo) {
  748. len = -EAGAIN;
  749. break;
  750. }
  751. if (signal_pending(current)) {
  752. len = sock_intr_errno(timeo);
  753. break;
  754. }
  755. sk_wait_data(sk, &timeo, NULL);
  756. continue;
  757. found_ok_skb:
  758. if (len > skb->len)
  759. len = skb->len;
  760. else if (len < skb->len)
  761. msg->msg_flags |= MSG_TRUNC;
  762. if (skb_copy_datagram_msg(skb, 0, msg, len)) {
  763. /* Exception. Bailout! */
  764. len = -EFAULT;
  765. break;
  766. }
  767. if (flags & MSG_TRUNC)
  768. len = skb->len;
  769. found_fin_ok:
  770. if (!(flags & MSG_PEEK))
  771. sk_eat_skb(sk, skb);
  772. break;
  773. } while (1);
  774. out:
  775. release_sock(sk);
  776. return len;
  777. }
  778. EXPORT_SYMBOL_GPL(dccp_recvmsg);
  779. int inet_dccp_listen(struct socket *sock, int backlog)
  780. {
  781. struct sock *sk = sock->sk;
  782. unsigned char old_state;
  783. int err;
  784. lock_sock(sk);
  785. err = -EINVAL;
  786. if (sock->state != SS_UNCONNECTED || sock->type != SOCK_DCCP)
  787. goto out;
  788. old_state = sk->sk_state;
  789. if (!((1 << old_state) & (DCCPF_CLOSED | DCCPF_LISTEN)))
  790. goto out;
  791. /* Really, if the socket is already in listen state
  792. * we can only allow the backlog to be adjusted.
  793. */
  794. if (old_state != DCCP_LISTEN) {
  795. /*
  796. * FIXME: here it probably should be sk->sk_prot->listen_start
  797. * see tcp_listen_start
  798. */
  799. err = dccp_listen_start(sk, backlog);
  800. if (err)
  801. goto out;
  802. }
  803. sk->sk_max_ack_backlog = backlog;
  804. err = 0;
  805. out:
  806. release_sock(sk);
  807. return err;
  808. }
  809. EXPORT_SYMBOL_GPL(inet_dccp_listen);
  810. static void dccp_terminate_connection(struct sock *sk)
  811. {
  812. u8 next_state = DCCP_CLOSED;
  813. switch (sk->sk_state) {
  814. case DCCP_PASSIVE_CLOSE:
  815. case DCCP_PASSIVE_CLOSEREQ:
  816. dccp_finish_passive_close(sk);
  817. break;
  818. case DCCP_PARTOPEN:
  819. dccp_pr_debug("Stop PARTOPEN timer (%p)\n", sk);
  820. inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK);
  821. /* fall through */
  822. case DCCP_OPEN:
  823. dccp_send_close(sk, 1);
  824. if (dccp_sk(sk)->dccps_role == DCCP_ROLE_SERVER &&
  825. !dccp_sk(sk)->dccps_server_timewait)
  826. next_state = DCCP_ACTIVE_CLOSEREQ;
  827. else
  828. next_state = DCCP_CLOSING;
  829. /* fall through */
  830. default:
  831. dccp_set_state(sk, next_state);
  832. }
  833. }
  834. void dccp_close(struct sock *sk, long timeout)
  835. {
  836. struct dccp_sock *dp = dccp_sk(sk);
  837. struct sk_buff *skb;
  838. u32 data_was_unread = 0;
  839. int state;
  840. lock_sock(sk);
  841. sk->sk_shutdown = SHUTDOWN_MASK;
  842. if (sk->sk_state == DCCP_LISTEN) {
  843. dccp_set_state(sk, DCCP_CLOSED);
  844. /* Special case. */
  845. inet_csk_listen_stop(sk);
  846. goto adjudge_to_death;
  847. }
  848. sk_stop_timer(sk, &dp->dccps_xmit_timer);
  849. /*
  850. * We need to flush the recv. buffs. We do this only on the
  851. * descriptor close, not protocol-sourced closes, because the
  852. *reader process may not have drained the data yet!
  853. */
  854. while ((skb = __skb_dequeue(&sk->sk_receive_queue)) != NULL) {
  855. data_was_unread += skb->len;
  856. __kfree_skb(skb);
  857. }
  858. /* If socket has been already reset kill it. */
  859. if (sk->sk_state == DCCP_CLOSED)
  860. goto adjudge_to_death;
  861. if (data_was_unread) {
  862. /* Unread data was tossed, send an appropriate Reset Code */
  863. DCCP_WARN("ABORT with %u bytes unread\n", data_was_unread);
  864. dccp_send_reset(sk, DCCP_RESET_CODE_ABORTED);
  865. dccp_set_state(sk, DCCP_CLOSED);
  866. } else if (sock_flag(sk, SOCK_LINGER) && !sk->sk_lingertime) {
  867. /* Check zero linger _after_ checking for unread data. */
  868. sk->sk_prot->disconnect(sk, 0);
  869. } else if (sk->sk_state != DCCP_CLOSED) {
  870. /*
  871. * Normal connection termination. May need to wait if there are
  872. * still packets in the TX queue that are delayed by the CCID.
  873. */
  874. dccp_flush_write_queue(sk, &timeout);
  875. dccp_terminate_connection(sk);
  876. }
  877. /*
  878. * Flush write queue. This may be necessary in several cases:
  879. * - we have been closed by the peer but still have application data;
  880. * - abortive termination (unread data or zero linger time),
  881. * - normal termination but queue could not be flushed within time limit
  882. */
  883. __skb_queue_purge(&sk->sk_write_queue);
  884. sk_stream_wait_close(sk, timeout);
  885. adjudge_to_death:
  886. state = sk->sk_state;
  887. sock_hold(sk);
  888. sock_orphan(sk);
  889. /*
  890. * It is the last release_sock in its life. It will remove backlog.
  891. */
  892. release_sock(sk);
  893. /*
  894. * Now socket is owned by kernel and we acquire BH lock
  895. * to finish close. No need to check for user refs.
  896. */
  897. local_bh_disable();
  898. bh_lock_sock(sk);
  899. WARN_ON(sock_owned_by_user(sk));
  900. percpu_counter_inc(sk->sk_prot->orphan_count);
  901. /* Have we already been destroyed by a softirq or backlog? */
  902. if (state != DCCP_CLOSED && sk->sk_state == DCCP_CLOSED)
  903. goto out;
  904. if (sk->sk_state == DCCP_CLOSED)
  905. inet_csk_destroy_sock(sk);
  906. /* Otherwise, socket is reprieved until protocol close. */
  907. out:
  908. bh_unlock_sock(sk);
  909. local_bh_enable();
  910. sock_put(sk);
  911. }
  912. EXPORT_SYMBOL_GPL(dccp_close);
  913. void dccp_shutdown(struct sock *sk, int how)
  914. {
  915. dccp_pr_debug("called shutdown(%x)\n", how);
  916. }
  917. EXPORT_SYMBOL_GPL(dccp_shutdown);
  918. static inline int __init dccp_mib_init(void)
  919. {
  920. dccp_statistics = alloc_percpu(struct dccp_mib);
  921. if (!dccp_statistics)
  922. return -ENOMEM;
  923. return 0;
  924. }
  925. static inline void dccp_mib_exit(void)
  926. {
  927. free_percpu(dccp_statistics);
  928. }
  929. static int thash_entries;
  930. module_param(thash_entries, int, 0444);
  931. MODULE_PARM_DESC(thash_entries, "Number of ehash buckets");
  932. #ifdef CONFIG_IP_DCCP_DEBUG
  933. bool dccp_debug;
  934. module_param(dccp_debug, bool, 0644);
  935. MODULE_PARM_DESC(dccp_debug, "Enable debug messages");
  936. EXPORT_SYMBOL_GPL(dccp_debug);
  937. #endif
  938. static int __init dccp_init(void)
  939. {
  940. unsigned long goal;
  941. int ehash_order, bhash_order, i;
  942. int rc;
  943. BUILD_BUG_ON(sizeof(struct dccp_skb_cb) >
  944. FIELD_SIZEOF(struct sk_buff, cb));
  945. rc = percpu_counter_init(&dccp_orphan_count, 0, GFP_KERNEL);
  946. if (rc)
  947. goto out_fail;
  948. rc = -ENOBUFS;
  949. inet_hashinfo_init(&dccp_hashinfo);
  950. dccp_hashinfo.bind_bucket_cachep =
  951. kmem_cache_create("dccp_bind_bucket",
  952. sizeof(struct inet_bind_bucket), 0,
  953. SLAB_HWCACHE_ALIGN, NULL);
  954. if (!dccp_hashinfo.bind_bucket_cachep)
  955. goto out_free_percpu;
  956. /*
  957. * Size and allocate the main established and bind bucket
  958. * hash tables.
  959. *
  960. * The methodology is similar to that of the buffer cache.
  961. */
  962. if (totalram_pages >= (128 * 1024))
  963. goal = totalram_pages >> (21 - PAGE_SHIFT);
  964. else
  965. goal = totalram_pages >> (23 - PAGE_SHIFT);
  966. if (thash_entries)
  967. goal = (thash_entries *
  968. sizeof(struct inet_ehash_bucket)) >> PAGE_SHIFT;
  969. for (ehash_order = 0; (1UL << ehash_order) < goal; ehash_order++)
  970. ;
  971. do {
  972. unsigned long hash_size = (1UL << ehash_order) * PAGE_SIZE /
  973. sizeof(struct inet_ehash_bucket);
  974. while (hash_size & (hash_size - 1))
  975. hash_size--;
  976. dccp_hashinfo.ehash_mask = hash_size - 1;
  977. dccp_hashinfo.ehash = (struct inet_ehash_bucket *)
  978. __get_free_pages(GFP_ATOMIC|__GFP_NOWARN, ehash_order);
  979. } while (!dccp_hashinfo.ehash && --ehash_order > 0);
  980. if (!dccp_hashinfo.ehash) {
  981. DCCP_CRIT("Failed to allocate DCCP established hash table");
  982. goto out_free_bind_bucket_cachep;
  983. }
  984. for (i = 0; i <= dccp_hashinfo.ehash_mask; i++)
  985. INIT_HLIST_NULLS_HEAD(&dccp_hashinfo.ehash[i].chain, i);
  986. if (inet_ehash_locks_alloc(&dccp_hashinfo))
  987. goto out_free_dccp_ehash;
  988. bhash_order = ehash_order;
  989. do {
  990. dccp_hashinfo.bhash_size = (1UL << bhash_order) * PAGE_SIZE /
  991. sizeof(struct inet_bind_hashbucket);
  992. if ((dccp_hashinfo.bhash_size > (64 * 1024)) &&
  993. bhash_order > 0)
  994. continue;
  995. dccp_hashinfo.bhash = (struct inet_bind_hashbucket *)
  996. __get_free_pages(GFP_ATOMIC|__GFP_NOWARN, bhash_order);
  997. } while (!dccp_hashinfo.bhash && --bhash_order >= 0);
  998. if (!dccp_hashinfo.bhash) {
  999. DCCP_CRIT("Failed to allocate DCCP bind hash table");
  1000. goto out_free_dccp_locks;
  1001. }
  1002. for (i = 0; i < dccp_hashinfo.bhash_size; i++) {
  1003. spin_lock_init(&dccp_hashinfo.bhash[i].lock);
  1004. INIT_HLIST_HEAD(&dccp_hashinfo.bhash[i].chain);
  1005. }
  1006. rc = dccp_mib_init();
  1007. if (rc)
  1008. goto out_free_dccp_bhash;
  1009. rc = dccp_ackvec_init();
  1010. if (rc)
  1011. goto out_free_dccp_mib;
  1012. rc = dccp_sysctl_init();
  1013. if (rc)
  1014. goto out_ackvec_exit;
  1015. rc = ccid_initialize_builtins();
  1016. if (rc)
  1017. goto out_sysctl_exit;
  1018. dccp_timestamping_init();
  1019. return 0;
  1020. out_sysctl_exit:
  1021. dccp_sysctl_exit();
  1022. out_ackvec_exit:
  1023. dccp_ackvec_exit();
  1024. out_free_dccp_mib:
  1025. dccp_mib_exit();
  1026. out_free_dccp_bhash:
  1027. free_pages((unsigned long)dccp_hashinfo.bhash, bhash_order);
  1028. out_free_dccp_locks:
  1029. inet_ehash_locks_free(&dccp_hashinfo);
  1030. out_free_dccp_ehash:
  1031. free_pages((unsigned long)dccp_hashinfo.ehash, ehash_order);
  1032. out_free_bind_bucket_cachep:
  1033. kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep);
  1034. out_free_percpu:
  1035. percpu_counter_destroy(&dccp_orphan_count);
  1036. out_fail:
  1037. dccp_hashinfo.bhash = NULL;
  1038. dccp_hashinfo.ehash = NULL;
  1039. dccp_hashinfo.bind_bucket_cachep = NULL;
  1040. return rc;
  1041. }
  1042. static void __exit dccp_fini(void)
  1043. {
  1044. ccid_cleanup_builtins();
  1045. dccp_mib_exit();
  1046. free_pages((unsigned long)dccp_hashinfo.bhash,
  1047. get_order(dccp_hashinfo.bhash_size *
  1048. sizeof(struct inet_bind_hashbucket)));
  1049. free_pages((unsigned long)dccp_hashinfo.ehash,
  1050. get_order((dccp_hashinfo.ehash_mask + 1) *
  1051. sizeof(struct inet_ehash_bucket)));
  1052. inet_ehash_locks_free(&dccp_hashinfo);
  1053. kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep);
  1054. dccp_ackvec_exit();
  1055. dccp_sysctl_exit();
  1056. percpu_counter_destroy(&dccp_orphan_count);
  1057. }
  1058. module_init(dccp_init);
  1059. module_exit(dccp_fini);
  1060. MODULE_LICENSE("GPL");
  1061. MODULE_AUTHOR("Arnaldo Carvalho de Melo <acme@conectiva.com.br>");
  1062. MODULE_DESCRIPTION("DCCP - Datagram Congestion Controlled Protocol");