ipv6.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187
  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 = inet6_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) ||
  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. /*
  634. * Step 2:
  635. * If no socket ...
  636. */
  637. if (sk == NULL) {
  638. dccp_pr_debug("failed to look up flow ID in table and "
  639. "get corresponding socket\n");
  640. goto no_dccp_socket;
  641. }
  642. /*
  643. * Step 2:
  644. * ... or S.state == TIMEWAIT,
  645. * Generate Reset(No Connection) unless P.type == Reset
  646. * Drop packet and return
  647. */
  648. if (sk->sk_state == DCCP_TIME_WAIT) {
  649. dccp_pr_debug("sk->sk_state == DCCP_TIME_WAIT: do_time_wait\n");
  650. inet_twsk_put(inet_twsk(sk));
  651. goto no_dccp_socket;
  652. }
  653. /*
  654. * RFC 4340, sec. 9.2.1: Minimum Checksum Coverage
  655. * o if MinCsCov = 0, only packets with CsCov = 0 are accepted
  656. * o if MinCsCov > 0, also accept packets with CsCov >= MinCsCov
  657. */
  658. min_cov = dccp_sk(sk)->dccps_pcrlen;
  659. if (dh->dccph_cscov && (min_cov == 0 || dh->dccph_cscov < min_cov)) {
  660. dccp_pr_debug("Packet CsCov %d does not satisfy MinCsCov %d\n",
  661. dh->dccph_cscov, min_cov);
  662. /* FIXME: send Data Dropped option (see also dccp_v4_rcv) */
  663. goto discard_and_relse;
  664. }
  665. if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
  666. goto discard_and_relse;
  667. return sk_receive_skb(sk, skb, 1) ? -1 : 0;
  668. no_dccp_socket:
  669. if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))
  670. goto discard_it;
  671. /*
  672. * Step 2:
  673. * If no socket ...
  674. * Generate Reset(No Connection) unless P.type == Reset
  675. * Drop packet and return
  676. */
  677. if (dh->dccph_type != DCCP_PKT_RESET) {
  678. DCCP_SKB_CB(skb)->dccpd_reset_code =
  679. DCCP_RESET_CODE_NO_CONNECTION;
  680. dccp_v6_ctl_send_reset(sk, skb);
  681. }
  682. discard_it:
  683. kfree_skb(skb);
  684. return 0;
  685. discard_and_relse:
  686. sock_put(sk);
  687. goto discard_it;
  688. }
  689. static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
  690. int addr_len)
  691. {
  692. struct sockaddr_in6 *usin = (struct sockaddr_in6 *)uaddr;
  693. struct inet_connection_sock *icsk = inet_csk(sk);
  694. struct inet_sock *inet = inet_sk(sk);
  695. struct ipv6_pinfo *np = inet6_sk(sk);
  696. struct dccp_sock *dp = dccp_sk(sk);
  697. struct in6_addr *saddr = NULL, *final_p, final;
  698. struct flowi6 fl6;
  699. struct dst_entry *dst;
  700. int addr_type;
  701. int err;
  702. dp->dccps_role = DCCP_ROLE_CLIENT;
  703. if (addr_len < SIN6_LEN_RFC2133)
  704. return -EINVAL;
  705. if (usin->sin6_family != AF_INET6)
  706. return -EAFNOSUPPORT;
  707. memset(&fl6, 0, sizeof(fl6));
  708. if (np->sndflow) {
  709. fl6.flowlabel = usin->sin6_flowinfo & IPV6_FLOWINFO_MASK;
  710. IP6_ECN_flow_init(fl6.flowlabel);
  711. if (fl6.flowlabel & IPV6_FLOWLABEL_MASK) {
  712. struct ip6_flowlabel *flowlabel;
  713. flowlabel = fl6_sock_lookup(sk, fl6.flowlabel);
  714. if (flowlabel == NULL)
  715. return -EINVAL;
  716. fl6_sock_release(flowlabel);
  717. }
  718. }
  719. /*
  720. * connect() to INADDR_ANY means loopback (BSD'ism).
  721. */
  722. if (ipv6_addr_any(&usin->sin6_addr))
  723. usin->sin6_addr.s6_addr[15] = 1;
  724. addr_type = ipv6_addr_type(&usin->sin6_addr);
  725. if (addr_type & IPV6_ADDR_MULTICAST)
  726. return -ENETUNREACH;
  727. if (addr_type & IPV6_ADDR_LINKLOCAL) {
  728. if (addr_len >= sizeof(struct sockaddr_in6) &&
  729. usin->sin6_scope_id) {
  730. /* If interface is set while binding, indices
  731. * must coincide.
  732. */
  733. if (sk->sk_bound_dev_if &&
  734. sk->sk_bound_dev_if != usin->sin6_scope_id)
  735. return -EINVAL;
  736. sk->sk_bound_dev_if = usin->sin6_scope_id;
  737. }
  738. /* Connect to link-local address requires an interface */
  739. if (!sk->sk_bound_dev_if)
  740. return -EINVAL;
  741. }
  742. sk->sk_v6_daddr = usin->sin6_addr;
  743. np->flow_label = fl6.flowlabel;
  744. /*
  745. * DCCP over IPv4
  746. */
  747. if (addr_type == IPV6_ADDR_MAPPED) {
  748. u32 exthdrlen = icsk->icsk_ext_hdr_len;
  749. struct sockaddr_in sin;
  750. SOCK_DEBUG(sk, "connect: ipv4 mapped\n");
  751. if (__ipv6_only_sock(sk))
  752. return -ENETUNREACH;
  753. sin.sin_family = AF_INET;
  754. sin.sin_port = usin->sin6_port;
  755. sin.sin_addr.s_addr = usin->sin6_addr.s6_addr32[3];
  756. icsk->icsk_af_ops = &dccp_ipv6_mapped;
  757. sk->sk_backlog_rcv = dccp_v4_do_rcv;
  758. err = dccp_v4_connect(sk, (struct sockaddr *)&sin, sizeof(sin));
  759. if (err) {
  760. icsk->icsk_ext_hdr_len = exthdrlen;
  761. icsk->icsk_af_ops = &dccp_ipv6_af_ops;
  762. sk->sk_backlog_rcv = dccp_v6_do_rcv;
  763. goto failure;
  764. }
  765. ipv6_addr_set_v4mapped(inet->inet_saddr, &np->saddr);
  766. ipv6_addr_set_v4mapped(inet->inet_rcv_saddr, &sk->sk_v6_rcv_saddr);
  767. return err;
  768. }
  769. if (!ipv6_addr_any(&sk->sk_v6_rcv_saddr))
  770. saddr = &sk->sk_v6_rcv_saddr;
  771. fl6.flowi6_proto = IPPROTO_DCCP;
  772. fl6.daddr = sk->sk_v6_daddr;
  773. fl6.saddr = saddr ? *saddr : np->saddr;
  774. fl6.flowi6_oif = sk->sk_bound_dev_if;
  775. fl6.fl6_dport = usin->sin6_port;
  776. fl6.fl6_sport = inet->inet_sport;
  777. security_sk_classify_flow(sk, flowi6_to_flowi(&fl6));
  778. final_p = fl6_update_dst(&fl6, np->opt, &final);
  779. dst = ip6_dst_lookup_flow(sk, &fl6, final_p);
  780. if (IS_ERR(dst)) {
  781. err = PTR_ERR(dst);
  782. goto failure;
  783. }
  784. if (saddr == NULL) {
  785. saddr = &fl6.saddr;
  786. sk->sk_v6_rcv_saddr = *saddr;
  787. }
  788. /* set the source address */
  789. np->saddr = *saddr;
  790. inet->inet_rcv_saddr = LOOPBACK4_IPV6;
  791. __ip6_dst_store(sk, dst, NULL, NULL);
  792. icsk->icsk_ext_hdr_len = 0;
  793. if (np->opt != NULL)
  794. icsk->icsk_ext_hdr_len = (np->opt->opt_flen +
  795. np->opt->opt_nflen);
  796. inet->inet_dport = usin->sin6_port;
  797. dccp_set_state(sk, DCCP_REQUESTING);
  798. err = inet6_hash_connect(&dccp_death_row, sk);
  799. if (err)
  800. goto late_failure;
  801. dp->dccps_iss = secure_dccpv6_sequence_number(np->saddr.s6_addr32,
  802. sk->sk_v6_daddr.s6_addr32,
  803. inet->inet_sport,
  804. inet->inet_dport);
  805. err = dccp_connect(sk);
  806. if (err)
  807. goto late_failure;
  808. return 0;
  809. late_failure:
  810. dccp_set_state(sk, DCCP_CLOSED);
  811. __sk_dst_reset(sk);
  812. failure:
  813. inet->inet_dport = 0;
  814. sk->sk_route_caps = 0;
  815. return err;
  816. }
  817. static const struct inet_connection_sock_af_ops dccp_ipv6_af_ops = {
  818. .queue_xmit = inet6_csk_xmit,
  819. .send_check = dccp_v6_send_check,
  820. .rebuild_header = inet6_sk_rebuild_header,
  821. .conn_request = dccp_v6_conn_request,
  822. .syn_recv_sock = dccp_v6_request_recv_sock,
  823. .net_header_len = sizeof(struct ipv6hdr),
  824. .setsockopt = ipv6_setsockopt,
  825. .getsockopt = ipv6_getsockopt,
  826. .addr2sockaddr = inet6_csk_addr2sockaddr,
  827. .sockaddr_len = sizeof(struct sockaddr_in6),
  828. .bind_conflict = inet6_csk_bind_conflict,
  829. #ifdef CONFIG_COMPAT
  830. .compat_setsockopt = compat_ipv6_setsockopt,
  831. .compat_getsockopt = compat_ipv6_getsockopt,
  832. #endif
  833. };
  834. /*
  835. * DCCP over IPv4 via INET6 API
  836. */
  837. static const struct inet_connection_sock_af_ops dccp_ipv6_mapped = {
  838. .queue_xmit = ip_queue_xmit,
  839. .send_check = dccp_v4_send_check,
  840. .rebuild_header = inet_sk_rebuild_header,
  841. .conn_request = dccp_v6_conn_request,
  842. .syn_recv_sock = dccp_v6_request_recv_sock,
  843. .net_header_len = sizeof(struct iphdr),
  844. .setsockopt = ipv6_setsockopt,
  845. .getsockopt = ipv6_getsockopt,
  846. .addr2sockaddr = inet6_csk_addr2sockaddr,
  847. .sockaddr_len = sizeof(struct sockaddr_in6),
  848. #ifdef CONFIG_COMPAT
  849. .compat_setsockopt = compat_ipv6_setsockopt,
  850. .compat_getsockopt = compat_ipv6_getsockopt,
  851. #endif
  852. };
  853. /* NOTE: A lot of things set to zero explicitly by call to
  854. * sk_alloc() so need not be done here.
  855. */
  856. static int dccp_v6_init_sock(struct sock *sk)
  857. {
  858. static __u8 dccp_v6_ctl_sock_initialized;
  859. int err = dccp_init_sock(sk, dccp_v6_ctl_sock_initialized);
  860. if (err == 0) {
  861. if (unlikely(!dccp_v6_ctl_sock_initialized))
  862. dccp_v6_ctl_sock_initialized = 1;
  863. inet_csk(sk)->icsk_af_ops = &dccp_ipv6_af_ops;
  864. }
  865. return err;
  866. }
  867. static void dccp_v6_destroy_sock(struct sock *sk)
  868. {
  869. dccp_destroy_sock(sk);
  870. inet6_destroy_sock(sk);
  871. }
  872. static struct timewait_sock_ops dccp6_timewait_sock_ops = {
  873. .twsk_obj_size = sizeof(struct dccp6_timewait_sock),
  874. };
  875. static struct proto dccp_v6_prot = {
  876. .name = "DCCPv6",
  877. .owner = THIS_MODULE,
  878. .close = dccp_close,
  879. .connect = dccp_v6_connect,
  880. .disconnect = dccp_disconnect,
  881. .ioctl = dccp_ioctl,
  882. .init = dccp_v6_init_sock,
  883. .setsockopt = dccp_setsockopt,
  884. .getsockopt = dccp_getsockopt,
  885. .sendmsg = dccp_sendmsg,
  886. .recvmsg = dccp_recvmsg,
  887. .backlog_rcv = dccp_v6_do_rcv,
  888. .hash = dccp_v6_hash,
  889. .unhash = inet_unhash,
  890. .accept = inet_csk_accept,
  891. .get_port = inet_csk_get_port,
  892. .shutdown = dccp_shutdown,
  893. .destroy = dccp_v6_destroy_sock,
  894. .orphan_count = &dccp_orphan_count,
  895. .max_header = MAX_DCCP_HEADER,
  896. .obj_size = sizeof(struct dccp6_sock),
  897. .slab_flags = SLAB_DESTROY_BY_RCU,
  898. .rsk_prot = &dccp6_request_sock_ops,
  899. .twsk_prot = &dccp6_timewait_sock_ops,
  900. .h.hashinfo = &dccp_hashinfo,
  901. #ifdef CONFIG_COMPAT
  902. .compat_setsockopt = compat_dccp_setsockopt,
  903. .compat_getsockopt = compat_dccp_getsockopt,
  904. #endif
  905. };
  906. static const struct inet6_protocol dccp_v6_protocol = {
  907. .handler = dccp_v6_rcv,
  908. .err_handler = dccp_v6_err,
  909. .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
  910. };
  911. static const struct proto_ops inet6_dccp_ops = {
  912. .family = PF_INET6,
  913. .owner = THIS_MODULE,
  914. .release = inet6_release,
  915. .bind = inet6_bind,
  916. .connect = inet_stream_connect,
  917. .socketpair = sock_no_socketpair,
  918. .accept = inet_accept,
  919. .getname = inet6_getname,
  920. .poll = dccp_poll,
  921. .ioctl = inet6_ioctl,
  922. .listen = inet_dccp_listen,
  923. .shutdown = inet_shutdown,
  924. .setsockopt = sock_common_setsockopt,
  925. .getsockopt = sock_common_getsockopt,
  926. .sendmsg = inet_sendmsg,
  927. .recvmsg = sock_common_recvmsg,
  928. .mmap = sock_no_mmap,
  929. .sendpage = sock_no_sendpage,
  930. #ifdef CONFIG_COMPAT
  931. .compat_setsockopt = compat_sock_common_setsockopt,
  932. .compat_getsockopt = compat_sock_common_getsockopt,
  933. #endif
  934. };
  935. static struct inet_protosw dccp_v6_protosw = {
  936. .type = SOCK_DCCP,
  937. .protocol = IPPROTO_DCCP,
  938. .prot = &dccp_v6_prot,
  939. .ops = &inet6_dccp_ops,
  940. .flags = INET_PROTOSW_ICSK,
  941. };
  942. static int __net_init dccp_v6_init_net(struct net *net)
  943. {
  944. if (dccp_hashinfo.bhash == NULL)
  945. return -ESOCKTNOSUPPORT;
  946. return inet_ctl_sock_create(&net->dccp.v6_ctl_sk, PF_INET6,
  947. SOCK_DCCP, IPPROTO_DCCP, net);
  948. }
  949. static void __net_exit dccp_v6_exit_net(struct net *net)
  950. {
  951. inet_ctl_sock_destroy(net->dccp.v6_ctl_sk);
  952. }
  953. static struct pernet_operations dccp_v6_ops = {
  954. .init = dccp_v6_init_net,
  955. .exit = dccp_v6_exit_net,
  956. };
  957. static int __init dccp_v6_init(void)
  958. {
  959. int err = proto_register(&dccp_v6_prot, 1);
  960. if (err != 0)
  961. goto out;
  962. err = inet6_add_protocol(&dccp_v6_protocol, IPPROTO_DCCP);
  963. if (err != 0)
  964. goto out_unregister_proto;
  965. inet6_register_protosw(&dccp_v6_protosw);
  966. err = register_pernet_subsys(&dccp_v6_ops);
  967. if (err != 0)
  968. goto out_destroy_ctl_sock;
  969. out:
  970. return err;
  971. out_destroy_ctl_sock:
  972. inet6_del_protocol(&dccp_v6_protocol, IPPROTO_DCCP);
  973. inet6_unregister_protosw(&dccp_v6_protosw);
  974. out_unregister_proto:
  975. proto_unregister(&dccp_v6_prot);
  976. goto out;
  977. }
  978. static void __exit dccp_v6_exit(void)
  979. {
  980. unregister_pernet_subsys(&dccp_v6_ops);
  981. inet6_del_protocol(&dccp_v6_protocol, IPPROTO_DCCP);
  982. inet6_unregister_protosw(&dccp_v6_protosw);
  983. proto_unregister(&dccp_v6_prot);
  984. }
  985. module_init(dccp_v6_init);
  986. module_exit(dccp_v6_exit);
  987. /*
  988. * __stringify doesn't likes enums, so use SOCK_DCCP (6) and IPPROTO_DCCP (33)
  989. * values directly, Also cover the case where the protocol is not specified,
  990. * i.e. net-pf-PF_INET6-proto-0-type-SOCK_DCCP
  991. */
  992. MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_INET6, 33, 6);
  993. MODULE_ALIAS_NET_PF_PROTO_TYPE(PF_INET6, 0, 6);
  994. MODULE_LICENSE("GPL");
  995. MODULE_AUTHOR("Arnaldo Carvalho de Melo <acme@mandriva.com>");
  996. MODULE_DESCRIPTION("DCCPv6 - Datagram Congestion Controlled Protocol");