~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/sctp/protocol.c

Version: ~ [ linux-5.9.1 ] ~ [ linux-5.8.16 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.72 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.152 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.202 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.240 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.240 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SCTP kernel reference Implementation
  2  * Copyright (c) 1999-2000 Cisco, Inc.
  3  * Copyright (c) 1999-2001 Motorola, Inc.
  4  * Copyright (c) 2001-2003 International Business Machines, Corp.
  5  * Copyright (c) 2001 Intel Corp.
  6  * Copyright (c) 2001 Nokia, Inc.
  7  * Copyright (c) 2001 La Monte H.P. Yarroll
  8  *
  9  * This file is part of the SCTP kernel reference Implementation
 10  *
 11  * Initialization/cleanup for SCTP protocol support.
 12  *
 13  * The SCTP reference implementation is free software;
 14  * you can redistribute it and/or modify it under the terms of
 15  * the GNU General Public License as published by
 16  * the Free Software Foundation; either version 2, or (at your option)
 17  * any later version.
 18  *
 19  * The SCTP reference implementation is distributed in the hope that it
 20  * will be useful, but WITHOUT ANY WARRANTY; without even the implied
 21  *                 ************************
 22  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 23  * See the GNU General Public License for more details.
 24  *
 25  * You should have received a copy of the GNU General Public License
 26  * along with GNU CC; see the file COPYING.  If not, write to
 27  * the Free Software Foundation, 59 Temple Place - Suite 330,
 28  * Boston, MA 02111-1307, USA.
 29  *
 30  * Please send any bug reports or fixes you make to the
 31  * email address(es):
 32  *    lksctp developers <lksctp-developers@lists.sourceforge.net>
 33  *
 34  * Or submit a bug report through the following website:
 35  *    http://www.sf.net/projects/lksctp
 36  *
 37  * Written or modified by:
 38  *    La Monte H.P. Yarroll <piggy@acm.org>
 39  *    Karl Knutson <karl@athena.chicago.il.us>
 40  *    Jon Grimm <jgrimm@us.ibm.com>
 41  *    Sridhar Samudrala <sri@us.ibm.com>
 42  *    Daisy Chang <daisyc@us.ibm.com>
 43  *    Ardelle Fan <ardelle.fan@intel.com>
 44  *
 45  * Any bugs reported given to us we will try to fix... any fixes shared will
 46  * be incorporated into the next SCTP release.
 47  */
 48 
 49 #include <linux/module.h>
 50 #include <linux/init.h>
 51 #include <linux/netdevice.h>
 52 #include <linux/inetdevice.h>
 53 #include <linux/seq_file.h>
 54 #include <net/protocol.h>
 55 #include <net/ip.h>
 56 #include <net/ipv6.h>
 57 #include <net/sctp/sctp.h>
 58 #include <net/addrconf.h>
 59 #include <net/inet_common.h>
 60 #include <net/inet_ecn.h>
 61 
 62 /* Global data structures. */
 63 struct sctp_globals sctp_globals;
 64 struct proc_dir_entry   *proc_net_sctp;
 65 DEFINE_SNMP_STAT(struct sctp_mib, sctp_statistics);
 66 
 67 /* This is the global socket data structure used for responding to
 68  * the Out-of-the-blue (OOTB) packets.  A control sock will be created
 69  * for this socket at the initialization time.
 70  */
 71 static struct socket *sctp_ctl_socket;
 72 
 73 static struct sctp_pf *sctp_pf_inet6_specific;
 74 static struct sctp_pf *sctp_pf_inet_specific;
 75 static struct sctp_af *sctp_af_v4_specific;
 76 static struct sctp_af *sctp_af_v6_specific;
 77 
 78 kmem_cache_t *sctp_chunk_cachep;
 79 kmem_cache_t *sctp_bucket_cachep;
 80 
 81 extern struct net_proto_family inet_family_ops;
 82 
 83 extern int sctp_snmp_proc_init(void);
 84 extern int sctp_snmp_proc_exit(void);
 85 extern int sctp_eps_proc_init(void);
 86 extern int sctp_eps_proc_exit(void);
 87 extern int sctp_assocs_proc_init(void);
 88 extern int sctp_assocs_proc_exit(void);
 89 
 90 /* Return the address of the control sock. */
 91 struct sock *sctp_get_ctl_sock(void)
 92 {
 93         return sctp_ctl_socket->sk;
 94 }
 95 
 96 /* Set up the proc fs entry for the SCTP protocol. */
 97 __init int sctp_proc_init(void)
 98 {
 99         if (!proc_net_sctp) {
100                 struct proc_dir_entry *ent;
101                 ent = proc_mkdir("net/sctp", 0);
102                 if (ent) {
103                         ent->owner = THIS_MODULE;
104                         proc_net_sctp = ent;
105                 } else
106                         goto out_nomem;
107         }
108 
109         if (sctp_snmp_proc_init())
110                 goto out_nomem; 
111         if (sctp_eps_proc_init())
112                 goto out_nomem; 
113         if (sctp_assocs_proc_init())
114                 goto out_nomem; 
115 
116         return 0;
117 
118 out_nomem:
119         return -ENOMEM;
120 }
121 
122 /* Clean up the proc fs entry for the SCTP protocol. 
123  * Note: Do not make this __exit as it is used in the init error
124  * path.
125  */
126 void sctp_proc_exit(void)
127 {
128         sctp_snmp_proc_exit();
129         sctp_eps_proc_exit();
130         sctp_assocs_proc_exit();
131 
132         if (proc_net_sctp) {
133                 proc_net_sctp = NULL;
134                 remove_proc_entry("net/sctp", 0);
135         }
136 }
137 
138 /* Private helper to extract ipv4 address and stash them in
139  * the protocol structure.
140  */
141 static void sctp_v4_copy_addrlist(struct list_head *addrlist,
142                                   struct net_device *dev)
143 {
144         struct in_device *in_dev;
145         struct in_ifaddr *ifa;
146         struct sctp_sockaddr_entry *addr;
147 
148         read_lock(&inetdev_lock);
149         if ((in_dev = __in_dev_get(dev)) == NULL) {
150                 read_unlock(&inetdev_lock);
151                 return;
152         }
153 
154         read_lock(&in_dev->lock);
155         for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
156                 /* Add the address to the local list.  */
157                 addr = t_new(struct sctp_sockaddr_entry, GFP_ATOMIC);
158                 if (addr) {
159                         addr->a.v4.sin_family = AF_INET;
160                         addr->a.v4.sin_port = 0;
161                         addr->a.v4.sin_addr.s_addr = ifa->ifa_local;
162                         list_add_tail(&addr->list, addrlist);
163                 }
164         }
165 
166         read_unlock(&in_dev->lock);
167         read_unlock(&inetdev_lock);
168 }
169 
170 /* Extract our IP addresses from the system and stash them in the
171  * protocol structure.
172  */
173 static void __sctp_get_local_addr_list(void)
174 {
175         struct net_device *dev;
176         struct list_head *pos;
177         struct sctp_af *af;
178 
179         read_lock(&dev_base_lock);
180         for (dev = dev_base; dev; dev = dev->next) {
181                 __list_for_each(pos, &sctp_address_families) {
182                         af = list_entry(pos, struct sctp_af, list);
183                         af->copy_addrlist(&sctp_local_addr_list, dev);
184                 }
185         }
186         read_unlock(&dev_base_lock);
187 }
188 
189 static void sctp_get_local_addr_list(void)
190 {
191         unsigned long flags;
192 
193         sctp_spin_lock_irqsave(&sctp_local_addr_lock, flags);
194         __sctp_get_local_addr_list();
195         sctp_spin_unlock_irqrestore(&sctp_local_addr_lock, flags);
196 }
197 
198 /* Free the existing local addresses.  */
199 static void __sctp_free_local_addr_list(void)
200 {
201         struct sctp_sockaddr_entry *addr;
202         struct list_head *pos, *temp;
203 
204         list_for_each_safe(pos, temp, &sctp_local_addr_list) {
205                 addr = list_entry(pos, struct sctp_sockaddr_entry, list);
206                 list_del(pos);
207                 kfree(addr);
208         }
209 }
210 
211 /* Free the existing local addresses.  */
212 static void sctp_free_local_addr_list(void)
213 {
214         unsigned long flags;
215 
216         sctp_spin_lock_irqsave(&sctp_local_addr_lock, flags);
217         __sctp_free_local_addr_list();
218         sctp_spin_unlock_irqrestore(&sctp_local_addr_lock, flags);
219 }
220 
221 /* Copy the local addresses which are valid for 'scope' into 'bp'.  */
222 int sctp_copy_local_addr_list(struct sctp_bind_addr *bp, sctp_scope_t scope,
223                               int gfp, int copy_flags)
224 {
225         struct sctp_sockaddr_entry *addr;
226         int error = 0;
227         struct list_head *pos;
228         unsigned long flags;
229 
230         sctp_spin_lock_irqsave(&sctp_local_addr_lock, flags);
231         list_for_each(pos, &sctp_local_addr_list) {
232                 addr = list_entry(pos, struct sctp_sockaddr_entry, list);
233                 if (sctp_in_scope(&addr->a, scope)) {
234                         /* Now that the address is in scope, check to see if
235                          * the address type is really supported by the local
236                          * sock as well as the remote peer.
237                          */
238                         if ((((AF_INET == addr->a.sa.sa_family) &&
239                               (copy_flags & SCTP_ADDR4_PEERSUPP))) ||
240                             (((AF_INET6 == addr->a.sa.sa_family) &&
241                               (copy_flags & SCTP_ADDR6_ALLOWED) &&
242                               (copy_flags & SCTP_ADDR6_PEERSUPP)))) {
243                                 error = sctp_add_bind_addr(bp, &addr->a, 
244                                                            GFP_ATOMIC);
245                                 if (error)
246                                         goto end_copy;
247                         }
248                 }
249         }
250 
251 end_copy:
252         sctp_spin_unlock_irqrestore(&sctp_local_addr_lock, flags);
253         return error;
254 }
255 
256 /* Initialize a sctp_addr from in incoming skb.  */
257 static void sctp_v4_from_skb(union sctp_addr *addr, struct sk_buff *skb,
258                              int is_saddr)
259 {
260         void *from;
261         __u16 *port;
262         struct sctphdr *sh;
263 
264         port = &addr->v4.sin_port;
265         addr->v4.sin_family = AF_INET;
266 
267         sh = (struct sctphdr *) skb->h.raw;
268         if (is_saddr) {
269                 *port  = ntohs(sh->source);
270                 from = &skb->nh.iph->saddr;
271         } else {
272                 *port = ntohs(sh->dest);
273                 from = &skb->nh.iph->daddr;
274         }
275         memcpy(&addr->v4.sin_addr.s_addr, from, sizeof(struct in_addr));
276 }
277 
278 /* Initialize an sctp_addr from a socket. */
279 static void sctp_v4_from_sk(union sctp_addr *addr, struct sock *sk)
280 {
281         addr->v4.sin_family = AF_INET;
282         addr->v4.sin_port = inet_sk(sk)->num;
283         addr->v4.sin_addr.s_addr = inet_sk(sk)->rcv_saddr;
284 }
285 
286 /* Initialize sk->sk_rcv_saddr from sctp_addr. */
287 static void sctp_v4_to_sk_saddr(union sctp_addr *addr, struct sock *sk)
288 {
289         inet_sk(sk)->rcv_saddr = addr->v4.sin_addr.s_addr;
290 }
291 
292 /* Initialize sk->sk_daddr from sctp_addr. */
293 static void sctp_v4_to_sk_daddr(union sctp_addr *addr, struct sock *sk)
294 {
295         inet_sk(sk)->daddr = addr->v4.sin_addr.s_addr;
296 }
297 
298 /* Initialize a sctp_addr from an address parameter. */
299 static void sctp_v4_from_addr_param(union sctp_addr *addr,
300                                     union sctp_addr_param *param,
301                                     __u16 port, int iif)
302 {
303         addr->v4.sin_family = AF_INET;
304         addr->v4.sin_port = port;
305         addr->v4.sin_addr.s_addr = param->v4.addr.s_addr;
306 }
307 
308 /* Initialize an address parameter from a sctp_addr and return the length
309  * of the address parameter.
310  */
311 static int sctp_v4_to_addr_param(const union sctp_addr *addr,
312                                  union sctp_addr_param *param)
313 {
314         int length = sizeof(sctp_ipv4addr_param_t);
315 
316         param->v4.param_hdr.type = SCTP_PARAM_IPV4_ADDRESS;
317         param->v4.param_hdr.length = ntohs(length);
318         param->v4.addr.s_addr = addr->v4.sin_addr.s_addr;       
319 
320         return length;
321 }
322 
323 /* Initialize a sctp_addr from a dst_entry. */
324 static void sctp_v4_dst_saddr(union sctp_addr *saddr, struct dst_entry *dst,
325                               unsigned short port)
326 {
327         struct rtable *rt = (struct rtable *)dst;
328         saddr->v4.sin_family = AF_INET;
329         saddr->v4.sin_port = port;
330         saddr->v4.sin_addr.s_addr = rt->rt_src;
331 }
332 
333 /* Compare two addresses exactly. */
334 static int sctp_v4_cmp_addr(const union sctp_addr *addr1,
335                             const union sctp_addr *addr2)
336 {
337         if (addr1->sa.sa_family != addr2->sa.sa_family)
338                 return 0;
339         if (addr1->v4.sin_port != addr2->v4.sin_port)
340                 return 0;
341         if (addr1->v4.sin_addr.s_addr != addr2->v4.sin_addr.s_addr)
342                 return 0;
343 
344         return 1;
345 }
346 
347 /* Initialize addr struct to INADDR_ANY. */
348 static void sctp_v4_inaddr_any(union sctp_addr *addr, unsigned short port)
349 {
350         addr->v4.sin_family = AF_INET;
351         addr->v4.sin_addr.s_addr = INADDR_ANY;
352         addr->v4.sin_port = port;
353 }
354 
355 /* Is this a wildcard address? */
356 static int sctp_v4_is_any(const union sctp_addr *addr)
357 {
358         return INADDR_ANY == addr->v4.sin_addr.s_addr;
359 }
360 
361 /* This function checks if the address is a valid address to be used for
362  * SCTP binding.
363  *
364  * Output:
365  * Return 0 - If the address is a non-unicast or an illegal address.
366  * Return 1 - If the address is a unicast.
367  */
368 static int sctp_v4_addr_valid(union sctp_addr *addr, struct sctp_opt *sp)
369 {
370         /* Is this a non-unicast address or a unusable SCTP address? */
371         if (IS_IPV4_UNUSABLE_ADDRESS(&addr->v4.sin_addr.s_addr))
372                 return 0;
373 
374         return 1;
375 }
376 
377 /* Should this be available for binding?   */
378 static int sctp_v4_available(union sctp_addr *addr, struct sctp_opt *sp)
379 {
380         int ret = inet_addr_type(addr->v4.sin_addr.s_addr);
381 
382         /* FIXME: ip_nonlocal_bind sysctl support. */
383 
384         if (addr->v4.sin_addr.s_addr != INADDR_ANY && ret != RTN_LOCAL)
385                 return 0;
386         return 1;
387 }
388 
389 /* Checking the loopback, private and other address scopes as defined in
390  * RFC 1918.   The IPv4 scoping is based on the draft for SCTP IPv4
391  * scoping <draft-stewart-tsvwg-sctp-ipv4-00.txt>.
392  *
393  * Level 0 - unusable SCTP addresses
394  * Level 1 - loopback address
395  * Level 2 - link-local addresses
396  * Level 3 - private addresses.
397  * Level 4 - global addresses
398  * For INIT and INIT-ACK address list, let L be the level of
399  * of requested destination address, sender and receiver
400  * SHOULD include all of its addresses with level greater
401  * than or equal to L.
402  */
403 static sctp_scope_t sctp_v4_scope(union sctp_addr *addr)
404 {
405         sctp_scope_t retval;
406 
407         /* Should IPv4 scoping be a sysctl configurable option
408          * so users can turn it off (default on) for certain
409          * unconventional networking environments?
410          */
411 
412         /* Check for unusable SCTP addresses. */
413         if (IS_IPV4_UNUSABLE_ADDRESS(&addr->v4.sin_addr.s_addr)) {
414                 retval =  SCTP_SCOPE_UNUSABLE;
415         } else if (LOOPBACK(addr->v4.sin_addr.s_addr)) {
416                 retval = SCTP_SCOPE_LOOPBACK;
417         } else if (IS_IPV4_LINK_ADDRESS(&addr->v4.sin_addr.s_addr)) {
418                 retval = SCTP_SCOPE_LINK;
419         } else if (IS_IPV4_PRIVATE_ADDRESS(&addr->v4.sin_addr.s_addr)) {
420                 retval = SCTP_SCOPE_PRIVATE;
421         } else {
422                 retval = SCTP_SCOPE_GLOBAL;
423         }
424 
425         return retval;
426 }
427 
428 /* Returns a valid dst cache entry for the given source and destination ip
429  * addresses. If an association is passed, trys to get a dst entry with a
430  * source address that matches an address in the bind address list.
431  */
432 struct dst_entry *sctp_v4_get_dst(struct sctp_association *asoc,
433                                   union sctp_addr *daddr,
434                                   union sctp_addr *saddr)
435 {
436         struct rtable *rt;
437         struct flowi fl;
438         struct sctp_bind_addr *bp;
439         rwlock_t *addr_lock;
440         struct sctp_sockaddr_entry *laddr;
441         struct list_head *pos;
442         struct dst_entry *dst = NULL;
443         union sctp_addr dst_saddr;
444 
445         memset(&fl, 0x0, sizeof(struct flowi));
446         fl.fl4_dst  = daddr->v4.sin_addr.s_addr;
447         fl.proto = IPPROTO_SCTP;
448 
449         if (saddr)
450                 fl.fl4_src = saddr->v4.sin_addr.s_addr;
451 
452         SCTP_DEBUG_PRINTK("%s: DST:%u.%u.%u.%u, SRC:%u.%u.%u.%u - ",
453                           __FUNCTION__, NIPQUAD(fl.fl4_dst),
454                           NIPQUAD(fl.fl4_src));
455 
456         if (!ip_route_output_key(&rt, &fl)) {
457                 dst = &rt->u.dst;
458         }
459 
460         /* If there is no association or if a source address is passed, no
461          * more validation is required.
462          */
463         if (!asoc || saddr)
464                 goto out;
465 
466         bp = &asoc->base.bind_addr;
467         addr_lock = &asoc->base.addr_lock;
468 
469         if (dst) {
470                 /* Walk through the bind address list and look for a bind
471                  * address that matches the source address of the returned dst.
472                  */
473                 sctp_read_lock(addr_lock);
474                 list_for_each(pos, &bp->address_list) {
475                         laddr = list_entry(pos, struct sctp_sockaddr_entry,
476                                            list);
477                         sctp_v4_dst_saddr(&dst_saddr, dst, bp->port);
478                         if (sctp_v4_cmp_addr(&dst_saddr, &laddr->a))
479                                 goto out_unlock;
480                 }
481                 sctp_read_unlock(addr_lock);
482 
483                 /* None of the bound addresses match the source address of the
484                  * dst. So release it.
485                  */
486                 dst_release(dst);
487                 dst = NULL;
488         }
489 
490         /* Walk through the bind address list and try to get a dst that
491          * matches a bind address as the source address.
492          */
493         sctp_read_lock(addr_lock);
494         list_for_each(pos, &bp->address_list) {
495                 laddr = list_entry(pos, struct sctp_sockaddr_entry, list);
496 
497                 if (AF_INET == laddr->a.sa.sa_family) {
498                         fl.fl4_src = laddr->a.v4.sin_addr.s_addr;
499                         if (!ip_route_output_key(&rt, &fl)) {
500                                 dst = &rt->u.dst;
501                                 goto out_unlock;
502                         }
503                 }
504         }
505 
506 out_unlock:
507         sctp_read_unlock(addr_lock);
508 out:
509         if (dst)
510                 SCTP_DEBUG_PRINTK("rt_dst:%u.%u.%u.%u, rt_src:%u.%u.%u.%u\n",
511                                   NIPQUAD(rt->rt_dst), NIPQUAD(rt->rt_src));
512         else
513                 SCTP_DEBUG_PRINTK("NO ROUTE\n");
514 
515         return dst;
516 }
517 
518 /* For v4, the source address is cached in the route entry(dst). So no need
519  * to cache it separately and hence this is an empty routine.
520  */
521 void sctp_v4_get_saddr(struct sctp_association *asoc,
522                        struct dst_entry *dst,
523                        union sctp_addr *daddr,
524                        union sctp_addr *saddr)
525 {
526         struct rtable *rt = (struct rtable *)dst;
527 
528         if (rt) {
529                 saddr->v4.sin_family = AF_INET;
530                 saddr->v4.sin_port = asoc->base.bind_addr.port;  
531                 saddr->v4.sin_addr.s_addr = rt->rt_src; 
532         }
533 }
534 
535 /* What interface did this skb arrive on? */
536 static int sctp_v4_skb_iif(const struct sk_buff *skb)
537 {
538         return ((struct rtable *)skb->dst)->rt_iif;
539 }
540 
541 /* Was this packet marked by Explicit Congestion Notification? */
542 static int sctp_v4_is_ce(const struct sk_buff *skb)
543 {
544         return INET_ECN_is_ce(skb->nh.iph->tos);
545 }
546 
547 /* Create and initialize a new sk for the socket returned by accept(). */
548 struct sock *sctp_v4_create_accept_sk(struct sock *sk,
549                                       struct sctp_association *asoc)
550 {
551         struct sock *newsk;
552         struct inet_opt *inet = inet_sk(sk);
553         struct inet_opt *newinet;
554 
555         newsk = sk_alloc(PF_INET, GFP_KERNEL, sizeof(struct sctp_sock),
556                          sk->sk_slab);
557         if (!newsk)
558                 goto out;
559 
560         sock_init_data(NULL, newsk);
561         sk_set_owner(newsk, THIS_MODULE);
562 
563         newsk->sk_type = SOCK_STREAM;
564 
565         newsk->sk_prot = sk->sk_prot;
566         newsk->sk_no_check = sk->sk_no_check;
567         newsk->sk_reuse = sk->sk_reuse;
568         newsk->sk_shutdown = sk->sk_shutdown;
569 
570         newsk->sk_destruct = inet_sock_destruct;
571         newsk->sk_zapped = 0;
572         newsk->sk_family = PF_INET;
573         newsk->sk_protocol = IPPROTO_SCTP;
574         newsk->sk_backlog_rcv = sk->sk_prot->backlog_rcv;
575 
576         newinet = inet_sk(newsk);
577 
578         /* Initialize sk's sport, dport, rcv_saddr and daddr for
579          * getsockname() and getpeername()
580          */
581         newinet->sport = inet->sport;
582         newinet->saddr = inet->saddr;
583         newinet->rcv_saddr = inet->rcv_saddr;
584         newinet->dport = htons(asoc->peer.port);
585         newinet->daddr = asoc->peer.primary_addr.v4.sin_addr.s_addr;
586         newinet->pmtudisc = inet->pmtudisc;
587         newinet->id = 0;
588 
589         newinet->uc_ttl = -1;
590         newinet->mc_loop = 1;
591         newinet->mc_ttl = 1;
592         newinet->mc_index = 0;
593         newinet->mc_list = NULL;
594 
595 #ifdef INET_REFCNT_DEBUG
596         atomic_inc(&inet_sock_nr);
597 #endif
598 
599         if (newsk->sk_prot->init(newsk)) {
600                 inet_sock_release(newsk);
601                 newsk = NULL;
602         }
603 
604 out:
605         return newsk;
606 }
607 
608 /* Map address, empty for v4 family */
609 static void sctp_v4_addr_v4map(struct sctp_opt *sp, union sctp_addr *addr)
610 {
611         /* Empty */
612 }
613 
614 /* Dump the v4 addr to the seq file. */
615 static void sctp_v4_seq_dump_addr(struct seq_file *seq, union sctp_addr *addr)
616 {
617         seq_printf(seq, "%d.%d.%d.%d ", NIPQUAD(addr->v4.sin_addr));
618 }
619 
620 /* Event handler for inet address addition/deletion events.
621  * Basically, whenever there is an event, we re-build our local address list.
622  */
623 static int sctp_inetaddr_event(struct notifier_block *this, unsigned long ev,
624                                void *ptr)
625 {
626         unsigned long flags;
627 
628         sctp_spin_lock_irqsave(&sctp_local_addr_lock, flags);
629         __sctp_free_local_addr_list();
630         __sctp_get_local_addr_list();
631         sctp_spin_unlock_irqrestore(&sctp_local_addr_lock, flags);
632 
633         return NOTIFY_DONE;
634 }
635 
636 /*
637  * Initialize the control inode/socket with a control endpoint data
638  * structure.  This endpoint is reserved exclusively for the OOTB processing.
639  */
640 int sctp_ctl_sock_init(void)
641 {
642         int err;
643         sa_family_t family;
644 
645         if (sctp_get_pf_specific(PF_INET6))
646                 family = PF_INET6;
647         else
648                 family = PF_INET;
649 
650         err = sock_create(family, SOCK_SEQPACKET, IPPROTO_SCTP,
651                           &sctp_ctl_socket);
652         if (err < 0) {
653                 printk(KERN_ERR
654                        "SCTP: Failed to create the SCTP control socket.\n");
655                 return err;
656         }
657         sctp_ctl_socket->sk->sk_allocation = GFP_ATOMIC;
658         inet_sk(sctp_ctl_socket->sk)->uc_ttl = -1;
659 
660         return 0;
661 }
662 
663 /* Register address family specific functions. */
664 int sctp_register_af(struct sctp_af *af)
665 {
666         switch (af->sa_family) {
667         case AF_INET:
668                 if (sctp_af_v4_specific)
669                         return 0;
670                 sctp_af_v4_specific = af;
671                 break;
672         case AF_INET6:
673                 if (sctp_af_v6_specific)
674                         return 0;
675                 sctp_af_v6_specific = af;
676                 break;
677         default:
678                 return 0;
679         }
680 
681         INIT_LIST_HEAD(&af->list);
682         list_add_tail(&af->list, &sctp_address_families);
683         return 1;
684 }
685 
686 /* Get the table of functions for manipulating a particular address
687  * family.
688  */
689 struct sctp_af *sctp_get_af_specific(sa_family_t family)
690 {
691         switch (family) {
692         case AF_INET:
693                 return sctp_af_v4_specific;
694         case AF_INET6:
695                 return sctp_af_v6_specific;
696         default:
697                 return NULL;
698         }
699 }
700 
701 /* Common code to initialize a AF_INET msg_name. */
702 static void sctp_inet_msgname(char *msgname, int *addr_len)
703 {
704         struct sockaddr_in *sin;
705 
706         sin = (struct sockaddr_in *)msgname;
707         *addr_len = sizeof(struct sockaddr_in);
708         sin->sin_family = AF_INET;
709         memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
710 }
711 
712 /* Copy the primary address of the peer primary address as the msg_name. */
713 static void sctp_inet_event_msgname(struct sctp_ulpevent *event, char *msgname,
714                                     int *addr_len)
715 {
716         struct sockaddr_in *sin, *sinfrom;
717 
718         if (msgname) {
719                 struct sctp_association *asoc;
720 
721                 asoc = event->sndrcvinfo.sinfo_assoc_id;
722                 sctp_inet_msgname(msgname, addr_len);
723                 sin = (struct sockaddr_in *)msgname;
724                 sinfrom = &asoc->peer.primary_addr.v4;
725                 sin->sin_port = htons(asoc->peer.port);
726                 sin->sin_addr.s_addr = sinfrom->sin_addr.s_addr;
727         }
728 }
729 
730 /* Initialize and copy out a msgname from an inbound skb. */
731 static void sctp_inet_skb_msgname(struct sk_buff *skb, char *msgname, int *len)
732 {
733         struct sctphdr *sh;
734         struct sockaddr_in *sin;
735 
736         if (msgname) {
737                 sctp_inet_msgname(msgname, len);
738                 sin = (struct sockaddr_in *)msgname;
739                 sh = (struct sctphdr *)skb->h.raw;
740                 sin->sin_port = sh->source;
741                 sin->sin_addr.s_addr = skb->nh.iph->saddr;
742         }
743 }
744 
745 /* Do we support this AF? */
746 static int sctp_inet_af_supported(sa_family_t family, struct sctp_opt *sp)
747 {
748         /* PF_INET only supports AF_INET addresses. */
749         return (AF_INET == family);
750 }
751 
752 /* Address matching with wildcards allowed. */
753 static int sctp_inet_cmp_addr(const union sctp_addr *addr1,
754                               const union sctp_addr *addr2,
755                               struct sctp_opt *opt)
756 {
757         /* PF_INET only supports AF_INET addresses. */
758         if (addr1->sa.sa_family != addr2->sa.sa_family)
759                 return 0;
760         if (INADDR_ANY == addr1->v4.sin_addr.s_addr ||
761             INADDR_ANY == addr2->v4.sin_addr.s_addr)
762                 return 1;
763         if (addr1->v4.sin_addr.s_addr == addr2->v4.sin_addr.s_addr)
764                 return 1;
765 
766         return 0;
767 }
768 
769 /* Verify that provided sockaddr looks bindable.  Common verification has
770  * already been taken care of.
771  */
772 static int sctp_inet_bind_verify(struct sctp_opt *opt, union sctp_addr *addr)
773 {
774         return sctp_v4_available(addr, opt);
775 }
776 
777 /* Verify that sockaddr looks sendable.  Common verification has already
778  * been taken care of.
779  */
780 static int sctp_inet_send_verify(struct sctp_opt *opt, union sctp_addr *addr)
781 {
782         return 1;
783 }
784 
785 /* Fill in Supported Address Type information for INIT and INIT-ACK
786  * chunks.  Returns number of addresses supported.
787  */
788 static int sctp_inet_supported_addrs(const struct sctp_opt *opt,
789                                      __u16 *types)
790 {
791         types[0] = SCTP_PARAM_IPV4_ADDRESS;
792         return 1;
793 }
794 
795 /* Wrapper routine that calls the ip transmit routine. */
796 static inline int sctp_v4_xmit(struct sk_buff *skb,
797                                struct sctp_transport *transport, int ipfragok)
798 {
799         SCTP_DEBUG_PRINTK("%s: skb:%p, len:%d, "
800                           "src:%u.%u.%u.%u, dst:%u.%u.%u.%u\n",
801                           __FUNCTION__, skb, skb->len,
802                           NIPQUAD(((struct rtable *)skb->dst)->rt_src),
803                           NIPQUAD(((struct rtable *)skb->dst)->rt_dst));
804 
805         SCTP_INC_STATS(SctpOutSCTPPacks);
806         return ip_queue_xmit(skb, ipfragok);
807 }
808 
809 struct sctp_af sctp_ipv4_specific;
810 
811 static struct sctp_pf sctp_pf_inet = {
812         .event_msgname = sctp_inet_event_msgname,
813         .skb_msgname   = sctp_inet_skb_msgname,
814         .af_supported  = sctp_inet_af_supported,
815         .cmp_addr      = sctp_inet_cmp_addr,
816         .bind_verify   = sctp_inet_bind_verify,
817         .send_verify   = sctp_inet_send_verify,
818         .supported_addrs = sctp_inet_supported_addrs,
819         .create_accept_sk = sctp_v4_create_accept_sk,
820         .addr_v4map     = sctp_v4_addr_v4map,
821         .af            = &sctp_ipv4_specific,
822 };
823 
824 /* Notifier for inetaddr addition/deletion events.  */
825 struct notifier_block sctp_inetaddr_notifier = {
826         .notifier_call = sctp_inetaddr_event,
827 };
828 
829 /* Socket operations.  */
830 struct proto_ops inet_seqpacket_ops = {
831         .family      = PF_INET,
832         .owner       = THIS_MODULE,
833         .release     = inet_release,       /* Needs to be wrapped... */
834         .bind        = inet_bind,
835         .connect     = inet_dgram_connect,
836         .socketpair  = sock_no_socketpair,
837         .accept      = inet_accept,
838         .getname     = inet_getname,      /* Semantics are different.  */
839         .poll        = sctp_poll,
840         .ioctl       = inet_ioctl,
841         .listen      = sctp_inet_listen,
842         .shutdown    = inet_shutdown,     /* Looks harmless.  */
843         .setsockopt  = inet_setsockopt,   /* IP_SOL IP_OPTION is a problem. */
844         .getsockopt  = inet_getsockopt,
845         .sendmsg     = inet_sendmsg,
846         .recvmsg     = inet_recvmsg,
847         .mmap        = sock_no_mmap,
848         .sendpage    = sock_no_sendpage,
849 };
850 
851 /* Registration with AF_INET family.  */
852 static struct inet_protosw sctp_seqpacket_protosw = {
853         .type       = SOCK_SEQPACKET,
854         .protocol   = IPPROTO_SCTP,
855         .prot       = &sctp_prot,
856         .ops        = &inet_seqpacket_ops,
857         .capability = -1,
858         .no_check   = 0,
859         .flags      = SCTP_PROTOSW_FLAG
860 };
861 static struct inet_protosw sctp_stream_protosw = {
862         .type       = SOCK_STREAM,
863         .protocol   = IPPROTO_SCTP,
864         .prot       = &sctp_prot,
865         .ops        = &inet_seqpacket_ops,
866         .capability = -1,
867         .no_check   = 0,
868         .flags      = SCTP_PROTOSW_FLAG
869 };
870 
871 /* Register with IP layer.  */
872 static struct inet_protocol sctp_protocol = {
873         .handler     = sctp_rcv,
874         .err_handler = sctp_v4_err,
875         .no_policy   = 1,
876 };
877 
878 /* IPv4 address related functions.  */
879 struct sctp_af sctp_ipv4_specific = {
880         .sctp_xmit      = sctp_v4_xmit,
881         .setsockopt     = ip_setsockopt,
882         .getsockopt     = ip_getsockopt,
883         .get_dst        = sctp_v4_get_dst,
884         .get_saddr      = sctp_v4_get_saddr,
885         .copy_addrlist  = sctp_v4_copy_addrlist,
886         .from_skb       = sctp_v4_from_skb,
887         .from_sk        = sctp_v4_from_sk,
888         .to_sk_saddr    = sctp_v4_to_sk_saddr,
889         .to_sk_daddr    = sctp_v4_to_sk_daddr,
890         .from_addr_param= sctp_v4_from_addr_param,
891         .to_addr_param  = sctp_v4_to_addr_param,        
892         .dst_saddr      = sctp_v4_dst_saddr,
893         .cmp_addr       = sctp_v4_cmp_addr,
894         .addr_valid     = sctp_v4_addr_valid,
895         .inaddr_any     = sctp_v4_inaddr_any,
896         .is_any         = sctp_v4_is_any,
897         .available      = sctp_v4_available,
898         .scope          = sctp_v4_scope,
899         .skb_iif        = sctp_v4_skb_iif,
900         .is_ce          = sctp_v4_is_ce,
901         .seq_dump_addr  = sctp_v4_seq_dump_addr,
902         .net_header_len = sizeof(struct iphdr),
903         .sockaddr_len   = sizeof(struct sockaddr_in),
904         .sa_family      = AF_INET,
905 };
906 
907 struct sctp_pf *sctp_get_pf_specific(sa_family_t family) {
908 
909         switch (family) {
910         case PF_INET:
911                 return sctp_pf_inet_specific;
912         case PF_INET6:
913                 return sctp_pf_inet6_specific;
914         default:
915                 return NULL;
916         }
917 }
918 
919 /* Register the PF specific function table.  */
920 int sctp_register_pf(struct sctp_pf *pf, sa_family_t family)
921 {
922         switch (family) {
923         case PF_INET:
924                 if (sctp_pf_inet_specific)
925                         return 0;
926                 sctp_pf_inet_specific = pf;
927                 break;
928         case PF_INET6:
929                 if (sctp_pf_inet6_specific)
930                         return 0;
931                 sctp_pf_inet6_specific = pf;
932                 break;
933         default:
934                 return 0;
935         }
936         return 1;
937 }
938 
939 static int __init init_sctp_mibs(void)
940 {
941         sctp_statistics[0] = alloc_percpu(struct sctp_mib);
942         if (!sctp_statistics[0])
943                 return -ENOMEM;
944         sctp_statistics[1] = alloc_percpu(struct sctp_mib);
945         if (!sctp_statistics[1]) {
946                 free_percpu(sctp_statistics[0]);
947                 return -ENOMEM;
948         }
949         return 0;
950 
951 }
952 
953 static void cleanup_sctp_mibs(void)
954 {
955         free_percpu(sctp_statistics[0]);
956         free_percpu(sctp_statistics[1]);
957 }
958 
959 /* Initialize the universe into something sensible.  */
960 __init int sctp_init(void)
961 {
962         int i;
963         int status = 0;
964         unsigned long goal;
965         int order;
966 
967         /* SCTP_DEBUG sanity check. */
968         if (!sctp_sanity_check())
969                 return -EINVAL;
970 
971         /* Add SCTP to inet_protos hash table.  */
972         if (inet_add_protocol(&sctp_protocol, IPPROTO_SCTP) < 0)
973                 return -EAGAIN;
974 
975         /* Add SCTP(TCP and UDP style) to inetsw linked list.  */
976         inet_register_protosw(&sctp_seqpacket_protosw);
977         inet_register_protosw(&sctp_stream_protosw);
978 
979         /* Allocate a cache pools. */
980         sctp_bucket_cachep = kmem_cache_create("sctp_bind_bucket",
981                                                sizeof(struct sctp_bind_bucket),
982                                                0, SLAB_HWCACHE_ALIGN,
983                                                NULL, NULL);
984 
985         if (!sctp_bucket_cachep)
986                 goto err_bucket_cachep;
987 
988         sctp_chunk_cachep = kmem_cache_create("sctp_chunk",
989                                                sizeof(struct sctp_chunk),
990                                                0, SLAB_HWCACHE_ALIGN,
991                                                NULL, NULL);
992         if (!sctp_chunk_cachep)
993                 goto err_chunk_cachep;
994 
995         /* Allocate and initialise sctp mibs.  */
996         status = init_sctp_mibs();
997         if (status)
998                 goto err_init_mibs;
999 
1000         /* Initialize proc fs directory.  */
1001         sctp_proc_init();
1002 
1003         /* Initialize object count debugging.  */
1004         sctp_dbg_objcnt_init();
1005 
1006         /* Initialize the SCTP specific PF functions. */
1007         sctp_register_pf(&sctp_pf_inet, PF_INET);
1008         /*
1009          * 14. Suggested SCTP Protocol Parameter Values
1010          */
1011         /* The following protocol parameters are RECOMMENDED:  */
1012         /* RTO.Initial              - 3  seconds */
1013         sctp_rto_initial                = SCTP_RTO_INITIAL;
1014         /* RTO.Min                  - 1  second */
1015         sctp_rto_min                    = SCTP_RTO_MIN;
1016         /* RTO.Max                 -  60 seconds */
1017         sctp_rto_max                    = SCTP_RTO_MAX;
1018         /* RTO.Alpha                - 1/8 */
1019         sctp_rto_alpha                  = SCTP_RTO_ALPHA;
1020         /* RTO.Beta                 - 1/4 */
1021         sctp_rto_beta                   = SCTP_RTO_BETA;
1022 
1023         /* Valid.Cookie.Life        - 60  seconds */
1024         sctp_valid_cookie_life          = 60 * HZ;
1025 
1026         /* Whether Cookie Preservative is enabled(1) or not(0) */
1027         sctp_cookie_preserve_enable     = 1;
1028 
1029         /* Max.Burst                - 4 */
1030         sctp_max_burst                  = SCTP_MAX_BURST;
1031 
1032         /* Association.Max.Retrans  - 10 attempts
1033          * Path.Max.Retrans         - 5  attempts (per destination address)
1034          * Max.Init.Retransmits     - 8  attempts
1035          */
1036         sctp_max_retrans_association    = 10;
1037         sctp_max_retrans_path           = 5;
1038         sctp_max_retrans_init           = 8;
1039 
1040         /* HB.interval              - 30 seconds */
1041         sctp_hb_interval                = 30 * HZ;
1042 
1043         /* Implementation specific variables. */
1044 
1045         /* Initialize default stream count setup information. */
1046         sctp_max_instreams              = SCTP_DEFAULT_INSTREAMS;
1047         sctp_max_outstreams             = SCTP_DEFAULT_OUTSTREAMS;
1048 
1049         /* Size and allocate the association hash table.
1050          * The methodology is similar to that of the tcp hash tables.
1051          */
1052         if (num_physpages >= (128 * 1024))
1053                 goal = num_physpages >> (22 - PAGE_SHIFT);
1054         else
1055                 goal = num_physpages >> (24 - PAGE_SHIFT);
1056 
1057         for (order = 0; (1UL << order) < goal; order++)
1058                 ;
1059 
1060         do {
1061                 sctp_assoc_hashsize = (1UL << order) * PAGE_SIZE /
1062                                         sizeof(struct sctp_hashbucket);
1063                 if ((sctp_assoc_hashsize > (64 * 1024)) && order > 0)
1064                         continue;
1065                 sctp_assoc_hashtable = (struct sctp_hashbucket *)
1066                                         __get_free_pages(GFP_ATOMIC, order);
1067         } while (!sctp_assoc_hashtable && --order > 0);
1068         if (!sctp_assoc_hashtable) {
1069                 printk(KERN_ERR "SCTP: Failed association hash alloc.\n");
1070                 status = -ENOMEM;
1071                 goto err_ahash_alloc;
1072         }
1073         for (i = 0; i < sctp_assoc_hashsize; i++) {
1074                 sctp_assoc_hashtable[i].lock = RW_LOCK_UNLOCKED;
1075                 sctp_assoc_hashtable[i].chain = NULL;
1076         }
1077 
1078         /* Allocate and initialize the endpoint hash table.  */
1079         sctp_ep_hashsize = 64;
1080         sctp_ep_hashtable = (struct sctp_hashbucket *)
1081                 kmalloc(64 * sizeof(struct sctp_hashbucket), GFP_KERNEL);
1082         if (!sctp_ep_hashtable) {
1083                 printk(KERN_ERR "SCTP: Failed endpoint_hash alloc.\n");
1084                 status = -ENOMEM;
1085                 goto err_ehash_alloc;
1086         }
1087         for (i = 0; i < sctp_ep_hashsize; i++) {
1088                 sctp_ep_hashtable[i].lock = RW_LOCK_UNLOCKED;
1089                 sctp_ep_hashtable[i].chain = NULL;
1090         }
1091 
1092         /* Allocate and initialize the SCTP port hash table.  */
1093         do {
1094                 sctp_port_hashsize = (1UL << order) * PAGE_SIZE /
1095                                         sizeof(struct sctp_bind_hashbucket);
1096                 if ((sctp_port_hashsize > (64 * 1024)) && order > 0)
1097                         continue;
1098                 sctp_port_hashtable = (struct sctp_bind_hashbucket *)
1099                                         __get_free_pages(GFP_ATOMIC, order);
1100         } while (!sctp_port_hashtable && --order > 0);
1101         if (!sctp_port_hashtable) {
1102                 printk(KERN_ERR "SCTP: Failed bind hash alloc.");
1103                 status = -ENOMEM;
1104                 goto err_bhash_alloc;
1105         }
1106         for (i = 0; i < sctp_port_hashsize; i++) {
1107                 sctp_port_hashtable[i].lock = SPIN_LOCK_UNLOCKED;
1108                 sctp_port_hashtable[i].chain = NULL;
1109         }
1110 
1111         sctp_port_alloc_lock = SPIN_LOCK_UNLOCKED;
1112         sctp_port_rover = sysctl_local_port_range[0] - 1;
1113 
1114         printk(KERN_INFO "SCTP: Hash tables configured "
1115                          "(established %d bind %d)\n",
1116                 sctp_assoc_hashsize, sctp_port_hashsize);
1117 
1118         sctp_sysctl_register();
1119 
1120         INIT_LIST_HEAD(&sctp_address_families);
1121         sctp_register_af(&sctp_ipv4_specific);
1122 
1123         status = sctp_v6_init();
1124         if (status)
1125                 goto err_v6_init;
1126 
1127         /* Initialize the control inode/socket for handling OOTB packets.  */
1128         if ((status = sctp_ctl_sock_init())) {
1129                 printk (KERN_ERR
1130                         "SCTP: Failed to initialize the SCTP control sock.\n");
1131                 goto err_ctl_sock_init;
1132         }
1133 
1134         /* Initialize the local address list. */
1135         INIT_LIST_HEAD(&sctp_local_addr_list);
1136         sctp_local_addr_lock = SPIN_LOCK_UNLOCKED;
1137 
1138         /* Register notifier for inet address additions/deletions. */
1139         register_inetaddr_notifier(&sctp_inetaddr_notifier);
1140 
1141         sctp_get_local_addr_list();
1142 
1143         __unsafe(THIS_MODULE);
1144         return 0;
1145 
1146 err_ctl_sock_init:
1147         sctp_v6_exit();
1148 err_v6_init:
1149         sctp_sysctl_unregister();
1150         list_del(&sctp_ipv4_specific.list);
1151         free_pages((unsigned long)sctp_port_hashtable,
1152                    get_order(sctp_port_hashsize *
1153                              sizeof(struct sctp_bind_hashbucket)));
1154 err_bhash_alloc:
1155         kfree(sctp_ep_hashtable);
1156 err_ehash_alloc:
1157         free_pages((unsigned long)sctp_assoc_hashtable,
1158                    get_order(sctp_assoc_hashsize *
1159                              sizeof(struct sctp_hashbucket)));
1160 err_ahash_alloc:
1161         sctp_dbg_objcnt_exit();
1162         sctp_proc_exit();
1163         cleanup_sctp_mibs();
1164 err_init_mibs:
1165         kmem_cache_destroy(sctp_chunk_cachep);
1166 err_chunk_cachep:
1167         kmem_cache_destroy(sctp_bucket_cachep);
1168 err_bucket_cachep:
1169         inet_del_protocol(&sctp_protocol, IPPROTO_SCTP);
1170         inet_unregister_protosw(&sctp_seqpacket_protosw);
1171         inet_unregister_protosw(&sctp_stream_protosw);
1172         return status;
1173 }
1174 
1175 /* Exit handler for the SCTP protocol.  */
1176 __exit void sctp_exit(void)
1177 {
1178         /* BUG.  This should probably do something useful like clean
1179          * up all the remaining associations and all that memory.
1180          */
1181 
1182         /* Unregister notifier for inet address additions/deletions. */
1183         unregister_inetaddr_notifier(&sctp_inetaddr_notifier);
1184 
1185         /* Free the local address list.  */
1186         sctp_free_local_addr_list();
1187 
1188         /* Free the control endpoint.  */
1189         sock_release(sctp_ctl_socket);
1190 
1191         sctp_v6_exit();
1192         sctp_sysctl_unregister();
1193         list_del(&sctp_ipv4_specific.list);
1194 
1195         free_pages((unsigned long)sctp_assoc_hashtable,
1196                    get_order(sctp_assoc_hashsize *
1197                              sizeof(struct sctp_hashbucket)));
1198         kfree(sctp_ep_hashtable);
1199         free_pages((unsigned long)sctp_port_hashtable,
1200                    get_order(sctp_port_hashsize *
1201                              sizeof(struct sctp_bind_hashbucket)));
1202 
1203         kmem_cache_destroy(sctp_chunk_cachep);
1204         kmem_cache_destroy(sctp_bucket_cachep);
1205 
1206         sctp_dbg_objcnt_exit();
1207         sctp_proc_exit();
1208         cleanup_sctp_mibs();
1209 
1210         inet_del_protocol(&sctp_protocol, IPPROTO_SCTP);
1211         inet_unregister_protosw(&sctp_seqpacket_protosw);
1212         inet_unregister_protosw(&sctp_stream_protosw);
1213 }
1214 
1215 module_init(sctp_init);
1216 module_exit(sctp_exit);
1217 
1218 MODULE_AUTHOR("Linux Kernel SCTP developers <lksctp-developers@lists.sourceforge.net>");
1219 MODULE_DESCRIPTION("Support for the SCTP protocol (RFC2960)");
1220 MODULE_LICENSE("GPL");
1221 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp