]> bbs.cooldavid.org Git - net-next-2.6.git/blame - net/dccp/ipv6.c
[IPV6] tcp_v6_send_synack: release the destination
[net-next-2.6.git] / net / dccp / ipv6.c
CommitLineData
3df80d93
ACM
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
15#include <linux/config.h>
16#include <linux/module.h>
17#include <linux/random.h>
18#include <linux/xfrm.h>
19
20#include <net/addrconf.h>
21#include <net/inet_common.h>
22#include <net/inet_hashtables.h>
14c85021 23#include <net/inet_sock.h>
3df80d93
ACM
24#include <net/inet6_connection_sock.h>
25#include <net/inet6_hashtables.h>
26#include <net/ip6_route.h>
27#include <net/ipv6.h>
28#include <net/protocol.h>
29#include <net/transp_v6.h>
aa0e4e4a 30#include <net/ip6_checksum.h>
3df80d93
ACM
31#include <net/xfrm.h>
32
33#include "dccp.h"
34#include "ipv6.h"
35
36static void dccp_v6_ctl_send_reset(struct sk_buff *skb);
37static void dccp_v6_reqsk_send_ack(struct sk_buff *skb,
38 struct request_sock *req);
39static void dccp_v6_send_check(struct sock *sk, int len, struct sk_buff *skb);
40
41static int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb);
42
43static struct inet_connection_sock_af_ops dccp_ipv6_mapped;
44static struct inet_connection_sock_af_ops dccp_ipv6_af_ops;
45
46static int dccp_v6_get_port(struct sock *sk, unsigned short snum)
47{
48 return inet_csk_get_port(&dccp_hashinfo, sk, snum,
49 inet6_csk_bind_conflict);
50}
51
52static void dccp_v6_hash(struct sock *sk)
53{
54 if (sk->sk_state != DCCP_CLOSED) {
55 if (inet_csk(sk)->icsk_af_ops == &dccp_ipv6_mapped) {
56 dccp_prot.hash(sk);
57 return;
58 }
59 local_bh_disable();
60 __inet6_hash(&dccp_hashinfo, sk);
61 local_bh_enable();
62 }
63}
64
65static inline u16 dccp_v6_check(struct dccp_hdr *dh, int len,
66 struct in6_addr *saddr,
67 struct in6_addr *daddr,
68 unsigned long base)
69{
70 return csum_ipv6_magic(saddr, daddr, len, IPPROTO_DCCP, base);
71}
72
73static __u32 dccp_v6_init_sequence(struct sock *sk, struct sk_buff *skb)
74{
75 const struct dccp_hdr *dh = dccp_hdr(skb);
76
77 if (skb->protocol == htons(ETH_P_IPV6))
78 return secure_tcpv6_sequence_number(skb->nh.ipv6h->daddr.s6_addr32,
79 skb->nh.ipv6h->saddr.s6_addr32,
80 dh->dccph_dport,
81 dh->dccph_sport);
82 else
83 return secure_dccp_sequence_number(skb->nh.iph->daddr,
84 skb->nh.iph->saddr,
85 dh->dccph_dport,
86 dh->dccph_sport);
87}
88
3df80d93
ACM
89static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
90 int addr_len)
91{
92 struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr;
d83d8461 93 struct inet_connection_sock *icsk = inet_csk(sk);
3df80d93
ACM
94 struct inet_sock *inet = inet_sk(sk);
95 struct ipv6_pinfo *np = inet6_sk(sk);
96 struct dccp_sock *dp = dccp_sk(sk);
97 struct in6_addr *saddr = NULL, *final_p = NULL, final;
98 struct flowi fl;
99 struct dst_entry *dst;
100 int addr_type;
101 int err;
102
103 dp->dccps_role = DCCP_ROLE_CLIENT;
104
105 if (addr_len < SIN6_LEN_RFC2133)
106 return -EINVAL;
107
108 if (usin->sin6_family != AF_INET6)
109 return -EAFNOSUPPORT;
110
111 memset(&fl, 0, sizeof(fl));
112
113 if (np->sndflow) {
114 fl.fl6_flowlabel = usin->sin6_flowinfo & IPV6_FLOWINFO_MASK;
115 IP6_ECN_flow_init(fl.fl6_flowlabel);
116 if (fl.fl6_flowlabel & IPV6_FLOWLABEL_MASK) {
117 struct ip6_flowlabel *flowlabel;
118 flowlabel = fl6_sock_lookup(sk, fl.fl6_flowlabel);
119 if (flowlabel == NULL)
120 return -EINVAL;
121 ipv6_addr_copy(&usin->sin6_addr, &flowlabel->dst);
122 fl6_sock_release(flowlabel);
123 }
124 }
125
126 /*
127 * connect() to INADDR_ANY means loopback (BSD'ism).
128 */
129
130 if (ipv6_addr_any(&usin->sin6_addr))
131 usin->sin6_addr.s6_addr[15] = 0x1;
132
133 addr_type = ipv6_addr_type(&usin->sin6_addr);
134
135 if(addr_type & IPV6_ADDR_MULTICAST)
136 return -ENETUNREACH;
137
138 if (addr_type & IPV6_ADDR_LINKLOCAL) {
139 if (addr_len >= sizeof(struct sockaddr_in6) &&
140 usin->sin6_scope_id) {
141 /* If interface is set while binding, indices
142 * must coincide.
143 */
144 if (sk->sk_bound_dev_if &&
145 sk->sk_bound_dev_if != usin->sin6_scope_id)
146 return -EINVAL;
147
148 sk->sk_bound_dev_if = usin->sin6_scope_id;
149 }
150
151 /* Connect to link-local address requires an interface */
152 if (!sk->sk_bound_dev_if)
153 return -EINVAL;
154 }
155
156 ipv6_addr_copy(&np->daddr, &usin->sin6_addr);
157 np->flow_label = fl.fl6_flowlabel;
158
159 /*
160 * DCCP over IPv4
161 */
162
163 if (addr_type == IPV6_ADDR_MAPPED) {
d83d8461 164 u32 exthdrlen = icsk->icsk_ext_hdr_len;
3df80d93
ACM
165 struct sockaddr_in sin;
166
167 SOCK_DEBUG(sk, "connect: ipv4 mapped\n");
168
169 if (__ipv6_only_sock(sk))
170 return -ENETUNREACH;
171
172 sin.sin_family = AF_INET;
173 sin.sin_port = usin->sin6_port;
174 sin.sin_addr.s_addr = usin->sin6_addr.s6_addr32[3];
175
d83d8461 176 icsk->icsk_af_ops = &dccp_ipv6_mapped;
3df80d93
ACM
177 sk->sk_backlog_rcv = dccp_v4_do_rcv;
178
179 err = dccp_v4_connect(sk, (struct sockaddr *)&sin, sizeof(sin));
180
181 if (err) {
d83d8461
ACM
182 icsk->icsk_ext_hdr_len = exthdrlen;
183 icsk->icsk_af_ops = &dccp_ipv6_af_ops;
3df80d93
ACM
184 sk->sk_backlog_rcv = dccp_v6_do_rcv;
185 goto failure;
186 } else {
187 ipv6_addr_set(&np->saddr, 0, 0, htonl(0x0000FFFF),
188 inet->saddr);
189 ipv6_addr_set(&np->rcv_saddr, 0, 0, htonl(0x0000FFFF),
190 inet->rcv_saddr);
191 }
192
193 return err;
194 }
195
196 if (!ipv6_addr_any(&np->rcv_saddr))
197 saddr = &np->rcv_saddr;
198
199 fl.proto = IPPROTO_DCCP;
200 ipv6_addr_copy(&fl.fl6_dst, &np->daddr);
201 ipv6_addr_copy(&fl.fl6_src, saddr ? saddr : &np->saddr);
202 fl.oif = sk->sk_bound_dev_if;
203 fl.fl_ip_dport = usin->sin6_port;
204 fl.fl_ip_sport = inet->sport;
205
206 if (np->opt && np->opt->srcrt) {
207 struct rt0_hdr *rt0 = (struct rt0_hdr *)np->opt->srcrt;
208 ipv6_addr_copy(&final, &fl.fl6_dst);
209 ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
210 final_p = &final;
211 }
212
213 err = ip6_dst_lookup(sk, &dst, &fl);
214 if (err)
215 goto failure;
216 if (final_p)
217 ipv6_addr_copy(&fl.fl6_dst, final_p);
218
219 if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0)
220 goto failure;
221
222 if (saddr == NULL) {
223 saddr = &fl.fl6_src;
224 ipv6_addr_copy(&np->rcv_saddr, saddr);
225 }
226
227 /* set the source address */
228 ipv6_addr_copy(&np->saddr, saddr);
229 inet->rcv_saddr = LOOPBACK4_IPV6;
230
231 ip6_dst_store(sk, dst, NULL);
232
d83d8461 233 icsk->icsk_ext_hdr_len = 0;
3df80d93 234 if (np->opt)
d83d8461
ACM
235 icsk->icsk_ext_hdr_len = (np->opt->opt_flen +
236 np->opt->opt_nflen);
3df80d93
ACM
237
238 inet->dport = usin->sin6_port;
239
240 dccp_set_state(sk, DCCP_REQUESTING);
d8313f5c 241 err = inet6_hash_connect(&dccp_death_row, sk);
3df80d93
ACM
242 if (err)
243 goto late_failure;
244 /* FIXME */
245#if 0
246 dp->dccps_gar = secure_dccp_v6_sequence_number(np->saddr.s6_addr32,
247 np->daddr.s6_addr32,
248 inet->sport,
249 inet->dport);
250#endif
251 err = dccp_connect(sk);
252 if (err)
253 goto late_failure;
254
255 return 0;
256
257late_failure:
258 dccp_set_state(sk, DCCP_CLOSED);
259 __sk_dst_reset(sk);
260failure:
261 inet->dport = 0;
262 sk->sk_route_caps = 0;
263 return err;
264}
265
266static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
267 int type, int code, int offset, __u32 info)
268{
269 struct ipv6hdr *hdr = (struct ipv6hdr *)skb->data;
270 const struct dccp_hdr *dh = (struct dccp_hdr *)(skb->data + offset);
271 struct ipv6_pinfo *np;
272 struct sock *sk;
273 int err;
274 __u64 seq;
275
276 sk = inet6_lookup(&dccp_hashinfo, &hdr->daddr, dh->dccph_dport,
277 &hdr->saddr, dh->dccph_sport, skb->dev->ifindex);
278
279 if (sk == NULL) {
280 ICMP6_INC_STATS_BH(__in6_dev_get(skb->dev), ICMP6_MIB_INERRORS);
281 return;
282 }
283
284 if (sk->sk_state == DCCP_TIME_WAIT) {
285 inet_twsk_put((struct inet_timewait_sock *)sk);
286 return;
287 }
288
289 bh_lock_sock(sk);
290 if (sock_owned_by_user(sk))
291 NET_INC_STATS_BH(LINUX_MIB_LOCKDROPPEDICMPS);
292
293 if (sk->sk_state == DCCP_CLOSED)
294 goto out;
295
296 np = inet6_sk(sk);
297
298 if (type == ICMPV6_PKT_TOOBIG) {
3df80d93
ACM
299 struct dst_entry *dst = NULL;
300
301 if (sock_owned_by_user(sk))
302 goto out;
303 if ((1 << sk->sk_state) & (DCCPF_LISTEN | DCCPF_CLOSED))
304 goto out;
305
306 /* icmp should have updated the destination cache entry */
307 dst = __sk_dst_check(sk, np->dst_cookie);
308
309 if (dst == NULL) {
310 struct inet_sock *inet = inet_sk(sk);
311 struct flowi fl;
312
313 /* BUGGG_FUTURE: Again, it is not clear how
314 to handle rthdr case. Ignore this complexity
315 for now.
316 */
317 memset(&fl, 0, sizeof(fl));
318 fl.proto = IPPROTO_DCCP;
319 ipv6_addr_copy(&fl.fl6_dst, &np->daddr);
320 ipv6_addr_copy(&fl.fl6_src, &np->saddr);
321 fl.oif = sk->sk_bound_dev_if;
322 fl.fl_ip_dport = inet->dport;
323 fl.fl_ip_sport = inet->sport;
324
325 if ((err = ip6_dst_lookup(sk, &dst, &fl))) {
326 sk->sk_err_soft = -err;
327 goto out;
328 }
329
330 if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) {
331 sk->sk_err_soft = -err;
332 goto out;
333 }
334
335 } else
336 dst_hold(dst);
337
d83d8461 338 if (inet_csk(sk)->icsk_pmtu_cookie > dst_mtu(dst)) {
3df80d93
ACM
339 dccp_sync_mss(sk, dst_mtu(dst));
340 } /* else let the usual retransmit timer handle it */
341 dst_release(dst);
342 goto out;
343 }
344
345 icmpv6_err_convert(type, code, &err);
346
347 seq = DCCP_SKB_CB(skb)->dccpd_seq;
348 /* Might be for an request_sock */
349 switch (sk->sk_state) {
350 struct request_sock *req, **prev;
351 case DCCP_LISTEN:
352 if (sock_owned_by_user(sk))
353 goto out;
354
355 req = inet6_csk_search_req(sk, &prev, dh->dccph_dport,
356 &hdr->daddr, &hdr->saddr,
357 inet6_iif(skb));
358 if (!req)
359 goto out;
360
361 /* ICMPs are not backlogged, hence we cannot get
362 * an established socket here.
363 */
364 BUG_TRAP(req->sk == NULL);
365
366 if (seq != dccp_rsk(req)->dreq_iss) {
367 NET_INC_STATS_BH(LINUX_MIB_OUTOFWINDOWICMPS);
368 goto out;
369 }
370
371 inet_csk_reqsk_queue_drop(sk, req, prev);
372 goto out;
373
374 case DCCP_REQUESTING:
375 case DCCP_RESPOND: /* Cannot happen.
376 It can, it SYNs are crossed. --ANK */
377 if (!sock_owned_by_user(sk)) {
378 DCCP_INC_STATS_BH(DCCP_MIB_ATTEMPTFAILS);
379 sk->sk_err = err;
380 /*
381 * Wake people up to see the error
382 * (see connect in sock.c)
383 */
384 sk->sk_error_report(sk);
385
386 dccp_done(sk);
387 } else
388 sk->sk_err_soft = err;
389 goto out;
390 }
391
392 if (!sock_owned_by_user(sk) && np->recverr) {
393 sk->sk_err = err;
394 sk->sk_error_report(sk);
395 } else
396 sk->sk_err_soft = err;
397
398out:
399 bh_unlock_sock(sk);
400 sock_put(sk);
401}
402
403
404static int dccp_v6_send_response(struct sock *sk, struct request_sock *req,
405 struct dst_entry *dst)
406{
407 struct inet6_request_sock *ireq6 = inet6_rsk(req);
408 struct ipv6_pinfo *np = inet6_sk(sk);
409 struct sk_buff *skb;
410 struct ipv6_txoptions *opt = NULL;
411 struct in6_addr *final_p = NULL, final;
412 struct flowi fl;
413 int err = -1;
414
415 memset(&fl, 0, sizeof(fl));
416 fl.proto = IPPROTO_DCCP;
417 ipv6_addr_copy(&fl.fl6_dst, &ireq6->rmt_addr);
418 ipv6_addr_copy(&fl.fl6_src, &ireq6->loc_addr);
419 fl.fl6_flowlabel = 0;
420 fl.oif = ireq6->iif;
421 fl.fl_ip_dport = inet_rsk(req)->rmt_port;
422 fl.fl_ip_sport = inet_sk(sk)->sport;
423
424 if (dst == NULL) {
425 opt = np->opt;
426 if (opt == NULL &&
427 np->rxopt.bits.osrcrt == 2 &&
428 ireq6->pktopts) {
429 struct sk_buff *pktopts = ireq6->pktopts;
430 struct inet6_skb_parm *rxopt = IP6CB(pktopts);
431 if (rxopt->srcrt)
432 opt = ipv6_invert_rthdr(sk,
433 (struct ipv6_rt_hdr *)(pktopts->nh.raw +
434 rxopt->srcrt));
435 }
436
437 if (opt && opt->srcrt) {
438 struct rt0_hdr *rt0 = (struct rt0_hdr *)opt->srcrt;
439 ipv6_addr_copy(&final, &fl.fl6_dst);
440 ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
441 final_p = &final;
442 }
443
444 err = ip6_dst_lookup(sk, &dst, &fl);
445 if (err)
446 goto done;
447 if (final_p)
448 ipv6_addr_copy(&fl.fl6_dst, final_p);
449 if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0)
450 goto done;
451 }
452
453 skb = dccp_make_response(sk, dst, req);
454 if (skb != NULL) {
455 struct dccp_hdr *dh = dccp_hdr(skb);
456 dh->dccph_checksum = dccp_v6_check(dh, skb->len,
457 &ireq6->loc_addr,
458 &ireq6->rmt_addr,
459 csum_partial((char *)dh,
460 skb->len,
461 skb->csum));
462 ipv6_addr_copy(&fl.fl6_dst, &ireq6->rmt_addr);
463 err = ip6_xmit(sk, skb, &fl, opt, 0);
464 if (err == NET_XMIT_CN)
465 err = 0;
466 }
467
468done:
469 if (opt && opt != np->opt)
470 sock_kfree_s(sk, opt, opt->tot_len);
471 return err;
472}
473
474static void dccp_v6_reqsk_destructor(struct request_sock *req)
475{
476 if (inet6_rsk(req)->pktopts != NULL)
477 kfree_skb(inet6_rsk(req)->pktopts);
478}
479
480static struct request_sock_ops dccp6_request_sock_ops = {
481 .family = AF_INET6,
482 .obj_size = sizeof(struct dccp6_request_sock),
483 .rtx_syn_ack = dccp_v6_send_response,
484 .send_ack = dccp_v6_reqsk_send_ack,
485 .destructor = dccp_v6_reqsk_destructor,
486 .send_reset = dccp_v6_ctl_send_reset,
487};
488
6d6ee43e
ACM
489static struct timewait_sock_ops dccp6_timewait_sock_ops = {
490 .twsk_obj_size = sizeof(struct dccp6_timewait_sock),
491};
492
3df80d93
ACM
493static void dccp_v6_send_check(struct sock *sk, int len, struct sk_buff *skb)
494{
495 struct ipv6_pinfo *np = inet6_sk(sk);
496 struct dccp_hdr *dh = dccp_hdr(skb);
497
498 dh->dccph_checksum = csum_ipv6_magic(&np->saddr, &np->daddr,
499 len, IPPROTO_DCCP,
500 csum_partial((char *)dh,
501 dh->dccph_doff << 2,
502 skb->csum));
503}
504
505static void dccp_v6_ctl_send_reset(struct sk_buff *rxskb)
506{
507 struct dccp_hdr *rxdh = dccp_hdr(rxskb), *dh;
508 const int dccp_hdr_reset_len = sizeof(struct dccp_hdr) +
509 sizeof(struct dccp_hdr_ext) +
510 sizeof(struct dccp_hdr_reset);
511 struct sk_buff *skb;
512 struct flowi fl;
513 u64 seqno;
514
515 if (rxdh->dccph_type == DCCP_PKT_RESET)
516 return;
517
518 if (!ipv6_unicast_destination(rxskb))
519 return;
520
521 /*
522 * We need to grab some memory, and put together an RST,
523 * and then put it into the queue to be sent.
524 */
525
526 skb = alloc_skb(MAX_HEADER + sizeof(struct ipv6hdr) +
527 dccp_hdr_reset_len, GFP_ATOMIC);
528 if (skb == NULL)
529 return;
530
531 skb_reserve(skb, MAX_HEADER + sizeof(struct ipv6hdr) +
532 dccp_hdr_reset_len);
533
534 skb->h.raw = skb_push(skb, dccp_hdr_reset_len);
535 dh = dccp_hdr(skb);
536 memset(dh, 0, dccp_hdr_reset_len);
537
538 /* Swap the send and the receive. */
539 dh->dccph_type = DCCP_PKT_RESET;
540 dh->dccph_sport = rxdh->dccph_dport;
541 dh->dccph_dport = rxdh->dccph_sport;
542 dh->dccph_doff = dccp_hdr_reset_len / 4;
543 dh->dccph_x = 1;
544 dccp_hdr_reset(skb)->dccph_reset_code =
545 DCCP_SKB_CB(rxskb)->dccpd_reset_code;
546
547 /* See "8.3.1. Abnormal Termination" in draft-ietf-dccp-spec-11 */
548 seqno = 0;
549 if (DCCP_SKB_CB(rxskb)->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ)
550 dccp_set_seqno(&seqno, DCCP_SKB_CB(rxskb)->dccpd_ack_seq + 1);
551
552 dccp_hdr_set_seq(dh, seqno);
553 dccp_hdr_set_ack(dccp_hdr_ack_bits(skb),
554 DCCP_SKB_CB(rxskb)->dccpd_seq);
555
556 memset(&fl, 0, sizeof(fl));
557 ipv6_addr_copy(&fl.fl6_dst, &rxskb->nh.ipv6h->saddr);
558 ipv6_addr_copy(&fl.fl6_src, &rxskb->nh.ipv6h->daddr);
559 dh->dccph_checksum = csum_ipv6_magic(&fl.fl6_src, &fl.fl6_dst,
560 sizeof(*dh), IPPROTO_DCCP,
561 skb->csum);
562 fl.proto = IPPROTO_DCCP;
563 fl.oif = inet6_iif(rxskb);
564 fl.fl_ip_dport = dh->dccph_dport;
565 fl.fl_ip_sport = dh->dccph_sport;
566
567 /* sk = NULL, but it is safe for now. RST socket required. */
568 if (!ip6_dst_lookup(NULL, &skb->dst, &fl)) {
569 if (xfrm_lookup(&skb->dst, &fl, NULL, 0) >= 0) {
570 ip6_xmit(NULL, skb, &fl, NULL, 0);
571 DCCP_INC_STATS_BH(DCCP_MIB_OUTSEGS);
572 DCCP_INC_STATS_BH(DCCP_MIB_OUTRSTS);
573 return;
574 }
575 }
576
577 kfree_skb(skb);
578}
579
580static void dccp_v6_ctl_send_ack(struct sk_buff *rxskb)
581{
582 struct flowi fl;
583 struct dccp_hdr *rxdh = dccp_hdr(rxskb), *dh;
584 const int dccp_hdr_ack_len = sizeof(struct dccp_hdr) +
585 sizeof(struct dccp_hdr_ext) +
586 sizeof(struct dccp_hdr_ack_bits);
587 struct sk_buff *skb;
588
589 skb = alloc_skb(MAX_HEADER + sizeof(struct ipv6hdr) +
590 dccp_hdr_ack_len, GFP_ATOMIC);
591 if (skb == NULL)
592 return;
593
594 skb_reserve(skb, MAX_HEADER + sizeof(struct ipv6hdr) +
595 dccp_hdr_ack_len);
596
597 skb->h.raw = skb_push(skb, dccp_hdr_ack_len);
598 dh = dccp_hdr(skb);
599 memset(dh, 0, dccp_hdr_ack_len);
600
601 /* Build DCCP header and checksum it. */
602 dh->dccph_type = DCCP_PKT_ACK;
603 dh->dccph_sport = rxdh->dccph_dport;
604 dh->dccph_dport = rxdh->dccph_sport;
605 dh->dccph_doff = dccp_hdr_ack_len / 4;
606 dh->dccph_x = 1;
607
608 dccp_hdr_set_seq(dh, DCCP_SKB_CB(rxskb)->dccpd_ack_seq);
609 dccp_hdr_set_ack(dccp_hdr_ack_bits(skb),
610 DCCP_SKB_CB(rxskb)->dccpd_seq);
611
612 memset(&fl, 0, sizeof(fl));
613 ipv6_addr_copy(&fl.fl6_dst, &rxskb->nh.ipv6h->saddr);
614 ipv6_addr_copy(&fl.fl6_src, &rxskb->nh.ipv6h->daddr);
615
616 /* FIXME: calculate checksum, IPv4 also should... */
617
618 fl.proto = IPPROTO_DCCP;
619 fl.oif = inet6_iif(rxskb);
620 fl.fl_ip_dport = dh->dccph_dport;
621 fl.fl_ip_sport = dh->dccph_sport;
622
623 if (!ip6_dst_lookup(NULL, &skb->dst, &fl)) {
624 if (xfrm_lookup(&skb->dst, &fl, NULL, 0) >= 0) {
625 ip6_xmit(NULL, skb, &fl, NULL, 0);
626 DCCP_INC_STATS_BH(DCCP_MIB_OUTSEGS);
627 return;
628 }
629 }
630
631 kfree_skb(skb);
632}
633
634static void dccp_v6_reqsk_send_ack(struct sk_buff *skb,
635 struct request_sock *req)
636{
637 dccp_v6_ctl_send_ack(skb);
638}
639
640static struct sock *dccp_v6_hnd_req(struct sock *sk,struct sk_buff *skb)
641{
642 const struct dccp_hdr *dh = dccp_hdr(skb);
643 const struct ipv6hdr *iph = skb->nh.ipv6h;
644 struct sock *nsk;
645 struct request_sock **prev;
646 /* Find possible connection requests. */
647 struct request_sock *req = inet6_csk_search_req(sk, &prev,
648 dh->dccph_sport,
649 &iph->saddr,
650 &iph->daddr,
651 inet6_iif(skb));
652 if (req != NULL)
653 return dccp_check_req(sk, skb, req, prev);
654
655 nsk = __inet6_lookup_established(&dccp_hashinfo,
656 &iph->saddr, dh->dccph_sport,
657 &iph->daddr, ntohs(dh->dccph_dport),
658 inet6_iif(skb));
659
660 if (nsk != NULL) {
661 if (nsk->sk_state != DCCP_TIME_WAIT) {
662 bh_lock_sock(nsk);
663 return nsk;
664 }
665 inet_twsk_put((struct inet_timewait_sock *)nsk);
666 return NULL;
667 }
668
669 return sk;
670}
671
672static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
673{
674 struct inet_request_sock *ireq;
675 struct dccp_sock dp;
676 struct request_sock *req;
677 struct dccp_request_sock *dreq;
678 struct inet6_request_sock *ireq6;
679 struct ipv6_pinfo *np = inet6_sk(sk);
680 const __u32 service = dccp_hdr_request(skb)->dccph_req_service;
681 struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
682 __u8 reset_code = DCCP_RESET_CODE_TOO_BUSY;
683
684 if (skb->protocol == htons(ETH_P_IP))
685 return dccp_v4_conn_request(sk, skb);
686
687 if (!ipv6_unicast_destination(skb))
688 goto drop;
689
690 if (dccp_bad_service_code(sk, service)) {
691 reset_code = DCCP_RESET_CODE_BAD_SERVICE_CODE;
692 goto drop;
693 }
694 /*
695 * There are no SYN attacks on IPv6, yet...
696 */
697 if (inet_csk_reqsk_queue_is_full(sk))
698 goto drop;
699
700 if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1)
701 goto drop;
702
703 req = inet6_reqsk_alloc(sk->sk_prot->rsk_prot);
704 if (req == NULL)
705 goto drop;
706
707 /* FIXME: process options */
708
709 dccp_openreq_init(req, &dp, skb);
710
711 ireq6 = inet6_rsk(req);
712 ireq = inet_rsk(req);
713 ipv6_addr_copy(&ireq6->rmt_addr, &skb->nh.ipv6h->saddr);
714 ipv6_addr_copy(&ireq6->loc_addr, &skb->nh.ipv6h->daddr);
715 req->rcv_wnd = 100; /* Fake, option parsing will get the
716 right value */
717 ireq6->pktopts = NULL;
718
719 if (ipv6_opt_accepted(sk, skb) ||
720 np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo ||
721 np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim) {
722 atomic_inc(&skb->users);
723 ireq6->pktopts = skb;
724 }
725 ireq6->iif = sk->sk_bound_dev_if;
726
727 /* So that link locals have meaning */
728 if (!sk->sk_bound_dev_if &&
729 ipv6_addr_type(&ireq6->rmt_addr) & IPV6_ADDR_LINKLOCAL)
730 ireq6->iif = inet6_iif(skb);
731
732 /*
733 * Step 3: Process LISTEN state
734 *
735 * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie
736 *
737 * In fact we defer setting S.GSR, S.SWL, S.SWH to
738 * dccp_create_openreq_child.
739 */
740 dreq = dccp_rsk(req);
741 dreq->dreq_isr = dcb->dccpd_seq;
742 dreq->dreq_iss = dccp_v6_init_sequence(sk, skb);
743 dreq->dreq_service = service;
744
745 if (dccp_v6_send_response(sk, req, NULL))
746 goto drop_and_free;
747
748 inet6_csk_reqsk_queue_hash_add(sk, req, DCCP_TIMEOUT_INIT);
749 return 0;
750
751drop_and_free:
752 reqsk_free(req);
753drop:
754 DCCP_INC_STATS_BH(DCCP_MIB_ATTEMPTFAILS);
755 dcb->dccpd_reset_code = reset_code;
756 return -1;
757}
758
759static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
760 struct sk_buff *skb,
761 struct request_sock *req,
762 struct dst_entry *dst)
763{
764 struct inet6_request_sock *ireq6 = inet6_rsk(req);
765 struct ipv6_pinfo *newnp, *np = inet6_sk(sk);
766 struct inet_sock *newinet;
767 struct dccp_sock *newdp;
768 struct dccp6_sock *newdp6;
769 struct sock *newsk;
770 struct ipv6_txoptions *opt;
771
772 if (skb->protocol == htons(ETH_P_IP)) {
773 /*
774 * v6 mapped
775 */
776
777 newsk = dccp_v4_request_recv_sock(sk, skb, req, dst);
778 if (newsk == NULL)
779 return NULL;
780
781 newdp6 = (struct dccp6_sock *)newsk;
782 newdp = dccp_sk(newsk);
783 newinet = inet_sk(newsk);
784 newinet->pinet6 = &newdp6->inet6;
785 newnp = inet6_sk(newsk);
786
787 memcpy(newnp, np, sizeof(struct ipv6_pinfo));
788
789 ipv6_addr_set(&newnp->daddr, 0, 0, htonl(0x0000FFFF),
790 newinet->daddr);
791
792 ipv6_addr_set(&newnp->saddr, 0, 0, htonl(0x0000FFFF),
793 newinet->saddr);
794
795 ipv6_addr_copy(&newnp->rcv_saddr, &newnp->saddr);
796
797 inet_csk(newsk)->icsk_af_ops = &dccp_ipv6_mapped;
798 newsk->sk_backlog_rcv = dccp_v4_do_rcv;
799 newnp->pktoptions = NULL;
800 newnp->opt = NULL;
801 newnp->mcast_oif = inet6_iif(skb);
802 newnp->mcast_hops = skb->nh.ipv6h->hop_limit;
803
804 /*
805 * No need to charge this sock to the relevant IPv6 refcnt debug socks count
806 * here, dccp_create_openreq_child now does this for us, see the comment in
807 * that function for the gory details. -acme
808 */
809
810 /* It is tricky place. Until this moment IPv4 tcp
811 worked with IPv6 icsk.icsk_af_ops.
812 Sync it now.
813 */
d83d8461 814 dccp_sync_mss(newsk, inet_csk(newsk)->icsk_pmtu_cookie);
3df80d93
ACM
815
816 return newsk;
817 }
818
819 opt = np->opt;
820
821 if (sk_acceptq_is_full(sk))
822 goto out_overflow;
823
824 if (np->rxopt.bits.osrcrt == 2 &&
825 opt == NULL && ireq6->pktopts) {
826 struct inet6_skb_parm *rxopt = IP6CB(ireq6->pktopts);
827 if (rxopt->srcrt)
828 opt = ipv6_invert_rthdr(sk,
829 (struct ipv6_rt_hdr *)(ireq6->pktopts->nh.raw +
830 rxopt->srcrt));
831 }
832
833 if (dst == NULL) {
834 struct in6_addr *final_p = NULL, final;
835 struct flowi fl;
836
837 memset(&fl, 0, sizeof(fl));
838 fl.proto = IPPROTO_DCCP;
839 ipv6_addr_copy(&fl.fl6_dst, &ireq6->rmt_addr);
840 if (opt && opt->srcrt) {
841 struct rt0_hdr *rt0 = (struct rt0_hdr *) opt->srcrt;
842 ipv6_addr_copy(&final, &fl.fl6_dst);
843 ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
844 final_p = &final;
845 }
846 ipv6_addr_copy(&fl.fl6_src, &ireq6->loc_addr);
847 fl.oif = sk->sk_bound_dev_if;
848 fl.fl_ip_dport = inet_rsk(req)->rmt_port;
849 fl.fl_ip_sport = inet_sk(sk)->sport;
850
851 if (ip6_dst_lookup(sk, &dst, &fl))
852 goto out;
853
854 if (final_p)
855 ipv6_addr_copy(&fl.fl6_dst, final_p);
856
857 if ((xfrm_lookup(&dst, &fl, sk, 0)) < 0)
858 goto out;
859 }
860
861 newsk = dccp_create_openreq_child(sk, req, skb);
862 if (newsk == NULL)
863 goto out;
864
865 /*
866 * No need to charge this sock to the relevant IPv6 refcnt debug socks
867 * count here, dccp_create_openreq_child now does this for us, see the
868 * comment in that function for the gory details. -acme
869 */
870
871 ip6_dst_store(newsk, dst, NULL);
872 newsk->sk_route_caps = dst->dev->features &
873 ~(NETIF_F_IP_CSUM | NETIF_F_TSO);
874
875 newdp6 = (struct dccp6_sock *)newsk;
876 newinet = inet_sk(newsk);
877 newinet->pinet6 = &newdp6->inet6;
878 newdp = dccp_sk(newsk);
879 newnp = inet6_sk(newsk);
880
881 memcpy(newnp, np, sizeof(struct ipv6_pinfo));
882
883 ipv6_addr_copy(&newnp->daddr, &ireq6->rmt_addr);
884 ipv6_addr_copy(&newnp->saddr, &ireq6->loc_addr);
885 ipv6_addr_copy(&newnp->rcv_saddr, &ireq6->loc_addr);
886 newsk->sk_bound_dev_if = ireq6->iif;
887
888 /* Now IPv6 options...
889
890 First: no IPv4 options.
891 */
892 newinet->opt = NULL;
893
894 /* Clone RX bits */
895 newnp->rxopt.all = np->rxopt.all;
896
897 /* Clone pktoptions received with SYN */
898 newnp->pktoptions = NULL;
899 if (ireq6->pktopts != NULL) {
900 newnp->pktoptions = skb_clone(ireq6->pktopts, GFP_ATOMIC);
901 kfree_skb(ireq6->pktopts);
902 ireq6->pktopts = NULL;
903 if (newnp->pktoptions)
904 skb_set_owner_r(newnp->pktoptions, newsk);
905 }
906 newnp->opt = NULL;
907 newnp->mcast_oif = inet6_iif(skb);
908 newnp->mcast_hops = skb->nh.ipv6h->hop_limit;
909
910 /* Clone native IPv6 options from listening socket (if any)
911
912 Yes, keeping reference count would be much more clever,
913 but we make one more one thing there: reattach optmem
914 to newsk.
915 */
916 if (opt) {
917 newnp->opt = ipv6_dup_options(newsk, opt);
918 if (opt != np->opt)
919 sock_kfree_s(sk, opt, opt->tot_len);
920 }
921
d83d8461 922 inet_csk(newsk)->icsk_ext_hdr_len = 0;
3df80d93 923 if (newnp->opt)
d83d8461
ACM
924 inet_csk(newsk)->icsk_ext_hdr_len = (newnp->opt->opt_nflen +
925 newnp->opt->opt_flen);
3df80d93
ACM
926
927 dccp_sync_mss(newsk, dst_mtu(dst));
928
929 newinet->daddr = newinet->saddr = newinet->rcv_saddr = LOOPBACK4_IPV6;
930
931 __inet6_hash(&dccp_hashinfo, newsk);
932 inet_inherit_port(&dccp_hashinfo, sk, newsk);
933
934 return newsk;
935
936out_overflow:
937 NET_INC_STATS_BH(LINUX_MIB_LISTENOVERFLOWS);
938out:
939 NET_INC_STATS_BH(LINUX_MIB_LISTENDROPS);
940 if (opt && opt != np->opt)
941 sock_kfree_s(sk, opt, opt->tot_len);
942 dst_release(dst);
943 return NULL;
944}
945
946/* The socket must have it's spinlock held when we get
947 * here.
948 *
949 * We have a potential double-lock case here, so even when
950 * doing backlog processing we use the BH locking scheme.
951 * This is because we cannot sleep with the original spinlock
952 * held.
953 */
954static int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
955{
956 struct ipv6_pinfo *np = inet6_sk(sk);
957 struct sk_buff *opt_skb = NULL;
958
959 /* Imagine: socket is IPv6. IPv4 packet arrives,
960 goes to IPv4 receive handler and backlogged.
961 From backlog it always goes here. Kerboom...
962 Fortunately, dccp_rcv_established and rcv_established
963 handle them correctly, but it is not case with
964 dccp_v6_hnd_req and dccp_v6_ctl_send_reset(). --ANK
965 */
966
967 if (skb->protocol == htons(ETH_P_IP))
968 return dccp_v4_do_rcv(sk, skb);
969
970 if (sk_filter(sk, skb, 0))
971 goto discard;
972
973 /*
974 * socket locking is here for SMP purposes as backlog rcv
975 * is currently called with bh processing disabled.
976 */
977
978 /* Do Stevens' IPV6_PKTOPTIONS.
979
980 Yes, guys, it is the only place in our code, where we
981 may make it not affecting IPv4.
982 The rest of code is protocol independent,
983 and I do not like idea to uglify IPv4.
984
985 Actually, all the idea behind IPV6_PKTOPTIONS
986 looks not very well thought. For now we latch
987 options, received in the last packet, enqueued
988 by tcp. Feel free to propose better solution.
989 --ANK (980728)
990 */
991 if (np->rxopt.all)
992 opt_skb = skb_clone(skb, GFP_ATOMIC);
993
994 if (sk->sk_state == DCCP_OPEN) { /* Fast path */
995 if (dccp_rcv_established(sk, skb, dccp_hdr(skb), skb->len))
996 goto reset;
997 return 0;
998 }
999
1000 if (sk->sk_state == DCCP_LISTEN) {
1001 struct sock *nsk = dccp_v6_hnd_req(sk, skb);
1002 if (!nsk)
1003 goto discard;
1004
1005 /*
1006 * Queue it on the new socket if the new socket is active,
1007 * otherwise we just shortcircuit this and continue with
1008 * the new socket..
1009 */
1010 if(nsk != sk) {
1011 if (dccp_child_process(sk, nsk, skb))
1012 goto reset;
1013 if (opt_skb)
1014 __kfree_skb(opt_skb);
1015 return 0;
1016 }
1017 }
1018
1019 if (dccp_rcv_state_process(sk, skb, dccp_hdr(skb), skb->len))
1020 goto reset;
1021 return 0;
1022
1023reset:
1024 dccp_v6_ctl_send_reset(skb);
1025discard:
1026 if (opt_skb)
1027 __kfree_skb(opt_skb);
1028 kfree_skb(skb);
1029 return 0;
1030}
1031
951dbc8a 1032static int dccp_v6_rcv(struct sk_buff **pskb)
3df80d93
ACM
1033{
1034 const struct dccp_hdr *dh;
1035 struct sk_buff *skb = *pskb;
1036 struct sock *sk;
3df80d93
ACM
1037
1038 /* Step 1: Check header basics: */
1039
1040 if (dccp_invalid_packet(skb))
1041 goto discard_it;
1042
1043 dh = dccp_hdr(skb);
1044
1045 DCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(skb);
1046 DCCP_SKB_CB(skb)->dccpd_type = dh->dccph_type;
1047
1048 if (dccp_packet_without_ack(skb))
1049 DCCP_SKB_CB(skb)->dccpd_ack_seq = DCCP_PKT_WITHOUT_ACK_SEQ;
1050 else
1051 DCCP_SKB_CB(skb)->dccpd_ack_seq = dccp_hdr_ack_seq(skb);
1052
1053 /* Step 2:
1054 * Look up flow ID in table and get corresponding socket */
1055 sk = __inet6_lookup(&dccp_hashinfo, &skb->nh.ipv6h->saddr,
1056 dh->dccph_sport,
1057 &skb->nh.ipv6h->daddr, ntohs(dh->dccph_dport),
1058 inet6_iif(skb));
1059 /*
1060 * Step 2:
1061 * If no socket ...
1062 * Generate Reset(No Connection) unless P.type == Reset
1063 * Drop packet and return
1064 */
1065 if (sk == NULL)
1066 goto no_dccp_socket;
1067
1068 /*
1069 * Step 2:
1070 * ... or S.state == TIMEWAIT,
1071 * Generate Reset(No Connection) unless P.type == Reset
1072 * Drop packet and return
1073 */
1074
1075 if (sk->sk_state == DCCP_TIME_WAIT)
1076 goto do_time_wait;
1077
1078 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
1079 goto discard_and_relse;
1080
25995ff5 1081 return sk_receive_skb(sk, skb) ? -1 : 0;
3df80d93
ACM
1082
1083no_dccp_socket:
1084 if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))
1085 goto discard_it;
1086 /*
1087 * Step 2:
1088 * Generate Reset(No Connection) unless P.type == Reset
1089 * Drop packet and return
1090 */
1091 if (dh->dccph_type != DCCP_PKT_RESET) {
1092 DCCP_SKB_CB(skb)->dccpd_reset_code =
1093 DCCP_RESET_CODE_NO_CONNECTION;
1094 dccp_v6_ctl_send_reset(skb);
1095 }
1096discard_it:
1097
1098 /*
1099 * Discard frame
1100 */
1101
1102 kfree_skb(skb);
1103 return 0;
1104
1105discard_and_relse:
1106 sock_put(sk);
1107 goto discard_it;
1108
1109do_time_wait:
1110 inet_twsk_put((struct inet_timewait_sock *)sk);
1111 goto no_dccp_socket;
1112}
1113
1114static struct inet_connection_sock_af_ops dccp_ipv6_af_ops = {
1115 .queue_xmit = inet6_csk_xmit,
1116 .send_check = dccp_v6_send_check,
1117 .rebuild_header = inet6_sk_rebuild_header,
1118 .conn_request = dccp_v6_conn_request,
1119 .syn_recv_sock = dccp_v6_request_recv_sock,
1120 .net_header_len = sizeof(struct ipv6hdr),
1121 .setsockopt = ipv6_setsockopt,
1122 .getsockopt = ipv6_getsockopt,
1123 .addr2sockaddr = inet6_csk_addr2sockaddr,
1124 .sockaddr_len = sizeof(struct sockaddr_in6)
1125};
1126
1127/*
1128 * DCCP over IPv4 via INET6 API
1129 */
1130static struct inet_connection_sock_af_ops dccp_ipv6_mapped = {
1131 .queue_xmit = ip_queue_xmit,
1132 .send_check = dccp_v4_send_check,
1133 .rebuild_header = inet_sk_rebuild_header,
1134 .conn_request = dccp_v6_conn_request,
1135 .syn_recv_sock = dccp_v6_request_recv_sock,
1136 .net_header_len = sizeof(struct iphdr),
1137 .setsockopt = ipv6_setsockopt,
1138 .getsockopt = ipv6_getsockopt,
1139 .addr2sockaddr = inet6_csk_addr2sockaddr,
1140 .sockaddr_len = sizeof(struct sockaddr_in6)
1141};
1142
1143/* NOTE: A lot of things set to zero explicitly by call to
1144 * sk_alloc() so need not be done here.
1145 */
1146static int dccp_v6_init_sock(struct sock *sk)
1147{
1148 int err = dccp_v4_init_sock(sk);
1149
1150 if (err == 0)
1151 inet_csk(sk)->icsk_af_ops = &dccp_ipv6_af_ops;
1152
1153 return err;
1154}
1155
1156static int dccp_v6_destroy_sock(struct sock *sk)
1157{
1158 dccp_v4_destroy_sock(sk);
1159 return inet6_destroy_sock(sk);
1160}
1161
1162static struct proto dccp_v6_prot = {
1163 .name = "DCCPv6",
1164 .owner = THIS_MODULE,
1165 .close = dccp_close,
1166 .connect = dccp_v6_connect,
1167 .disconnect = dccp_disconnect,
1168 .ioctl = dccp_ioctl,
1169 .init = dccp_v6_init_sock,
1170 .setsockopt = dccp_setsockopt,
1171 .getsockopt = dccp_getsockopt,
1172 .sendmsg = dccp_sendmsg,
1173 .recvmsg = dccp_recvmsg,
1174 .backlog_rcv = dccp_v6_do_rcv,
1175 .hash = dccp_v6_hash,
1176 .unhash = dccp_unhash,
1177 .accept = inet_csk_accept,
1178 .get_port = dccp_v6_get_port,
1179 .shutdown = dccp_shutdown,
1180 .destroy = dccp_v6_destroy_sock,
1181 .orphan_count = &dccp_orphan_count,
1182 .max_header = MAX_DCCP_HEADER,
1183 .obj_size = sizeof(struct dccp6_sock),
1184 .rsk_prot = &dccp6_request_sock_ops,
6d6ee43e 1185 .twsk_prot = &dccp6_timewait_sock_ops,
3df80d93
ACM
1186};
1187
1188static struct inet6_protocol dccp_v6_protocol = {
1189 .handler = dccp_v6_rcv,
1190 .err_handler = dccp_v6_err,
1191 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
1192};
1193
1194static struct proto_ops inet6_dccp_ops = {
1195 .family = PF_INET6,
1196 .owner = THIS_MODULE,
1197 .release = inet6_release,
1198 .bind = inet6_bind,
1199 .connect = inet_stream_connect,
1200 .socketpair = sock_no_socketpair,
1201 .accept = inet_accept,
1202 .getname = inet6_getname,
1203 .poll = dccp_poll,
1204 .ioctl = inet6_ioctl,
1205 .listen = inet_dccp_listen,
1206 .shutdown = inet_shutdown,
1207 .setsockopt = sock_common_setsockopt,
1208 .getsockopt = sock_common_getsockopt,
1209 .sendmsg = inet_sendmsg,
1210 .recvmsg = sock_common_recvmsg,
1211 .mmap = sock_no_mmap,
1212 .sendpage = sock_no_sendpage,
1213};
1214
1215static struct inet_protosw dccp_v6_protosw = {
1216 .type = SOCK_DCCP,
1217 .protocol = IPPROTO_DCCP,
1218 .prot = &dccp_v6_prot,
1219 .ops = &inet6_dccp_ops,
1220 .capability = -1,
d83d8461 1221 .flags = INET_PROTOSW_ICSK,
3df80d93
ACM
1222};
1223
1224static int __init dccp_v6_init(void)
1225{
1226 int err = proto_register(&dccp_v6_prot, 1);
1227
1228 if (err != 0)
1229 goto out;
1230
1231 err = inet6_add_protocol(&dccp_v6_protocol, IPPROTO_DCCP);
1232 if (err != 0)
1233 goto out_unregister_proto;
1234
1235 inet6_register_protosw(&dccp_v6_protosw);
1236out:
1237 return err;
1238out_unregister_proto:
1239 proto_unregister(&dccp_v6_prot);
1240 goto out;
1241}
1242
1243static void __exit dccp_v6_exit(void)
1244{
1245 inet6_del_protocol(&dccp_v6_protocol, IPPROTO_DCCP);
1246 inet6_unregister_protosw(&dccp_v6_protosw);
1247 proto_unregister(&dccp_v6_prot);
1248}
1249
1250module_init(dccp_v6_init);
1251module_exit(dccp_v6_exit);
1252
1253/*
1254 * __stringify doesn't likes enums, so use SOCK_DCCP (6) and IPPROTO_DCCP (33)
1255 * values directly, Also cover the case where the protocol is not specified,
1256 * i.e. net-pf-PF_INET6-proto-0-type-SOCK_DCCP
1257 */
1258MODULE_ALIAS("net-pf-" __stringify(PF_INET6) "-proto-33-type-6");
1259MODULE_ALIAS("net-pf-" __stringify(PF_INET6) "-proto-0-type-6");
1260MODULE_LICENSE("GPL");
1261MODULE_AUTHOR("Arnaldo Carvalho de Melo <acme@mandriva.com>");
1262MODULE_DESCRIPTION("DCCPv6 - Datagram Congestion Controlled Protocol");