ipv6.c 31 KB

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