ipv6.c 31 KB

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