input.c 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273
  1. /* SCTP kernel 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 implementation
  10. *
  11. * These functions handle all input from the IP layer into SCTP.
  12. *
  13. * This SCTP 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. * This SCTP 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, see
  27. * <http://www.gnu.org/licenses/>.
  28. *
  29. * Please send any bug reports or fixes you make to the
  30. * email address(es):
  31. * lksctp developers <linux-sctp@vger.kernel.org>
  32. *
  33. * Written or modified by:
  34. * La Monte H.P. Yarroll <piggy@acm.org>
  35. * Karl Knutson <karl@athena.chicago.il.us>
  36. * Xingang Guo <xingang.guo@intel.com>
  37. * Jon Grimm <jgrimm@us.ibm.com>
  38. * Hui Huang <hui.huang@nokia.com>
  39. * Daisy Chang <daisyc@us.ibm.com>
  40. * Sridhar Samudrala <sri@us.ibm.com>
  41. * Ardelle Fan <ardelle.fan@intel.com>
  42. */
  43. #include <linux/types.h>
  44. #include <linux/list.h> /* For struct list_head */
  45. #include <linux/socket.h>
  46. #include <linux/ip.h>
  47. #include <linux/time.h> /* For struct timeval */
  48. #include <linux/slab.h>
  49. #include <net/ip.h>
  50. #include <net/icmp.h>
  51. #include <net/snmp.h>
  52. #include <net/sock.h>
  53. #include <net/xfrm.h>
  54. #include <net/sctp/sctp.h>
  55. #include <net/sctp/sm.h>
  56. #include <net/sctp/checksum.h>
  57. #include <net/net_namespace.h>
  58. #include <linux/rhashtable.h>
  59. /* Forward declarations for internal helpers. */
  60. static int sctp_rcv_ootb(struct sk_buff *);
  61. static struct sctp_association *__sctp_rcv_lookup(struct net *net,
  62. struct sk_buff *skb,
  63. const union sctp_addr *paddr,
  64. const union sctp_addr *laddr,
  65. struct sctp_transport **transportp);
  66. static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(struct net *net,
  67. const union sctp_addr *laddr);
  68. static struct sctp_association *__sctp_lookup_association(
  69. struct net *net,
  70. const union sctp_addr *local,
  71. const union sctp_addr *peer,
  72. struct sctp_transport **pt);
  73. static int sctp_add_backlog(struct sock *sk, struct sk_buff *skb);
  74. /* Calculate the SCTP checksum of an SCTP packet. */
  75. static inline int sctp_rcv_checksum(struct net *net, struct sk_buff *skb)
  76. {
  77. struct sctphdr *sh = sctp_hdr(skb);
  78. __le32 cmp = sh->checksum;
  79. __le32 val = sctp_compute_cksum(skb, 0);
  80. if (val != cmp) {
  81. /* CRC failure, dump it. */
  82. __SCTP_INC_STATS(net, SCTP_MIB_CHECKSUMERRORS);
  83. return -1;
  84. }
  85. return 0;
  86. }
  87. /*
  88. * This is the routine which IP calls when receiving an SCTP packet.
  89. */
  90. int sctp_rcv(struct sk_buff *skb)
  91. {
  92. struct sock *sk;
  93. struct sctp_association *asoc;
  94. struct sctp_endpoint *ep = NULL;
  95. struct sctp_ep_common *rcvr;
  96. struct sctp_transport *transport = NULL;
  97. struct sctp_chunk *chunk;
  98. union sctp_addr src;
  99. union sctp_addr dest;
  100. int family;
  101. struct sctp_af *af;
  102. struct net *net = dev_net(skb->dev);
  103. bool is_gso = skb_is_gso(skb) && skb_is_gso_sctp(skb);
  104. if (skb->pkt_type != PACKET_HOST)
  105. goto discard_it;
  106. __SCTP_INC_STATS(net, SCTP_MIB_INSCTPPACKS);
  107. /* If packet is too small to contain a single chunk, let's not
  108. * waste time on it anymore.
  109. */
  110. if (skb->len < sizeof(struct sctphdr) + sizeof(struct sctp_chunkhdr) +
  111. skb_transport_offset(skb))
  112. goto discard_it;
  113. /* If the packet is fragmented and we need to do crc checking,
  114. * it's better to just linearize it otherwise crc computing
  115. * takes longer.
  116. */
  117. if ((!is_gso && skb_linearize(skb)) ||
  118. !pskb_may_pull(skb, sizeof(struct sctphdr)))
  119. goto discard_it;
  120. /* Pull up the IP header. */
  121. __skb_pull(skb, skb_transport_offset(skb));
  122. skb->csum_valid = 0; /* Previous value not applicable */
  123. if (skb_csum_unnecessary(skb))
  124. __skb_decr_checksum_unnecessary(skb);
  125. else if (!sctp_checksum_disable &&
  126. !is_gso &&
  127. sctp_rcv_checksum(net, skb) < 0)
  128. goto discard_it;
  129. skb->csum_valid = 1;
  130. __skb_pull(skb, sizeof(struct sctphdr));
  131. family = ipver2af(ip_hdr(skb)->version);
  132. af = sctp_get_af_specific(family);
  133. if (unlikely(!af))
  134. goto discard_it;
  135. SCTP_INPUT_CB(skb)->af = af;
  136. /* Initialize local addresses for lookups. */
  137. af->from_skb(&src, skb, 1);
  138. af->from_skb(&dest, skb, 0);
  139. /* If the packet is to or from a non-unicast address,
  140. * silently discard the packet.
  141. *
  142. * This is not clearly defined in the RFC except in section
  143. * 8.4 - OOTB handling. However, based on the book "Stream Control
  144. * Transmission Protocol" 2.1, "It is important to note that the
  145. * IP address of an SCTP transport address must be a routable
  146. * unicast address. In other words, IP multicast addresses and
  147. * IP broadcast addresses cannot be used in an SCTP transport
  148. * address."
  149. */
  150. if (!af->addr_valid(&src, NULL, skb) ||
  151. !af->addr_valid(&dest, NULL, skb))
  152. goto discard_it;
  153. asoc = __sctp_rcv_lookup(net, skb, &src, &dest, &transport);
  154. if (!asoc)
  155. ep = __sctp_rcv_lookup_endpoint(net, &dest);
  156. /* Retrieve the common input handling substructure. */
  157. rcvr = asoc ? &asoc->base : &ep->base;
  158. sk = rcvr->sk;
  159. /*
  160. * If a frame arrives on an interface and the receiving socket is
  161. * bound to another interface, via SO_BINDTODEVICE, treat it as OOTB
  162. */
  163. if (sk->sk_bound_dev_if && (sk->sk_bound_dev_if != af->skb_iif(skb))) {
  164. if (transport) {
  165. sctp_transport_put(transport);
  166. asoc = NULL;
  167. transport = NULL;
  168. } else {
  169. sctp_endpoint_put(ep);
  170. ep = NULL;
  171. }
  172. sk = net->sctp.ctl_sock;
  173. ep = sctp_sk(sk)->ep;
  174. sctp_endpoint_hold(ep);
  175. rcvr = &ep->base;
  176. }
  177. /*
  178. * RFC 2960, 8.4 - Handle "Out of the blue" Packets.
  179. * An SCTP packet is called an "out of the blue" (OOTB)
  180. * packet if it is correctly formed, i.e., passed the
  181. * receiver's checksum check, but the receiver is not
  182. * able to identify the association to which this
  183. * packet belongs.
  184. */
  185. if (!asoc) {
  186. if (sctp_rcv_ootb(skb)) {
  187. __SCTP_INC_STATS(net, SCTP_MIB_OUTOFBLUES);
  188. goto discard_release;
  189. }
  190. }
  191. if (!xfrm_policy_check(sk, XFRM_POLICY_IN, skb, family))
  192. goto discard_release;
  193. nf_reset(skb);
  194. if (sk_filter(sk, skb))
  195. goto discard_release;
  196. /* Create an SCTP packet structure. */
  197. chunk = sctp_chunkify(skb, asoc, sk, GFP_ATOMIC);
  198. if (!chunk)
  199. goto discard_release;
  200. SCTP_INPUT_CB(skb)->chunk = chunk;
  201. /* Remember what endpoint is to handle this packet. */
  202. chunk->rcvr = rcvr;
  203. /* Remember the SCTP header. */
  204. chunk->sctp_hdr = sctp_hdr(skb);
  205. /* Set the source and destination addresses of the incoming chunk. */
  206. sctp_init_addrs(chunk, &src, &dest);
  207. /* Remember where we came from. */
  208. chunk->transport = transport;
  209. /* Acquire access to the sock lock. Note: We are safe from other
  210. * bottom halves on this lock, but a user may be in the lock too,
  211. * so check if it is busy.
  212. */
  213. bh_lock_sock(sk);
  214. if (sk != rcvr->sk) {
  215. /* Our cached sk is different from the rcvr->sk. This is
  216. * because migrate()/accept() may have moved the association
  217. * to a new socket and released all the sockets. So now we
  218. * are holding a lock on the old socket while the user may
  219. * be doing something with the new socket. Switch our veiw
  220. * of the current sk.
  221. */
  222. bh_unlock_sock(sk);
  223. sk = rcvr->sk;
  224. bh_lock_sock(sk);
  225. }
  226. if (sock_owned_by_user(sk)) {
  227. if (sctp_add_backlog(sk, skb)) {
  228. bh_unlock_sock(sk);
  229. sctp_chunk_free(chunk);
  230. skb = NULL; /* sctp_chunk_free already freed the skb */
  231. goto discard_release;
  232. }
  233. __SCTP_INC_STATS(net, SCTP_MIB_IN_PKT_BACKLOG);
  234. } else {
  235. __SCTP_INC_STATS(net, SCTP_MIB_IN_PKT_SOFTIRQ);
  236. sctp_inq_push(&chunk->rcvr->inqueue, chunk);
  237. }
  238. bh_unlock_sock(sk);
  239. /* Release the asoc/ep ref we took in the lookup calls. */
  240. if (transport)
  241. sctp_transport_put(transport);
  242. else
  243. sctp_endpoint_put(ep);
  244. return 0;
  245. discard_it:
  246. __SCTP_INC_STATS(net, SCTP_MIB_IN_PKT_DISCARDS);
  247. kfree_skb(skb);
  248. return 0;
  249. discard_release:
  250. /* Release the asoc/ep ref we took in the lookup calls. */
  251. if (transport)
  252. sctp_transport_put(transport);
  253. else
  254. sctp_endpoint_put(ep);
  255. goto discard_it;
  256. }
  257. /* Process the backlog queue of the socket. Every skb on
  258. * the backlog holds a ref on an association or endpoint.
  259. * We hold this ref throughout the state machine to make
  260. * sure that the structure we need is still around.
  261. */
  262. int sctp_backlog_rcv(struct sock *sk, struct sk_buff *skb)
  263. {
  264. struct sctp_chunk *chunk = SCTP_INPUT_CB(skb)->chunk;
  265. struct sctp_inq *inqueue = &chunk->rcvr->inqueue;
  266. struct sctp_transport *t = chunk->transport;
  267. struct sctp_ep_common *rcvr = NULL;
  268. int backloged = 0;
  269. rcvr = chunk->rcvr;
  270. /* If the rcvr is dead then the association or endpoint
  271. * has been deleted and we can safely drop the chunk
  272. * and refs that we are holding.
  273. */
  274. if (rcvr->dead) {
  275. sctp_chunk_free(chunk);
  276. goto done;
  277. }
  278. if (unlikely(rcvr->sk != sk)) {
  279. /* In this case, the association moved from one socket to
  280. * another. We are currently sitting on the backlog of the
  281. * old socket, so we need to move.
  282. * However, since we are here in the process context we
  283. * need to take make sure that the user doesn't own
  284. * the new socket when we process the packet.
  285. * If the new socket is user-owned, queue the chunk to the
  286. * backlog of the new socket without dropping any refs.
  287. * Otherwise, we can safely push the chunk on the inqueue.
  288. */
  289. sk = rcvr->sk;
  290. local_bh_disable();
  291. bh_lock_sock(sk);
  292. if (sock_owned_by_user(sk)) {
  293. if (sk_add_backlog(sk, skb, sk->sk_rcvbuf))
  294. sctp_chunk_free(chunk);
  295. else
  296. backloged = 1;
  297. } else
  298. sctp_inq_push(inqueue, chunk);
  299. bh_unlock_sock(sk);
  300. local_bh_enable();
  301. /* If the chunk was backloged again, don't drop refs */
  302. if (backloged)
  303. return 0;
  304. } else {
  305. sctp_inq_push(inqueue, chunk);
  306. }
  307. done:
  308. /* Release the refs we took in sctp_add_backlog */
  309. if (SCTP_EP_TYPE_ASSOCIATION == rcvr->type)
  310. sctp_transport_put(t);
  311. else if (SCTP_EP_TYPE_SOCKET == rcvr->type)
  312. sctp_endpoint_put(sctp_ep(rcvr));
  313. else
  314. BUG();
  315. return 0;
  316. }
  317. static int sctp_add_backlog(struct sock *sk, struct sk_buff *skb)
  318. {
  319. struct sctp_chunk *chunk = SCTP_INPUT_CB(skb)->chunk;
  320. struct sctp_transport *t = chunk->transport;
  321. struct sctp_ep_common *rcvr = chunk->rcvr;
  322. int ret;
  323. ret = sk_add_backlog(sk, skb, sk->sk_rcvbuf);
  324. if (!ret) {
  325. /* Hold the assoc/ep while hanging on the backlog queue.
  326. * This way, we know structures we need will not disappear
  327. * from us
  328. */
  329. if (SCTP_EP_TYPE_ASSOCIATION == rcvr->type)
  330. sctp_transport_hold(t);
  331. else if (SCTP_EP_TYPE_SOCKET == rcvr->type)
  332. sctp_endpoint_hold(sctp_ep(rcvr));
  333. else
  334. BUG();
  335. }
  336. return ret;
  337. }
  338. /* Handle icmp frag needed error. */
  339. void sctp_icmp_frag_needed(struct sock *sk, struct sctp_association *asoc,
  340. struct sctp_transport *t, __u32 pmtu)
  341. {
  342. if (!t || (t->pathmtu <= pmtu))
  343. return;
  344. if (sock_owned_by_user(sk)) {
  345. asoc->pmtu_pending = 1;
  346. t->pmtu_pending = 1;
  347. return;
  348. }
  349. if (!(t->param_flags & SPP_PMTUD_ENABLE))
  350. /* We can't allow retransmitting in such case, as the
  351. * retransmission would be sized just as before, and thus we
  352. * would get another icmp, and retransmit again.
  353. */
  354. return;
  355. /* Update transports view of the MTU. Return if no update was needed.
  356. * If an update wasn't needed/possible, it also doesn't make sense to
  357. * try to retransmit now.
  358. */
  359. if (!sctp_transport_update_pmtu(t, pmtu))
  360. return;
  361. /* Update association pmtu. */
  362. sctp_assoc_sync_pmtu(asoc);
  363. /* Retransmit with the new pmtu setting. */
  364. sctp_retransmit(&asoc->outqueue, t, SCTP_RTXR_PMTUD);
  365. }
  366. void sctp_icmp_redirect(struct sock *sk, struct sctp_transport *t,
  367. struct sk_buff *skb)
  368. {
  369. struct dst_entry *dst;
  370. if (sock_owned_by_user(sk) || !t)
  371. return;
  372. dst = sctp_transport_dst_check(t);
  373. if (dst)
  374. dst->ops->redirect(dst, sk, skb);
  375. }
  376. /*
  377. * SCTP Implementer's Guide, 2.37 ICMP handling procedures
  378. *
  379. * ICMP8) If the ICMP code is a "Unrecognized next header type encountered"
  380. * or a "Protocol Unreachable" treat this message as an abort
  381. * with the T bit set.
  382. *
  383. * This function sends an event to the state machine, which will abort the
  384. * association.
  385. *
  386. */
  387. void sctp_icmp_proto_unreachable(struct sock *sk,
  388. struct sctp_association *asoc,
  389. struct sctp_transport *t)
  390. {
  391. if (sock_owned_by_user(sk)) {
  392. if (timer_pending(&t->proto_unreach_timer))
  393. return;
  394. else {
  395. if (!mod_timer(&t->proto_unreach_timer,
  396. jiffies + (HZ/20)))
  397. sctp_association_hold(asoc);
  398. }
  399. } else {
  400. struct net *net = sock_net(sk);
  401. pr_debug("%s: unrecognized next header type "
  402. "encountered!\n", __func__);
  403. if (del_timer(&t->proto_unreach_timer))
  404. sctp_association_put(asoc);
  405. sctp_do_sm(net, SCTP_EVENT_T_OTHER,
  406. SCTP_ST_OTHER(SCTP_EVENT_ICMP_PROTO_UNREACH),
  407. asoc->state, asoc->ep, asoc, t,
  408. GFP_ATOMIC);
  409. }
  410. }
  411. /* Common lookup code for icmp/icmpv6 error handler. */
  412. struct sock *sctp_err_lookup(struct net *net, int family, struct sk_buff *skb,
  413. struct sctphdr *sctphdr,
  414. struct sctp_association **app,
  415. struct sctp_transport **tpp)
  416. {
  417. struct sctp_init_chunk *chunkhdr, _chunkhdr;
  418. union sctp_addr saddr;
  419. union sctp_addr daddr;
  420. struct sctp_af *af;
  421. struct sock *sk = NULL;
  422. struct sctp_association *asoc;
  423. struct sctp_transport *transport = NULL;
  424. __u32 vtag = ntohl(sctphdr->vtag);
  425. *app = NULL; *tpp = NULL;
  426. af = sctp_get_af_specific(family);
  427. if (unlikely(!af)) {
  428. return NULL;
  429. }
  430. /* Initialize local addresses for lookups. */
  431. af->from_skb(&saddr, skb, 1);
  432. af->from_skb(&daddr, skb, 0);
  433. /* Look for an association that matches the incoming ICMP error
  434. * packet.
  435. */
  436. asoc = __sctp_lookup_association(net, &saddr, &daddr, &transport);
  437. if (!asoc)
  438. return NULL;
  439. sk = asoc->base.sk;
  440. /* RFC 4960, Appendix C. ICMP Handling
  441. *
  442. * ICMP6) An implementation MUST validate that the Verification Tag
  443. * contained in the ICMP message matches the Verification Tag of
  444. * the peer. If the Verification Tag is not 0 and does NOT
  445. * match, discard the ICMP message. If it is 0 and the ICMP
  446. * message contains enough bytes to verify that the chunk type is
  447. * an INIT chunk and that the Initiate Tag matches the tag of the
  448. * peer, continue with ICMP7. If the ICMP message is too short
  449. * or the chunk type or the Initiate Tag does not match, silently
  450. * discard the packet.
  451. */
  452. if (vtag == 0) {
  453. /* chunk header + first 4 octects of init header */
  454. chunkhdr = skb_header_pointer(skb, skb_transport_offset(skb) +
  455. sizeof(struct sctphdr),
  456. sizeof(struct sctp_chunkhdr) +
  457. sizeof(__be32), &_chunkhdr);
  458. if (!chunkhdr ||
  459. chunkhdr->chunk_hdr.type != SCTP_CID_INIT ||
  460. ntohl(chunkhdr->init_hdr.init_tag) != asoc->c.my_vtag)
  461. goto out;
  462. } else if (vtag != asoc->c.peer_vtag) {
  463. goto out;
  464. }
  465. bh_lock_sock(sk);
  466. /* If too many ICMPs get dropped on busy
  467. * servers this needs to be solved differently.
  468. */
  469. if (sock_owned_by_user(sk))
  470. __NET_INC_STATS(net, LINUX_MIB_LOCKDROPPEDICMPS);
  471. *app = asoc;
  472. *tpp = transport;
  473. return sk;
  474. out:
  475. sctp_transport_put(transport);
  476. return NULL;
  477. }
  478. /* Common cleanup code for icmp/icmpv6 error handler. */
  479. void sctp_err_finish(struct sock *sk, struct sctp_transport *t)
  480. {
  481. bh_unlock_sock(sk);
  482. sctp_transport_put(t);
  483. }
  484. /*
  485. * This routine is called by the ICMP module when it gets some
  486. * sort of error condition. If err < 0 then the socket should
  487. * be closed and the error returned to the user. If err > 0
  488. * it's just the icmp type << 8 | icmp code. After adjustment
  489. * header points to the first 8 bytes of the sctp header. We need
  490. * to find the appropriate port.
  491. *
  492. * The locking strategy used here is very "optimistic". When
  493. * someone else accesses the socket the ICMP is just dropped
  494. * and for some paths there is no check at all.
  495. * A more general error queue to queue errors for later handling
  496. * is probably better.
  497. *
  498. */
  499. void sctp_v4_err(struct sk_buff *skb, __u32 info)
  500. {
  501. const struct iphdr *iph = (const struct iphdr *)skb->data;
  502. const int ihlen = iph->ihl * 4;
  503. const int type = icmp_hdr(skb)->type;
  504. const int code = icmp_hdr(skb)->code;
  505. struct sock *sk;
  506. struct sctp_association *asoc = NULL;
  507. struct sctp_transport *transport;
  508. struct inet_sock *inet;
  509. __u16 saveip, savesctp;
  510. int err;
  511. struct net *net = dev_net(skb->dev);
  512. /* Fix up skb to look at the embedded net header. */
  513. saveip = skb->network_header;
  514. savesctp = skb->transport_header;
  515. skb_reset_network_header(skb);
  516. skb_set_transport_header(skb, ihlen);
  517. sk = sctp_err_lookup(net, AF_INET, skb, sctp_hdr(skb), &asoc, &transport);
  518. /* Put back, the original values. */
  519. skb->network_header = saveip;
  520. skb->transport_header = savesctp;
  521. if (!sk) {
  522. __ICMP_INC_STATS(net, ICMP_MIB_INERRORS);
  523. return;
  524. }
  525. /* Warning: The sock lock is held. Remember to call
  526. * sctp_err_finish!
  527. */
  528. switch (type) {
  529. case ICMP_PARAMETERPROB:
  530. err = EPROTO;
  531. break;
  532. case ICMP_DEST_UNREACH:
  533. if (code > NR_ICMP_UNREACH)
  534. goto out_unlock;
  535. /* PMTU discovery (RFC1191) */
  536. if (ICMP_FRAG_NEEDED == code) {
  537. sctp_icmp_frag_needed(sk, asoc, transport,
  538. SCTP_TRUNC4(info));
  539. goto out_unlock;
  540. } else {
  541. if (ICMP_PROT_UNREACH == code) {
  542. sctp_icmp_proto_unreachable(sk, asoc,
  543. transport);
  544. goto out_unlock;
  545. }
  546. }
  547. err = icmp_err_convert[code].errno;
  548. break;
  549. case ICMP_TIME_EXCEEDED:
  550. /* Ignore any time exceeded errors due to fragment reassembly
  551. * timeouts.
  552. */
  553. if (ICMP_EXC_FRAGTIME == code)
  554. goto out_unlock;
  555. err = EHOSTUNREACH;
  556. break;
  557. case ICMP_REDIRECT:
  558. sctp_icmp_redirect(sk, transport, skb);
  559. /* Fall through to out_unlock. */
  560. default:
  561. goto out_unlock;
  562. }
  563. inet = inet_sk(sk);
  564. if (!sock_owned_by_user(sk) && inet->recverr) {
  565. sk->sk_err = err;
  566. sk->sk_error_report(sk);
  567. } else { /* Only an error on timeout */
  568. sk->sk_err_soft = err;
  569. }
  570. out_unlock:
  571. sctp_err_finish(sk, transport);
  572. }
  573. /*
  574. * RFC 2960, 8.4 - Handle "Out of the blue" Packets.
  575. *
  576. * This function scans all the chunks in the OOTB packet to determine if
  577. * the packet should be discarded right away. If a response might be needed
  578. * for this packet, or, if further processing is possible, the packet will
  579. * be queued to a proper inqueue for the next phase of handling.
  580. *
  581. * Output:
  582. * Return 0 - If further processing is needed.
  583. * Return 1 - If the packet can be discarded right away.
  584. */
  585. static int sctp_rcv_ootb(struct sk_buff *skb)
  586. {
  587. struct sctp_chunkhdr *ch, _ch;
  588. int ch_end, offset = 0;
  589. /* Scan through all the chunks in the packet. */
  590. do {
  591. /* Make sure we have at least the header there */
  592. if (offset + sizeof(_ch) > skb->len)
  593. break;
  594. ch = skb_header_pointer(skb, offset, sizeof(*ch), &_ch);
  595. /* Break out if chunk length is less then minimal. */
  596. if (ntohs(ch->length) < sizeof(_ch))
  597. break;
  598. ch_end = offset + SCTP_PAD4(ntohs(ch->length));
  599. if (ch_end > skb->len)
  600. break;
  601. /* RFC 8.4, 2) If the OOTB packet contains an ABORT chunk, the
  602. * receiver MUST silently discard the OOTB packet and take no
  603. * further action.
  604. */
  605. if (SCTP_CID_ABORT == ch->type)
  606. goto discard;
  607. /* RFC 8.4, 6) If the packet contains a SHUTDOWN COMPLETE
  608. * chunk, the receiver should silently discard the packet
  609. * and take no further action.
  610. */
  611. if (SCTP_CID_SHUTDOWN_COMPLETE == ch->type)
  612. goto discard;
  613. /* RFC 4460, 2.11.2
  614. * This will discard packets with INIT chunk bundled as
  615. * subsequent chunks in the packet. When INIT is first,
  616. * the normal INIT processing will discard the chunk.
  617. */
  618. if (SCTP_CID_INIT == ch->type && (void *)ch != skb->data)
  619. goto discard;
  620. offset = ch_end;
  621. } while (ch_end < skb->len);
  622. return 0;
  623. discard:
  624. return 1;
  625. }
  626. /* Insert endpoint into the hash table. */
  627. static void __sctp_hash_endpoint(struct sctp_endpoint *ep)
  628. {
  629. struct net *net = sock_net(ep->base.sk);
  630. struct sctp_ep_common *epb;
  631. struct sctp_hashbucket *head;
  632. epb = &ep->base;
  633. epb->hashent = sctp_ep_hashfn(net, epb->bind_addr.port);
  634. head = &sctp_ep_hashtable[epb->hashent];
  635. write_lock(&head->lock);
  636. hlist_add_head(&epb->node, &head->chain);
  637. write_unlock(&head->lock);
  638. }
  639. /* Add an endpoint to the hash. Local BH-safe. */
  640. void sctp_hash_endpoint(struct sctp_endpoint *ep)
  641. {
  642. local_bh_disable();
  643. __sctp_hash_endpoint(ep);
  644. local_bh_enable();
  645. }
  646. /* Remove endpoint from the hash table. */
  647. static void __sctp_unhash_endpoint(struct sctp_endpoint *ep)
  648. {
  649. struct net *net = sock_net(ep->base.sk);
  650. struct sctp_hashbucket *head;
  651. struct sctp_ep_common *epb;
  652. epb = &ep->base;
  653. epb->hashent = sctp_ep_hashfn(net, epb->bind_addr.port);
  654. head = &sctp_ep_hashtable[epb->hashent];
  655. write_lock(&head->lock);
  656. hlist_del_init(&epb->node);
  657. write_unlock(&head->lock);
  658. }
  659. /* Remove endpoint from the hash. Local BH-safe. */
  660. void sctp_unhash_endpoint(struct sctp_endpoint *ep)
  661. {
  662. local_bh_disable();
  663. __sctp_unhash_endpoint(ep);
  664. local_bh_enable();
  665. }
  666. /* Look up an endpoint. */
  667. static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(struct net *net,
  668. const union sctp_addr *laddr)
  669. {
  670. struct sctp_hashbucket *head;
  671. struct sctp_ep_common *epb;
  672. struct sctp_endpoint *ep;
  673. int hash;
  674. hash = sctp_ep_hashfn(net, ntohs(laddr->v4.sin_port));
  675. head = &sctp_ep_hashtable[hash];
  676. read_lock(&head->lock);
  677. sctp_for_each_hentry(epb, &head->chain) {
  678. ep = sctp_ep(epb);
  679. if (sctp_endpoint_is_match(ep, net, laddr))
  680. goto hit;
  681. }
  682. ep = sctp_sk(net->sctp.ctl_sock)->ep;
  683. hit:
  684. sctp_endpoint_hold(ep);
  685. read_unlock(&head->lock);
  686. return ep;
  687. }
  688. /* rhashtable for transport */
  689. struct sctp_hash_cmp_arg {
  690. const union sctp_addr *paddr;
  691. const struct net *net;
  692. __be16 lport;
  693. };
  694. static inline int sctp_hash_cmp(struct rhashtable_compare_arg *arg,
  695. const void *ptr)
  696. {
  697. struct sctp_transport *t = (struct sctp_transport *)ptr;
  698. const struct sctp_hash_cmp_arg *x = arg->key;
  699. int err = 1;
  700. if (!sctp_cmp_addr_exact(&t->ipaddr, x->paddr))
  701. return err;
  702. if (!sctp_transport_hold(t))
  703. return err;
  704. if (!net_eq(sock_net(t->asoc->base.sk), x->net))
  705. goto out;
  706. if (x->lport != htons(t->asoc->base.bind_addr.port))
  707. goto out;
  708. err = 0;
  709. out:
  710. sctp_transport_put(t);
  711. return err;
  712. }
  713. static inline __u32 sctp_hash_obj(const void *data, u32 len, u32 seed)
  714. {
  715. const struct sctp_transport *t = data;
  716. const union sctp_addr *paddr = &t->ipaddr;
  717. const struct net *net = sock_net(t->asoc->base.sk);
  718. __be16 lport = htons(t->asoc->base.bind_addr.port);
  719. __u32 addr;
  720. if (paddr->sa.sa_family == AF_INET6)
  721. addr = jhash(&paddr->v6.sin6_addr, 16, seed);
  722. else
  723. addr = (__force __u32)paddr->v4.sin_addr.s_addr;
  724. return jhash_3words(addr, ((__force __u32)paddr->v4.sin_port) << 16 |
  725. (__force __u32)lport, net_hash_mix(net), seed);
  726. }
  727. static inline __u32 sctp_hash_key(const void *data, u32 len, u32 seed)
  728. {
  729. const struct sctp_hash_cmp_arg *x = data;
  730. const union sctp_addr *paddr = x->paddr;
  731. const struct net *net = x->net;
  732. __be16 lport = x->lport;
  733. __u32 addr;
  734. if (paddr->sa.sa_family == AF_INET6)
  735. addr = jhash(&paddr->v6.sin6_addr, 16, seed);
  736. else
  737. addr = (__force __u32)paddr->v4.sin_addr.s_addr;
  738. return jhash_3words(addr, ((__force __u32)paddr->v4.sin_port) << 16 |
  739. (__force __u32)lport, net_hash_mix(net), seed);
  740. }
  741. static const struct rhashtable_params sctp_hash_params = {
  742. .head_offset = offsetof(struct sctp_transport, node),
  743. .hashfn = sctp_hash_key,
  744. .obj_hashfn = sctp_hash_obj,
  745. .obj_cmpfn = sctp_hash_cmp,
  746. .automatic_shrinking = true,
  747. };
  748. int sctp_transport_hashtable_init(void)
  749. {
  750. return rhltable_init(&sctp_transport_hashtable, &sctp_hash_params);
  751. }
  752. void sctp_transport_hashtable_destroy(void)
  753. {
  754. rhltable_destroy(&sctp_transport_hashtable);
  755. }
  756. int sctp_hash_transport(struct sctp_transport *t)
  757. {
  758. struct sctp_transport *transport;
  759. struct rhlist_head *tmp, *list;
  760. struct sctp_hash_cmp_arg arg;
  761. int err;
  762. if (t->asoc->temp)
  763. return 0;
  764. arg.net = sock_net(t->asoc->base.sk);
  765. arg.paddr = &t->ipaddr;
  766. arg.lport = htons(t->asoc->base.bind_addr.port);
  767. rcu_read_lock();
  768. list = rhltable_lookup(&sctp_transport_hashtable, &arg,
  769. sctp_hash_params);
  770. rhl_for_each_entry_rcu(transport, tmp, list, node)
  771. if (transport->asoc->ep == t->asoc->ep) {
  772. rcu_read_unlock();
  773. return -EEXIST;
  774. }
  775. rcu_read_unlock();
  776. err = rhltable_insert_key(&sctp_transport_hashtable, &arg,
  777. &t->node, sctp_hash_params);
  778. if (err)
  779. pr_err_once("insert transport fail, errno %d\n", err);
  780. return err;
  781. }
  782. void sctp_unhash_transport(struct sctp_transport *t)
  783. {
  784. if (t->asoc->temp)
  785. return;
  786. rhltable_remove(&sctp_transport_hashtable, &t->node,
  787. sctp_hash_params);
  788. }
  789. /* return a transport with holding it */
  790. struct sctp_transport *sctp_addrs_lookup_transport(
  791. struct net *net,
  792. const union sctp_addr *laddr,
  793. const union sctp_addr *paddr)
  794. {
  795. struct rhlist_head *tmp, *list;
  796. struct sctp_transport *t;
  797. struct sctp_hash_cmp_arg arg = {
  798. .paddr = paddr,
  799. .net = net,
  800. .lport = laddr->v4.sin_port,
  801. };
  802. list = rhltable_lookup(&sctp_transport_hashtable, &arg,
  803. sctp_hash_params);
  804. rhl_for_each_entry_rcu(t, tmp, list, node) {
  805. if (!sctp_transport_hold(t))
  806. continue;
  807. if (sctp_bind_addr_match(&t->asoc->base.bind_addr,
  808. laddr, sctp_sk(t->asoc->base.sk)))
  809. return t;
  810. sctp_transport_put(t);
  811. }
  812. return NULL;
  813. }
  814. /* return a transport without holding it, as it's only used under sock lock */
  815. struct sctp_transport *sctp_epaddr_lookup_transport(
  816. const struct sctp_endpoint *ep,
  817. const union sctp_addr *paddr)
  818. {
  819. struct net *net = sock_net(ep->base.sk);
  820. struct rhlist_head *tmp, *list;
  821. struct sctp_transport *t;
  822. struct sctp_hash_cmp_arg arg = {
  823. .paddr = paddr,
  824. .net = net,
  825. .lport = htons(ep->base.bind_addr.port),
  826. };
  827. list = rhltable_lookup(&sctp_transport_hashtable, &arg,
  828. sctp_hash_params);
  829. rhl_for_each_entry_rcu(t, tmp, list, node)
  830. if (ep == t->asoc->ep)
  831. return t;
  832. return NULL;
  833. }
  834. /* Look up an association. */
  835. static struct sctp_association *__sctp_lookup_association(
  836. struct net *net,
  837. const union sctp_addr *local,
  838. const union sctp_addr *peer,
  839. struct sctp_transport **pt)
  840. {
  841. struct sctp_transport *t;
  842. struct sctp_association *asoc = NULL;
  843. t = sctp_addrs_lookup_transport(net, local, peer);
  844. if (!t)
  845. goto out;
  846. asoc = t->asoc;
  847. *pt = t;
  848. out:
  849. return asoc;
  850. }
  851. /* Look up an association. protected by RCU read lock */
  852. static
  853. struct sctp_association *sctp_lookup_association(struct net *net,
  854. const union sctp_addr *laddr,
  855. const union sctp_addr *paddr,
  856. struct sctp_transport **transportp)
  857. {
  858. struct sctp_association *asoc;
  859. rcu_read_lock();
  860. asoc = __sctp_lookup_association(net, laddr, paddr, transportp);
  861. rcu_read_unlock();
  862. return asoc;
  863. }
  864. /* Is there an association matching the given local and peer addresses? */
  865. bool sctp_has_association(struct net *net,
  866. const union sctp_addr *laddr,
  867. const union sctp_addr *paddr)
  868. {
  869. struct sctp_transport *transport;
  870. if (sctp_lookup_association(net, laddr, paddr, &transport)) {
  871. sctp_transport_put(transport);
  872. return true;
  873. }
  874. return false;
  875. }
  876. /*
  877. * SCTP Implementors Guide, 2.18 Handling of address
  878. * parameters within the INIT or INIT-ACK.
  879. *
  880. * D) When searching for a matching TCB upon reception of an INIT
  881. * or INIT-ACK chunk the receiver SHOULD use not only the
  882. * source address of the packet (containing the INIT or
  883. * INIT-ACK) but the receiver SHOULD also use all valid
  884. * address parameters contained within the chunk.
  885. *
  886. * 2.18.3 Solution description
  887. *
  888. * This new text clearly specifies to an implementor the need
  889. * to look within the INIT or INIT-ACK. Any implementation that
  890. * does not do this, may not be able to establish associations
  891. * in certain circumstances.
  892. *
  893. */
  894. static struct sctp_association *__sctp_rcv_init_lookup(struct net *net,
  895. struct sk_buff *skb,
  896. const union sctp_addr *laddr, struct sctp_transport **transportp)
  897. {
  898. struct sctp_association *asoc;
  899. union sctp_addr addr;
  900. union sctp_addr *paddr = &addr;
  901. struct sctphdr *sh = sctp_hdr(skb);
  902. union sctp_params params;
  903. struct sctp_init_chunk *init;
  904. struct sctp_af *af;
  905. /*
  906. * This code will NOT touch anything inside the chunk--it is
  907. * strictly READ-ONLY.
  908. *
  909. * RFC 2960 3 SCTP packet Format
  910. *
  911. * Multiple chunks can be bundled into one SCTP packet up to
  912. * the MTU size, except for the INIT, INIT ACK, and SHUTDOWN
  913. * COMPLETE chunks. These chunks MUST NOT be bundled with any
  914. * other chunk in a packet. See Section 6.10 for more details
  915. * on chunk bundling.
  916. */
  917. /* Find the start of the TLVs and the end of the chunk. This is
  918. * the region we search for address parameters.
  919. */
  920. init = (struct sctp_init_chunk *)skb->data;
  921. /* Walk the parameters looking for embedded addresses. */
  922. sctp_walk_params(params, init, init_hdr.params) {
  923. /* Note: Ignoring hostname addresses. */
  924. af = sctp_get_af_specific(param_type2af(params.p->type));
  925. if (!af)
  926. continue;
  927. af->from_addr_param(paddr, params.addr, sh->source, 0);
  928. asoc = __sctp_lookup_association(net, laddr, paddr, transportp);
  929. if (asoc)
  930. return asoc;
  931. }
  932. return NULL;
  933. }
  934. /* ADD-IP, Section 5.2
  935. * When an endpoint receives an ASCONF Chunk from the remote peer
  936. * special procedures may be needed to identify the association the
  937. * ASCONF Chunk is associated with. To properly find the association
  938. * the following procedures SHOULD be followed:
  939. *
  940. * D2) If the association is not found, use the address found in the
  941. * Address Parameter TLV combined with the port number found in the
  942. * SCTP common header. If found proceed to rule D4.
  943. *
  944. * D2-ext) If more than one ASCONF Chunks are packed together, use the
  945. * address found in the ASCONF Address Parameter TLV of each of the
  946. * subsequent ASCONF Chunks. If found, proceed to rule D4.
  947. */
  948. static struct sctp_association *__sctp_rcv_asconf_lookup(
  949. struct net *net,
  950. struct sctp_chunkhdr *ch,
  951. const union sctp_addr *laddr,
  952. __be16 peer_port,
  953. struct sctp_transport **transportp)
  954. {
  955. struct sctp_addip_chunk *asconf = (struct sctp_addip_chunk *)ch;
  956. struct sctp_af *af;
  957. union sctp_addr_param *param;
  958. union sctp_addr paddr;
  959. /* Skip over the ADDIP header and find the Address parameter */
  960. param = (union sctp_addr_param *)(asconf + 1);
  961. af = sctp_get_af_specific(param_type2af(param->p.type));
  962. if (unlikely(!af))
  963. return NULL;
  964. af->from_addr_param(&paddr, param, peer_port, 0);
  965. return __sctp_lookup_association(net, laddr, &paddr, transportp);
  966. }
  967. /* SCTP-AUTH, Section 6.3:
  968. * If the receiver does not find a STCB for a packet containing an AUTH
  969. * chunk as the first chunk and not a COOKIE-ECHO chunk as the second
  970. * chunk, it MUST use the chunks after the AUTH chunk to look up an existing
  971. * association.
  972. *
  973. * This means that any chunks that can help us identify the association need
  974. * to be looked at to find this association.
  975. */
  976. static struct sctp_association *__sctp_rcv_walk_lookup(struct net *net,
  977. struct sk_buff *skb,
  978. const union sctp_addr *laddr,
  979. struct sctp_transport **transportp)
  980. {
  981. struct sctp_association *asoc = NULL;
  982. struct sctp_chunkhdr *ch;
  983. int have_auth = 0;
  984. unsigned int chunk_num = 1;
  985. __u8 *ch_end;
  986. /* Walk through the chunks looking for AUTH or ASCONF chunks
  987. * to help us find the association.
  988. */
  989. ch = (struct sctp_chunkhdr *)skb->data;
  990. do {
  991. /* Break out if chunk length is less then minimal. */
  992. if (ntohs(ch->length) < sizeof(*ch))
  993. break;
  994. ch_end = ((__u8 *)ch) + SCTP_PAD4(ntohs(ch->length));
  995. if (ch_end > skb_tail_pointer(skb))
  996. break;
  997. switch (ch->type) {
  998. case SCTP_CID_AUTH:
  999. have_auth = chunk_num;
  1000. break;
  1001. case SCTP_CID_COOKIE_ECHO:
  1002. /* If a packet arrives containing an AUTH chunk as
  1003. * a first chunk, a COOKIE-ECHO chunk as the second
  1004. * chunk, and possibly more chunks after them, and
  1005. * the receiver does not have an STCB for that
  1006. * packet, then authentication is based on
  1007. * the contents of the COOKIE- ECHO chunk.
  1008. */
  1009. if (have_auth == 1 && chunk_num == 2)
  1010. return NULL;
  1011. break;
  1012. case SCTP_CID_ASCONF:
  1013. if (have_auth || net->sctp.addip_noauth)
  1014. asoc = __sctp_rcv_asconf_lookup(
  1015. net, ch, laddr,
  1016. sctp_hdr(skb)->source,
  1017. transportp);
  1018. default:
  1019. break;
  1020. }
  1021. if (asoc)
  1022. break;
  1023. ch = (struct sctp_chunkhdr *)ch_end;
  1024. chunk_num++;
  1025. } while (ch_end < skb_tail_pointer(skb));
  1026. return asoc;
  1027. }
  1028. /*
  1029. * There are circumstances when we need to look inside the SCTP packet
  1030. * for information to help us find the association. Examples
  1031. * include looking inside of INIT/INIT-ACK chunks or after the AUTH
  1032. * chunks.
  1033. */
  1034. static struct sctp_association *__sctp_rcv_lookup_harder(struct net *net,
  1035. struct sk_buff *skb,
  1036. const union sctp_addr *laddr,
  1037. struct sctp_transport **transportp)
  1038. {
  1039. struct sctp_chunkhdr *ch;
  1040. /* We do not allow GSO frames here as we need to linearize and
  1041. * then cannot guarantee frame boundaries. This shouldn't be an
  1042. * issue as packets hitting this are mostly INIT or INIT-ACK and
  1043. * those cannot be on GSO-style anyway.
  1044. */
  1045. if (skb_is_gso(skb) && skb_is_gso_sctp(skb))
  1046. return NULL;
  1047. ch = (struct sctp_chunkhdr *)skb->data;
  1048. /* The code below will attempt to walk the chunk and extract
  1049. * parameter information. Before we do that, we need to verify
  1050. * that the chunk length doesn't cause overflow. Otherwise, we'll
  1051. * walk off the end.
  1052. */
  1053. if (SCTP_PAD4(ntohs(ch->length)) > skb->len)
  1054. return NULL;
  1055. /* If this is INIT/INIT-ACK look inside the chunk too. */
  1056. if (ch->type == SCTP_CID_INIT || ch->type == SCTP_CID_INIT_ACK)
  1057. return __sctp_rcv_init_lookup(net, skb, laddr, transportp);
  1058. return __sctp_rcv_walk_lookup(net, skb, laddr, transportp);
  1059. }
  1060. /* Lookup an association for an inbound skb. */
  1061. static struct sctp_association *__sctp_rcv_lookup(struct net *net,
  1062. struct sk_buff *skb,
  1063. const union sctp_addr *paddr,
  1064. const union sctp_addr *laddr,
  1065. struct sctp_transport **transportp)
  1066. {
  1067. struct sctp_association *asoc;
  1068. asoc = __sctp_lookup_association(net, laddr, paddr, transportp);
  1069. if (asoc)
  1070. goto out;
  1071. /* Further lookup for INIT/INIT-ACK packets.
  1072. * SCTP Implementors Guide, 2.18 Handling of address
  1073. * parameters within the INIT or INIT-ACK.
  1074. */
  1075. asoc = __sctp_rcv_lookup_harder(net, skb, laddr, transportp);
  1076. if (asoc)
  1077. goto out;
  1078. if (paddr->sa.sa_family == AF_INET)
  1079. pr_debug("sctp: asoc not found for src:%pI4:%d dst:%pI4:%d\n",
  1080. &laddr->v4.sin_addr, ntohs(laddr->v4.sin_port),
  1081. &paddr->v4.sin_addr, ntohs(paddr->v4.sin_port));
  1082. else
  1083. pr_debug("sctp: asoc not found for src:%pI6:%d dst:%pI6:%d\n",
  1084. &laddr->v6.sin6_addr, ntohs(laddr->v6.sin6_port),
  1085. &paddr->v6.sin6_addr, ntohs(paddr->v6.sin6_port));
  1086. out:
  1087. return asoc;
  1088. }