1 /* transport.c: Rx Transport routines
3 * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #include <linux/sched.h>
13 #include <linux/slab.h>
14 #include <linux/module.h>
15 #include <rxrpc/transport.h>
16 #include <rxrpc/peer.h>
17 #include <rxrpc/connection.h>
18 #include <rxrpc/call.h>
19 #include <rxrpc/message.h>
20 #include <rxrpc/krxiod.h>
21 #include <rxrpc/krxsecd.h>
22 #include <linux/udp.h>
24 #include <linux/in6.h>
25 #include <linux/icmp.h>
26 #include <linux/skbuff.h>
29 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
30 #include <linux/ipv6.h> /* this should _really_ be in errqueue.h.. */
32 #include <linux/errqueue.h>
33 #include <asm/uaccess.h>
34 #include <asm/checksum.h>
38 struct cmsghdr cmsg
; /* control message header */
39 struct sock_extended_err ee
; /* extended error information */
40 struct sockaddr_in icmp_src
; /* ICMP packet source address */
43 static DEFINE_SPINLOCK(rxrpc_transports_lock
);
44 static struct list_head rxrpc_transports
= LIST_HEAD_INIT(rxrpc_transports
);
46 __RXACCT_DECL(atomic_t rxrpc_transport_count
);
47 LIST_HEAD(rxrpc_proc_transports
);
48 DECLARE_RWSEM(rxrpc_proc_transports_sem
);
50 static void rxrpc_data_ready(struct sock
*sk
, int count
);
51 static void rxrpc_error_report(struct sock
*sk
);
52 static int rxrpc_trans_receive_new_call(struct rxrpc_transport
*trans
,
53 struct list_head
*msgq
);
54 static void rxrpc_trans_receive_error_report(struct rxrpc_transport
*trans
);
56 /*****************************************************************************/
58 * create a new transport endpoint using the specified UDP port
60 int rxrpc_create_transport(unsigned short port
,
61 struct rxrpc_transport
**_trans
)
63 struct rxrpc_transport
*trans
;
64 struct sockaddr_in sin
;
71 trans
= kmalloc(sizeof(struct rxrpc_transport
), GFP_KERNEL
);
75 memset(trans
, 0, sizeof(struct rxrpc_transport
));
76 atomic_set(&trans
->usage
, 1);
77 INIT_LIST_HEAD(&trans
->services
);
78 INIT_LIST_HEAD(&trans
->link
);
79 INIT_LIST_HEAD(&trans
->krxiodq_link
);
80 spin_lock_init(&trans
->lock
);
81 INIT_LIST_HEAD(&trans
->peer_active
);
82 INIT_LIST_HEAD(&trans
->peer_graveyard
);
83 spin_lock_init(&trans
->peer_gylock
);
84 init_waitqueue_head(&trans
->peer_gy_waitq
);
85 rwlock_init(&trans
->peer_lock
);
86 atomic_set(&trans
->peer_count
, 0);
89 /* create a UDP socket to be my actual transport endpoint */
90 ret
= sock_create_kern(PF_INET
, SOCK_DGRAM
, IPPROTO_UDP
, &trans
->socket
);
94 /* use the specified port */
96 memset(&sin
, 0, sizeof(sin
));
97 sin
.sin_family
= AF_INET
;
98 sin
.sin_port
= htons(port
);
99 ret
= trans
->socket
->ops
->bind(trans
->socket
,
100 (struct sockaddr
*) &sin
,
109 ret
= trans
->socket
->ops
->setsockopt(trans
->socket
, SOL_IP
, IP_RECVERR
,
110 (char *) &opt
, sizeof(opt
));
113 spin_lock(&rxrpc_transports_lock
);
114 list_add(&trans
->link
, &rxrpc_transports
);
115 spin_unlock(&rxrpc_transports_lock
);
117 /* set the socket up */
118 sock
= trans
->socket
->sk
;
119 sock
->sk_user_data
= trans
;
120 sock
->sk_data_ready
= rxrpc_data_ready
;
121 sock
->sk_error_report
= rxrpc_error_report
;
123 down_write(&rxrpc_proc_transports_sem
);
124 list_add_tail(&trans
->proc_link
, &rxrpc_proc_transports
);
125 up_write(&rxrpc_proc_transports_sem
);
127 __RXACCT(atomic_inc(&rxrpc_transport_count
));
130 _leave(" = 0 (%p)", trans
);
134 /* finish cleaning up the transport (not really needed here, but...) */
136 trans
->socket
->ops
->shutdown(trans
->socket
, 2);
138 /* close the socket */
140 trans
->socket
->sk
->sk_user_data
= NULL
;
141 sock_release(trans
->socket
);
142 trans
->socket
= NULL
;
148 _leave(" = %d", ret
);
150 } /* end rxrpc_create_transport() */
152 /*****************************************************************************/
154 * destroy a transport endpoint
156 void rxrpc_put_transport(struct rxrpc_transport
*trans
)
158 _enter("%p{u=%d p=%hu}",
159 trans
, atomic_read(&trans
->usage
), trans
->port
);
161 BUG_ON(atomic_read(&trans
->usage
) <= 0);
163 /* to prevent a race, the decrement and the dequeue must be
164 * effectively atomic */
165 spin_lock(&rxrpc_transports_lock
);
166 if (likely(!atomic_dec_and_test(&trans
->usage
))) {
167 spin_unlock(&rxrpc_transports_lock
);
172 list_del(&trans
->link
);
173 spin_unlock(&rxrpc_transports_lock
);
175 /* finish cleaning up the transport */
177 trans
->socket
->ops
->shutdown(trans
->socket
, 2);
179 rxrpc_krxsecd_clear_transport(trans
);
180 rxrpc_krxiod_dequeue_transport(trans
);
182 /* discard all peer information */
183 rxrpc_peer_clearall(trans
);
185 down_write(&rxrpc_proc_transports_sem
);
186 list_del(&trans
->proc_link
);
187 up_write(&rxrpc_proc_transports_sem
);
188 __RXACCT(atomic_dec(&rxrpc_transport_count
));
190 /* close the socket */
192 trans
->socket
->sk
->sk_user_data
= NULL
;
193 sock_release(trans
->socket
);
194 trans
->socket
= NULL
;
200 } /* end rxrpc_put_transport() */
202 /*****************************************************************************/
204 * add a service to a transport to be listened upon
206 int rxrpc_add_service(struct rxrpc_transport
*trans
,
207 struct rxrpc_service
*newsrv
)
209 struct rxrpc_service
*srv
;
210 struct list_head
*_p
;
213 _enter("%p{%hu},%p{%hu}",
214 trans
, trans
->port
, newsrv
, newsrv
->service_id
);
216 /* verify that the service ID is not already present */
217 spin_lock(&trans
->lock
);
219 list_for_each(_p
, &trans
->services
) {
220 srv
= list_entry(_p
, struct rxrpc_service
, link
);
221 if (srv
->service_id
== newsrv
->service_id
)
225 /* okay - add the transport to the list */
226 list_add_tail(&newsrv
->link
, &trans
->services
);
227 rxrpc_get_transport(trans
);
231 spin_unlock(&trans
->lock
);
235 } /* end rxrpc_add_service() */
237 /*****************************************************************************/
239 * remove a service from a transport
241 void rxrpc_del_service(struct rxrpc_transport
*trans
, struct rxrpc_service
*srv
)
243 _enter("%p{%hu},%p{%hu}", trans
, trans
->port
, srv
, srv
->service_id
);
245 spin_lock(&trans
->lock
);
246 list_del(&srv
->link
);
247 spin_unlock(&trans
->lock
);
249 rxrpc_put_transport(trans
);
252 } /* end rxrpc_del_service() */
254 /*****************************************************************************/
256 * INET callback when data has been received on the socket.
258 static void rxrpc_data_ready(struct sock
*sk
, int count
)
260 struct rxrpc_transport
*trans
;
262 _enter("%p{t=%p},%d", sk
, sk
->sk_user_data
, count
);
264 /* queue the transport for attention by krxiod */
265 trans
= (struct rxrpc_transport
*) sk
->sk_user_data
;
267 rxrpc_krxiod_queue_transport(trans
);
269 /* wake up anyone waiting on the socket */
270 if (sk
->sk_sleep
&& waitqueue_active(sk
->sk_sleep
))
271 wake_up_interruptible(sk
->sk_sleep
);
274 } /* end rxrpc_data_ready() */
276 /*****************************************************************************/
278 * INET callback when an ICMP error packet is received
279 * - sk->err is error (EHOSTUNREACH, EPROTO or EMSGSIZE)
281 static void rxrpc_error_report(struct sock
*sk
)
283 struct rxrpc_transport
*trans
;
285 _enter("%p{t=%p}", sk
, sk
->sk_user_data
);
287 /* queue the transport for attention by krxiod */
288 trans
= (struct rxrpc_transport
*) sk
->sk_user_data
;
290 trans
->error_rcvd
= 1;
291 rxrpc_krxiod_queue_transport(trans
);
294 /* wake up anyone waiting on the socket */
295 if (sk
->sk_sleep
&& waitqueue_active(sk
->sk_sleep
))
296 wake_up_interruptible(sk
->sk_sleep
);
299 } /* end rxrpc_error_report() */
301 /*****************************************************************************/
303 * split a message up, allocating message records and filling them in
304 * from the contents of a socket buffer
306 static int rxrpc_incoming_msg(struct rxrpc_transport
*trans
,
308 struct list_head
*msgq
)
310 struct rxrpc_message
*msg
;
315 msg
= kmalloc(sizeof(struct rxrpc_message
), GFP_KERNEL
);
317 _leave(" = -ENOMEM");
321 memset(msg
, 0, sizeof(*msg
));
322 atomic_set(&msg
->usage
, 1);
323 list_add_tail(&msg
->link
,msgq
);
325 /* dig out the Rx routing parameters */
326 if (skb_copy_bits(pkt
, sizeof(struct udphdr
),
327 &msg
->hdr
, sizeof(msg
->hdr
)) < 0) {
333 msg
->state
= RXRPC_MSG_RECEIVED
;
334 skb_get_timestamp(pkt
, &msg
->stamp
);
335 if (msg
->stamp
.tv_sec
== 0) {
336 do_gettimeofday(&msg
->stamp
);
338 sock_enable_timestamp(pkt
->sk
);
340 msg
->seq
= ntohl(msg
->hdr
.seq
);
342 /* attach the packet */
346 msg
->offset
= sizeof(struct udphdr
) + sizeof(struct rxrpc_header
);
347 msg
->dsize
= msg
->pkt
->len
- msg
->offset
;
349 _net("Rx Received packet from %s (%08x;%08x,%1x,%d,%s,%02x,%d,%d)",
350 msg
->hdr
.flags
& RXRPC_CLIENT_INITIATED
? "client" : "server",
351 ntohl(msg
->hdr
.epoch
),
352 (ntohl(msg
->hdr
.cid
) & RXRPC_CIDMASK
) >> RXRPC_CIDSHIFT
,
353 ntohl(msg
->hdr
.cid
) & RXRPC_CHANNELMASK
,
354 ntohl(msg
->hdr
.callNumber
),
355 rxrpc_pkts
[msg
->hdr
.type
],
357 ntohs(msg
->hdr
.serviceId
),
358 msg
->hdr
.securityIndex
);
360 __RXACCT(atomic_inc(&rxrpc_message_count
));
362 /* split off jumbo packets */
363 while (msg
->hdr
.type
== RXRPC_PACKET_TYPE_DATA
&&
364 msg
->hdr
.flags
& RXRPC_JUMBO_PACKET
366 struct rxrpc_jumbo_header jumbo
;
367 struct rxrpc_message
*jumbomsg
= msg
;
369 _debug("split jumbo packet");
371 /* quick sanity check */
374 RXRPC_JUMBO_DATALEN
+ sizeof(struct rxrpc_jumbo_header
))
376 if (msg
->hdr
.flags
& RXRPC_LAST_PACKET
)
379 /* dig out the secondary header */
380 if (skb_copy_bits(pkt
, msg
->offset
+ RXRPC_JUMBO_DATALEN
,
381 &jumbo
, sizeof(jumbo
)) < 0)
384 /* allocate a new message record */
386 msg
= kmalloc(sizeof(struct rxrpc_message
), GFP_KERNEL
);
390 memcpy(msg
, jumbomsg
, sizeof(*msg
));
391 list_add_tail(&msg
->link
, msgq
);
393 /* adjust the jumbo packet */
394 jumbomsg
->dsize
= RXRPC_JUMBO_DATALEN
;
396 /* attach the packet here too */
399 /* adjust the parameters */
401 msg
->hdr
.seq
= htonl(msg
->seq
);
402 msg
->hdr
.serial
= htonl(ntohl(msg
->hdr
.serial
) + 1);
403 msg
->offset
+= RXRPC_JUMBO_DATALEN
+
404 sizeof(struct rxrpc_jumbo_header
);
405 msg
->dsize
-= RXRPC_JUMBO_DATALEN
+
406 sizeof(struct rxrpc_jumbo_header
);
407 msg
->hdr
.flags
= jumbo
.flags
;
408 msg
->hdr
._rsvd
= jumbo
._rsvd
;
410 _net("Rx Split jumbo packet from %s"
411 " (%08x;%08x,%1x,%d,%s,%02x,%d,%d)",
412 msg
->hdr
.flags
& RXRPC_CLIENT_INITIATED
? "client" : "server",
413 ntohl(msg
->hdr
.epoch
),
414 (ntohl(msg
->hdr
.cid
) & RXRPC_CIDMASK
) >> RXRPC_CIDSHIFT
,
415 ntohl(msg
->hdr
.cid
) & RXRPC_CHANNELMASK
,
416 ntohl(msg
->hdr
.callNumber
),
417 rxrpc_pkts
[msg
->hdr
.type
],
419 ntohs(msg
->hdr
.serviceId
),
420 msg
->hdr
.securityIndex
);
422 __RXACCT(atomic_inc(&rxrpc_message_count
));
425 _leave(" = 0 #%d", atomic_read(&rxrpc_message_count
));
429 while (!list_empty(msgq
)) {
430 msg
= list_entry(msgq
->next
, struct rxrpc_message
, link
);
431 list_del_init(&msg
->link
);
433 rxrpc_put_message(msg
);
436 _leave(" = %d", ret
);
438 } /* end rxrpc_incoming_msg() */
440 /*****************************************************************************/
443 * - called from krxiod in process context
445 void rxrpc_trans_receive_packet(struct rxrpc_transport
*trans
)
447 struct rxrpc_message
*msg
;
448 struct rxrpc_peer
*peer
;
456 _enter("%p{%d}", trans
, trans
->port
);
459 /* deal with outstanting errors first */
460 if (trans
->error_rcvd
)
461 rxrpc_trans_receive_error_report(trans
);
463 /* attempt to receive a packet */
464 pkt
= skb_recv_datagram(trans
->socket
->sk
, 0, 1, &ret
);
466 if (ret
== -EAGAIN
) {
471 /* an icmp error may have occurred */
472 rxrpc_krxiod_queue_transport(trans
);
473 _leave(" error %d\n", ret
);
477 /* we'll probably need to checksum it (didn't call
479 if (skb_checksum_complete(pkt
)) {
481 rxrpc_krxiod_queue_transport(trans
);
482 _leave(" CSUM failed");
486 addr
= pkt
->nh
.iph
->saddr
;
487 port
= pkt
->h
.uh
->source
;
489 _net("Rx Received UDP packet from %08x:%04hu",
490 ntohl(addr
), ntohs(port
));
492 /* unmarshall the Rx parameters and split jumbo packets */
493 ret
= rxrpc_incoming_msg(trans
, pkt
, &msgq
);
496 rxrpc_krxiod_queue_transport(trans
);
497 _leave(" bad packet");
501 BUG_ON(list_empty(&msgq
));
503 msg
= list_entry(msgq
.next
, struct rxrpc_message
, link
);
505 /* locate the record for the peer from which it
507 ret
= rxrpc_peer_lookup(trans
, addr
, &peer
);
509 kdebug("Rx No connections from that peer");
510 rxrpc_trans_immediate_abort(trans
, msg
, -EINVAL
);
514 /* try and find a matching connection */
515 ret
= rxrpc_connection_lookup(peer
, msg
, &msg
->conn
);
517 kdebug("Rx Unknown Connection");
518 rxrpc_trans_immediate_abort(trans
, msg
, -EINVAL
);
519 rxrpc_put_peer(peer
);
522 rxrpc_put_peer(peer
);
524 /* deal with the first packet of a new call */
525 if (msg
->hdr
.flags
& RXRPC_CLIENT_INITIATED
&&
526 msg
->hdr
.type
== RXRPC_PACKET_TYPE_DATA
&&
527 ntohl(msg
->hdr
.seq
) == 1
529 _debug("Rx New server call");
530 rxrpc_trans_receive_new_call(trans
, &msgq
);
534 /* deal with subsequent packet(s) of call */
535 _debug("Rx Call packet");
536 while (!list_empty(&msgq
)) {
537 msg
= list_entry(msgq
.next
, struct rxrpc_message
, link
);
538 list_del_init(&msg
->link
);
540 ret
= rxrpc_conn_receive_call_packet(msg
->conn
, NULL
, msg
);
542 rxrpc_trans_immediate_abort(trans
, msg
, ret
);
543 rxrpc_put_message(msg
);
547 rxrpc_put_message(msg
);
552 /* dispose of the packets */
554 while (!list_empty(&msgq
)) {
555 msg
= list_entry(msgq
.next
, struct rxrpc_message
, link
);
556 list_del_init(&msg
->link
);
558 rxrpc_put_message(msg
);
565 } /* end rxrpc_trans_receive_packet() */
567 /*****************************************************************************/
569 * accept a new call from a client trying to connect to one of my services
570 * - called in process context
572 static int rxrpc_trans_receive_new_call(struct rxrpc_transport
*trans
,
573 struct list_head
*msgq
)
575 struct rxrpc_message
*msg
;
579 /* only bother with the first packet */
580 msg
= list_entry(msgq
->next
, struct rxrpc_message
, link
);
581 list_del_init(&msg
->link
);
582 rxrpc_krxsecd_queue_incoming_call(msg
);
583 rxrpc_put_message(msg
);
588 } /* end rxrpc_trans_receive_new_call() */
590 /*****************************************************************************/
592 * perform an immediate abort without connection or call structures
594 int rxrpc_trans_immediate_abort(struct rxrpc_transport
*trans
,
595 struct rxrpc_message
*msg
,
598 struct rxrpc_header ahdr
;
599 struct sockaddr_in sin
;
600 struct msghdr msghdr
;
605 _enter("%p,%p,%d", trans
, msg
, error
);
607 /* don't abort an abort packet */
608 if (msg
->hdr
.type
== RXRPC_PACKET_TYPE_ABORT
) {
613 _error
= htonl(-error
);
615 /* set up the message to be transmitted */
616 memcpy(&ahdr
, &msg
->hdr
, sizeof(ahdr
));
617 ahdr
.epoch
= msg
->hdr
.epoch
;
618 ahdr
.serial
= htonl(1);
620 ahdr
.type
= RXRPC_PACKET_TYPE_ABORT
;
621 ahdr
.flags
= RXRPC_LAST_PACKET
;
622 ahdr
.flags
|= ~msg
->hdr
.flags
& RXRPC_CLIENT_INITIATED
;
624 iov
[0].iov_len
= sizeof(ahdr
);
625 iov
[0].iov_base
= &ahdr
;
626 iov
[1].iov_len
= sizeof(_error
);
627 iov
[1].iov_base
= &_error
;
629 len
= sizeof(ahdr
) + sizeof(_error
);
631 memset(&sin
,0,sizeof(sin
));
632 sin
.sin_family
= AF_INET
;
633 sin
.sin_port
= msg
->pkt
->h
.uh
->source
;
634 sin
.sin_addr
.s_addr
= msg
->pkt
->nh
.iph
->saddr
;
636 msghdr
.msg_name
= &sin
;
637 msghdr
.msg_namelen
= sizeof(sin
);
638 msghdr
.msg_control
= NULL
;
639 msghdr
.msg_controllen
= 0;
640 msghdr
.msg_flags
= MSG_DONTWAIT
;
642 _net("Sending message type %d of %d bytes to %08x:%d",
645 ntohl(sin
.sin_addr
.s_addr
),
646 ntohs(sin
.sin_port
));
648 /* send the message */
649 ret
= kernel_sendmsg(trans
->socket
, &msghdr
, iov
, 2, len
);
651 _leave(" = %d", ret
);
653 } /* end rxrpc_trans_immediate_abort() */
655 /*****************************************************************************/
657 * receive an ICMP error report and percolate it to all connections
658 * heading to the affected host or port
660 static void rxrpc_trans_receive_error_report(struct rxrpc_transport
*trans
)
662 struct rxrpc_connection
*conn
;
663 struct sockaddr_in sin
;
664 struct rxrpc_peer
*peer
;
665 struct list_head connq
, *_p
;
666 struct errormsg emsg
;
674 trans
->error_rcvd
= 0;
676 /* try and receive an error message */
678 msg
.msg_namelen
= sizeof(sin
);
679 msg
.msg_control
= &emsg
;
680 msg
.msg_controllen
= sizeof(emsg
);
683 err
= kernel_recvmsg(trans
->socket
, &msg
, NULL
, 0, 0,
684 MSG_ERRQUEUE
| MSG_DONTWAIT
| MSG_TRUNC
);
686 if (err
== -EAGAIN
) {
692 printk("%s: unable to recv an error report: %d\n",
698 msg
.msg_controllen
= (char *) msg
.msg_control
- (char *) &emsg
;
700 if (msg
.msg_controllen
< sizeof(emsg
.cmsg
) ||
701 msg
.msg_namelen
< sizeof(sin
)) {
702 printk("%s: short control message"
703 " (nlen=%u clen=%Zu fl=%x)\n",
711 _net("Rx Received control message"
712 " { len=%Zu level=%u type=%u }",
714 emsg
.cmsg
.cmsg_level
,
715 emsg
.cmsg
.cmsg_type
);
717 if (sin
.sin_family
!= AF_INET
) {
718 printk("Rx Ignoring error report with non-INET address"
724 _net("Rx Received message pertaining to host addr=%x port=%hu",
725 ntohl(sin
.sin_addr
.s_addr
), ntohs(sin
.sin_port
));
727 if (emsg
.cmsg
.cmsg_level
!= SOL_IP
||
728 emsg
.cmsg
.cmsg_type
!= IP_RECVERR
) {
729 printk("Rx Ignoring unknown error report"
730 " { level=%u type=%u }",
731 emsg
.cmsg
.cmsg_level
,
732 emsg
.cmsg
.cmsg_type
);
736 if (msg
.msg_controllen
< sizeof(emsg
.cmsg
) + sizeof(emsg
.ee
)) {
737 printk("%s: short error message (%Zu)\n",
738 __FUNCTION__
, msg
.msg_controllen
);
745 switch (emsg
.ee
.ee_origin
) {
746 case SO_EE_ORIGIN_ICMP
:
748 switch (emsg
.ee
.ee_type
) {
749 case ICMP_DEST_UNREACH
:
750 switch (emsg
.ee
.ee_code
) {
751 case ICMP_NET_UNREACH
:
752 _net("Rx Received ICMP Network Unreachable");
756 case ICMP_HOST_UNREACH
:
757 _net("Rx Received ICMP Host Unreachable");
761 case ICMP_PORT_UNREACH
:
762 _net("Rx Received ICMP Port Unreachable");
765 case ICMP_NET_UNKNOWN
:
766 _net("Rx Received ICMP Unknown Network");
770 case ICMP_HOST_UNKNOWN
:
771 _net("Rx Received ICMP Unknown Host");
776 _net("Rx Received ICMP DestUnreach { code=%u }",
778 err
= emsg
.ee
.ee_errno
;
783 case ICMP_TIME_EXCEEDED
:
784 _net("Rx Received ICMP TTL Exceeded");
785 err
= emsg
.ee
.ee_errno
;
789 _proto("Rx Received ICMP error { type=%u code=%u }",
790 emsg
.ee
.ee_type
, emsg
.ee
.ee_code
);
791 err
= emsg
.ee
.ee_errno
;
796 case SO_EE_ORIGIN_LOCAL
:
797 _proto("Rx Received local error { error=%d }",
800 err
= emsg
.ee
.ee_errno
;
803 case SO_EE_ORIGIN_NONE
:
804 case SO_EE_ORIGIN_ICMP6
:
806 _proto("Rx Received error report { orig=%u }",
809 err
= emsg
.ee
.ee_errno
;
813 /* find all the connections between this transport and the
814 * affected destination */
815 INIT_LIST_HEAD(&connq
);
817 if (rxrpc_peer_lookup(trans
, sin
.sin_addr
.s_addr
,
819 read_lock(&peer
->conn_lock
);
820 list_for_each(_p
, &peer
->conn_active
) {
821 conn
= list_entry(_p
, struct rxrpc_connection
,
823 if (port
&& conn
->addr
.sin_port
!= port
)
825 if (!list_empty(&conn
->err_link
))
828 rxrpc_get_connection(conn
);
829 list_add_tail(&conn
->err_link
, &connq
);
831 read_unlock(&peer
->conn_lock
);
833 /* service all those connections */
834 while (!list_empty(&connq
)) {
835 conn
= list_entry(connq
.next
,
836 struct rxrpc_connection
,
838 list_del(&conn
->err_link
);
840 rxrpc_conn_handle_error(conn
, local
, err
);
842 rxrpc_put_connection(conn
);
845 rxrpc_put_peer(peer
);
851 } /* end rxrpc_trans_receive_error_report() */