input.c 34 KB

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