input.c 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274
  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. atomic_set(&t->mtu_info, pmtu);
  346. asoc->pmtu_pending = 1;
  347. t->pmtu_pending = 1;
  348. return;
  349. }
  350. if (!(t->param_flags & SPP_PMTUD_ENABLE))
  351. /* We can't allow retransmitting in such case, as the
  352. * retransmission would be sized just as before, and thus we
  353. * would get another icmp, and retransmit again.
  354. */
  355. return;
  356. /* Update transports view of the MTU. Return if no update was needed.
  357. * If an update wasn't needed/possible, it also doesn't make sense to
  358. * try to retransmit now.
  359. */
  360. if (!sctp_transport_update_pmtu(t, pmtu))
  361. return;
  362. /* Update association pmtu. */
  363. sctp_assoc_sync_pmtu(asoc);
  364. /* Retransmit with the new pmtu setting. */
  365. sctp_retransmit(&asoc->outqueue, t, SCTP_RTXR_PMTUD);
  366. }
  367. void sctp_icmp_redirect(struct sock *sk, struct sctp_transport *t,
  368. struct sk_buff *skb)
  369. {
  370. struct dst_entry *dst;
  371. if (sock_owned_by_user(sk) || !t)
  372. return;
  373. dst = sctp_transport_dst_check(t);
  374. if (dst)
  375. dst->ops->redirect(dst, sk, skb);
  376. }
  377. /*
  378. * SCTP Implementer's Guide, 2.37 ICMP handling procedures
  379. *
  380. * ICMP8) If the ICMP code is a "Unrecognized next header type encountered"
  381. * or a "Protocol Unreachable" treat this message as an abort
  382. * with the T bit set.
  383. *
  384. * This function sends an event to the state machine, which will abort the
  385. * association.
  386. *
  387. */
  388. void sctp_icmp_proto_unreachable(struct sock *sk,
  389. struct sctp_association *asoc,
  390. struct sctp_transport *t)
  391. {
  392. if (sock_owned_by_user(sk)) {
  393. if (timer_pending(&t->proto_unreach_timer))
  394. return;
  395. else {
  396. if (!mod_timer(&t->proto_unreach_timer,
  397. jiffies + (HZ/20)))
  398. sctp_association_hold(asoc);
  399. }
  400. } else {
  401. struct net *net = sock_net(sk);
  402. pr_debug("%s: unrecognized next header type "
  403. "encountered!\n", __func__);
  404. if (del_timer(&t->proto_unreach_timer))
  405. sctp_association_put(asoc);
  406. sctp_do_sm(net, SCTP_EVENT_T_OTHER,
  407. SCTP_ST_OTHER(SCTP_EVENT_ICMP_PROTO_UNREACH),
  408. asoc->state, asoc->ep, asoc, t,
  409. GFP_ATOMIC);
  410. }
  411. }
  412. /* Common lookup code for icmp/icmpv6 error handler. */
  413. struct sock *sctp_err_lookup(struct net *net, int family, struct sk_buff *skb,
  414. struct sctphdr *sctphdr,
  415. struct sctp_association **app,
  416. struct sctp_transport **tpp)
  417. {
  418. struct sctp_init_chunk *chunkhdr, _chunkhdr;
  419. union sctp_addr saddr;
  420. union sctp_addr daddr;
  421. struct sctp_af *af;
  422. struct sock *sk = NULL;
  423. struct sctp_association *asoc;
  424. struct sctp_transport *transport = NULL;
  425. __u32 vtag = ntohl(sctphdr->vtag);
  426. *app = NULL; *tpp = NULL;
  427. af = sctp_get_af_specific(family);
  428. if (unlikely(!af)) {
  429. return NULL;
  430. }
  431. /* Initialize local addresses for lookups. */
  432. af->from_skb(&saddr, skb, 1);
  433. af->from_skb(&daddr, skb, 0);
  434. /* Look for an association that matches the incoming ICMP error
  435. * packet.
  436. */
  437. asoc = __sctp_lookup_association(net, &saddr, &daddr, &transport);
  438. if (!asoc)
  439. return NULL;
  440. sk = asoc->base.sk;
  441. /* RFC 4960, Appendix C. ICMP Handling
  442. *
  443. * ICMP6) An implementation MUST validate that the Verification Tag
  444. * contained in the ICMP message matches the Verification Tag of
  445. * the peer. If the Verification Tag is not 0 and does NOT
  446. * match, discard the ICMP message. If it is 0 and the ICMP
  447. * message contains enough bytes to verify that the chunk type is
  448. * an INIT chunk and that the Initiate Tag matches the tag of the
  449. * peer, continue with ICMP7. If the ICMP message is too short
  450. * or the chunk type or the Initiate Tag does not match, silently
  451. * discard the packet.
  452. */
  453. if (vtag == 0) {
  454. /* chunk header + first 4 octects of init header */
  455. chunkhdr = skb_header_pointer(skb, skb_transport_offset(skb) +
  456. sizeof(struct sctphdr),
  457. sizeof(struct sctp_chunkhdr) +
  458. sizeof(__be32), &_chunkhdr);
  459. if (!chunkhdr ||
  460. chunkhdr->chunk_hdr.type != SCTP_CID_INIT ||
  461. ntohl(chunkhdr->init_hdr.init_tag) != asoc->c.my_vtag)
  462. goto out;
  463. } else if (vtag != asoc->c.peer_vtag) {
  464. goto out;
  465. }
  466. bh_lock_sock(sk);
  467. /* If too many ICMPs get dropped on busy
  468. * servers this needs to be solved differently.
  469. */
  470. if (sock_owned_by_user(sk))
  471. __NET_INC_STATS(net, LINUX_MIB_LOCKDROPPEDICMPS);
  472. *app = asoc;
  473. *tpp = transport;
  474. return sk;
  475. out:
  476. sctp_transport_put(transport);
  477. return NULL;
  478. }
  479. /* Common cleanup code for icmp/icmpv6 error handler. */
  480. void sctp_err_finish(struct sock *sk, struct sctp_transport *t)
  481. {
  482. bh_unlock_sock(sk);
  483. sctp_transport_put(t);
  484. }
  485. /*
  486. * This routine is called by the ICMP module when it gets some
  487. * sort of error condition. If err < 0 then the socket should
  488. * be closed and the error returned to the user. If err > 0
  489. * it's just the icmp type << 8 | icmp code. After adjustment
  490. * header points to the first 8 bytes of the sctp header. We need
  491. * to find the appropriate port.
  492. *
  493. * The locking strategy used here is very "optimistic". When
  494. * someone else accesses the socket the ICMP is just dropped
  495. * and for some paths there is no check at all.
  496. * A more general error queue to queue errors for later handling
  497. * is probably better.
  498. *
  499. */
  500. void sctp_v4_err(struct sk_buff *skb, __u32 info)
  501. {
  502. const struct iphdr *iph = (const struct iphdr *)skb->data;
  503. const int ihlen = iph->ihl * 4;
  504. const int type = icmp_hdr(skb)->type;
  505. const int code = icmp_hdr(skb)->code;
  506. struct sock *sk;
  507. struct sctp_association *asoc = NULL;
  508. struct sctp_transport *transport;
  509. struct inet_sock *inet;
  510. __u16 saveip, savesctp;
  511. int err;
  512. struct net *net = dev_net(skb->dev);
  513. /* Fix up skb to look at the embedded net header. */
  514. saveip = skb->network_header;
  515. savesctp = skb->transport_header;
  516. skb_reset_network_header(skb);
  517. skb_set_transport_header(skb, ihlen);
  518. sk = sctp_err_lookup(net, AF_INET, skb, sctp_hdr(skb), &asoc, &transport);
  519. /* Put back, the original values. */
  520. skb->network_header = saveip;
  521. skb->transport_header = savesctp;
  522. if (!sk) {
  523. __ICMP_INC_STATS(net, ICMP_MIB_INERRORS);
  524. return;
  525. }
  526. /* Warning: The sock lock is held. Remember to call
  527. * sctp_err_finish!
  528. */
  529. switch (type) {
  530. case ICMP_PARAMETERPROB:
  531. err = EPROTO;
  532. break;
  533. case ICMP_DEST_UNREACH:
  534. if (code > NR_ICMP_UNREACH)
  535. goto out_unlock;
  536. /* PMTU discovery (RFC1191) */
  537. if (ICMP_FRAG_NEEDED == code) {
  538. sctp_icmp_frag_needed(sk, asoc, transport,
  539. SCTP_TRUNC4(info));
  540. goto out_unlock;
  541. } else {
  542. if (ICMP_PROT_UNREACH == code) {
  543. sctp_icmp_proto_unreachable(sk, asoc,
  544. transport);
  545. goto out_unlock;
  546. }
  547. }
  548. err = icmp_err_convert[code].errno;
  549. break;
  550. case ICMP_TIME_EXCEEDED:
  551. /* Ignore any time exceeded errors due to fragment reassembly
  552. * timeouts.
  553. */
  554. if (ICMP_EXC_FRAGTIME == code)
  555. goto out_unlock;
  556. err = EHOSTUNREACH;
  557. break;
  558. case ICMP_REDIRECT:
  559. sctp_icmp_redirect(sk, transport, skb);
  560. /* Fall through to out_unlock. */
  561. default:
  562. goto out_unlock;
  563. }
  564. inet = inet_sk(sk);
  565. if (!sock_owned_by_user(sk) && inet->recverr) {
  566. sk->sk_err = err;
  567. sk->sk_error_report(sk);
  568. } else { /* Only an error on timeout */
  569. sk->sk_err_soft = err;
  570. }
  571. out_unlock:
  572. sctp_err_finish(sk, transport);
  573. }
  574. /*
  575. * RFC 2960, 8.4 - Handle "Out of the blue" Packets.
  576. *
  577. * This function scans all the chunks in the OOTB packet to determine if
  578. * the packet should be discarded right away. If a response might be needed
  579. * for this packet, or, if further processing is possible, the packet will
  580. * be queued to a proper inqueue for the next phase of handling.
  581. *
  582. * Output:
  583. * Return 0 - If further processing is needed.
  584. * Return 1 - If the packet can be discarded right away.
  585. */
  586. static int sctp_rcv_ootb(struct sk_buff *skb)
  587. {
  588. struct sctp_chunkhdr *ch, _ch;
  589. int ch_end, offset = 0;
  590. /* Scan through all the chunks in the packet. */
  591. do {
  592. /* Make sure we have at least the header there */
  593. if (offset + sizeof(_ch) > skb->len)
  594. break;
  595. ch = skb_header_pointer(skb, offset, sizeof(*ch), &_ch);
  596. /* Break out if chunk length is less then minimal. */
  597. if (ntohs(ch->length) < sizeof(_ch))
  598. break;
  599. ch_end = offset + SCTP_PAD4(ntohs(ch->length));
  600. if (ch_end > skb->len)
  601. break;
  602. /* RFC 8.4, 2) If the OOTB packet contains an ABORT chunk, the
  603. * receiver MUST silently discard the OOTB packet and take no
  604. * further action.
  605. */
  606. if (SCTP_CID_ABORT == ch->type)
  607. goto discard;
  608. /* RFC 8.4, 6) If the packet contains a SHUTDOWN COMPLETE
  609. * chunk, the receiver should silently discard the packet
  610. * and take no further action.
  611. */
  612. if (SCTP_CID_SHUTDOWN_COMPLETE == ch->type)
  613. goto discard;
  614. /* RFC 4460, 2.11.2
  615. * This will discard packets with INIT chunk bundled as
  616. * subsequent chunks in the packet. When INIT is first,
  617. * the normal INIT processing will discard the chunk.
  618. */
  619. if (SCTP_CID_INIT == ch->type && (void *)ch != skb->data)
  620. goto discard;
  621. offset = ch_end;
  622. } while (ch_end < skb->len);
  623. return 0;
  624. discard:
  625. return 1;
  626. }
  627. /* Insert endpoint into the hash table. */
  628. static void __sctp_hash_endpoint(struct sctp_endpoint *ep)
  629. {
  630. struct net *net = sock_net(ep->base.sk);
  631. struct sctp_ep_common *epb;
  632. struct sctp_hashbucket *head;
  633. epb = &ep->base;
  634. epb->hashent = sctp_ep_hashfn(net, epb->bind_addr.port);
  635. head = &sctp_ep_hashtable[epb->hashent];
  636. write_lock(&head->lock);
  637. hlist_add_head(&epb->node, &head->chain);
  638. write_unlock(&head->lock);
  639. }
  640. /* Add an endpoint to the hash. Local BH-safe. */
  641. void sctp_hash_endpoint(struct sctp_endpoint *ep)
  642. {
  643. local_bh_disable();
  644. __sctp_hash_endpoint(ep);
  645. local_bh_enable();
  646. }
  647. /* Remove endpoint from the hash table. */
  648. static void __sctp_unhash_endpoint(struct sctp_endpoint *ep)
  649. {
  650. struct net *net = sock_net(ep->base.sk);
  651. struct sctp_hashbucket *head;
  652. struct sctp_ep_common *epb;
  653. epb = &ep->base;
  654. epb->hashent = sctp_ep_hashfn(net, epb->bind_addr.port);
  655. head = &sctp_ep_hashtable[epb->hashent];
  656. write_lock(&head->lock);
  657. hlist_del_init(&epb->node);
  658. write_unlock(&head->lock);
  659. }
  660. /* Remove endpoint from the hash. Local BH-safe. */
  661. void sctp_unhash_endpoint(struct sctp_endpoint *ep)
  662. {
  663. local_bh_disable();
  664. __sctp_unhash_endpoint(ep);
  665. local_bh_enable();
  666. }
  667. /* Look up an endpoint. */
  668. static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(struct net *net,
  669. const union sctp_addr *laddr)
  670. {
  671. struct sctp_hashbucket *head;
  672. struct sctp_ep_common *epb;
  673. struct sctp_endpoint *ep;
  674. int hash;
  675. hash = sctp_ep_hashfn(net, ntohs(laddr->v4.sin_port));
  676. head = &sctp_ep_hashtable[hash];
  677. read_lock(&head->lock);
  678. sctp_for_each_hentry(epb, &head->chain) {
  679. ep = sctp_ep(epb);
  680. if (sctp_endpoint_is_match(ep, net, laddr))
  681. goto hit;
  682. }
  683. ep = sctp_sk(net->sctp.ctl_sock)->ep;
  684. hit:
  685. sctp_endpoint_hold(ep);
  686. read_unlock(&head->lock);
  687. return ep;
  688. }
  689. /* rhashtable for transport */
  690. struct sctp_hash_cmp_arg {
  691. const union sctp_addr *paddr;
  692. const struct net *net;
  693. __be16 lport;
  694. };
  695. static inline int sctp_hash_cmp(struct rhashtable_compare_arg *arg,
  696. const void *ptr)
  697. {
  698. struct sctp_transport *t = (struct sctp_transport *)ptr;
  699. const struct sctp_hash_cmp_arg *x = arg->key;
  700. int err = 1;
  701. if (!sctp_cmp_addr_exact(&t->ipaddr, x->paddr))
  702. return err;
  703. if (!sctp_transport_hold(t))
  704. return err;
  705. if (!net_eq(sock_net(t->asoc->base.sk), x->net))
  706. goto out;
  707. if (x->lport != htons(t->asoc->base.bind_addr.port))
  708. goto out;
  709. err = 0;
  710. out:
  711. sctp_transport_put(t);
  712. return err;
  713. }
  714. static inline __u32 sctp_hash_obj(const void *data, u32 len, u32 seed)
  715. {
  716. const struct sctp_transport *t = data;
  717. const union sctp_addr *paddr = &t->ipaddr;
  718. const struct net *net = sock_net(t->asoc->base.sk);
  719. __be16 lport = htons(t->asoc->base.bind_addr.port);
  720. __u32 addr;
  721. if (paddr->sa.sa_family == AF_INET6)
  722. addr = jhash(&paddr->v6.sin6_addr, 16, seed);
  723. else
  724. addr = (__force __u32)paddr->v4.sin_addr.s_addr;
  725. return jhash_3words(addr, ((__force __u32)paddr->v4.sin_port) << 16 |
  726. (__force __u32)lport, net_hash_mix(net), seed);
  727. }
  728. static inline __u32 sctp_hash_key(const void *data, u32 len, u32 seed)
  729. {
  730. const struct sctp_hash_cmp_arg *x = data;
  731. const union sctp_addr *paddr = x->paddr;
  732. const struct net *net = x->net;
  733. __be16 lport = x->lport;
  734. __u32 addr;
  735. if (paddr->sa.sa_family == AF_INET6)
  736. addr = jhash(&paddr->v6.sin6_addr, 16, seed);
  737. else
  738. addr = (__force __u32)paddr->v4.sin_addr.s_addr;
  739. return jhash_3words(addr, ((__force __u32)paddr->v4.sin_port) << 16 |
  740. (__force __u32)lport, net_hash_mix(net), seed);
  741. }
  742. static const struct rhashtable_params sctp_hash_params = {
  743. .head_offset = offsetof(struct sctp_transport, node),
  744. .hashfn = sctp_hash_key,
  745. .obj_hashfn = sctp_hash_obj,
  746. .obj_cmpfn = sctp_hash_cmp,
  747. .automatic_shrinking = true,
  748. };
  749. int sctp_transport_hashtable_init(void)
  750. {
  751. return rhltable_init(&sctp_transport_hashtable, &sctp_hash_params);
  752. }
  753. void sctp_transport_hashtable_destroy(void)
  754. {
  755. rhltable_destroy(&sctp_transport_hashtable);
  756. }
  757. int sctp_hash_transport(struct sctp_transport *t)
  758. {
  759. struct sctp_transport *transport;
  760. struct rhlist_head *tmp, *list;
  761. struct sctp_hash_cmp_arg arg;
  762. int err;
  763. if (t->asoc->temp)
  764. return 0;
  765. arg.net = sock_net(t->asoc->base.sk);
  766. arg.paddr = &t->ipaddr;
  767. arg.lport = htons(t->asoc->base.bind_addr.port);
  768. rcu_read_lock();
  769. list = rhltable_lookup(&sctp_transport_hashtable, &arg,
  770. sctp_hash_params);
  771. rhl_for_each_entry_rcu(transport, tmp, list, node)
  772. if (transport->asoc->ep == t->asoc->ep) {
  773. rcu_read_unlock();
  774. return -EEXIST;
  775. }
  776. rcu_read_unlock();
  777. err = rhltable_insert_key(&sctp_transport_hashtable, &arg,
  778. &t->node, sctp_hash_params);
  779. if (err)
  780. pr_err_once("insert transport fail, errno %d\n", err);
  781. return err;
  782. }
  783. void sctp_unhash_transport(struct sctp_transport *t)
  784. {
  785. if (t->asoc->temp)
  786. return;
  787. rhltable_remove(&sctp_transport_hashtable, &t->node,
  788. sctp_hash_params);
  789. }
  790. /* return a transport with holding it */
  791. struct sctp_transport *sctp_addrs_lookup_transport(
  792. struct net *net,
  793. const union sctp_addr *laddr,
  794. const union sctp_addr *paddr)
  795. {
  796. struct rhlist_head *tmp, *list;
  797. struct sctp_transport *t;
  798. struct sctp_hash_cmp_arg arg = {
  799. .paddr = paddr,
  800. .net = net,
  801. .lport = laddr->v4.sin_port,
  802. };
  803. list = rhltable_lookup(&sctp_transport_hashtable, &arg,
  804. sctp_hash_params);
  805. rhl_for_each_entry_rcu(t, tmp, list, node) {
  806. if (!sctp_transport_hold(t))
  807. continue;
  808. if (sctp_bind_addr_match(&t->asoc->base.bind_addr,
  809. laddr, sctp_sk(t->asoc->base.sk)))
  810. return t;
  811. sctp_transport_put(t);
  812. }
  813. return NULL;
  814. }
  815. /* return a transport without holding it, as it's only used under sock lock */
  816. struct sctp_transport *sctp_epaddr_lookup_transport(
  817. const struct sctp_endpoint *ep,
  818. const union sctp_addr *paddr)
  819. {
  820. struct net *net = sock_net(ep->base.sk);
  821. struct rhlist_head *tmp, *list;
  822. struct sctp_transport *t;
  823. struct sctp_hash_cmp_arg arg = {
  824. .paddr = paddr,
  825. .net = net,
  826. .lport = htons(ep->base.bind_addr.port),
  827. };
  828. list = rhltable_lookup(&sctp_transport_hashtable, &arg,
  829. sctp_hash_params);
  830. rhl_for_each_entry_rcu(t, tmp, list, node)
  831. if (ep == t->asoc->ep)
  832. return t;
  833. return NULL;
  834. }
  835. /* Look up an association. */
  836. static struct sctp_association *__sctp_lookup_association(
  837. struct net *net,
  838. const union sctp_addr *local,
  839. const union sctp_addr *peer,
  840. struct sctp_transport **pt)
  841. {
  842. struct sctp_transport *t;
  843. struct sctp_association *asoc = NULL;
  844. t = sctp_addrs_lookup_transport(net, local, peer);
  845. if (!t)
  846. goto out;
  847. asoc = t->asoc;
  848. *pt = t;
  849. out:
  850. return asoc;
  851. }
  852. /* Look up an association. protected by RCU read lock */
  853. static
  854. struct sctp_association *sctp_lookup_association(struct net *net,
  855. const union sctp_addr *laddr,
  856. const union sctp_addr *paddr,
  857. struct sctp_transport **transportp)
  858. {
  859. struct sctp_association *asoc;
  860. rcu_read_lock();
  861. asoc = __sctp_lookup_association(net, laddr, paddr, transportp);
  862. rcu_read_unlock();
  863. return asoc;
  864. }
  865. /* Is there an association matching the given local and peer addresses? */
  866. bool sctp_has_association(struct net *net,
  867. const union sctp_addr *laddr,
  868. const union sctp_addr *paddr)
  869. {
  870. struct sctp_transport *transport;
  871. if (sctp_lookup_association(net, laddr, paddr, &transport)) {
  872. sctp_transport_put(transport);
  873. return true;
  874. }
  875. return false;
  876. }
  877. /*
  878. * SCTP Implementors Guide, 2.18 Handling of address
  879. * parameters within the INIT or INIT-ACK.
  880. *
  881. * D) When searching for a matching TCB upon reception of an INIT
  882. * or INIT-ACK chunk the receiver SHOULD use not only the
  883. * source address of the packet (containing the INIT or
  884. * INIT-ACK) but the receiver SHOULD also use all valid
  885. * address parameters contained within the chunk.
  886. *
  887. * 2.18.3 Solution description
  888. *
  889. * This new text clearly specifies to an implementor the need
  890. * to look within the INIT or INIT-ACK. Any implementation that
  891. * does not do this, may not be able to establish associations
  892. * in certain circumstances.
  893. *
  894. */
  895. static struct sctp_association *__sctp_rcv_init_lookup(struct net *net,
  896. struct sk_buff *skb,
  897. const union sctp_addr *laddr, struct sctp_transport **transportp)
  898. {
  899. struct sctp_association *asoc;
  900. union sctp_addr addr;
  901. union sctp_addr *paddr = &addr;
  902. struct sctphdr *sh = sctp_hdr(skb);
  903. union sctp_params params;
  904. struct sctp_init_chunk *init;
  905. struct sctp_af *af;
  906. /*
  907. * This code will NOT touch anything inside the chunk--it is
  908. * strictly READ-ONLY.
  909. *
  910. * RFC 2960 3 SCTP packet Format
  911. *
  912. * Multiple chunks can be bundled into one SCTP packet up to
  913. * the MTU size, except for the INIT, INIT ACK, and SHUTDOWN
  914. * COMPLETE chunks. These chunks MUST NOT be bundled with any
  915. * other chunk in a packet. See Section 6.10 for more details
  916. * on chunk bundling.
  917. */
  918. /* Find the start of the TLVs and the end of the chunk. This is
  919. * the region we search for address parameters.
  920. */
  921. init = (struct sctp_init_chunk *)skb->data;
  922. /* Walk the parameters looking for embedded addresses. */
  923. sctp_walk_params(params, init, init_hdr.params) {
  924. /* Note: Ignoring hostname addresses. */
  925. af = sctp_get_af_specific(param_type2af(params.p->type));
  926. if (!af)
  927. continue;
  928. af->from_addr_param(paddr, params.addr, sh->source, 0);
  929. asoc = __sctp_lookup_association(net, laddr, paddr, transportp);
  930. if (asoc)
  931. return asoc;
  932. }
  933. return NULL;
  934. }
  935. /* ADD-IP, Section 5.2
  936. * When an endpoint receives an ASCONF Chunk from the remote peer
  937. * special procedures may be needed to identify the association the
  938. * ASCONF Chunk is associated with. To properly find the association
  939. * the following procedures SHOULD be followed:
  940. *
  941. * D2) If the association is not found, use the address found in the
  942. * Address Parameter TLV combined with the port number found in the
  943. * SCTP common header. If found proceed to rule D4.
  944. *
  945. * D2-ext) If more than one ASCONF Chunks are packed together, use the
  946. * address found in the ASCONF Address Parameter TLV of each of the
  947. * subsequent ASCONF Chunks. If found, proceed to rule D4.
  948. */
  949. static struct sctp_association *__sctp_rcv_asconf_lookup(
  950. struct net *net,
  951. struct sctp_chunkhdr *ch,
  952. const union sctp_addr *laddr,
  953. __be16 peer_port,
  954. struct sctp_transport **transportp)
  955. {
  956. struct sctp_addip_chunk *asconf = (struct sctp_addip_chunk *)ch;
  957. struct sctp_af *af;
  958. union sctp_addr_param *param;
  959. union sctp_addr paddr;
  960. /* Skip over the ADDIP header and find the Address parameter */
  961. param = (union sctp_addr_param *)(asconf + 1);
  962. af = sctp_get_af_specific(param_type2af(param->p.type));
  963. if (unlikely(!af))
  964. return NULL;
  965. af->from_addr_param(&paddr, param, peer_port, 0);
  966. return __sctp_lookup_association(net, laddr, &paddr, transportp);
  967. }
  968. /* SCTP-AUTH, Section 6.3:
  969. * If the receiver does not find a STCB for a packet containing an AUTH
  970. * chunk as the first chunk and not a COOKIE-ECHO chunk as the second
  971. * chunk, it MUST use the chunks after the AUTH chunk to look up an existing
  972. * association.
  973. *
  974. * This means that any chunks that can help us identify the association need
  975. * to be looked at to find this association.
  976. */
  977. static struct sctp_association *__sctp_rcv_walk_lookup(struct net *net,
  978. struct sk_buff *skb,
  979. const union sctp_addr *laddr,
  980. struct sctp_transport **transportp)
  981. {
  982. struct sctp_association *asoc = NULL;
  983. struct sctp_chunkhdr *ch;
  984. int have_auth = 0;
  985. unsigned int chunk_num = 1;
  986. __u8 *ch_end;
  987. /* Walk through the chunks looking for AUTH or ASCONF chunks
  988. * to help us find the association.
  989. */
  990. ch = (struct sctp_chunkhdr *)skb->data;
  991. do {
  992. /* Break out if chunk length is less then minimal. */
  993. if (ntohs(ch->length) < sizeof(*ch))
  994. break;
  995. ch_end = ((__u8 *)ch) + SCTP_PAD4(ntohs(ch->length));
  996. if (ch_end > skb_tail_pointer(skb))
  997. break;
  998. switch (ch->type) {
  999. case SCTP_CID_AUTH:
  1000. have_auth = chunk_num;
  1001. break;
  1002. case SCTP_CID_COOKIE_ECHO:
  1003. /* If a packet arrives containing an AUTH chunk as
  1004. * a first chunk, a COOKIE-ECHO chunk as the second
  1005. * chunk, and possibly more chunks after them, and
  1006. * the receiver does not have an STCB for that
  1007. * packet, then authentication is based on
  1008. * the contents of the COOKIE- ECHO chunk.
  1009. */
  1010. if (have_auth == 1 && chunk_num == 2)
  1011. return NULL;
  1012. break;
  1013. case SCTP_CID_ASCONF:
  1014. if (have_auth || net->sctp.addip_noauth)
  1015. asoc = __sctp_rcv_asconf_lookup(
  1016. net, ch, laddr,
  1017. sctp_hdr(skb)->source,
  1018. transportp);
  1019. default:
  1020. break;
  1021. }
  1022. if (asoc)
  1023. break;
  1024. ch = (struct sctp_chunkhdr *)ch_end;
  1025. chunk_num++;
  1026. } while (ch_end < skb_tail_pointer(skb));
  1027. return asoc;
  1028. }
  1029. /*
  1030. * There are circumstances when we need to look inside the SCTP packet
  1031. * for information to help us find the association. Examples
  1032. * include looking inside of INIT/INIT-ACK chunks or after the AUTH
  1033. * chunks.
  1034. */
  1035. static struct sctp_association *__sctp_rcv_lookup_harder(struct net *net,
  1036. struct sk_buff *skb,
  1037. const union sctp_addr *laddr,
  1038. struct sctp_transport **transportp)
  1039. {
  1040. struct sctp_chunkhdr *ch;
  1041. /* We do not allow GSO frames here as we need to linearize and
  1042. * then cannot guarantee frame boundaries. This shouldn't be an
  1043. * issue as packets hitting this are mostly INIT or INIT-ACK and
  1044. * those cannot be on GSO-style anyway.
  1045. */
  1046. if (skb_is_gso(skb) && skb_is_gso_sctp(skb))
  1047. return NULL;
  1048. ch = (struct sctp_chunkhdr *)skb->data;
  1049. /* The code below will attempt to walk the chunk and extract
  1050. * parameter information. Before we do that, we need to verify
  1051. * that the chunk length doesn't cause overflow. Otherwise, we'll
  1052. * walk off the end.
  1053. */
  1054. if (SCTP_PAD4(ntohs(ch->length)) > skb->len)
  1055. return NULL;
  1056. /* If this is INIT/INIT-ACK look inside the chunk too. */
  1057. if (ch->type == SCTP_CID_INIT || ch->type == SCTP_CID_INIT_ACK)
  1058. return __sctp_rcv_init_lookup(net, skb, laddr, transportp);
  1059. return __sctp_rcv_walk_lookup(net, skb, laddr, transportp);
  1060. }
  1061. /* Lookup an association for an inbound skb. */
  1062. static struct sctp_association *__sctp_rcv_lookup(struct net *net,
  1063. struct sk_buff *skb,
  1064. const union sctp_addr *paddr,
  1065. const union sctp_addr *laddr,
  1066. struct sctp_transport **transportp)
  1067. {
  1068. struct sctp_association *asoc;
  1069. asoc = __sctp_lookup_association(net, laddr, paddr, transportp);
  1070. if (asoc)
  1071. goto out;
  1072. /* Further lookup for INIT/INIT-ACK packets.
  1073. * SCTP Implementors Guide, 2.18 Handling of address
  1074. * parameters within the INIT or INIT-ACK.
  1075. */
  1076. asoc = __sctp_rcv_lookup_harder(net, skb, laddr, transportp);
  1077. if (asoc)
  1078. goto out;
  1079. if (paddr->sa.sa_family == AF_INET)
  1080. pr_debug("sctp: asoc not found for src:%pI4:%d dst:%pI4:%d\n",
  1081. &laddr->v4.sin_addr, ntohs(laddr->v4.sin_port),
  1082. &paddr->v4.sin_addr, ntohs(paddr->v4.sin_port));
  1083. else
  1084. pr_debug("sctp: asoc not found for src:%pI6:%d dst:%pI6:%d\n",
  1085. &laddr->v6.sin6_addr, ntohs(laddr->v6.sin6_port),
  1086. &paddr->v6.sin6_addr, ntohs(paddr->v6.sin6_port));
  1087. out:
  1088. return asoc;
  1089. }