blob: 5f9b145b0b90ca21c0d9dafca93697e5aacfbc0b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* SCTP kernel reference Implementation
2 * (C) Copyright IBM Corp. 2002, 2004
3 * Copyright (c) 2001 Nokia, Inc.
4 * Copyright (c) 2001 La Monte H.P. Yarroll
5 * Copyright (c) 2002-2003 Intel Corp.
6 *
7 * This file is part of the SCTP kernel reference Implementation
8 *
9 * SCTP over IPv6.
10 *
11 * The SCTP reference implementation is free software;
12 * you can redistribute it and/or modify it under the terms of
13 * the GNU General Public License as published by
14 * the Free Software Foundation; either version 2, or (at your option)
15 * any later version.
16 *
17 * The SCTP reference implementation is distributed in the hope that it
18 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
19 * ************************
20 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 * See the GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with GNU CC; see the file COPYING. If not, write to
25 * the Free Software Foundation, 59 Temple Place - Suite 330,
26 * Boston, MA 02111-1307, USA.
27 *
28 * Please send any bug reports or fixes you make to the
29 * email address(es):
30 * lksctp developers <lksctp-developers@lists.sourceforge.net>
31 *
32 * Or submit a bug report through the following website:
33 * http://www.sf.net/projects/lksctp
34 *
35 * Written or modified by:
36 * Le Yanqun <yanqun.le@nokia.com>
37 * Hui Huang <hui.huang@nokia.com>
38 * La Monte H.P. Yarroll <piggy@acm.org>
39 * Sridhar Samudrala <sri@us.ibm.com>
40 * Jon Grimm <jgrimm@us.ibm.com>
41 * Ardelle Fan <ardelle.fan@intel.com>
42 *
43 * Based on:
44 * linux/net/ipv6/tcp_ipv6.c
45 *
46 * Any bugs reported given to us we will try to fix... any fixes shared will
47 * be incorporated into the next SCTP release.
48 */
49
50#include <linux/module.h>
51#include <linux/errno.h>
52#include <linux/types.h>
53#include <linux/socket.h>
54#include <linux/sockios.h>
55#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070056#include <linux/in.h>
57#include <linux/in6.h>
58#include <linux/netdevice.h>
59#include <linux/init.h>
60#include <linux/ipsec.h>
61
62#include <linux/ipv6.h>
63#include <linux/icmpv6.h>
64#include <linux/random.h>
65#include <linux/seq_file.h>
66
67#include <net/protocol.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070068#include <net/ndisc.h>
Arnaldo Carvalho de Meloc752f072005-08-09 20:08:28 -070069#include <net/ip.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070070#include <net/ipv6.h>
71#include <net/transp_v6.h>
72#include <net/addrconf.h>
73#include <net/ip6_route.h>
74#include <net/inet_common.h>
75#include <net/inet_ecn.h>
76#include <net/sctp/sctp.h>
77
78#include <asm/uaccess.h>
79
Sridhar Samudrala29c7cf92006-12-13 16:26:26 -080080/* Event handler for inet6 address addition/deletion events. */
Adrian Bunk24123182006-12-20 16:08:22 -080081static int sctp_inet6addr_event(struct notifier_block *this, unsigned long ev,
82 void *ptr)
Sridhar Samudrala29c7cf92006-12-13 16:26:26 -080083{
84 struct inet6_ifaddr *ifa = (struct inet6_ifaddr *)ptr;
85 struct sctp_sockaddr_entry *addr;
86 struct list_head *pos, *temp;
87
88 switch (ev) {
89 case NETDEV_UP:
90 addr = kmalloc(sizeof(struct sctp_sockaddr_entry), GFP_ATOMIC);
91 if (addr) {
92 addr->a.v6.sin6_family = AF_INET6;
93 addr->a.v6.sin6_port = 0;
94 memcpy(&addr->a.v6.sin6_addr, &ifa->addr,
95 sizeof(struct in6_addr));
96 addr->a.v6.sin6_scope_id = ifa->idev->dev->ifindex;
97 list_add_tail(&addr->list, &sctp_local_addr_list);
98 }
99 break;
100 case NETDEV_DOWN:
101 list_for_each_safe(pos, temp, &sctp_local_addr_list) {
102 addr = list_entry(pos, struct sctp_sockaddr_entry, list);
103 if (ipv6_addr_equal(&addr->a.v6.sin6_addr, &ifa->addr)) {
104 list_del(pos);
105 kfree(addr);
106 break;
107 }
108 }
109
110 break;
111 }
112
113 return NOTIFY_DONE;
114}
115
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116static struct notifier_block sctp_inet6addr_notifier = {
Sridhar Samudrala29c7cf92006-12-13 16:26:26 -0800117 .notifier_call = sctp_inet6addr_event,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118};
119
120/* ICMP error handler. */
121SCTP_STATIC void sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
Al Viro04ce6902006-11-08 00:21:01 -0800122 int type, int code, int offset, __be32 info)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123{
124 struct inet6_dev *idev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 struct sctphdr *sh = (struct sctphdr *)(skb->data + offset);
126 struct sock *sk;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 struct sctp_association *asoc;
128 struct sctp_transport *transport;
129 struct ipv6_pinfo *np;
130 char *saveip, *savesctp;
131 int err;
132
133 idev = in6_dev_get(skb->dev);
134
135 /* Fix up skb to look at the embedded net header. */
136 saveip = skb->nh.raw;
137 savesctp = skb->h.raw;
Arnaldo Carvalho de Melo1ced98e2007-03-10 19:57:15 -0300138 skb_reset_network_header(skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 skb->h.raw = (char *)sh;
Sridhar Samudralad1ad1ff2005-07-18 13:44:10 -0700140 sk = sctp_err_lookup(AF_INET6, skb, sh, &asoc, &transport);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 /* Put back, the original pointers. */
142 skb->nh.raw = saveip;
143 skb->h.raw = savesctp;
144 if (!sk) {
145 ICMP6_INC_STATS_BH(idev, ICMP6_MIB_INERRORS);
146 goto out;
147 }
148
149 /* Warning: The sock lock is held. Remember to call
150 * sctp_err_finish!
151 */
152
153 switch (type) {
154 case ICMPV6_PKT_TOOBIG:
155 sctp_icmp_frag_needed(sk, asoc, transport, ntohl(info));
156 goto out_unlock;
157 case ICMPV6_PARAMPROB:
158 if (ICMPV6_UNK_NEXTHDR == code) {
Sridhar Samudralad1ad1ff2005-07-18 13:44:10 -0700159 sctp_icmp_proto_unreachable(sk, asoc, transport);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 goto out_unlock;
161 }
162 break;
163 default:
164 break;
165 }
166
167 np = inet6_sk(sk);
168 icmpv6_err_convert(type, code, &err);
169 if (!sock_owned_by_user(sk) && np->recverr) {
170 sk->sk_err = err;
171 sk->sk_error_report(sk);
172 } else { /* Only an error on timeout */
173 sk->sk_err_soft = err;
174 }
175
176out_unlock:
Sridhar Samudralad1ad1ff2005-07-18 13:44:10 -0700177 sctp_err_finish(sk, asoc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178out:
179 if (likely(idev != NULL))
180 in6_dev_put(idev);
181}
182
183/* Based on tcp_v6_xmit() in tcp_ipv6.c. */
184static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport,
185 int ipfragok)
186{
187 struct sock *sk = skb->sk;
188 struct ipv6_pinfo *np = inet6_sk(sk);
189 struct flowi fl;
190
191 memset(&fl, 0, sizeof(fl));
192
193 fl.proto = sk->sk_protocol;
194
195 /* Fill in the dest address from the route entry passed with the skb
196 * and the source address from the transport.
197 */
Al Virob3f5b3b2006-11-20 17:22:43 -0800198 ipv6_addr_copy(&fl.fl6_dst, &transport->ipaddr.v6.sin6_addr);
Al Viroa9266262006-11-20 17:13:58 -0800199 ipv6_addr_copy(&fl.fl6_src, &transport->saddr.v6.sin6_addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200
201 fl.fl6_flowlabel = np->flow_label;
202 IP6_ECN_flow_xmit(sk, fl.fl6_flowlabel);
203 if (ipv6_addr_type(&fl.fl6_src) & IPV6_ADDR_LINKLOCAL)
Al Viroa9266262006-11-20 17:13:58 -0800204 fl.oif = transport->saddr.v6.sin6_scope_id;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 else
206 fl.oif = sk->sk_bound_dev_if;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207
208 if (np->opt && np->opt->srcrt) {
209 struct rt0_hdr *rt0 = (struct rt0_hdr *) np->opt->srcrt;
210 ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
211 }
212
213 SCTP_DEBUG_PRINTK("%s: skb:%p, len:%d, "
Joe Perches46b86a22006-01-13 14:29:07 -0800214 "src:" NIP6_FMT " dst:" NIP6_FMT "\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215 __FUNCTION__, skb, skb->len,
216 NIP6(fl.fl6_src), NIP6(fl.fl6_dst));
217
218 SCTP_INC_STATS(SCTP_MIB_OUTSCTPPACKS);
219
220 return ip6_xmit(sk, skb, &fl, np->opt, ipfragok);
221}
222
223/* Returns the dst cache entry for the given source and destination ip
224 * addresses.
225 */
226static struct dst_entry *sctp_v6_get_dst(struct sctp_association *asoc,
227 union sctp_addr *daddr,
228 union sctp_addr *saddr)
229{
230 struct dst_entry *dst;
231 struct flowi fl;
232
233 memset(&fl, 0, sizeof(fl));
234 ipv6_addr_copy(&fl.fl6_dst, &daddr->v6.sin6_addr);
235 if (ipv6_addr_type(&daddr->v6.sin6_addr) & IPV6_ADDR_LINKLOCAL)
236 fl.oif = daddr->v6.sin6_scope_id;
YOSHIFUJI Hideakid808ad92007-02-09 23:25:18 +0900237
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238
Joe Perches46b86a22006-01-13 14:29:07 -0800239 SCTP_DEBUG_PRINTK("%s: DST=" NIP6_FMT " ",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 __FUNCTION__, NIP6(fl.fl6_dst));
241
242 if (saddr) {
243 ipv6_addr_copy(&fl.fl6_src, &saddr->v6.sin6_addr);
244 SCTP_DEBUG_PRINTK(
Joe Perches46b86a22006-01-13 14:29:07 -0800245 "SRC=" NIP6_FMT " - ",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 NIP6(fl.fl6_src));
247 }
248
249 dst = ip6_route_output(NULL, &fl);
Ville Nuorvala42513202006-10-16 22:10:05 -0700250 if (!dst->error) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 struct rt6_info *rt;
252 rt = (struct rt6_info *)dst;
253 SCTP_DEBUG_PRINTK(
Joe Perches46b86a22006-01-13 14:29:07 -0800254 "rt6_dst:" NIP6_FMT " rt6_src:" NIP6_FMT "\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255 NIP6(rt->rt6i_dst.addr), NIP6(rt->rt6i_src.addr));
Ville Nuorvala42513202006-10-16 22:10:05 -0700256 return dst;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257 }
Ville Nuorvala42513202006-10-16 22:10:05 -0700258 SCTP_DEBUG_PRINTK("NO ROUTE\n");
259 dst_release(dst);
260 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261}
262
263/* Returns the number of consecutive initial bits that match in the 2 ipv6
264 * addresses.
265 */
266static inline int sctp_v6_addr_match_len(union sctp_addr *s1,
267 union sctp_addr *s2)
268{
269 struct in6_addr *a1 = &s1->v6.sin6_addr;
270 struct in6_addr *a2 = &s2->v6.sin6_addr;
271 int i, j;
272
273 for (i = 0; i < 4 ; i++) {
Al Virodbc16db2006-11-20 17:01:42 -0800274 __be32 a1xora2;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275
276 a1xora2 = a1->s6_addr32[i] ^ a2->s6_addr32[i];
277
278 if ((j = fls(ntohl(a1xora2))))
279 return (i * 32 + 32 - j);
280 }
281
282 return (i*32);
283}
284
285/* Fills in the source address(saddr) based on the destination address(daddr)
286 * and asoc's bind address list.
287 */
288static void sctp_v6_get_saddr(struct sctp_association *asoc,
289 struct dst_entry *dst,
290 union sctp_addr *daddr,
291 union sctp_addr *saddr)
292{
293 struct sctp_bind_addr *bp;
294 rwlock_t *addr_lock;
295 struct sctp_sockaddr_entry *laddr;
296 struct list_head *pos;
297 sctp_scope_t scope;
298 union sctp_addr *baddr = NULL;
299 __u8 matchlen = 0;
300 __u8 bmatchlen;
301
302 SCTP_DEBUG_PRINTK("%s: asoc:%p dst:%p "
Joe Perches46b86a22006-01-13 14:29:07 -0800303 "daddr:" NIP6_FMT " ",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304 __FUNCTION__, asoc, dst, NIP6(daddr->v6.sin6_addr));
305
306 if (!asoc) {
307 ipv6_get_saddr(dst, &daddr->v6.sin6_addr,&saddr->v6.sin6_addr);
Joe Perches46b86a22006-01-13 14:29:07 -0800308 SCTP_DEBUG_PRINTK("saddr from ipv6_get_saddr: " NIP6_FMT "\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 NIP6(saddr->v6.sin6_addr));
310 return;
311 }
312
313 scope = sctp_scope(daddr);
314
315 bp = &asoc->base.bind_addr;
316 addr_lock = &asoc->base.addr_lock;
317
318 /* Go through the bind address list and find the best source address
319 * that matches the scope of the destination address.
320 */
321 sctp_read_lock(addr_lock);
322 list_for_each(pos, &bp->address_list) {
323 laddr = list_entry(pos, struct sctp_sockaddr_entry, list);
Sridhar Samudraladc022a92006-07-21 14:49:25 -0700324 if ((laddr->use_as_src) &&
Al Viro6244be42006-11-20 17:21:44 -0800325 (laddr->a.sa.sa_family == AF_INET6) &&
326 (scope <= sctp_scope(&laddr->a))) {
Al Virod3f7a542006-11-20 17:12:41 -0800327 bmatchlen = sctp_v6_addr_match_len(daddr, &laddr->a);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328 if (!baddr || (matchlen < bmatchlen)) {
Al Virod3f7a542006-11-20 17:12:41 -0800329 baddr = &laddr->a;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 matchlen = bmatchlen;
331 }
332 }
333 }
334
335 if (baddr) {
336 memcpy(saddr, baddr, sizeof(union sctp_addr));
Joe Perches46b86a22006-01-13 14:29:07 -0800337 SCTP_DEBUG_PRINTK("saddr: " NIP6_FMT "\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 NIP6(saddr->v6.sin6_addr));
339 } else {
340 printk(KERN_ERR "%s: asoc:%p Could not find a valid source "
Joe Perches46b86a22006-01-13 14:29:07 -0800341 "address for the dest:" NIP6_FMT "\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 __FUNCTION__, asoc, NIP6(daddr->v6.sin6_addr));
343 }
344
345 sctp_read_unlock(addr_lock);
346}
347
348/* Make a copy of all potential local addresses. */
349static void sctp_v6_copy_addrlist(struct list_head *addrlist,
350 struct net_device *dev)
351{
352 struct inet6_dev *in6_dev;
353 struct inet6_ifaddr *ifp;
354 struct sctp_sockaddr_entry *addr;
355
YOSHIFUJI Hideaki8814c4b2006-09-22 14:44:24 -0700356 rcu_read_lock();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357 if ((in6_dev = __in6_dev_get(dev)) == NULL) {
YOSHIFUJI Hideaki8814c4b2006-09-22 14:44:24 -0700358 rcu_read_unlock();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 return;
360 }
361
Jarek Poplawskie2eb8d42007-03-08 14:43:41 -0800362 read_lock_bh(&in6_dev->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363 for (ifp = in6_dev->addr_list; ifp; ifp = ifp->if_next) {
364 /* Add the address to the local list. */
365 addr = t_new(struct sctp_sockaddr_entry, GFP_ATOMIC);
366 if (addr) {
Al Viro2a6fd782006-11-20 17:04:42 -0800367 addr->a.v6.sin6_family = AF_INET6;
368 addr->a.v6.sin6_port = 0;
369 addr->a.v6.sin6_addr = ifp->addr;
370 addr->a.v6.sin6_scope_id = dev->ifindex;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 INIT_LIST_HEAD(&addr->list);
372 list_add_tail(&addr->list, addrlist);
373 }
374 }
375
Jarek Poplawskie2eb8d42007-03-08 14:43:41 -0800376 read_unlock_bh(&in6_dev->lock);
YOSHIFUJI Hideaki8814c4b2006-09-22 14:44:24 -0700377 rcu_read_unlock();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378}
379
380/* Initialize a sockaddr_storage from in incoming skb. */
381static void sctp_v6_from_skb(union sctp_addr *addr,struct sk_buff *skb,
382 int is_saddr)
383{
384 void *from;
Al Virod55c41b2006-11-20 17:09:40 -0800385 __be16 *port;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386 struct sctphdr *sh;
387
388 port = &addr->v6.sin6_port;
389 addr->v6.sin6_family = AF_INET6;
390 addr->v6.sin6_flowinfo = 0; /* FIXME */
391 addr->v6.sin6_scope_id = ((struct inet6_skb_parm *)skb->cb)->iif;
392
393 sh = (struct sctphdr *) skb->h.raw;
394 if (is_saddr) {
Al Virod55c41b2006-11-20 17:09:40 -0800395 *port = sh->source;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396 from = &skb->nh.ipv6h->saddr;
397 } else {
Al Virod55c41b2006-11-20 17:09:40 -0800398 *port = sh->dest;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 from = &skb->nh.ipv6h->daddr;
400 }
401 ipv6_addr_copy(&addr->v6.sin6_addr, from);
402}
403
404/* Initialize an sctp_addr from a socket. */
405static void sctp_v6_from_sk(union sctp_addr *addr, struct sock *sk)
406{
407 addr->v6.sin6_family = AF_INET6;
Al Viro7dcdbd92006-11-20 17:24:21 -0800408 addr->v6.sin6_port = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 addr->v6.sin6_addr = inet6_sk(sk)->rcv_saddr;
410}
411
412/* Initialize sk->sk_rcv_saddr from sctp_addr. */
413static void sctp_v6_to_sk_saddr(union sctp_addr *addr, struct sock *sk)
414{
415 if (addr->sa.sa_family == AF_INET && sctp_sk(sk)->v4mapped) {
416 inet6_sk(sk)->rcv_saddr.s6_addr32[0] = 0;
417 inet6_sk(sk)->rcv_saddr.s6_addr32[1] = 0;
418 inet6_sk(sk)->rcv_saddr.s6_addr32[2] = htonl(0x0000ffff);
419 inet6_sk(sk)->rcv_saddr.s6_addr32[3] =
420 addr->v4.sin_addr.s_addr;
421 } else {
422 inet6_sk(sk)->rcv_saddr = addr->v6.sin6_addr;
423 }
424}
425
426/* Initialize sk->sk_daddr from sctp_addr. */
427static void sctp_v6_to_sk_daddr(union sctp_addr *addr, struct sock *sk)
428{
429 if (addr->sa.sa_family == AF_INET && sctp_sk(sk)->v4mapped) {
430 inet6_sk(sk)->daddr.s6_addr32[0] = 0;
431 inet6_sk(sk)->daddr.s6_addr32[1] = 0;
432 inet6_sk(sk)->daddr.s6_addr32[2] = htonl(0x0000ffff);
433 inet6_sk(sk)->daddr.s6_addr32[3] = addr->v4.sin_addr.s_addr;
434 } else {
435 inet6_sk(sk)->daddr = addr->v6.sin6_addr;
436 }
437}
438
439/* Initialize a sctp_addr from an address parameter. */
440static void sctp_v6_from_addr_param(union sctp_addr *addr,
441 union sctp_addr_param *param,
Al Virodd86d132006-11-20 17:11:13 -0800442 __be16 port, int iif)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443{
444 addr->v6.sin6_family = AF_INET6;
445 addr->v6.sin6_port = port;
446 addr->v6.sin6_flowinfo = 0; /* BUG */
447 ipv6_addr_copy(&addr->v6.sin6_addr, &param->v6.addr);
448 addr->v6.sin6_scope_id = iif;
449}
450
451/* Initialize an address parameter from a sctp_addr and return the length
452 * of the address parameter.
453 */
454static int sctp_v6_to_addr_param(const union sctp_addr *addr,
455 union sctp_addr_param *param)
456{
457 int length = sizeof(sctp_ipv6addr_param_t);
458
459 param->v6.param_hdr.type = SCTP_PARAM_IPV6_ADDRESS;
Al Virodbc16db2006-11-20 17:01:42 -0800460 param->v6.param_hdr.length = htons(length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461 ipv6_addr_copy(&param->v6.addr, &addr->v6.sin6_addr);
462
463 return length;
464}
465
466/* Initialize a sctp_addr from a dst_entry. */
467static void sctp_v6_dst_saddr(union sctp_addr *addr, struct dst_entry *dst,
Al Viro854d43a2006-11-20 17:06:24 -0800468 __be16 port)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469{
470 struct rt6_info *rt = (struct rt6_info *)dst;
471 addr->sa.sa_family = AF_INET6;
472 addr->v6.sin6_port = port;
473 ipv6_addr_copy(&addr->v6.sin6_addr, &rt->rt6i_src.addr);
474}
475
476/* Compare addresses exactly.
477 * v4-mapped-v6 is also in consideration.
478 */
479static int sctp_v6_cmp_addr(const union sctp_addr *addr1,
480 const union sctp_addr *addr2)
481{
482 if (addr1->sa.sa_family != addr2->sa.sa_family) {
483 if (addr1->sa.sa_family == AF_INET &&
484 addr2->sa.sa_family == AF_INET6 &&
485 IPV6_ADDR_MAPPED == ipv6_addr_type(&addr2->v6.sin6_addr)) {
486 if (addr2->v6.sin6_port == addr1->v4.sin_port &&
487 addr2->v6.sin6_addr.s6_addr32[3] ==
488 addr1->v4.sin_addr.s_addr)
489 return 1;
490 }
491 if (addr2->sa.sa_family == AF_INET &&
492 addr1->sa.sa_family == AF_INET6 &&
493 IPV6_ADDR_MAPPED == ipv6_addr_type(&addr1->v6.sin6_addr)) {
494 if (addr1->v6.sin6_port == addr2->v4.sin_port &&
495 addr1->v6.sin6_addr.s6_addr32[3] ==
496 addr2->v4.sin_addr.s_addr)
497 return 1;
498 }
499 return 0;
500 }
501 if (!ipv6_addr_equal(&addr1->v6.sin6_addr, &addr2->v6.sin6_addr))
502 return 0;
503 /* If this is a linklocal address, compare the scope_id. */
504 if (ipv6_addr_type(&addr1->v6.sin6_addr) & IPV6_ADDR_LINKLOCAL) {
505 if (addr1->v6.sin6_scope_id && addr2->v6.sin6_scope_id &&
506 (addr1->v6.sin6_scope_id != addr2->v6.sin6_scope_id)) {
507 return 0;
508 }
509 }
510
511 return 1;
512}
513
514/* Initialize addr struct to INADDR_ANY. */
Al Viro6fbfa9f2006-11-20 17:24:53 -0800515static void sctp_v6_inaddr_any(union sctp_addr *addr, __be16 port)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516{
517 memset(addr, 0x00, sizeof(union sctp_addr));
518 addr->v6.sin6_family = AF_INET6;
519 addr->v6.sin6_port = port;
520}
521
522/* Is this a wildcard address? */
523static int sctp_v6_is_any(const union sctp_addr *addr)
524{
Brian Haleyb9b9e102005-04-28 11:59:16 -0700525 return ipv6_addr_any(&addr->v6.sin6_addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526}
527
528/* Should this be available for binding? */
529static int sctp_v6_available(union sctp_addr *addr, struct sctp_sock *sp)
530{
531 int type;
532 struct in6_addr *in6 = (struct in6_addr *)&addr->v6.sin6_addr;
533
534 type = ipv6_addr_type(in6);
535 if (IPV6_ADDR_ANY == type)
536 return 1;
537 if (type == IPV6_ADDR_MAPPED) {
538 if (sp && !sp->v4mapped)
539 return 0;
540 if (sp && ipv6_only_sock(sctp_opt2sk(sp)))
541 return 0;
542 sctp_v6_map_v4(addr);
543 return sctp_get_af_specific(AF_INET)->available(addr, sp);
544 }
545 if (!(type & IPV6_ADDR_UNICAST))
546 return 0;
547
548 return ipv6_chk_addr(in6, NULL, 0);
549}
550
551/* This function checks if the address is a valid address to be used for
552 * SCTP.
553 *
554 * Output:
555 * Return 0 - If the address is a non-unicast or an illegal address.
556 * Return 1 - If the address is a unicast.
557 */
Vlad Yasevich5636bef2006-06-17 22:55:35 -0700558static int sctp_v6_addr_valid(union sctp_addr *addr,
559 struct sctp_sock *sp,
560 const struct sk_buff *skb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561{
562 int ret = ipv6_addr_type(&addr->v6.sin6_addr);
563
564 /* Support v4-mapped-v6 address. */
565 if (ret == IPV6_ADDR_MAPPED) {
566 /* Note: This routine is used in input, so v4-mapped-v6
567 * are disallowed here when there is no sctp_sock.
568 */
569 if (!sp || !sp->v4mapped)
570 return 0;
571 if (sp && ipv6_only_sock(sctp_opt2sk(sp)))
572 return 0;
573 sctp_v6_map_v4(addr);
Vlad Yasevich5636bef2006-06-17 22:55:35 -0700574 return sctp_get_af_specific(AF_INET)->addr_valid(addr, sp, skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 }
576
577 /* Is this a non-unicast address */
578 if (!(ret & IPV6_ADDR_UNICAST))
579 return 0;
580
581 return 1;
582}
583
584/* What is the scope of 'addr'? */
585static sctp_scope_t sctp_v6_scope(union sctp_addr *addr)
586{
587 int v6scope;
588 sctp_scope_t retval;
589
590 /* The IPv6 scope is really a set of bit fields.
591 * See IFA_* in <net/if_inet6.h>. Map to a generic SCTP scope.
592 */
593
594 v6scope = ipv6_addr_scope(&addr->v6.sin6_addr);
595 switch (v6scope) {
596 case IFA_HOST:
597 retval = SCTP_SCOPE_LOOPBACK;
598 break;
599 case IFA_LINK:
600 retval = SCTP_SCOPE_LINK;
601 break;
602 case IFA_SITE:
603 retval = SCTP_SCOPE_PRIVATE;
604 break;
605 default:
606 retval = SCTP_SCOPE_GLOBAL;
607 break;
608 };
609
610 return retval;
611}
612
613/* Create and initialize a new sk for the socket to be returned by accept(). */
614static struct sock *sctp_v6_create_accept_sk(struct sock *sk,
615 struct sctp_association *asoc)
616{
617 struct inet_sock *inet = inet_sk(sk);
618 struct sock *newsk;
619 struct inet_sock *newinet;
620 struct ipv6_pinfo *newnp, *np = inet6_sk(sk);
621 struct sctp6_sock *newsctp6sk;
622
623 newsk = sk_alloc(PF_INET6, GFP_KERNEL, sk->sk_prot, 1);
624 if (!newsk)
625 goto out;
626
627 sock_init_data(NULL, newsk);
628
629 newsk->sk_type = SOCK_STREAM;
630
631 newsk->sk_prot = sk->sk_prot;
632 newsk->sk_no_check = sk->sk_no_check;
633 newsk->sk_reuse = sk->sk_reuse;
634
635 newsk->sk_destruct = inet_sock_destruct;
636 newsk->sk_family = PF_INET6;
637 newsk->sk_protocol = IPPROTO_SCTP;
638 newsk->sk_backlog_rcv = sk->sk_prot->backlog_rcv;
639 newsk->sk_shutdown = sk->sk_shutdown;
640 sock_reset_flag(sk, SOCK_ZAPPED);
641
642 newsctp6sk = (struct sctp6_sock *)newsk;
643 inet_sk(newsk)->pinet6 = &newsctp6sk->inet6;
644
645 newinet = inet_sk(newsk);
646 newnp = inet6_sk(newsk);
647
648 memcpy(newnp, np, sizeof(struct ipv6_pinfo));
649
650 /* Initialize sk's sport, dport, rcv_saddr and daddr for getsockname()
651 * and getpeername().
652 */
653 newinet->sport = inet->sport;
654 newnp->saddr = np->saddr;
655 newnp->rcv_saddr = np->rcv_saddr;
656 newinet->dport = htons(asoc->peer.port);
657 sctp_v6_to_sk_daddr(&asoc->peer.primary_addr, newsk);
658
659 /* Init the ipv4 part of the socket since we can have sockets
660 * using v6 API for ipv4.
661 */
662 newinet->uc_ttl = -1;
663 newinet->mc_loop = 1;
664 newinet->mc_ttl = 1;
665 newinet->mc_index = 0;
666 newinet->mc_list = NULL;
667
668 if (ipv4_config.no_pmtu_disc)
669 newinet->pmtudisc = IP_PMTUDISC_DONT;
670 else
671 newinet->pmtudisc = IP_PMTUDISC_WANT;
672
Arnaldo Carvalho de Meloe6848972005-08-09 19:45:38 -0700673 sk_refcnt_debug_inc(newsk);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674
675 if (newsk->sk_prot->init(newsk)) {
676 sk_common_release(newsk);
677 newsk = NULL;
678 }
679
680out:
681 return newsk;
682}
683
684/* Map v4 address to mapped v6 address */
685static void sctp_v6_addr_v4map(struct sctp_sock *sp, union sctp_addr *addr)
686{
687 if (sp->v4mapped && AF_INET == addr->sa.sa_family)
688 sctp_v4_map_v6(addr);
689}
690
691/* Where did this skb come from? */
692static int sctp_v6_skb_iif(const struct sk_buff *skb)
693{
694 struct inet6_skb_parm *opt = (struct inet6_skb_parm *) skb->cb;
695 return opt->iif;
696}
697
698/* Was this packet marked by Explicit Congestion Notification? */
699static int sctp_v6_is_ce(const struct sk_buff *skb)
700{
701 return *((__u32 *)(skb->nh.ipv6h)) & htonl(1<<20);
702}
703
704/* Dump the v6 addr to the seq file. */
705static void sctp_v6_seq_dump_addr(struct seq_file *seq, union sctp_addr *addr)
706{
Joe Perches46b86a22006-01-13 14:29:07 -0800707 seq_printf(seq, NIP6_FMT " ", NIP6(addr->v6.sin6_addr));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708}
709
710/* Initialize a PF_INET6 socket msg_name. */
711static void sctp_inet6_msgname(char *msgname, int *addr_len)
712{
713 struct sockaddr_in6 *sin6;
714
715 sin6 = (struct sockaddr_in6 *)msgname;
716 sin6->sin6_family = AF_INET6;
717 sin6->sin6_flowinfo = 0;
718 sin6->sin6_scope_id = 0; /*FIXME */
719 *addr_len = sizeof(struct sockaddr_in6);
720}
721
722/* Initialize a PF_INET msgname from a ulpevent. */
723static void sctp_inet6_event_msgname(struct sctp_ulpevent *event,
724 char *msgname, int *addrlen)
725{
726 struct sockaddr_in6 *sin6, *sin6from;
727
728 if (msgname) {
729 union sctp_addr *addr;
730 struct sctp_association *asoc;
731
732 asoc = event->asoc;
733 sctp_inet6_msgname(msgname, addrlen);
734 sin6 = (struct sockaddr_in6 *)msgname;
735 sin6->sin6_port = htons(asoc->peer.port);
736 addr = &asoc->peer.primary_addr;
737
738 /* Note: If we go to a common v6 format, this code
739 * will change.
740 */
741
742 /* Map ipv4 address into v4-mapped-on-v6 address. */
743 if (sctp_sk(asoc->base.sk)->v4mapped &&
744 AF_INET == addr->sa.sa_family) {
745 sctp_v4_map_v6((union sctp_addr *)sin6);
746 sin6->sin6_addr.s6_addr32[3] =
747 addr->v4.sin_addr.s_addr;
748 return;
749 }
750
751 sin6from = &asoc->peer.primary_addr.v6;
752 ipv6_addr_copy(&sin6->sin6_addr, &sin6from->sin6_addr);
753 if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL)
754 sin6->sin6_scope_id = sin6from->sin6_scope_id;
755 }
756}
757
758/* Initialize a msg_name from an inbound skb. */
759static void sctp_inet6_skb_msgname(struct sk_buff *skb, char *msgname,
760 int *addr_len)
761{
762 struct sctphdr *sh;
763 struct sockaddr_in6 *sin6;
764
765 if (msgname) {
766 sctp_inet6_msgname(msgname, addr_len);
767 sin6 = (struct sockaddr_in6 *)msgname;
768 sh = (struct sctphdr *)skb->h.raw;
769 sin6->sin6_port = sh->source;
770
771 /* Map ipv4 address into v4-mapped-on-v6 address. */
772 if (sctp_sk(skb->sk)->v4mapped &&
773 skb->nh.iph->version == 4) {
774 sctp_v4_map_v6((union sctp_addr *)sin6);
775 sin6->sin6_addr.s6_addr32[3] = skb->nh.iph->saddr;
776 return;
777 }
778
779 /* Otherwise, just copy the v6 address. */
780 ipv6_addr_copy(&sin6->sin6_addr, &skb->nh.ipv6h->saddr);
781 if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL) {
782 struct sctp_ulpevent *ev = sctp_skb2event(skb);
783 sin6->sin6_scope_id = ev->iif;
784 }
785 }
786}
787
788/* Do we support this AF? */
789static int sctp_inet6_af_supported(sa_family_t family, struct sctp_sock *sp)
790{
791 switch (family) {
792 case AF_INET6:
793 return 1;
794 /* v4-mapped-v6 addresses */
795 case AF_INET:
796 if (!__ipv6_only_sock(sctp_opt2sk(sp)) && sp->v4mapped)
797 return 1;
798 default:
799 return 0;
800 }
801}
802
803/* Address matching with wildcards allowed. This extra level
804 * of indirection lets us choose whether a PF_INET6 should
805 * disallow any v4 addresses if we so choose.
806 */
807static int sctp_inet6_cmp_addr(const union sctp_addr *addr1,
808 const union sctp_addr *addr2,
809 struct sctp_sock *opt)
810{
811 struct sctp_af *af1, *af2;
812
813 af1 = sctp_get_af_specific(addr1->sa.sa_family);
814 af2 = sctp_get_af_specific(addr2->sa.sa_family);
815
816 if (!af1 || !af2)
817 return 0;
818 /* Today, wildcard AF_INET/AF_INET6. */
819 if (sctp_is_any(addr1) || sctp_is_any(addr2))
820 return 1;
821
822 if (addr1->sa.sa_family != addr2->sa.sa_family)
823 return 0;
824
825 return af1->cmp_addr(addr1, addr2);
826}
827
828/* Verify that the provided sockaddr looks bindable. Common verification,
829 * has already been taken care of.
830 */
831static int sctp_inet6_bind_verify(struct sctp_sock *opt, union sctp_addr *addr)
832{
833 struct sctp_af *af;
834
835 /* ASSERT: address family has already been verified. */
836 if (addr->sa.sa_family != AF_INET6)
837 af = sctp_get_af_specific(addr->sa.sa_family);
838 else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700839 int type = ipv6_addr_type(&addr->v6.sin6_addr);
Sridhar Samudrala6a6ddb22005-06-13 15:13:05 -0700840 struct net_device *dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700841
Sridhar Samudrala6a6ddb22005-06-13 15:13:05 -0700842 if (type & IPV6_ADDR_LINKLOCAL) {
843 if (!addr->v6.sin6_scope_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700844 return 0;
Sridhar Samudrala6a6ddb22005-06-13 15:13:05 -0700845 dev = dev_get_by_index(addr->v6.sin6_scope_id);
846 if (!dev)
847 return 0;
848 dev_put(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849 }
850 af = opt->pf->af;
851 }
852 return af->available(addr, opt);
853}
854
Sridhar Samudrala6a6ddb22005-06-13 15:13:05 -0700855/* Verify that the provided sockaddr looks sendable. Common verification,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700856 * has already been taken care of.
857 */
858static int sctp_inet6_send_verify(struct sctp_sock *opt, union sctp_addr *addr)
859{
860 struct sctp_af *af = NULL;
861
862 /* ASSERT: address family has already been verified. */
863 if (addr->sa.sa_family != AF_INET6)
864 af = sctp_get_af_specific(addr->sa.sa_family);
865 else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866 int type = ipv6_addr_type(&addr->v6.sin6_addr);
Sridhar Samudrala6a6ddb22005-06-13 15:13:05 -0700867 struct net_device *dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700868
Sridhar Samudrala6a6ddb22005-06-13 15:13:05 -0700869 if (type & IPV6_ADDR_LINKLOCAL) {
870 if (!addr->v6.sin6_scope_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700871 return 0;
Sridhar Samudrala6a6ddb22005-06-13 15:13:05 -0700872 dev = dev_get_by_index(addr->v6.sin6_scope_id);
873 if (!dev)
874 return 0;
875 dev_put(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700876 }
877 af = opt->pf->af;
878 }
879
880 return af != NULL;
881}
882
883/* Fill in Supported Address Type information for INIT and INIT-ACK
884 * chunks. Note: In the future, we may want to look at sock options
885 * to determine whether a PF_INET6 socket really wants to have IPV4
886 * addresses.
887 * Returns number of addresses supported.
888 */
889static int sctp_inet6_supported_addrs(const struct sctp_sock *opt,
Al Viro3dbe8652006-11-20 17:25:49 -0800890 __be16 *types)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700891{
892 types[0] = SCTP_PARAM_IPV4_ADDRESS;
893 types[1] = SCTP_PARAM_IPV6_ADDRESS;
894 return 2;
895}
896
Eric Dumazet90ddc4f2005-12-22 12:49:22 -0800897static const struct proto_ops inet6_seqpacket_ops = {
Arnaldo Carvalho de Melo543d9cf2006-03-20 22:48:35 -0800898 .family = PF_INET6,
899 .owner = THIS_MODULE,
900 .release = inet6_release,
901 .bind = inet6_bind,
902 .connect = inet_dgram_connect,
903 .socketpair = sock_no_socketpair,
904 .accept = inet_accept,
905 .getname = inet6_getname,
906 .poll = sctp_poll,
907 .ioctl = inet6_ioctl,
908 .listen = sctp_inet_listen,
909 .shutdown = inet_shutdown,
910 .setsockopt = sock_common_setsockopt,
911 .getsockopt = sock_common_getsockopt,
912 .sendmsg = inet_sendmsg,
913 .recvmsg = sock_common_recvmsg,
914 .mmap = sock_no_mmap,
Dmitry Mishin3fdadf72006-03-20 22:45:21 -0800915#ifdef CONFIG_COMPAT
Arnaldo Carvalho de Melo543d9cf2006-03-20 22:48:35 -0800916 .compat_setsockopt = compat_sock_common_setsockopt,
917 .compat_getsockopt = compat_sock_common_getsockopt,
Dmitry Mishin3fdadf72006-03-20 22:45:21 -0800918#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700919};
920
921static struct inet_protosw sctpv6_seqpacket_protosw = {
922 .type = SOCK_SEQPACKET,
923 .protocol = IPPROTO_SCTP,
924 .prot = &sctpv6_prot,
925 .ops = &inet6_seqpacket_ops,
926 .capability = -1,
927 .no_check = 0,
928 .flags = SCTP_PROTOSW_FLAG
929};
930static struct inet_protosw sctpv6_stream_protosw = {
931 .type = SOCK_STREAM,
932 .protocol = IPPROTO_SCTP,
933 .prot = &sctpv6_prot,
934 .ops = &inet6_seqpacket_ops,
935 .capability = -1,
936 .no_check = 0,
937 .flags = SCTP_PROTOSW_FLAG,
938};
939
Patrick McHardy951dbc82006-01-06 23:02:34 -0800940static int sctp6_rcv(struct sk_buff **pskb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700941{
942 return sctp_rcv(*pskb) ? -1 : 0;
943}
944
945static struct inet6_protocol sctpv6_protocol = {
946 .handler = sctp6_rcv,
947 .err_handler = sctp_v6_err,
948 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
949};
950
951static struct sctp_af sctp_ipv6_specific = {
Arnaldo Carvalho de Melo543d9cf2006-03-20 22:48:35 -0800952 .sa_family = AF_INET6,
953 .sctp_xmit = sctp_v6_xmit,
954 .setsockopt = ipv6_setsockopt,
955 .getsockopt = ipv6_getsockopt,
956 .get_dst = sctp_v6_get_dst,
957 .get_saddr = sctp_v6_get_saddr,
958 .copy_addrlist = sctp_v6_copy_addrlist,
959 .from_skb = sctp_v6_from_skb,
960 .from_sk = sctp_v6_from_sk,
961 .to_sk_saddr = sctp_v6_to_sk_saddr,
962 .to_sk_daddr = sctp_v6_to_sk_daddr,
963 .from_addr_param = sctp_v6_from_addr_param,
964 .to_addr_param = sctp_v6_to_addr_param,
965 .dst_saddr = sctp_v6_dst_saddr,
966 .cmp_addr = sctp_v6_cmp_addr,
967 .scope = sctp_v6_scope,
968 .addr_valid = sctp_v6_addr_valid,
969 .inaddr_any = sctp_v6_inaddr_any,
970 .is_any = sctp_v6_is_any,
971 .available = sctp_v6_available,
972 .skb_iif = sctp_v6_skb_iif,
973 .is_ce = sctp_v6_is_ce,
974 .seq_dump_addr = sctp_v6_seq_dump_addr,
975 .net_header_len = sizeof(struct ipv6hdr),
976 .sockaddr_len = sizeof(struct sockaddr_in6),
Dmitry Mishin3fdadf72006-03-20 22:45:21 -0800977#ifdef CONFIG_COMPAT
Arnaldo Carvalho de Melo543d9cf2006-03-20 22:48:35 -0800978 .compat_setsockopt = compat_ipv6_setsockopt,
979 .compat_getsockopt = compat_ipv6_getsockopt,
Dmitry Mishin3fdadf72006-03-20 22:45:21 -0800980#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700981};
982
983static struct sctp_pf sctp_pf_inet6_specific = {
984 .event_msgname = sctp_inet6_event_msgname,
985 .skb_msgname = sctp_inet6_skb_msgname,
986 .af_supported = sctp_inet6_af_supported,
987 .cmp_addr = sctp_inet6_cmp_addr,
988 .bind_verify = sctp_inet6_bind_verify,
989 .send_verify = sctp_inet6_send_verify,
990 .supported_addrs = sctp_inet6_supported_addrs,
991 .create_accept_sk = sctp_v6_create_accept_sk,
992 .addr_v4map = sctp_v6_addr_v4map,
993 .af = &sctp_ipv6_specific,
994};
995
996/* Initialize IPv6 support and register with inet6 stack. */
997int sctp_v6_init(void)
998{
999 int rc = proto_register(&sctpv6_prot, 1);
1000
1001 if (rc)
1002 goto out;
1003 /* Register inet6 protocol. */
1004 rc = -EAGAIN;
1005 if (inet6_add_protocol(&sctpv6_protocol, IPPROTO_SCTP) < 0)
1006 goto out_unregister_sctp_proto;
1007
1008 /* Add SCTPv6(UDP and TCP style) to inetsw6 linked list. */
1009 inet6_register_protosw(&sctpv6_seqpacket_protosw);
1010 inet6_register_protosw(&sctpv6_stream_protosw);
1011
1012 /* Register the SCTP specific PF_INET6 functions. */
1013 sctp_register_pf(&sctp_pf_inet6_specific, PF_INET6);
1014
1015 /* Register the SCTP specific AF_INET6 functions. */
1016 sctp_register_af(&sctp_ipv6_specific);
1017
1018 /* Register notifier for inet6 address additions/deletions. */
1019 register_inet6addr_notifier(&sctp_inet6addr_notifier);
1020 rc = 0;
1021out:
1022 return rc;
1023out_unregister_sctp_proto:
1024 proto_unregister(&sctpv6_prot);
1025 goto out;
1026}
1027
1028/* IPv6 specific exit support. */
1029void sctp_v6_exit(void)
1030{
1031 list_del(&sctp_ipv6_specific.list);
1032 inet6_del_protocol(&sctpv6_protocol, IPPROTO_SCTP);
1033 inet6_unregister_protosw(&sctpv6_seqpacket_protosw);
1034 inet6_unregister_protosw(&sctpv6_stream_protosw);
1035 unregister_inet6addr_notifier(&sctp_inet6addr_notifier);
1036 proto_unregister(&sctpv6_prot);
1037}