ipv6.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184
  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 (sock_owned_by_user(sk))
  121. goto out;
  122. if ((1 << sk->sk_state) & (DCCPF_LISTEN | DCCPF_CLOSED))
  123. goto out;
  124. dst = inet6_csk_update_pmtu(sk, ntohl(info));
  125. if (!dst)
  126. goto out;
  127. if (inet_csk(sk)->icsk_pmtu_cookie > dst_mtu(dst))
  128. dccp_sync_mss(sk, dst_mtu(dst));
  129. goto out;
  130. }
  131. icmpv6_err_convert(type, code, &err);
  132. /* Might be for an request_sock */
  133. switch (sk->sk_state) {
  134. struct request_sock *req, **prev;
  135. case DCCP_LISTEN:
  136. if (sock_owned_by_user(sk))
  137. goto out;
  138. req = inet6_csk_search_req(sk, &prev, dh->dccph_dport,
  139. &hdr->daddr, &hdr->saddr,
  140. inet6_iif(skb));
  141. if (req == NULL)
  142. goto out;
  143. /*
  144. * ICMPs are not backlogged, hence we cannot get an established
  145. * socket here.
  146. */
  147. WARN_ON(req->sk != NULL);
  148. if (!between48(seq, dccp_rsk(req)->dreq_iss,
  149. dccp_rsk(req)->dreq_gss)) {
  150. NET_INC_STATS_BH(net, LINUX_MIB_OUTOFWINDOWICMPS);
  151. goto out;
  152. }
  153. inet_csk_reqsk_queue_drop(sk, req, prev);
  154. goto out;
  155. case DCCP_REQUESTING:
  156. case DCCP_RESPOND: /* Cannot happen.
  157. It can, it SYNs are crossed. --ANK */
  158. if (!sock_owned_by_user(sk)) {
  159. DCCP_INC_STATS_BH(DCCP_MIB_ATTEMPTFAILS);
  160. sk->sk_err = err;
  161. /*
  162. * Wake people up to see the error
  163. * (see connect in sock.c)
  164. */
  165. sk->sk_error_report(sk);
  166. dccp_done(sk);
  167. } else
  168. sk->sk_err_soft = err;
  169. goto out;
  170. }
  171. if (!sock_owned_by_user(sk) && np->recverr) {
  172. sk->sk_err = err;
  173. sk->sk_error_report(sk);
  174. } else
  175. sk->sk_err_soft = err;
  176. out:
  177. bh_unlock_sock(sk);
  178. sock_put(sk);
  179. }
  180. static int dccp_v6_send_response(struct sock *sk, struct request_sock *req)
  181. {
  182. struct inet_request_sock *ireq = inet_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 = ireq->ir_v6_rmt_addr;
  192. fl6.saddr = ireq->ir_v6_loc_addr;
  193. fl6.flowlabel = 0;
  194. fl6.flowi6_oif = ireq->ir_iif;
  195. fl6.fl6_dport = ireq->ir_rmt_port;
  196. fl6.fl6_sport = htons(ireq->ir_num);
  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. &ireq->ir_v6_loc_addr,
  210. &ireq->ir_v6_rmt_addr);
  211. fl6.daddr = ireq->ir_v6_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. kfree_skb(inet_rsk(req)->pktopts);
  223. }
  224. static void dccp_v6_ctl_send_reset(struct sock *sk, struct sk_buff *rxskb)
  225. {
  226. const struct ipv6hdr *rxip6h;
  227. struct sk_buff *skb;
  228. struct flowi6 fl6;
  229. struct net *net = dev_net(skb_dst(rxskb)->dev);
  230. struct sock *ctl_sk = net->dccp.v6_ctl_sk;
  231. struct dst_entry *dst;
  232. if (dccp_hdr(rxskb)->dccph_type == DCCP_PKT_RESET)
  233. return;
  234. if (!ipv6_unicast_destination(rxskb))
  235. return;
  236. skb = dccp_ctl_make_reset(ctl_sk, rxskb);
  237. if (skb == NULL)
  238. return;
  239. rxip6h = ipv6_hdr(rxskb);
  240. dccp_hdr(skb)->dccph_checksum = dccp_v6_csum_finish(skb, &rxip6h->saddr,
  241. &rxip6h->daddr);
  242. memset(&fl6, 0, sizeof(fl6));
  243. fl6.daddr = rxip6h->saddr;
  244. fl6.saddr = rxip6h->daddr;
  245. fl6.flowi6_proto = IPPROTO_DCCP;
  246. fl6.flowi6_oif = inet6_iif(rxskb);
  247. fl6.fl6_dport = dccp_hdr(skb)->dccph_dport;
  248. fl6.fl6_sport = dccp_hdr(skb)->dccph_sport;
  249. security_skb_classify_flow(rxskb, flowi6_to_flowi(&fl6));
  250. /* sk = NULL, but it is safe for now. RST socket required. */
  251. dst = ip6_dst_lookup_flow(ctl_sk, &fl6, NULL, false);
  252. if (!IS_ERR(dst)) {
  253. skb_dst_set(skb, dst);
  254. ip6_xmit(ctl_sk, skb, &fl6, NULL, 0);
  255. DCCP_INC_STATS_BH(DCCP_MIB_OUTSEGS);
  256. DCCP_INC_STATS_BH(DCCP_MIB_OUTRSTS);
  257. return;
  258. }
  259. kfree_skb(skb);
  260. }
  261. static struct request_sock_ops dccp6_request_sock_ops = {
  262. .family = AF_INET6,
  263. .obj_size = sizeof(struct dccp6_request_sock),
  264. .rtx_syn_ack = dccp_v6_send_response,
  265. .send_ack = dccp_reqsk_send_ack,
  266. .destructor = dccp_v6_reqsk_destructor,
  267. .send_reset = dccp_v6_ctl_send_reset,
  268. .syn_ack_timeout = dccp_syn_ack_timeout,
  269. };
  270. static struct sock *dccp_v6_hnd_req(struct sock *sk,struct sk_buff *skb)
  271. {
  272. const struct dccp_hdr *dh = dccp_hdr(skb);
  273. const struct ipv6hdr *iph = ipv6_hdr(skb);
  274. struct sock *nsk;
  275. struct request_sock **prev;
  276. /* Find possible connection requests. */
  277. struct request_sock *req = inet6_csk_search_req(sk, &prev,
  278. dh->dccph_sport,
  279. &iph->saddr,
  280. &iph->daddr,
  281. inet6_iif(skb));
  282. if (req != NULL)
  283. return dccp_check_req(sk, skb, req, prev);
  284. nsk = __inet6_lookup_established(sock_net(sk), &dccp_hashinfo,
  285. &iph->saddr, dh->dccph_sport,
  286. &iph->daddr, ntohs(dh->dccph_dport),
  287. inet6_iif(skb));
  288. if (nsk != NULL) {
  289. if (nsk->sk_state != DCCP_TIME_WAIT) {
  290. bh_lock_sock(nsk);
  291. return nsk;
  292. }
  293. inet_twsk_put(inet_twsk(nsk));
  294. return NULL;
  295. }
  296. return sk;
  297. }
  298. static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
  299. {
  300. struct request_sock *req;
  301. struct dccp_request_sock *dreq;
  302. struct inet_request_sock *ireq;
  303. struct ipv6_pinfo *np = inet6_sk(sk);
  304. const __be32 service = dccp_hdr_request(skb)->dccph_req_service;
  305. struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
  306. if (skb->protocol == htons(ETH_P_IP))
  307. return dccp_v4_conn_request(sk, skb);
  308. if (!ipv6_unicast_destination(skb))
  309. return 0; /* discard, don't send a reset here */
  310. if (dccp_bad_service_code(sk, service)) {
  311. dcb->dccpd_reset_code = DCCP_RESET_CODE_BAD_SERVICE_CODE;
  312. goto drop;
  313. }
  314. /*
  315. * There are no SYN attacks on IPv6, yet...
  316. */
  317. dcb->dccpd_reset_code = DCCP_RESET_CODE_TOO_BUSY;
  318. if (inet_csk_reqsk_queue_is_full(sk))
  319. goto drop;
  320. if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1)
  321. goto drop;
  322. req = inet6_reqsk_alloc(&dccp6_request_sock_ops);
  323. if (req == NULL)
  324. goto drop;
  325. if (dccp_reqsk_init(req, dccp_sk(sk), skb))
  326. goto drop_and_free;
  327. dreq = dccp_rsk(req);
  328. if (dccp_parse_options(sk, dreq, skb))
  329. goto drop_and_free;
  330. if (security_inet_conn_request(sk, skb, req))
  331. goto drop_and_free;
  332. ireq = inet_rsk(req);
  333. ireq->ir_v6_rmt_addr = ipv6_hdr(skb)->saddr;
  334. ireq->ir_v6_loc_addr = ipv6_hdr(skb)->daddr;
  335. if (ipv6_opt_accepted(sk, skb) ||
  336. np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo ||
  337. np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim) {
  338. atomic_inc(&skb->users);
  339. ireq->pktopts = skb;
  340. }
  341. ireq->ir_iif = sk->sk_bound_dev_if;
  342. /* So that link locals have meaning */
  343. if (!sk->sk_bound_dev_if &&
  344. ipv6_addr_type(&ireq->ir_v6_rmt_addr) & IPV6_ADDR_LINKLOCAL)
  345. ireq->ir_iif = inet6_iif(skb);
  346. /*
  347. * Step 3: Process LISTEN state
  348. *
  349. * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie
  350. *
  351. * Setting S.SWL/S.SWH to is deferred to dccp_create_openreq_child().
  352. */
  353. dreq->dreq_isr = dcb->dccpd_seq;
  354. dreq->dreq_gsr = dreq->dreq_isr;
  355. dreq->dreq_iss = dccp_v6_init_sequence(skb);
  356. dreq->dreq_gss = dreq->dreq_iss;
  357. dreq->dreq_service = service;
  358. if (dccp_v6_send_response(sk, req))
  359. goto drop_and_free;
  360. inet6_csk_reqsk_queue_hash_add(sk, req, DCCP_TIMEOUT_INIT);
  361. return 0;
  362. drop_and_free:
  363. reqsk_free(req);
  364. drop:
  365. DCCP_INC_STATS_BH(DCCP_MIB_ATTEMPTFAILS);
  366. return -1;
  367. }
  368. static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
  369. struct sk_buff *skb,
  370. struct request_sock *req,
  371. struct dst_entry *dst)
  372. {
  373. struct inet_request_sock *ireq = inet_rsk(req);
  374. struct ipv6_pinfo *newnp, *np = inet6_sk(sk);
  375. struct inet_sock *newinet;
  376. struct dccp6_sock *newdp6;
  377. struct sock *newsk;
  378. if (skb->protocol == htons(ETH_P_IP)) {
  379. /*
  380. * v6 mapped
  381. */
  382. newsk = dccp_v4_request_recv_sock(sk, skb, req, dst);
  383. if (newsk == NULL)
  384. return NULL;
  385. newdp6 = (struct dccp6_sock *)newsk;
  386. newinet = inet_sk(newsk);
  387. newinet->pinet6 = &newdp6->inet6;
  388. newnp = inet6_sk(newsk);
  389. memcpy(newnp, np, sizeof(struct ipv6_pinfo));
  390. ipv6_addr_set_v4mapped(newinet->inet_daddr, &newsk->sk_v6_daddr);
  391. ipv6_addr_set_v4mapped(newinet->inet_saddr, &newnp->saddr);
  392. newsk->sk_v6_rcv_saddr = newnp->saddr;
  393. inet_csk(newsk)->icsk_af_ops = &dccp_ipv6_mapped;
  394. newsk->sk_backlog_rcv = dccp_v4_do_rcv;
  395. newnp->pktoptions = NULL;
  396. newnp->opt = NULL;
  397. newnp->mcast_oif = inet6_iif(skb);
  398. newnp->mcast_hops = ipv6_hdr(skb)->hop_limit;
  399. /*
  400. * No need to charge this sock to the relevant IPv6 refcnt debug socks count
  401. * here, dccp_create_openreq_child now does this for us, see the comment in
  402. * that function for the gory details. -acme
  403. */
  404. /* It is tricky place. Until this moment IPv4 tcp
  405. worked with IPv6 icsk.icsk_af_ops.
  406. Sync it now.
  407. */
  408. dccp_sync_mss(newsk, inet_csk(newsk)->icsk_pmtu_cookie);
  409. return newsk;
  410. }
  411. if (sk_acceptq_is_full(sk))
  412. goto out_overflow;
  413. if (dst == NULL) {
  414. struct in6_addr *final_p, final;
  415. struct flowi6 fl6;
  416. memset(&fl6, 0, sizeof(fl6));
  417. fl6.flowi6_proto = IPPROTO_DCCP;
  418. fl6.daddr = ireq->ir_v6_rmt_addr;
  419. final_p = fl6_update_dst(&fl6, np->opt, &final);
  420. fl6.saddr = ireq->ir_v6_loc_addr;
  421. fl6.flowi6_oif = sk->sk_bound_dev_if;
  422. fl6.fl6_dport = ireq->ir_rmt_port;
  423. fl6.fl6_sport = htons(ireq->ir_num);
  424. security_sk_classify_flow(sk, flowi6_to_flowi(&fl6));
  425. dst = ip6_dst_lookup_flow(sk, &fl6, final_p, false);
  426. if (IS_ERR(dst))
  427. goto out;
  428. }
  429. newsk = dccp_create_openreq_child(sk, req, skb);
  430. if (newsk == NULL)
  431. goto out_nonewsk;
  432. /*
  433. * No need to charge this sock to the relevant IPv6 refcnt debug socks
  434. * count here, dccp_create_openreq_child now does this for us, see the
  435. * comment in that function for the gory details. -acme
  436. */
  437. __ip6_dst_store(newsk, dst, NULL, NULL);
  438. newsk->sk_route_caps = dst->dev->features & ~(NETIF_F_IP_CSUM |
  439. NETIF_F_TSO);
  440. newdp6 = (struct dccp6_sock *)newsk;
  441. newinet = inet_sk(newsk);
  442. newinet->pinet6 = &newdp6->inet6;
  443. newnp = inet6_sk(newsk);
  444. memcpy(newnp, np, sizeof(struct ipv6_pinfo));
  445. newsk->sk_v6_daddr = ireq->ir_v6_rmt_addr;
  446. newnp->saddr = ireq->ir_v6_loc_addr;
  447. newsk->sk_v6_rcv_saddr = ireq->ir_v6_loc_addr;
  448. newsk->sk_bound_dev_if = ireq->ir_iif;
  449. /* Now IPv6 options...
  450. First: no IPv4 options.
  451. */
  452. newinet->inet_opt = NULL;
  453. /* Clone RX bits */
  454. newnp->rxopt.all = np->rxopt.all;
  455. /* Clone pktoptions received with SYN */
  456. newnp->pktoptions = NULL;
  457. if (ireq->pktopts != NULL) {
  458. newnp->pktoptions = skb_clone(ireq->pktopts, GFP_ATOMIC);
  459. consume_skb(ireq->pktopts);
  460. ireq->pktopts = NULL;
  461. if (newnp->pktoptions)
  462. skb_set_owner_r(newnp->pktoptions, newsk);
  463. }
  464. newnp->opt = NULL;
  465. newnp->mcast_oif = inet6_iif(skb);
  466. newnp->mcast_hops = ipv6_hdr(skb)->hop_limit;
  467. /*
  468. * Clone native IPv6 options from listening socket (if any)
  469. *
  470. * Yes, keeping reference count would be much more clever, but we make
  471. * one more one thing there: reattach optmem to newsk.
  472. */
  473. if (np->opt != NULL)
  474. newnp->opt = ipv6_dup_options(newsk, np->opt);
  475. inet_csk(newsk)->icsk_ext_hdr_len = 0;
  476. if (newnp->opt != NULL)
  477. inet_csk(newsk)->icsk_ext_hdr_len = (newnp->opt->opt_nflen +
  478. newnp->opt->opt_flen);
  479. dccp_sync_mss(newsk, dst_mtu(dst));
  480. newinet->inet_daddr = newinet->inet_saddr = LOOPBACK4_IPV6;
  481. newinet->inet_rcv_saddr = LOOPBACK4_IPV6;
  482. if (__inet_inherit_port(sk, newsk) < 0) {
  483. inet_csk_prepare_forced_close(newsk);
  484. dccp_done(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. fl6_sock_release(flowlabel);
  715. }
  716. }
  717. /*
  718. * connect() to INADDR_ANY means loopback (BSD'ism).
  719. */
  720. if (ipv6_addr_any(&usin->sin6_addr))
  721. usin->sin6_addr.s6_addr[15] = 1;
  722. addr_type = ipv6_addr_type(&usin->sin6_addr);
  723. if (addr_type & IPV6_ADDR_MULTICAST)
  724. return -ENETUNREACH;
  725. if (addr_type & IPV6_ADDR_LINKLOCAL) {
  726. if (addr_len >= sizeof(struct sockaddr_in6) &&
  727. usin->sin6_scope_id) {
  728. /* If interface is set while binding, indices
  729. * must coincide.
  730. */
  731. if (sk->sk_bound_dev_if &&
  732. sk->sk_bound_dev_if != usin->sin6_scope_id)
  733. return -EINVAL;
  734. sk->sk_bound_dev_if = usin->sin6_scope_id;
  735. }
  736. /* Connect to link-local address requires an interface */
  737. if (!sk->sk_bound_dev_if)
  738. return -EINVAL;
  739. }
  740. sk->sk_v6_daddr = usin->sin6_addr;
  741. np->flow_label = fl6.flowlabel;
  742. /*
  743. * DCCP over IPv4
  744. */
  745. if (addr_type == IPV6_ADDR_MAPPED) {
  746. u32 exthdrlen = icsk->icsk_ext_hdr_len;
  747. struct sockaddr_in sin;
  748. SOCK_DEBUG(sk, "connect: ipv4 mapped\n");
  749. if (__ipv6_only_sock(sk))
  750. return -ENETUNREACH;
  751. sin.sin_family = AF_INET;
  752. sin.sin_port = usin->sin6_port;
  753. sin.sin_addr.s_addr = usin->sin6_addr.s6_addr32[3];
  754. icsk->icsk_af_ops = &dccp_ipv6_mapped;
  755. sk->sk_backlog_rcv = dccp_v4_do_rcv;
  756. err = dccp_v4_connect(sk, (struct sockaddr *)&sin, sizeof(sin));
  757. if (err) {
  758. icsk->icsk_ext_hdr_len = exthdrlen;
  759. icsk->icsk_af_ops = &dccp_ipv6_af_ops;
  760. sk->sk_backlog_rcv = dccp_v6_do_rcv;
  761. goto failure;
  762. }
  763. ipv6_addr_set_v4mapped(inet->inet_saddr, &np->saddr);
  764. ipv6_addr_set_v4mapped(inet->inet_rcv_saddr, &sk->sk_v6_rcv_saddr);
  765. return err;
  766. }
  767. if (!ipv6_addr_any(&sk->sk_v6_rcv_saddr))
  768. saddr = &sk->sk_v6_rcv_saddr;
  769. fl6.flowi6_proto = IPPROTO_DCCP;
  770. fl6.daddr = sk->sk_v6_daddr;
  771. fl6.saddr = saddr ? *saddr : np->saddr;
  772. fl6.flowi6_oif = sk->sk_bound_dev_if;
  773. fl6.fl6_dport = usin->sin6_port;
  774. fl6.fl6_sport = inet->inet_sport;
  775. security_sk_classify_flow(sk, flowi6_to_flowi(&fl6));
  776. final_p = fl6_update_dst(&fl6, np->opt, &final);
  777. dst = ip6_dst_lookup_flow(sk, &fl6, final_p, true);
  778. if (IS_ERR(dst)) {
  779. err = PTR_ERR(dst);
  780. goto failure;
  781. }
  782. if (saddr == NULL) {
  783. saddr = &fl6.saddr;
  784. sk->sk_v6_rcv_saddr = *saddr;
  785. }
  786. /* set the source address */
  787. np->saddr = *saddr;
  788. inet->inet_rcv_saddr = LOOPBACK4_IPV6;
  789. __ip6_dst_store(sk, dst, NULL, NULL);
  790. icsk->icsk_ext_hdr_len = 0;
  791. if (np->opt != NULL)
  792. icsk->icsk_ext_hdr_len = (np->opt->opt_flen +
  793. np->opt->opt_nflen);
  794. inet->inet_dport = usin->sin6_port;
  795. dccp_set_state(sk, DCCP_REQUESTING);
  796. err = inet6_hash_connect(&dccp_death_row, sk);
  797. if (err)
  798. goto late_failure;
  799. dp->dccps_iss = secure_dccpv6_sequence_number(np->saddr.s6_addr32,
  800. sk->sk_v6_daddr.s6_addr32,
  801. inet->inet_sport,
  802. inet->inet_dport);
  803. err = dccp_connect(sk);
  804. if (err)
  805. goto late_failure;
  806. return 0;
  807. late_failure:
  808. dccp_set_state(sk, DCCP_CLOSED);
  809. __sk_dst_reset(sk);
  810. failure:
  811. inet->inet_dport = 0;
  812. sk->sk_route_caps = 0;
  813. return err;
  814. }
  815. static const struct inet_connection_sock_af_ops dccp_ipv6_af_ops = {
  816. .queue_xmit = inet6_csk_xmit,
  817. .send_check = dccp_v6_send_check,
  818. .rebuild_header = inet6_sk_rebuild_header,
  819. .conn_request = dccp_v6_conn_request,
  820. .syn_recv_sock = dccp_v6_request_recv_sock,
  821. .net_header_len = sizeof(struct ipv6hdr),
  822. .setsockopt = ipv6_setsockopt,
  823. .getsockopt = ipv6_getsockopt,
  824. .addr2sockaddr = inet6_csk_addr2sockaddr,
  825. .sockaddr_len = sizeof(struct sockaddr_in6),
  826. .bind_conflict = inet6_csk_bind_conflict,
  827. #ifdef CONFIG_COMPAT
  828. .compat_setsockopt = compat_ipv6_setsockopt,
  829. .compat_getsockopt = compat_ipv6_getsockopt,
  830. #endif
  831. };
  832. /*
  833. * DCCP over IPv4 via INET6 API
  834. */
  835. static const struct inet_connection_sock_af_ops dccp_ipv6_mapped = {
  836. .queue_xmit = ip_queue_xmit,
  837. .send_check = dccp_v4_send_check,
  838. .rebuild_header = inet_sk_rebuild_header,
  839. .conn_request = dccp_v6_conn_request,
  840. .syn_recv_sock = dccp_v6_request_recv_sock,
  841. .net_header_len = sizeof(struct iphdr),
  842. .setsockopt = ipv6_setsockopt,
  843. .getsockopt = ipv6_getsockopt,
  844. .addr2sockaddr = inet6_csk_addr2sockaddr,
  845. .sockaddr_len = sizeof(struct sockaddr_in6),
  846. #ifdef CONFIG_COMPAT
  847. .compat_setsockopt = compat_ipv6_setsockopt,
  848. .compat_getsockopt = compat_ipv6_getsockopt,
  849. #endif
  850. };
  851. /* NOTE: A lot of things set to zero explicitly by call to
  852. * sk_alloc() so need not be done here.
  853. */
  854. static int dccp_v6_init_sock(struct sock *sk)
  855. {
  856. static __u8 dccp_v6_ctl_sock_initialized;
  857. int err = dccp_init_sock(sk, dccp_v6_ctl_sock_initialized);
  858. if (err == 0) {
  859. if (unlikely(!dccp_v6_ctl_sock_initialized))
  860. dccp_v6_ctl_sock_initialized = 1;
  861. inet_csk(sk)->icsk_af_ops = &dccp_ipv6_af_ops;
  862. }
  863. return err;
  864. }
  865. static void dccp_v6_destroy_sock(struct sock *sk)
  866. {
  867. dccp_destroy_sock(sk);
  868. inet6_destroy_sock(sk);
  869. }
  870. static struct timewait_sock_ops dccp6_timewait_sock_ops = {
  871. .twsk_obj_size = sizeof(struct dccp6_timewait_sock),
  872. };
  873. static struct proto dccp_v6_prot = {
  874. .name = "DCCPv6",
  875. .owner = THIS_MODULE,
  876. .close = dccp_close,
  877. .connect = dccp_v6_connect,
  878. .disconnect = dccp_disconnect,
  879. .ioctl = dccp_ioctl,
  880. .init = dccp_v6_init_sock,
  881. .setsockopt = dccp_setsockopt,
  882. .getsockopt = dccp_getsockopt,
  883. .sendmsg = dccp_sendmsg,
  884. .recvmsg = dccp_recvmsg,
  885. .backlog_rcv = dccp_v6_do_rcv,
  886. .hash = dccp_v6_hash,
  887. .unhash = inet_unhash,
  888. .accept = inet_csk_accept,
  889. .get_port = inet_csk_get_port,
  890. .shutdown = dccp_shutdown,
  891. .destroy = dccp_v6_destroy_sock,
  892. .orphan_count = &dccp_orphan_count,
  893. .max_header = MAX_DCCP_HEADER,
  894. .obj_size = sizeof(struct dccp6_sock),
  895. .slab_flags = SLAB_DESTROY_BY_RCU,
  896. .rsk_prot = &dccp6_request_sock_ops,
  897. .twsk_prot = &dccp6_timewait_sock_ops,
  898. .h.hashinfo = &dccp_hashinfo,
  899. #ifdef CONFIG_COMPAT
  900. .compat_setsockopt = compat_dccp_setsockopt,
  901. .compat_getsockopt = compat_dccp_getsockopt,
  902. #endif
  903. };
  904. static const struct inet6_protocol dccp_v6_protocol = {
  905. .handler = dccp_v6_rcv,
  906. .err_handler = dccp_v6_err,
  907. .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
  908. };
  909. static const struct proto_ops inet6_dccp_ops = {
  910. .family = PF_INET6,
  911. .owner = THIS_MODULE,
  912. .release = inet6_release,
  913. .bind = inet6_bind,
  914. .connect = inet_stream_connect,
  915. .socketpair = sock_no_socketpair,
  916. .accept = inet_accept,
  917. .getname = inet6_getname,
  918. .poll = dccp_poll,
  919. .ioctl = inet6_ioctl,
  920. .listen = inet_dccp_listen,
  921. .shutdown = inet_shutdown,
  922. .setsockopt = sock_common_setsockopt,
  923. .getsockopt = sock_common_getsockopt,
  924. .sendmsg = inet_sendmsg,
  925. .recvmsg = sock_common_recvmsg,
  926. .mmap = sock_no_mmap,
  927. .sendpage = sock_no_sendpage,
  928. #ifdef CONFIG_COMPAT
  929. .compat_setsockopt = compat_sock_common_setsockopt,
  930. .compat_getsockopt = compat_sock_common_getsockopt,
  931. #endif
  932. };
  933. static struct inet_protosw dccp_v6_protosw = {
  934. .type = SOCK_DCCP,
  935. .protocol = IPPROTO_DCCP,
  936. .prot = &dccp_v6_prot,
  937. .ops = &inet6_dccp_ops,
  938. .flags = INET_PROTOSW_ICSK,
  939. };
  940. static int __net_init dccp_v6_init_net(struct net *net)
  941. {
  942. if (dccp_hashinfo.bhash == NULL)
  943. return -ESOCKTNOSUPPORT;
  944. return inet_ctl_sock_create(&net->dccp.v6_ctl_sk, PF_INET6,
  945. SOCK_DCCP, IPPROTO_DCCP, net);
  946. }
  947. static void __net_exit dccp_v6_exit_net(struct net *net)
  948. {
  949. inet_ctl_sock_destroy(net->dccp.v6_ctl_sk);
  950. }
  951. static struct pernet_operations dccp_v6_ops = {
  952. .init = dccp_v6_init_net,
  953. .exit = dccp_v6_exit_net,
  954. };
  955. static int __init dccp_v6_init(void)
  956. {
  957. int err = proto_register(&dccp_v6_prot, 1);
  958. if (err != 0)
  959. goto out;
  960. err = inet6_add_protocol(&dccp_v6_protocol, IPPROTO_DCCP);
  961. if (err != 0)
  962. goto out_unregister_proto;
  963. inet6_register_protosw(&dccp_v6_protosw);
  964. err = register_pernet_subsys(&dccp_v6_ops);
  965. if (err != 0)
  966. goto out_destroy_ctl_sock;
  967. out:
  968. return err;
  969. out_destroy_ctl_sock:
  970. inet6_del_protocol(&dccp_v6_protocol, IPPROTO_DCCP);
  971. inet6_unregister_protosw(&dccp_v6_protosw);
  972. out_unregister_proto:
  973. proto_unregister(&dccp_v6_prot);
  974. goto out;
  975. }
  976. static void __exit dccp_v6_exit(void)
  977. {
  978. unregister_pernet_subsys(&dccp_v6_ops);
  979. inet6_del_protocol(&dccp_v6_protocol, IPPROTO_DCCP);
  980. inet6_unregister_protosw(&dccp_v6_protosw);
  981. proto_unregister(&dccp_v6_prot);
  982. }
  983. module_init(dccp_v6_init);
  984. module_exit(dccp_v6_exit);
  985. /*
  986. * __stringify doesn't likes enums, so use SOCK_DCCP (6) and IPPROTO_DCCP (33)
  987. * values directly, Also cover the case where the protocol is not specified,
  988. * i.e. net-pf-PF_INET6-proto-0-type-SOCK_DCCP
  989. */
  990. MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_INET6, 33, 6);
  991. MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_INET6, 0, 6);
  992. MODULE_LICENSE("GPL");
  993. MODULE_AUTHOR("Arnaldo Carvalho de Melo <acme@mandriva.com>");
  994. MODULE_DESCRIPTION("DCCPv6 - Datagram Congestion Controlled Protocol");