ipv6.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170
  1. /*
  2. * DCCP over IPv6
  3. * Linux INET6 implementation
  4. *
  5. * Based on net/dccp6/ipv6.c
  6. *
  7. * Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version
  12. * 2 of the License, or (at your option) any later version.
  13. */
  14. #include <linux/module.h>
  15. #include <linux/random.h>
  16. #include <linux/slab.h>
  17. #include <linux/xfrm.h>
  18. #include <linux/string.h>
  19. #include <net/addrconf.h>
  20. #include <net/inet_common.h>
  21. #include <net/inet_hashtables.h>
  22. #include <net/inet_sock.h>
  23. #include <net/inet6_connection_sock.h>
  24. #include <net/inet6_hashtables.h>
  25. #include <net/ip6_route.h>
  26. #include <net/ipv6.h>
  27. #include <net/protocol.h>
  28. #include <net/transp_v6.h>
  29. #include <net/ip6_checksum.h>
  30. #include <net/xfrm.h>
  31. #include <net/secure_seq.h>
  32. #include <net/sock.h>
  33. #include "dccp.h"
  34. #include "ipv6.h"
  35. #include "feat.h"
  36. /* The per-net dccp.v6_ctl_sk is used for sending RSTs and ACKs */
  37. static const struct inet_connection_sock_af_ops dccp_ipv6_mapped;
  38. static const struct inet_connection_sock_af_ops dccp_ipv6_af_ops;
  39. /* add pseudo-header to DCCP checksum stored in skb->csum */
  40. static inline __sum16 dccp_v6_csum_finish(struct sk_buff *skb,
  41. const struct in6_addr *saddr,
  42. const struct in6_addr *daddr)
  43. {
  44. return csum_ipv6_magic(saddr, daddr, skb->len, IPPROTO_DCCP, skb->csum);
  45. }
  46. static inline void dccp_v6_send_check(struct sock *sk, struct sk_buff *skb)
  47. {
  48. struct ipv6_pinfo *np = inet6_sk(sk);
  49. struct dccp_hdr *dh = dccp_hdr(skb);
  50. dccp_csum_outgoing(skb);
  51. dh->dccph_checksum = dccp_v6_csum_finish(skb, &np->saddr, &sk->sk_v6_daddr);
  52. }
  53. static inline __u64 dccp_v6_init_sequence(struct sk_buff *skb)
  54. {
  55. return secure_dccpv6_sequence_number(ipv6_hdr(skb)->daddr.s6_addr32,
  56. ipv6_hdr(skb)->saddr.s6_addr32,
  57. dccp_hdr(skb)->dccph_dport,
  58. dccp_hdr(skb)->dccph_sport );
  59. }
  60. static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
  61. u8 type, u8 code, int offset, __be32 info)
  62. {
  63. const struct ipv6hdr *hdr = (const struct ipv6hdr *)skb->data;
  64. const struct dccp_hdr *dh;
  65. struct dccp_sock *dp;
  66. struct ipv6_pinfo *np;
  67. struct sock *sk;
  68. int err;
  69. __u64 seq;
  70. struct net *net = dev_net(skb->dev);
  71. /* Only need dccph_dport & dccph_sport which are the first
  72. * 4 bytes in dccp header.
  73. * Our caller (icmpv6_notify()) already pulled 8 bytes for us.
  74. */
  75. BUILD_BUG_ON(offsetofend(struct dccp_hdr, dccph_sport) > 8);
  76. BUILD_BUG_ON(offsetofend(struct dccp_hdr, dccph_dport) > 8);
  77. dh = (struct dccp_hdr *)(skb->data + offset);
  78. sk = __inet6_lookup_established(net, &dccp_hashinfo,
  79. &hdr->daddr, dh->dccph_dport,
  80. &hdr->saddr, ntohs(dh->dccph_sport),
  81. inet6_iif(skb), 0);
  82. if (!sk) {
  83. __ICMP6_INC_STATS(net, __in6_dev_get(skb->dev),
  84. ICMP6_MIB_INERRORS);
  85. return;
  86. }
  87. if (sk->sk_state == DCCP_TIME_WAIT) {
  88. inet_twsk_put(inet_twsk(sk));
  89. return;
  90. }
  91. seq = dccp_hdr_seq(dh);
  92. if (sk->sk_state == DCCP_NEW_SYN_RECV)
  93. return dccp_req_err(sk, seq);
  94. bh_lock_sock(sk);
  95. if (sock_owned_by_user(sk))
  96. __NET_INC_STATS(net, LINUX_MIB_LOCKDROPPEDICMPS);
  97. if (sk->sk_state == DCCP_CLOSED)
  98. goto out;
  99. dp = dccp_sk(sk);
  100. if ((1 << sk->sk_state) & ~(DCCPF_REQUESTING | DCCPF_LISTEN) &&
  101. !between48(seq, dp->dccps_awl, dp->dccps_awh)) {
  102. __NET_INC_STATS(net, LINUX_MIB_OUTOFWINDOWICMPS);
  103. goto out;
  104. }
  105. np = inet6_sk(sk);
  106. if (type == NDISC_REDIRECT) {
  107. if (!sock_owned_by_user(sk)) {
  108. struct dst_entry *dst = __sk_dst_check(sk, np->dst_cookie);
  109. if (dst)
  110. dst->ops->redirect(dst, sk, skb);
  111. }
  112. goto out;
  113. }
  114. if (type == ICMPV6_PKT_TOOBIG) {
  115. struct dst_entry *dst = NULL;
  116. if (!ip6_sk_accept_pmtu(sk))
  117. goto out;
  118. if (sock_owned_by_user(sk))
  119. goto out;
  120. if ((1 << sk->sk_state) & (DCCPF_LISTEN | DCCPF_CLOSED))
  121. goto out;
  122. dst = inet6_csk_update_pmtu(sk, ntohl(info));
  123. if (!dst)
  124. goto out;
  125. if (inet_csk(sk)->icsk_pmtu_cookie > dst_mtu(dst))
  126. dccp_sync_mss(sk, dst_mtu(dst));
  127. goto out;
  128. }
  129. icmpv6_err_convert(type, code, &err);
  130. /* Might be for an request_sock */
  131. switch (sk->sk_state) {
  132. case DCCP_REQUESTING:
  133. case DCCP_RESPOND: /* Cannot happen.
  134. It can, it SYNs are crossed. --ANK */
  135. if (!sock_owned_by_user(sk)) {
  136. __DCCP_INC_STATS(DCCP_MIB_ATTEMPTFAILS);
  137. sk->sk_err = err;
  138. /*
  139. * Wake people up to see the error
  140. * (see connect in sock.c)
  141. */
  142. sk->sk_error_report(sk);
  143. dccp_done(sk);
  144. } else
  145. sk->sk_err_soft = err;
  146. goto out;
  147. }
  148. if (!sock_owned_by_user(sk) && np->recverr) {
  149. sk->sk_err = err;
  150. sk->sk_error_report(sk);
  151. } else
  152. sk->sk_err_soft = err;
  153. out:
  154. bh_unlock_sock(sk);
  155. sock_put(sk);
  156. }
  157. static int dccp_v6_send_response(const struct sock *sk, struct request_sock *req)
  158. {
  159. struct inet_request_sock *ireq = inet_rsk(req);
  160. struct ipv6_pinfo *np = inet6_sk(sk);
  161. struct sk_buff *skb;
  162. struct in6_addr *final_p, final;
  163. struct flowi6 fl6;
  164. int err = -1;
  165. struct dst_entry *dst;
  166. memset(&fl6, 0, sizeof(fl6));
  167. fl6.flowi6_proto = IPPROTO_DCCP;
  168. fl6.daddr = ireq->ir_v6_rmt_addr;
  169. fl6.saddr = ireq->ir_v6_loc_addr;
  170. fl6.flowlabel = 0;
  171. fl6.flowi6_oif = ireq->ir_iif;
  172. fl6.fl6_dport = ireq->ir_rmt_port;
  173. fl6.fl6_sport = htons(ireq->ir_num);
  174. security_req_classify_flow(req, flowi6_to_flowi(&fl6));
  175. rcu_read_lock();
  176. final_p = fl6_update_dst(&fl6, rcu_dereference(np->opt), &final);
  177. rcu_read_unlock();
  178. dst = ip6_dst_lookup_flow(sk, &fl6, final_p);
  179. if (IS_ERR(dst)) {
  180. err = PTR_ERR(dst);
  181. dst = NULL;
  182. goto done;
  183. }
  184. skb = dccp_make_response(sk, dst, req);
  185. if (skb != NULL) {
  186. struct dccp_hdr *dh = dccp_hdr(skb);
  187. struct ipv6_txoptions *opt;
  188. dh->dccph_checksum = dccp_v6_csum_finish(skb,
  189. &ireq->ir_v6_loc_addr,
  190. &ireq->ir_v6_rmt_addr);
  191. fl6.daddr = ireq->ir_v6_rmt_addr;
  192. rcu_read_lock();
  193. opt = ireq->ipv6_opt;
  194. if (!opt)
  195. opt = rcu_dereference(np->opt);
  196. err = ip6_xmit(sk, skb, &fl6, sk->sk_mark, opt, np->tclass);
  197. rcu_read_unlock();
  198. err = net_xmit_eval(err);
  199. }
  200. done:
  201. dst_release(dst);
  202. return err;
  203. }
  204. static void dccp_v6_reqsk_destructor(struct request_sock *req)
  205. {
  206. dccp_feat_list_purge(&dccp_rsk(req)->dreq_featneg);
  207. kfree(inet_rsk(req)->ipv6_opt);
  208. kfree_skb(inet_rsk(req)->pktopts);
  209. }
  210. static void dccp_v6_ctl_send_reset(const struct sock *sk, struct sk_buff *rxskb)
  211. {
  212. const struct ipv6hdr *rxip6h;
  213. struct sk_buff *skb;
  214. struct flowi6 fl6;
  215. struct net *net = dev_net(skb_dst(rxskb)->dev);
  216. struct sock *ctl_sk = net->dccp.v6_ctl_sk;
  217. struct dst_entry *dst;
  218. if (dccp_hdr(rxskb)->dccph_type == DCCP_PKT_RESET)
  219. return;
  220. if (!ipv6_unicast_destination(rxskb))
  221. return;
  222. skb = dccp_ctl_make_reset(ctl_sk, rxskb);
  223. if (skb == NULL)
  224. return;
  225. rxip6h = ipv6_hdr(rxskb);
  226. dccp_hdr(skb)->dccph_checksum = dccp_v6_csum_finish(skb, &rxip6h->saddr,
  227. &rxip6h->daddr);
  228. memset(&fl6, 0, sizeof(fl6));
  229. fl6.daddr = rxip6h->saddr;
  230. fl6.saddr = rxip6h->daddr;
  231. fl6.flowi6_proto = IPPROTO_DCCP;
  232. fl6.flowi6_oif = inet6_iif(rxskb);
  233. fl6.fl6_dport = dccp_hdr(skb)->dccph_dport;
  234. fl6.fl6_sport = dccp_hdr(skb)->dccph_sport;
  235. security_skb_classify_flow(rxskb, flowi6_to_flowi(&fl6));
  236. /* sk = NULL, but it is safe for now. RST socket required. */
  237. dst = ip6_dst_lookup_flow(ctl_sk, &fl6, NULL);
  238. if (!IS_ERR(dst)) {
  239. skb_dst_set(skb, dst);
  240. ip6_xmit(ctl_sk, skb, &fl6, 0, NULL, 0);
  241. DCCP_INC_STATS(DCCP_MIB_OUTSEGS);
  242. DCCP_INC_STATS(DCCP_MIB_OUTRSTS);
  243. return;
  244. }
  245. kfree_skb(skb);
  246. }
  247. static struct request_sock_ops dccp6_request_sock_ops = {
  248. .family = AF_INET6,
  249. .obj_size = sizeof(struct dccp6_request_sock),
  250. .rtx_syn_ack = dccp_v6_send_response,
  251. .send_ack = dccp_reqsk_send_ack,
  252. .destructor = dccp_v6_reqsk_destructor,
  253. .send_reset = dccp_v6_ctl_send_reset,
  254. .syn_ack_timeout = dccp_syn_ack_timeout,
  255. };
  256. static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
  257. {
  258. struct request_sock *req;
  259. struct dccp_request_sock *dreq;
  260. struct inet_request_sock *ireq;
  261. struct ipv6_pinfo *np = inet6_sk(sk);
  262. const __be32 service = dccp_hdr_request(skb)->dccph_req_service;
  263. struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
  264. if (skb->protocol == htons(ETH_P_IP))
  265. return dccp_v4_conn_request(sk, skb);
  266. if (!ipv6_unicast_destination(skb))
  267. return 0; /* discard, don't send a reset here */
  268. if (dccp_bad_service_code(sk, service)) {
  269. dcb->dccpd_reset_code = DCCP_RESET_CODE_BAD_SERVICE_CODE;
  270. goto drop;
  271. }
  272. /*
  273. * There are no SYN attacks on IPv6, yet...
  274. */
  275. dcb->dccpd_reset_code = DCCP_RESET_CODE_TOO_BUSY;
  276. if (inet_csk_reqsk_queue_is_full(sk))
  277. goto drop;
  278. if (sk_acceptq_is_full(sk))
  279. goto drop;
  280. req = inet_reqsk_alloc(&dccp6_request_sock_ops, sk, true);
  281. if (req == NULL)
  282. goto drop;
  283. if (dccp_reqsk_init(req, dccp_sk(sk), skb))
  284. goto drop_and_free;
  285. dreq = dccp_rsk(req);
  286. if (dccp_parse_options(sk, dreq, skb))
  287. goto drop_and_free;
  288. if (security_inet_conn_request(sk, skb, req))
  289. goto drop_and_free;
  290. ireq = inet_rsk(req);
  291. ireq->ir_v6_rmt_addr = ipv6_hdr(skb)->saddr;
  292. ireq->ir_v6_loc_addr = ipv6_hdr(skb)->daddr;
  293. ireq->ireq_family = AF_INET6;
  294. ireq->ir_mark = inet_request_mark(sk, skb);
  295. if (ipv6_opt_accepted(sk, skb, IP6CB(skb)) ||
  296. np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo ||
  297. np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim) {
  298. refcount_inc(&skb->users);
  299. ireq->pktopts = skb;
  300. }
  301. ireq->ir_iif = sk->sk_bound_dev_if;
  302. /* So that link locals have meaning */
  303. if (!sk->sk_bound_dev_if &&
  304. ipv6_addr_type(&ireq->ir_v6_rmt_addr) & IPV6_ADDR_LINKLOCAL)
  305. ireq->ir_iif = inet6_iif(skb);
  306. /*
  307. * Step 3: Process LISTEN state
  308. *
  309. * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie
  310. *
  311. * Setting S.SWL/S.SWH to is deferred to dccp_create_openreq_child().
  312. */
  313. dreq->dreq_isr = dcb->dccpd_seq;
  314. dreq->dreq_gsr = dreq->dreq_isr;
  315. dreq->dreq_iss = dccp_v6_init_sequence(skb);
  316. dreq->dreq_gss = dreq->dreq_iss;
  317. dreq->dreq_service = service;
  318. if (dccp_v6_send_response(sk, req))
  319. goto drop_and_free;
  320. inet_csk_reqsk_queue_hash_add(sk, req, DCCP_TIMEOUT_INIT);
  321. reqsk_put(req);
  322. return 0;
  323. drop_and_free:
  324. reqsk_free(req);
  325. drop:
  326. __DCCP_INC_STATS(DCCP_MIB_ATTEMPTFAILS);
  327. return -1;
  328. }
  329. static struct sock *dccp_v6_request_recv_sock(const struct sock *sk,
  330. struct sk_buff *skb,
  331. struct request_sock *req,
  332. struct dst_entry *dst,
  333. struct request_sock *req_unhash,
  334. bool *own_req)
  335. {
  336. struct inet_request_sock *ireq = inet_rsk(req);
  337. struct ipv6_pinfo *newnp;
  338. const struct ipv6_pinfo *np = inet6_sk(sk);
  339. struct ipv6_txoptions *opt;
  340. struct inet_sock *newinet;
  341. struct dccp6_sock *newdp6;
  342. struct sock *newsk;
  343. if (skb->protocol == htons(ETH_P_IP)) {
  344. /*
  345. * v6 mapped
  346. */
  347. newsk = dccp_v4_request_recv_sock(sk, skb, req, dst,
  348. req_unhash, own_req);
  349. if (newsk == NULL)
  350. return NULL;
  351. newdp6 = (struct dccp6_sock *)newsk;
  352. newinet = inet_sk(newsk);
  353. newinet->pinet6 = &newdp6->inet6;
  354. newnp = inet6_sk(newsk);
  355. memcpy(newnp, np, sizeof(struct ipv6_pinfo));
  356. newnp->saddr = newsk->sk_v6_rcv_saddr;
  357. inet_csk(newsk)->icsk_af_ops = &dccp_ipv6_mapped;
  358. newsk->sk_backlog_rcv = dccp_v4_do_rcv;
  359. newnp->pktoptions = NULL;
  360. newnp->opt = NULL;
  361. newnp->ipv6_mc_list = NULL;
  362. newnp->ipv6_ac_list = NULL;
  363. newnp->ipv6_fl_list = NULL;
  364. newnp->mcast_oif = inet_iif(skb);
  365. newnp->mcast_hops = ip_hdr(skb)->ttl;
  366. /*
  367. * No need to charge this sock to the relevant IPv6 refcnt debug socks count
  368. * here, dccp_create_openreq_child now does this for us, see the comment in
  369. * that function for the gory details. -acme
  370. */
  371. /* It is tricky place. Until this moment IPv4 tcp
  372. worked with IPv6 icsk.icsk_af_ops.
  373. Sync it now.
  374. */
  375. dccp_sync_mss(newsk, inet_csk(newsk)->icsk_pmtu_cookie);
  376. return newsk;
  377. }
  378. if (sk_acceptq_is_full(sk))
  379. goto out_overflow;
  380. if (!dst) {
  381. struct flowi6 fl6;
  382. dst = inet6_csk_route_req(sk, &fl6, req, IPPROTO_DCCP);
  383. if (!dst)
  384. goto out;
  385. }
  386. newsk = dccp_create_openreq_child(sk, req, skb);
  387. if (newsk == NULL)
  388. goto out_nonewsk;
  389. /*
  390. * No need to charge this sock to the relevant IPv6 refcnt debug socks
  391. * count here, dccp_create_openreq_child now does this for us, see the
  392. * comment in that function for the gory details. -acme
  393. */
  394. ip6_dst_store(newsk, dst, NULL, NULL);
  395. newsk->sk_route_caps = dst->dev->features & ~(NETIF_F_IP_CSUM |
  396. NETIF_F_TSO);
  397. newdp6 = (struct dccp6_sock *)newsk;
  398. newinet = inet_sk(newsk);
  399. newinet->pinet6 = &newdp6->inet6;
  400. newnp = inet6_sk(newsk);
  401. memcpy(newnp, np, sizeof(struct ipv6_pinfo));
  402. newsk->sk_v6_daddr = ireq->ir_v6_rmt_addr;
  403. newnp->saddr = ireq->ir_v6_loc_addr;
  404. newsk->sk_v6_rcv_saddr = ireq->ir_v6_loc_addr;
  405. newsk->sk_bound_dev_if = ireq->ir_iif;
  406. /* Now IPv6 options...
  407. First: no IPv4 options.
  408. */
  409. newinet->inet_opt = NULL;
  410. /* Clone RX bits */
  411. newnp->rxopt.all = np->rxopt.all;
  412. newnp->ipv6_mc_list = NULL;
  413. newnp->ipv6_ac_list = NULL;
  414. newnp->ipv6_fl_list = NULL;
  415. newnp->pktoptions = NULL;
  416. newnp->opt = NULL;
  417. newnp->mcast_oif = inet6_iif(skb);
  418. newnp->mcast_hops = ipv6_hdr(skb)->hop_limit;
  419. /*
  420. * Clone native IPv6 options from listening socket (if any)
  421. *
  422. * Yes, keeping reference count would be much more clever, but we make
  423. * one more one thing there: reattach optmem to newsk.
  424. */
  425. opt = ireq->ipv6_opt;
  426. if (!opt)
  427. opt = rcu_dereference(np->opt);
  428. if (opt) {
  429. opt = ipv6_dup_options(newsk, opt);
  430. RCU_INIT_POINTER(newnp->opt, opt);
  431. }
  432. inet_csk(newsk)->icsk_ext_hdr_len = 0;
  433. if (opt)
  434. inet_csk(newsk)->icsk_ext_hdr_len = opt->opt_nflen +
  435. opt->opt_flen;
  436. dccp_sync_mss(newsk, dst_mtu(dst));
  437. newinet->inet_daddr = newinet->inet_saddr = LOOPBACK4_IPV6;
  438. newinet->inet_rcv_saddr = LOOPBACK4_IPV6;
  439. if (__inet_inherit_port(sk, newsk) < 0) {
  440. inet_csk_prepare_forced_close(newsk);
  441. dccp_done(newsk);
  442. goto out;
  443. }
  444. *own_req = inet_ehash_nolisten(newsk, req_to_sk(req_unhash));
  445. /* Clone pktoptions received with SYN, if we own the req */
  446. if (*own_req && ireq->pktopts) {
  447. newnp->pktoptions = skb_clone(ireq->pktopts, GFP_ATOMIC);
  448. consume_skb(ireq->pktopts);
  449. ireq->pktopts = NULL;
  450. if (newnp->pktoptions)
  451. skb_set_owner_r(newnp->pktoptions, newsk);
  452. }
  453. return newsk;
  454. out_overflow:
  455. __NET_INC_STATS(sock_net(sk), LINUX_MIB_LISTENOVERFLOWS);
  456. out_nonewsk:
  457. dst_release(dst);
  458. out:
  459. __NET_INC_STATS(sock_net(sk), LINUX_MIB_LISTENDROPS);
  460. return NULL;
  461. }
  462. /* The socket must have it's spinlock held when we get
  463. * here.
  464. *
  465. * We have a potential double-lock case here, so even when
  466. * doing backlog processing we use the BH locking scheme.
  467. * This is because we cannot sleep with the original spinlock
  468. * held.
  469. */
  470. static int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
  471. {
  472. struct ipv6_pinfo *np = inet6_sk(sk);
  473. struct sk_buff *opt_skb = NULL;
  474. /* Imagine: socket is IPv6. IPv4 packet arrives,
  475. goes to IPv4 receive handler and backlogged.
  476. From backlog it always goes here. Kerboom...
  477. Fortunately, dccp_rcv_established and rcv_established
  478. handle them correctly, but it is not case with
  479. dccp_v6_hnd_req and dccp_v6_ctl_send_reset(). --ANK
  480. */
  481. if (skb->protocol == htons(ETH_P_IP))
  482. return dccp_v4_do_rcv(sk, skb);
  483. if (sk_filter(sk, skb))
  484. goto discard;
  485. /*
  486. * socket locking is here for SMP purposes as backlog rcv is currently
  487. * called with bh processing disabled.
  488. */
  489. /* Do Stevens' IPV6_PKTOPTIONS.
  490. Yes, guys, it is the only place in our code, where we
  491. may make it not affecting IPv4.
  492. The rest of code is protocol independent,
  493. and I do not like idea to uglify IPv4.
  494. Actually, all the idea behind IPV6_PKTOPTIONS
  495. looks not very well thought. For now we latch
  496. options, received in the last packet, enqueued
  497. by tcp. Feel free to propose better solution.
  498. --ANK (980728)
  499. */
  500. if (np->rxopt.all)
  501. opt_skb = skb_clone(skb, GFP_ATOMIC);
  502. if (sk->sk_state == DCCP_OPEN) { /* Fast path */
  503. if (dccp_rcv_established(sk, skb, dccp_hdr(skb), skb->len))
  504. goto reset;
  505. if (opt_skb)
  506. goto ipv6_pktoptions;
  507. return 0;
  508. }
  509. /*
  510. * Step 3: Process LISTEN state
  511. * If S.state == LISTEN,
  512. * If P.type == Request or P contains a valid Init Cookie option,
  513. * (* Must scan the packet's options to check for Init
  514. * Cookies. Only Init Cookies are processed here,
  515. * however; other options are processed in Step 8. This
  516. * scan need only be performed if the endpoint uses Init
  517. * Cookies *)
  518. * (* Generate a new socket and switch to that socket *)
  519. * Set S := new socket for this port pair
  520. * S.state = RESPOND
  521. * Choose S.ISS (initial seqno) or set from Init Cookies
  522. * Initialize S.GAR := S.ISS
  523. * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookies
  524. * Continue with S.state == RESPOND
  525. * (* A Response packet will be generated in Step 11 *)
  526. * Otherwise,
  527. * Generate Reset(No Connection) unless P.type == Reset
  528. * Drop packet and return
  529. *
  530. * NOTE: the check for the packet types is done in
  531. * dccp_rcv_state_process
  532. */
  533. if (dccp_rcv_state_process(sk, skb, dccp_hdr(skb), skb->len))
  534. goto reset;
  535. if (opt_skb)
  536. goto ipv6_pktoptions;
  537. return 0;
  538. reset:
  539. dccp_v6_ctl_send_reset(sk, skb);
  540. discard:
  541. if (opt_skb != NULL)
  542. __kfree_skb(opt_skb);
  543. kfree_skb(skb);
  544. return 0;
  545. /* Handling IPV6_PKTOPTIONS skb the similar
  546. * way it's done for net/ipv6/tcp_ipv6.c
  547. */
  548. ipv6_pktoptions:
  549. if (!((1 << sk->sk_state) & (DCCPF_CLOSED | DCCPF_LISTEN))) {
  550. if (np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo)
  551. np->mcast_oif = inet6_iif(opt_skb);
  552. if (np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim)
  553. np->mcast_hops = ipv6_hdr(opt_skb)->hop_limit;
  554. if (np->rxopt.bits.rxflow || np->rxopt.bits.rxtclass)
  555. np->rcv_flowinfo = ip6_flowinfo(ipv6_hdr(opt_skb));
  556. if (np->repflow)
  557. np->flow_label = ip6_flowlabel(ipv6_hdr(opt_skb));
  558. if (ipv6_opt_accepted(sk, opt_skb,
  559. &DCCP_SKB_CB(opt_skb)->header.h6)) {
  560. skb_set_owner_r(opt_skb, sk);
  561. memmove(IP6CB(opt_skb),
  562. &DCCP_SKB_CB(opt_skb)->header.h6,
  563. sizeof(struct inet6_skb_parm));
  564. opt_skb = xchg(&np->pktoptions, opt_skb);
  565. } else {
  566. __kfree_skb(opt_skb);
  567. opt_skb = xchg(&np->pktoptions, NULL);
  568. }
  569. }
  570. kfree_skb(opt_skb);
  571. return 0;
  572. }
  573. static int dccp_v6_rcv(struct sk_buff *skb)
  574. {
  575. const struct dccp_hdr *dh;
  576. bool refcounted;
  577. struct sock *sk;
  578. int min_cov;
  579. /* Step 1: Check header basics */
  580. if (dccp_invalid_packet(skb))
  581. goto discard_it;
  582. /* Step 1: If header checksum is incorrect, drop packet and return. */
  583. if (dccp_v6_csum_finish(skb, &ipv6_hdr(skb)->saddr,
  584. &ipv6_hdr(skb)->daddr)) {
  585. DCCP_WARN("dropped packet with invalid checksum\n");
  586. goto discard_it;
  587. }
  588. dh = dccp_hdr(skb);
  589. DCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(dh);
  590. DCCP_SKB_CB(skb)->dccpd_type = dh->dccph_type;
  591. if (dccp_packet_without_ack(skb))
  592. DCCP_SKB_CB(skb)->dccpd_ack_seq = DCCP_PKT_WITHOUT_ACK_SEQ;
  593. else
  594. DCCP_SKB_CB(skb)->dccpd_ack_seq = dccp_hdr_ack_seq(skb);
  595. lookup:
  596. sk = __inet6_lookup_skb(&dccp_hashinfo, skb, __dccp_hdr_len(dh),
  597. dh->dccph_sport, dh->dccph_dport,
  598. inet6_iif(skb), 0, &refcounted);
  599. if (!sk) {
  600. dccp_pr_debug("failed to look up flow ID in table and "
  601. "get corresponding socket\n");
  602. goto no_dccp_socket;
  603. }
  604. /*
  605. * Step 2:
  606. * ... or S.state == TIMEWAIT,
  607. * Generate Reset(No Connection) unless P.type == Reset
  608. * Drop packet and return
  609. */
  610. if (sk->sk_state == DCCP_TIME_WAIT) {
  611. dccp_pr_debug("sk->sk_state == DCCP_TIME_WAIT: do_time_wait\n");
  612. inet_twsk_put(inet_twsk(sk));
  613. goto no_dccp_socket;
  614. }
  615. if (sk->sk_state == DCCP_NEW_SYN_RECV) {
  616. struct request_sock *req = inet_reqsk(sk);
  617. struct sock *nsk;
  618. sk = req->rsk_listener;
  619. if (unlikely(sk->sk_state != DCCP_LISTEN)) {
  620. inet_csk_reqsk_queue_drop_and_put(sk, req);
  621. goto lookup;
  622. }
  623. sock_hold(sk);
  624. refcounted = true;
  625. nsk = dccp_check_req(sk, skb, req);
  626. if (!nsk) {
  627. reqsk_put(req);
  628. goto discard_and_relse;
  629. }
  630. if (nsk == sk) {
  631. reqsk_put(req);
  632. } else if (dccp_child_process(sk, nsk, skb)) {
  633. dccp_v6_ctl_send_reset(sk, skb);
  634. goto discard_and_relse;
  635. } else {
  636. sock_put(sk);
  637. return 0;
  638. }
  639. }
  640. /*
  641. * RFC 4340, sec. 9.2.1: Minimum Checksum Coverage
  642. * o if MinCsCov = 0, only packets with CsCov = 0 are accepted
  643. * o if MinCsCov > 0, also accept packets with CsCov >= MinCsCov
  644. */
  645. min_cov = dccp_sk(sk)->dccps_pcrlen;
  646. if (dh->dccph_cscov && (min_cov == 0 || dh->dccph_cscov < min_cov)) {
  647. dccp_pr_debug("Packet CsCov %d does not satisfy MinCsCov %d\n",
  648. dh->dccph_cscov, min_cov);
  649. /* FIXME: send Data Dropped option (see also dccp_v4_rcv) */
  650. goto discard_and_relse;
  651. }
  652. if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
  653. goto discard_and_relse;
  654. return __sk_receive_skb(sk, skb, 1, dh->dccph_doff * 4,
  655. refcounted) ? -1 : 0;
  656. no_dccp_socket:
  657. if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))
  658. goto discard_it;
  659. /*
  660. * Step 2:
  661. * If no socket ...
  662. * Generate Reset(No Connection) unless P.type == Reset
  663. * Drop packet and return
  664. */
  665. if (dh->dccph_type != DCCP_PKT_RESET) {
  666. DCCP_SKB_CB(skb)->dccpd_reset_code =
  667. DCCP_RESET_CODE_NO_CONNECTION;
  668. dccp_v6_ctl_send_reset(sk, skb);
  669. }
  670. discard_it:
  671. kfree_skb(skb);
  672. return 0;
  673. discard_and_relse:
  674. if (refcounted)
  675. sock_put(sk);
  676. goto discard_it;
  677. }
  678. static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
  679. int addr_len)
  680. {
  681. struct sockaddr_in6 *usin = (struct sockaddr_in6 *)uaddr;
  682. struct inet_connection_sock *icsk = inet_csk(sk);
  683. struct inet_sock *inet = inet_sk(sk);
  684. struct ipv6_pinfo *np = inet6_sk(sk);
  685. struct dccp_sock *dp = dccp_sk(sk);
  686. struct in6_addr *saddr = NULL, *final_p, final;
  687. struct ipv6_txoptions *opt;
  688. struct flowi6 fl6;
  689. struct dst_entry *dst;
  690. int addr_type;
  691. int err;
  692. dp->dccps_role = DCCP_ROLE_CLIENT;
  693. if (addr_len < SIN6_LEN_RFC2133)
  694. return -EINVAL;
  695. if (usin->sin6_family != AF_INET6)
  696. return -EAFNOSUPPORT;
  697. memset(&fl6, 0, sizeof(fl6));
  698. if (np->sndflow) {
  699. fl6.flowlabel = usin->sin6_flowinfo & IPV6_FLOWINFO_MASK;
  700. IP6_ECN_flow_init(fl6.flowlabel);
  701. if (fl6.flowlabel & IPV6_FLOWLABEL_MASK) {
  702. struct ip6_flowlabel *flowlabel;
  703. flowlabel = fl6_sock_lookup(sk, fl6.flowlabel);
  704. if (flowlabel == NULL)
  705. return -EINVAL;
  706. fl6_sock_release(flowlabel);
  707. }
  708. }
  709. /*
  710. * connect() to INADDR_ANY means loopback (BSD'ism).
  711. */
  712. if (ipv6_addr_any(&usin->sin6_addr))
  713. usin->sin6_addr.s6_addr[15] = 1;
  714. addr_type = ipv6_addr_type(&usin->sin6_addr);
  715. if (addr_type & IPV6_ADDR_MULTICAST)
  716. return -ENETUNREACH;
  717. if (addr_type & IPV6_ADDR_LINKLOCAL) {
  718. if (addr_len >= sizeof(struct sockaddr_in6) &&
  719. usin->sin6_scope_id) {
  720. /* If interface is set while binding, indices
  721. * must coincide.
  722. */
  723. if (sk->sk_bound_dev_if &&
  724. sk->sk_bound_dev_if != usin->sin6_scope_id)
  725. return -EINVAL;
  726. sk->sk_bound_dev_if = usin->sin6_scope_id;
  727. }
  728. /* Connect to link-local address requires an interface */
  729. if (!sk->sk_bound_dev_if)
  730. return -EINVAL;
  731. }
  732. sk->sk_v6_daddr = usin->sin6_addr;
  733. np->flow_label = fl6.flowlabel;
  734. /*
  735. * DCCP over IPv4
  736. */
  737. if (addr_type == IPV6_ADDR_MAPPED) {
  738. u32 exthdrlen = icsk->icsk_ext_hdr_len;
  739. struct sockaddr_in sin;
  740. SOCK_DEBUG(sk, "connect: ipv4 mapped\n");
  741. if (__ipv6_only_sock(sk))
  742. return -ENETUNREACH;
  743. sin.sin_family = AF_INET;
  744. sin.sin_port = usin->sin6_port;
  745. sin.sin_addr.s_addr = usin->sin6_addr.s6_addr32[3];
  746. icsk->icsk_af_ops = &dccp_ipv6_mapped;
  747. sk->sk_backlog_rcv = dccp_v4_do_rcv;
  748. err = dccp_v4_connect(sk, (struct sockaddr *)&sin, sizeof(sin));
  749. if (err) {
  750. icsk->icsk_ext_hdr_len = exthdrlen;
  751. icsk->icsk_af_ops = &dccp_ipv6_af_ops;
  752. sk->sk_backlog_rcv = dccp_v6_do_rcv;
  753. goto failure;
  754. }
  755. np->saddr = sk->sk_v6_rcv_saddr;
  756. return err;
  757. }
  758. if (!ipv6_addr_any(&sk->sk_v6_rcv_saddr))
  759. saddr = &sk->sk_v6_rcv_saddr;
  760. fl6.flowi6_proto = IPPROTO_DCCP;
  761. fl6.daddr = sk->sk_v6_daddr;
  762. fl6.saddr = saddr ? *saddr : np->saddr;
  763. fl6.flowi6_oif = sk->sk_bound_dev_if;
  764. fl6.fl6_dport = usin->sin6_port;
  765. fl6.fl6_sport = inet->inet_sport;
  766. security_sk_classify_flow(sk, flowi6_to_flowi(&fl6));
  767. opt = rcu_dereference_protected(np->opt, lockdep_sock_is_held(sk));
  768. final_p = fl6_update_dst(&fl6, opt, &final);
  769. dst = ip6_dst_lookup_flow(sk, &fl6, final_p);
  770. if (IS_ERR(dst)) {
  771. err = PTR_ERR(dst);
  772. goto failure;
  773. }
  774. if (saddr == NULL) {
  775. saddr = &fl6.saddr;
  776. sk->sk_v6_rcv_saddr = *saddr;
  777. }
  778. /* set the source address */
  779. np->saddr = *saddr;
  780. inet->inet_rcv_saddr = LOOPBACK4_IPV6;
  781. ip6_dst_store(sk, dst, NULL, NULL);
  782. icsk->icsk_ext_hdr_len = 0;
  783. if (opt)
  784. icsk->icsk_ext_hdr_len = opt->opt_flen + opt->opt_nflen;
  785. inet->inet_dport = usin->sin6_port;
  786. dccp_set_state(sk, DCCP_REQUESTING);
  787. err = inet6_hash_connect(&dccp_death_row, sk);
  788. if (err)
  789. goto late_failure;
  790. dp->dccps_iss = secure_dccpv6_sequence_number(np->saddr.s6_addr32,
  791. sk->sk_v6_daddr.s6_addr32,
  792. inet->inet_sport,
  793. inet->inet_dport);
  794. err = dccp_connect(sk);
  795. if (err)
  796. goto late_failure;
  797. return 0;
  798. late_failure:
  799. dccp_set_state(sk, DCCP_CLOSED);
  800. __sk_dst_reset(sk);
  801. failure:
  802. inet->inet_dport = 0;
  803. sk->sk_route_caps = 0;
  804. return err;
  805. }
  806. static const struct inet_connection_sock_af_ops dccp_ipv6_af_ops = {
  807. .queue_xmit = inet6_csk_xmit,
  808. .send_check = dccp_v6_send_check,
  809. .rebuild_header = inet6_sk_rebuild_header,
  810. .conn_request = dccp_v6_conn_request,
  811. .syn_recv_sock = dccp_v6_request_recv_sock,
  812. .net_header_len = sizeof(struct ipv6hdr),
  813. .setsockopt = ipv6_setsockopt,
  814. .getsockopt = ipv6_getsockopt,
  815. .addr2sockaddr = inet6_csk_addr2sockaddr,
  816. .sockaddr_len = sizeof(struct sockaddr_in6),
  817. #ifdef CONFIG_COMPAT
  818. .compat_setsockopt = compat_ipv6_setsockopt,
  819. .compat_getsockopt = compat_ipv6_getsockopt,
  820. #endif
  821. };
  822. /*
  823. * DCCP over IPv4 via INET6 API
  824. */
  825. static const struct inet_connection_sock_af_ops dccp_ipv6_mapped = {
  826. .queue_xmit = ip_queue_xmit,
  827. .send_check = dccp_v4_send_check,
  828. .rebuild_header = inet_sk_rebuild_header,
  829. .conn_request = dccp_v6_conn_request,
  830. .syn_recv_sock = dccp_v6_request_recv_sock,
  831. .net_header_len = sizeof(struct iphdr),
  832. .setsockopt = ipv6_setsockopt,
  833. .getsockopt = ipv6_getsockopt,
  834. .addr2sockaddr = inet6_csk_addr2sockaddr,
  835. .sockaddr_len = sizeof(struct sockaddr_in6),
  836. #ifdef CONFIG_COMPAT
  837. .compat_setsockopt = compat_ipv6_setsockopt,
  838. .compat_getsockopt = compat_ipv6_getsockopt,
  839. #endif
  840. };
  841. /* NOTE: A lot of things set to zero explicitly by call to
  842. * sk_alloc() so need not be done here.
  843. */
  844. static int dccp_v6_init_sock(struct sock *sk)
  845. {
  846. static __u8 dccp_v6_ctl_sock_initialized;
  847. int err = dccp_init_sock(sk, dccp_v6_ctl_sock_initialized);
  848. if (err == 0) {
  849. if (unlikely(!dccp_v6_ctl_sock_initialized))
  850. dccp_v6_ctl_sock_initialized = 1;
  851. inet_csk(sk)->icsk_af_ops = &dccp_ipv6_af_ops;
  852. }
  853. return err;
  854. }
  855. static void dccp_v6_destroy_sock(struct sock *sk)
  856. {
  857. dccp_destroy_sock(sk);
  858. inet6_destroy_sock(sk);
  859. }
  860. static struct timewait_sock_ops dccp6_timewait_sock_ops = {
  861. .twsk_obj_size = sizeof(struct dccp6_timewait_sock),
  862. };
  863. static struct proto dccp_v6_prot = {
  864. .name = "DCCPv6",
  865. .owner = THIS_MODULE,
  866. .close = dccp_close,
  867. .connect = dccp_v6_connect,
  868. .disconnect = dccp_disconnect,
  869. .ioctl = dccp_ioctl,
  870. .init = dccp_v6_init_sock,
  871. .setsockopt = dccp_setsockopt,
  872. .getsockopt = dccp_getsockopt,
  873. .sendmsg = dccp_sendmsg,
  874. .recvmsg = dccp_recvmsg,
  875. .backlog_rcv = dccp_v6_do_rcv,
  876. .hash = inet6_hash,
  877. .unhash = inet_unhash,
  878. .accept = inet_csk_accept,
  879. .get_port = inet_csk_get_port,
  880. .shutdown = dccp_shutdown,
  881. .destroy = dccp_v6_destroy_sock,
  882. .orphan_count = &dccp_orphan_count,
  883. .max_header = MAX_DCCP_HEADER,
  884. .obj_size = sizeof(struct dccp6_sock),
  885. .slab_flags = SLAB_TYPESAFE_BY_RCU,
  886. .rsk_prot = &dccp6_request_sock_ops,
  887. .twsk_prot = &dccp6_timewait_sock_ops,
  888. .h.hashinfo = &dccp_hashinfo,
  889. #ifdef CONFIG_COMPAT
  890. .compat_setsockopt = compat_dccp_setsockopt,
  891. .compat_getsockopt = compat_dccp_getsockopt,
  892. #endif
  893. };
  894. static const struct inet6_protocol dccp_v6_protocol = {
  895. .handler = dccp_v6_rcv,
  896. .err_handler = dccp_v6_err,
  897. .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
  898. };
  899. static const struct proto_ops inet6_dccp_ops = {
  900. .family = PF_INET6,
  901. .owner = THIS_MODULE,
  902. .release = inet6_release,
  903. .bind = inet6_bind,
  904. .connect = inet_stream_connect,
  905. .socketpair = sock_no_socketpair,
  906. .accept = inet_accept,
  907. .getname = inet6_getname,
  908. .poll = dccp_poll,
  909. .ioctl = inet6_ioctl,
  910. .listen = inet_dccp_listen,
  911. .shutdown = inet_shutdown,
  912. .setsockopt = sock_common_setsockopt,
  913. .getsockopt = sock_common_getsockopt,
  914. .sendmsg = inet_sendmsg,
  915. .recvmsg = sock_common_recvmsg,
  916. .mmap = sock_no_mmap,
  917. .sendpage = sock_no_sendpage,
  918. #ifdef CONFIG_COMPAT
  919. .compat_setsockopt = compat_sock_common_setsockopt,
  920. .compat_getsockopt = compat_sock_common_getsockopt,
  921. #endif
  922. };
  923. static struct inet_protosw dccp_v6_protosw = {
  924. .type = SOCK_DCCP,
  925. .protocol = IPPROTO_DCCP,
  926. .prot = &dccp_v6_prot,
  927. .ops = &inet6_dccp_ops,
  928. .flags = INET_PROTOSW_ICSK,
  929. };
  930. static int __net_init dccp_v6_init_net(struct net *net)
  931. {
  932. if (dccp_hashinfo.bhash == NULL)
  933. return -ESOCKTNOSUPPORT;
  934. return inet_ctl_sock_create(&net->dccp.v6_ctl_sk, PF_INET6,
  935. SOCK_DCCP, IPPROTO_DCCP, net);
  936. }
  937. static void __net_exit dccp_v6_exit_net(struct net *net)
  938. {
  939. inet_ctl_sock_destroy(net->dccp.v6_ctl_sk);
  940. }
  941. static void __net_exit dccp_v6_exit_batch(struct list_head *net_exit_list)
  942. {
  943. inet_twsk_purge(&dccp_hashinfo, AF_INET6);
  944. }
  945. static struct pernet_operations dccp_v6_ops = {
  946. .init = dccp_v6_init_net,
  947. .exit = dccp_v6_exit_net,
  948. .exit_batch = dccp_v6_exit_batch,
  949. };
  950. static int __init dccp_v6_init(void)
  951. {
  952. int err = proto_register(&dccp_v6_prot, 1);
  953. if (err)
  954. goto out;
  955. inet6_register_protosw(&dccp_v6_protosw);
  956. err = register_pernet_subsys(&dccp_v6_ops);
  957. if (err)
  958. goto out_destroy_ctl_sock;
  959. err = inet6_add_protocol(&dccp_v6_protocol, IPPROTO_DCCP);
  960. if (err)
  961. goto out_unregister_proto;
  962. out:
  963. return err;
  964. out_unregister_proto:
  965. unregister_pernet_subsys(&dccp_v6_ops);
  966. out_destroy_ctl_sock:
  967. inet6_unregister_protosw(&dccp_v6_protosw);
  968. proto_unregister(&dccp_v6_prot);
  969. goto out;
  970. }
  971. static void __exit dccp_v6_exit(void)
  972. {
  973. inet6_del_protocol(&dccp_v6_protocol, IPPROTO_DCCP);
  974. unregister_pernet_subsys(&dccp_v6_ops);
  975. inet6_unregister_protosw(&dccp_v6_protosw);
  976. proto_unregister(&dccp_v6_prot);
  977. }
  978. module_init(dccp_v6_init);
  979. module_exit(dccp_v6_exit);
  980. /*
  981. * __stringify doesn't likes enums, so use SOCK_DCCP (6) and IPPROTO_DCCP (33)
  982. * values directly, Also cover the case where the protocol is not specified,
  983. * i.e. net-pf-PF_INET6-proto-0-type-SOCK_DCCP
  984. */
  985. /* MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_INET6, 33, 6); */
  986. /* MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_INET6, 0, 6); */
  987. MODULE_LICENSE("GPL");
  988. MODULE_AUTHOR("Arnaldo Carvalho de Melo <acme@mandriva.com>");
  989. MODULE_DESCRIPTION("DCCPv6 - Datagram Congestion Controlled Protocol");