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
9 * This file is part of the SCTP kernel reference Implementation
11 * These functions handle all input from the IP layer into SCTP.
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)
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.
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.
30 * Please send any bug reports or fixes you make to the
32 * lksctp developers <lksctp-developers@lists.sourceforge.net>
34 * Or submit a bug report through the following website:
35 * http://www.sf.net/projects/lksctp
37 * Written or modified by:
38 * La Monte H.P. Yarroll <piggy@acm.org>
39 * Karl Knutson <karl@athena.chicago.il.us>
40 * Xingang Guo <xingang.guo@intel.com>
41 * Jon Grimm <jgrimm@us.ibm.com>
42 * Hui Huang <hui.huang@nokia.com>
43 * Daisy Chang <daisyc@us.ibm.com>
44 * Sridhar Samudrala <sri@us.ibm.com>
45 * Ardelle Fan <ardelle.fan@intel.com>
47 * Any bugs reported given to us we will try to fix... any fixes shared will
48 * be incorporated into the next SCTP release.
51 #include <linux/types.h>
52 #include <linux/list.h> /* For struct list_head */
53 #include <linux/socket.h>
55 #include <linux/time.h> /* For struct timeval */
61 #include <net/sctp/sctp.h>
62 #include <net/sctp/sm.h>
64 /* Forward declarations for internal helpers. */
65 static int sctp_rcv_ootb(struct sk_buff *);
66 static struct sctp_association *__sctp_rcv_lookup(struct sk_buff *skb,
67 const union sctp_addr *laddr,
68 const union sctp_addr *paddr,
69 struct sctp_transport **transportp);
70 static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(const union sctp_addr *laddr);
71 static struct sctp_association *__sctp_lookup_association(
72 const union sctp_addr *local,
73 const union sctp_addr *peer,
74 struct sctp_transport **pt);
77 /* Calculate the SCTP checksum of an SCTP packet. */
78 static inline int sctp_rcv_checksum(struct sk_buff *skb)
82 struct sk_buff *list = skb_shinfo(skb)->frag_list;
84 sh = (struct sctphdr *) skb->h.raw;
85 cmp = ntohl(sh->checksum);
87 val = sctp_start_cksum((__u8 *)sh, skb_headlen(skb));
89 for (; list; list = list->next)
90 val = sctp_update_cksum((__u8 *)list->data, skb_headlen(list),
93 val = sctp_end_cksum(val);
96 /* CRC failure, dump it. */
97 SCTP_INC_STATS_BH(SCTP_MIB_CHECKSUMERRORS);
103 struct sctp_input_cb {
105 struct inet_skb_parm h4;
106 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
107 struct inet6_skb_parm h6;
110 struct sctp_chunk *chunk;
112 #define SCTP_INPUT_CB(__skb) ((struct sctp_input_cb *)&((__skb)->cb[0]))
115 * This is the routine which IP calls when receiving an SCTP packet.
117 int sctp_rcv(struct sk_buff *skb)
120 struct sctp_association *asoc;
121 struct sctp_endpoint *ep = NULL;
122 struct sctp_ep_common *rcvr;
123 struct sctp_transport *transport = NULL;
124 struct sctp_chunk *chunk;
127 union sctp_addr dest;
131 if (skb->pkt_type!=PACKET_HOST)
134 SCTP_INC_STATS_BH(SCTP_MIB_INSCTPPACKS);
136 sh = (struct sctphdr *) skb->h.raw;
138 /* Pull up the IP and SCTP headers. */
139 __skb_pull(skb, skb->h.raw - skb->data);
140 if (skb->len < sizeof(struct sctphdr))
142 if (sctp_rcv_checksum(skb) < 0)
145 skb_pull(skb, sizeof(struct sctphdr));
147 /* Make sure we at least have chunk headers worth of data left. */
148 if (skb->len < sizeof(struct sctp_chunkhdr))
151 family = ipver2af(skb->nh.iph->version);
152 af = sctp_get_af_specific(family);
156 /* Initialize local addresses for lookups. */
157 af->from_skb(&src, skb, 1);
158 af->from_skb(&dest, skb, 0);
160 /* If the packet is to or from a non-unicast address,
161 * silently discard the packet.
163 * This is not clearly defined in the RFC except in section
164 * 8.4 - OOTB handling. However, based on the book "Stream Control
165 * Transmission Protocol" 2.1, "It is important to note that the
166 * IP address of an SCTP transport address must be a routable
167 * unicast address. In other words, IP multicast addresses and
168 * IP broadcast addresses cannot be used in an SCTP transport
171 if (!af->addr_valid(&src, NULL) || !af->addr_valid(&dest, NULL))
174 asoc = __sctp_rcv_lookup(skb, &src, &dest, &transport);
177 ep = __sctp_rcv_lookup_endpoint(&dest);
179 /* Retrieve the common input handling substructure. */
180 rcvr = asoc ? &asoc->base : &ep->base;
184 * If a frame arrives on an interface and the receiving socket is
185 * bound to another interface, via SO_BINDTODEVICE, treat it as OOTB
187 if (sk->sk_bound_dev_if && (sk->sk_bound_dev_if != af->skb_iif(skb)))
191 sctp_association_put(asoc);
194 sctp_endpoint_put(ep);
197 sk = sctp_get_ctl_sock();
198 ep = sctp_sk(sk)->ep;
199 sctp_endpoint_hold(ep);
205 * RFC 2960, 8.4 - Handle "Out of the blue" Packets.
206 * An SCTP packet is called an "out of the blue" (OOTB)
207 * packet if it is correctly formed, i.e., passed the
208 * receiver's checksum check, but the receiver is not
209 * able to identify the association to which this
213 if (sctp_rcv_ootb(skb)) {
214 SCTP_INC_STATS_BH(SCTP_MIB_OUTOFBLUES);
215 goto discard_release;
219 /* SCTP seems to always need a timestamp right now (FIXME) */
220 if (skb->tstamp.off_sec == 0) {
221 __net_timestamp(skb);
222 sock_enable_timestamp(sk);
225 if (!xfrm_policy_check(sk, XFRM_POLICY_IN, skb, family))
226 goto discard_release;
229 if (sk_filter(sk, skb, 1))
230 goto discard_release;
232 /* Create an SCTP packet structure. */
233 chunk = sctp_chunkify(skb, asoc, sk);
235 goto discard_release;
236 SCTP_INPUT_CB(skb)->chunk = chunk;
238 /* Remember what endpoint is to handle this packet. */
241 /* Remember the SCTP header. */
242 chunk->sctp_hdr = sh;
244 /* Set the source and destination addresses of the incoming chunk. */
245 sctp_init_addrs(chunk, &src, &dest);
247 /* Remember where we came from. */
248 chunk->transport = transport;
250 /* Acquire access to the sock lock. Note: We are safe from other
251 * bottom halves on this lock, but a user may be in the lock too,
252 * so check if it is busy.
254 sctp_bh_lock_sock(sk);
256 /* It is possible that the association could have moved to a different
257 * socket if it is peeled off. If so, update the sk.
259 if (sk != rcvr->sk) {
260 sctp_bh_lock_sock(rcvr->sk);
261 sctp_bh_unlock_sock(sk);
265 if (sock_owned_by_user(sk))
266 sk_add_backlog(sk, skb);
268 sctp_backlog_rcv(sk, skb);
270 /* Release the sock and the sock ref we took in the lookup calls.
271 * The asoc/ep ref will be released in sctp_backlog_rcv.
273 sctp_bh_unlock_sock(sk);
283 /* Release any structures we may be holding. */
286 sctp_association_put(asoc);
288 sctp_endpoint_put(ep);
293 /* Handle second half of inbound skb processing. If the sock was busy,
294 * we may have need to delay processing until later when the sock is
295 * released (on the backlog). If not busy, we call this routine
296 * directly from the bottom half.
298 int sctp_backlog_rcv(struct sock *sk, struct sk_buff *skb)
300 struct sctp_chunk *chunk = SCTP_INPUT_CB(skb)->chunk;
301 struct sctp_inq *inqueue = NULL;
302 struct sctp_ep_common *rcvr = NULL;
306 BUG_TRAP(rcvr->sk == sk);
309 sctp_chunk_free(chunk);
311 inqueue = &chunk->rcvr->inqueue;
312 sctp_inq_push(inqueue, chunk);
315 /* Release the asoc/ep ref we took in the lookup calls in sctp_rcv. */
316 if (SCTP_EP_TYPE_ASSOCIATION == rcvr->type)
317 sctp_association_put(sctp_assoc(rcvr));
319 sctp_endpoint_put(sctp_ep(rcvr));
324 void sctp_backlog_migrate(struct sctp_association *assoc,
325 struct sock *oldsk, struct sock *newsk)
328 struct sctp_chunk *chunk;
330 skb = oldsk->sk_backlog.head;
331 oldsk->sk_backlog.head = oldsk->sk_backlog.tail = NULL;
332 while (skb != NULL) {
333 struct sk_buff *next = skb->next;
335 chunk = SCTP_INPUT_CB(skb)->chunk;
337 if (&assoc->base == chunk->rcvr)
338 sk_add_backlog(newsk, skb);
340 sk_add_backlog(oldsk, skb);
345 /* Handle icmp frag needed error. */
346 void sctp_icmp_frag_needed(struct sock *sk, struct sctp_association *asoc,
347 struct sctp_transport *t, __u32 pmtu)
349 if (sock_owned_by_user(sk) || !t || (t->pathmtu == pmtu))
352 if (t->param_flags & SPP_PMTUD_ENABLE) {
353 if (unlikely(pmtu < SCTP_DEFAULT_MINSEGMENT)) {
354 printk(KERN_WARNING "%s: Reported pmtu %d too low, "
355 "using default minimum of %d\n",
357 SCTP_DEFAULT_MINSEGMENT);
358 /* Use default minimum segment size and disable
359 * pmtu discovery on this transport.
361 t->pathmtu = SCTP_DEFAULT_MINSEGMENT;
362 t->param_flags = (t->param_flags & ~SPP_HB) |
368 /* Update association pmtu. */
369 sctp_assoc_sync_pmtu(asoc);
372 /* Retransmit with the new pmtu setting.
373 * Normally, if PMTU discovery is disabled, an ICMP Fragmentation
374 * Needed will never be sent, but if a message was sent before
375 * PMTU discovery was disabled that was larger than the PMTU, it
376 * would not be fragmented, so it must be re-transmitted fragmented.
378 sctp_retransmit(&asoc->outqueue, t, SCTP_RTXR_PMTUD);
382 * SCTP Implementer's Guide, 2.37 ICMP handling procedures
384 * ICMP8) If the ICMP code is a "Unrecognized next header type encountered"
385 * or a "Protocol Unreachable" treat this message as an abort
386 * with the T bit set.
388 * This function sends an event to the state machine, which will abort the
392 void sctp_icmp_proto_unreachable(struct sock *sk,
393 struct sctp_association *asoc,
394 struct sctp_transport *t)
396 SCTP_DEBUG_PRINTK("%s\n", __FUNCTION__);
398 sctp_do_sm(SCTP_EVENT_T_OTHER,
399 SCTP_ST_OTHER(SCTP_EVENT_ICMP_PROTO_UNREACH),
400 asoc->state, asoc->ep, asoc, t,
405 /* Common lookup code for icmp/icmpv6 error handler. */
406 struct sock *sctp_err_lookup(int family, struct sk_buff *skb,
407 struct sctphdr *sctphdr,
408 struct sctp_association **app,
409 struct sctp_transport **tpp)
411 union sctp_addr saddr;
412 union sctp_addr daddr;
414 struct sock *sk = NULL;
415 struct sctp_association *asoc = NULL;
416 struct sctp_transport *transport = NULL;
418 *app = NULL; *tpp = NULL;
420 af = sctp_get_af_specific(family);
425 /* Initialize local addresses for lookups. */
426 af->from_skb(&saddr, skb, 1);
427 af->from_skb(&daddr, skb, 0);
429 /* Look for an association that matches the incoming ICMP error
432 asoc = __sctp_lookup_association(&saddr, &daddr, &transport);
438 if (ntohl(sctphdr->vtag) != asoc->c.peer_vtag) {
439 ICMP_INC_STATS_BH(ICMP_MIB_INERRORS);
443 sctp_bh_lock_sock(sk);
445 /* If too many ICMPs get dropped on busy
446 * servers this needs to be solved differently.
448 if (sock_owned_by_user(sk))
449 NET_INC_STATS_BH(LINUX_MIB_LOCKDROPPEDICMPS);
458 sctp_association_put(asoc);
462 /* Common cleanup code for icmp/icmpv6 error handler. */
463 void sctp_err_finish(struct sock *sk, struct sctp_association *asoc)
465 sctp_bh_unlock_sock(sk);
468 sctp_association_put(asoc);
472 * This routine is called by the ICMP module when it gets some
473 * sort of error condition. If err < 0 then the socket should
474 * be closed and the error returned to the user. If err > 0
475 * it's just the icmp type << 8 | icmp code. After adjustment
476 * header points to the first 8 bytes of the sctp header. We need
477 * to find the appropriate port.
479 * The locking strategy used here is very "optimistic". When
480 * someone else accesses the socket the ICMP is just dropped
481 * and for some paths there is no check at all.
482 * A more general error queue to queue errors for later handling
483 * is probably better.
486 void sctp_v4_err(struct sk_buff *skb, __u32 info)
488 struct iphdr *iph = (struct iphdr *)skb->data;
489 struct sctphdr *sh = (struct sctphdr *)(skb->data + (iph->ihl <<2));
490 int type = skb->h.icmph->type;
491 int code = skb->h.icmph->code;
493 struct sctp_association *asoc;
494 struct sctp_transport *transport;
495 struct inet_sock *inet;
496 char *saveip, *savesctp;
499 if (skb->len < ((iph->ihl << 2) + 8)) {
500 ICMP_INC_STATS_BH(ICMP_MIB_INERRORS);
504 /* Fix up skb to look at the embedded net header. */
505 saveip = skb->nh.raw;
506 savesctp = skb->h.raw;
508 skb->h.raw = (char *)sh;
509 sk = sctp_err_lookup(AF_INET, skb, sh, &asoc, &transport);
510 /* Put back, the original pointers. */
511 skb->nh.raw = saveip;
512 skb->h.raw = savesctp;
514 ICMP_INC_STATS_BH(ICMP_MIB_INERRORS);
517 /* Warning: The sock lock is held. Remember to call
522 case ICMP_PARAMETERPROB:
525 case ICMP_DEST_UNREACH:
526 if (code > NR_ICMP_UNREACH)
529 /* PMTU discovery (RFC1191) */
530 if (ICMP_FRAG_NEEDED == code) {
531 sctp_icmp_frag_needed(sk, asoc, transport, info);
535 if (ICMP_PROT_UNREACH == code) {
536 sctp_icmp_proto_unreachable(sk, asoc,
541 err = icmp_err_convert[code].errno;
543 case ICMP_TIME_EXCEEDED:
544 /* Ignore any time exceeded errors due to fragment reassembly
547 if (ICMP_EXC_FRAGTIME == code)
557 if (!sock_owned_by_user(sk) && inet->recverr) {
559 sk->sk_error_report(sk);
560 } else { /* Only an error on timeout */
561 sk->sk_err_soft = err;
565 sctp_err_finish(sk, asoc);
569 * RFC 2960, 8.4 - Handle "Out of the blue" Packets.
571 * This function scans all the chunks in the OOTB packet to determine if
572 * the packet should be discarded right away. If a response might be needed
573 * for this packet, or, if further processing is possible, the packet will
574 * be queued to a proper inqueue for the next phase of handling.
577 * Return 0 - If further processing is needed.
578 * Return 1 - If the packet can be discarded right away.
580 int sctp_rcv_ootb(struct sk_buff *skb)
586 ch = (sctp_chunkhdr_t *) skb->data;
588 /* Scan through all the chunks in the packet. */
590 /* Break out if chunk length is less then minimal. */
591 if (ntohs(ch->length) < sizeof(sctp_chunkhdr_t))
594 ch_end = ((__u8 *)ch) + WORD_ROUND(ntohs(ch->length));
595 if (ch_end > skb->tail)
598 /* RFC 8.4, 2) If the OOTB packet contains an ABORT chunk, the
599 * receiver MUST silently discard the OOTB packet and take no
602 if (SCTP_CID_ABORT == ch->type)
605 /* RFC 8.4, 6) If the packet contains a SHUTDOWN COMPLETE
606 * chunk, the receiver should silently discard the packet
607 * and take no further action.
609 if (SCTP_CID_SHUTDOWN_COMPLETE == ch->type)
612 /* RFC 8.4, 7) If the packet contains a "Stale cookie" ERROR
613 * or a COOKIE ACK the SCTP Packet should be silently
616 if (SCTP_CID_COOKIE_ACK == ch->type)
619 if (SCTP_CID_ERROR == ch->type) {
620 sctp_walk_errors(err, ch) {
621 if (SCTP_ERROR_STALE_COOKIE == err->cause)
626 ch = (sctp_chunkhdr_t *) ch_end;
627 } while (ch_end < skb->tail);
635 /* Insert endpoint into the hash table. */
636 static void __sctp_hash_endpoint(struct sctp_endpoint *ep)
638 struct sctp_ep_common **epp;
639 struct sctp_ep_common *epb;
640 struct sctp_hashbucket *head;
644 epb->hashent = sctp_ep_hashfn(epb->bind_addr.port);
645 head = &sctp_ep_hashtable[epb->hashent];
647 sctp_write_lock(&head->lock);
651 (*epp)->pprev = &epb->next;
654 sctp_write_unlock(&head->lock);
657 /* Add an endpoint to the hash. Local BH-safe. */
658 void sctp_hash_endpoint(struct sctp_endpoint *ep)
660 sctp_local_bh_disable();
661 __sctp_hash_endpoint(ep);
662 sctp_local_bh_enable();
665 /* Remove endpoint from the hash table. */
666 static void __sctp_unhash_endpoint(struct sctp_endpoint *ep)
668 struct sctp_hashbucket *head;
669 struct sctp_ep_common *epb;
673 epb->hashent = sctp_ep_hashfn(epb->bind_addr.port);
675 head = &sctp_ep_hashtable[epb->hashent];
677 sctp_write_lock(&head->lock);
681 epb->next->pprev = epb->pprev;
682 *epb->pprev = epb->next;
686 sctp_write_unlock(&head->lock);
689 /* Remove endpoint from the hash. Local BH-safe. */
690 void sctp_unhash_endpoint(struct sctp_endpoint *ep)
692 sctp_local_bh_disable();
693 __sctp_unhash_endpoint(ep);
694 sctp_local_bh_enable();
697 /* Look up an endpoint. */
698 static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(const union sctp_addr *laddr)
700 struct sctp_hashbucket *head;
701 struct sctp_ep_common *epb;
702 struct sctp_endpoint *ep;
705 hash = sctp_ep_hashfn(laddr->v4.sin_port);
706 head = &sctp_ep_hashtable[hash];
707 read_lock(&head->lock);
708 for (epb = head->chain; epb; epb = epb->next) {
710 if (sctp_endpoint_is_match(ep, laddr))
714 ep = sctp_sk((sctp_get_ctl_sock()))->ep;
718 sctp_endpoint_hold(ep);
720 read_unlock(&head->lock);
724 /* Insert association into the hash table. */
725 static void __sctp_hash_established(struct sctp_association *asoc)
727 struct sctp_ep_common **epp;
728 struct sctp_ep_common *epb;
729 struct sctp_hashbucket *head;
733 /* Calculate which chain this entry will belong to. */
734 epb->hashent = sctp_assoc_hashfn(epb->bind_addr.port, asoc->peer.port);
736 head = &sctp_assoc_hashtable[epb->hashent];
738 sctp_write_lock(&head->lock);
742 (*epp)->pprev = &epb->next;
745 sctp_write_unlock(&head->lock);
748 /* Add an association to the hash. Local BH-safe. */
749 void sctp_hash_established(struct sctp_association *asoc)
751 sctp_local_bh_disable();
752 __sctp_hash_established(asoc);
753 sctp_local_bh_enable();
756 /* Remove association from the hash table. */
757 static void __sctp_unhash_established(struct sctp_association *asoc)
759 struct sctp_hashbucket *head;
760 struct sctp_ep_common *epb;
764 epb->hashent = sctp_assoc_hashfn(epb->bind_addr.port,
767 head = &sctp_assoc_hashtable[epb->hashent];
769 sctp_write_lock(&head->lock);
773 epb->next->pprev = epb->pprev;
774 *epb->pprev = epb->next;
778 sctp_write_unlock(&head->lock);
781 /* Remove association from the hash table. Local BH-safe. */
782 void sctp_unhash_established(struct sctp_association *asoc)
784 sctp_local_bh_disable();
785 __sctp_unhash_established(asoc);
786 sctp_local_bh_enable();
789 /* Look up an association. */
790 static struct sctp_association *__sctp_lookup_association(
791 const union sctp_addr *local,
792 const union sctp_addr *peer,
793 struct sctp_transport **pt)
795 struct sctp_hashbucket *head;
796 struct sctp_ep_common *epb;
797 struct sctp_association *asoc;
798 struct sctp_transport *transport;
801 /* Optimize here for direct hit, only listening connections can
802 * have wildcards anyways.
804 hash = sctp_assoc_hashfn(local->v4.sin_port, peer->v4.sin_port);
805 head = &sctp_assoc_hashtable[hash];
806 read_lock(&head->lock);
807 for (epb = head->chain; epb; epb = epb->next) {
808 asoc = sctp_assoc(epb);
809 transport = sctp_assoc_is_match(asoc, local, peer);
814 read_unlock(&head->lock);
820 sctp_association_hold(asoc);
822 read_unlock(&head->lock);
826 /* Look up an association. BH-safe. */
828 struct sctp_association *sctp_lookup_association(const union sctp_addr *laddr,
829 const union sctp_addr *paddr,
830 struct sctp_transport **transportp)
832 struct sctp_association *asoc;
834 sctp_local_bh_disable();
835 asoc = __sctp_lookup_association(laddr, paddr, transportp);
836 sctp_local_bh_enable();
841 /* Is there an association matching the given local and peer addresses? */
842 int sctp_has_association(const union sctp_addr *laddr,
843 const union sctp_addr *paddr)
845 struct sctp_association *asoc;
846 struct sctp_transport *transport;
848 if ((asoc = sctp_lookup_association(laddr, paddr, &transport))) {
849 sock_put(asoc->base.sk);
850 sctp_association_put(asoc);
858 * SCTP Implementors Guide, 2.18 Handling of address
859 * parameters within the INIT or INIT-ACK.
861 * D) When searching for a matching TCB upon reception of an INIT
862 * or INIT-ACK chunk the receiver SHOULD use not only the
863 * source address of the packet (containing the INIT or
864 * INIT-ACK) but the receiver SHOULD also use all valid
865 * address parameters contained within the chunk.
867 * 2.18.3 Solution description
869 * This new text clearly specifies to an implementor the need
870 * to look within the INIT or INIT-ACK. Any implementation that
871 * does not do this, may not be able to establish associations
872 * in certain circumstances.
875 static struct sctp_association *__sctp_rcv_init_lookup(struct sk_buff *skb,
876 const union sctp_addr *laddr, struct sctp_transport **transportp)
878 struct sctp_association *asoc;
879 union sctp_addr addr;
880 union sctp_addr *paddr = &addr;
881 struct sctphdr *sh = (struct sctphdr *) skb->h.raw;
883 union sctp_params params;
884 sctp_init_chunk_t *init;
885 struct sctp_transport *transport;
888 ch = (sctp_chunkhdr_t *) skb->data;
890 /* If this is INIT/INIT-ACK look inside the chunk too. */
893 case SCTP_CID_INIT_ACK:
899 /* The code below will attempt to walk the chunk and extract
900 * parameter information. Before we do that, we need to verify
901 * that the chunk length doesn't cause overflow. Otherwise, we'll
904 if (WORD_ROUND(ntohs(ch->length)) > skb->len)
908 * This code will NOT touch anything inside the chunk--it is
909 * strictly READ-ONLY.
911 * RFC 2960 3 SCTP packet Format
913 * Multiple chunks can be bundled into one SCTP packet up to
914 * the MTU size, except for the INIT, INIT ACK, and SHUTDOWN
915 * COMPLETE chunks. These chunks MUST NOT be bundled with any
916 * other chunk in a packet. See Section 6.10 for more details
920 /* Find the start of the TLVs and the end of the chunk. This is
921 * the region we search for address parameters.
923 init = (sctp_init_chunk_t *)skb->data;
925 /* Walk the parameters looking for embedded addresses. */
926 sctp_walk_params(params, init, init_hdr.params) {
928 /* Note: Ignoring hostname addresses. */
929 af = sctp_get_af_specific(param_type2af(params.p->type));
933 af->from_addr_param(paddr, params.addr, ntohs(sh->source), 0);
935 asoc = __sctp_lookup_association(laddr, paddr, &transport);
943 /* Lookup an association for an inbound skb. */
944 static struct sctp_association *__sctp_rcv_lookup(struct sk_buff *skb,
945 const union sctp_addr *paddr,
946 const union sctp_addr *laddr,
947 struct sctp_transport **transportp)
949 struct sctp_association *asoc;
951 asoc = __sctp_lookup_association(laddr, paddr, transportp);
953 /* Further lookup for INIT/INIT-ACK packets.
954 * SCTP Implementors Guide, 2.18 Handling of address
955 * parameters within the INIT or INIT-ACK.
958 asoc = __sctp_rcv_init_lookup(skb, laddr, transportp);