xref: /openbmc/linux/net/rxrpc/conn_event.c (revision 8c3e34a4)
18c3e34a4SDavid Howells /* connection-level event handling
28c3e34a4SDavid Howells  *
38c3e34a4SDavid Howells  * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
48c3e34a4SDavid Howells  * Written by David Howells (dhowells@redhat.com)
58c3e34a4SDavid Howells  *
68c3e34a4SDavid Howells  * This program is free software; you can redistribute it and/or
78c3e34a4SDavid Howells  * modify it under the terms of the GNU General Public License
88c3e34a4SDavid Howells  * as published by the Free Software Foundation; either version
98c3e34a4SDavid Howells  * 2 of the License, or (at your option) any later version.
108c3e34a4SDavid Howells  */
118c3e34a4SDavid Howells 
128c3e34a4SDavid Howells #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
138c3e34a4SDavid Howells 
148c3e34a4SDavid Howells #include <linux/module.h>
158c3e34a4SDavid Howells #include <linux/net.h>
168c3e34a4SDavid Howells #include <linux/skbuff.h>
178c3e34a4SDavid Howells #include <linux/errqueue.h>
188c3e34a4SDavid Howells #include <linux/udp.h>
198c3e34a4SDavid Howells #include <linux/in.h>
208c3e34a4SDavid Howells #include <linux/in6.h>
218c3e34a4SDavid Howells #include <linux/icmp.h>
228c3e34a4SDavid Howells #include <net/sock.h>
238c3e34a4SDavid Howells #include <net/af_rxrpc.h>
248c3e34a4SDavid Howells #include <net/ip.h>
258c3e34a4SDavid Howells #include "ar-internal.h"
268c3e34a4SDavid Howells 
278c3e34a4SDavid Howells /*
288c3e34a4SDavid Howells  * pass a connection-level abort onto all calls on that connection
298c3e34a4SDavid Howells  */
308c3e34a4SDavid Howells static void rxrpc_abort_calls(struct rxrpc_connection *conn, int state,
318c3e34a4SDavid Howells 			      u32 abort_code)
328c3e34a4SDavid Howells {
338c3e34a4SDavid Howells 	struct rxrpc_call *call;
348c3e34a4SDavid Howells 	struct rb_node *p;
358c3e34a4SDavid Howells 
368c3e34a4SDavid Howells 	_enter("{%d},%x", conn->debug_id, abort_code);
378c3e34a4SDavid Howells 
388c3e34a4SDavid Howells 	read_lock_bh(&conn->lock);
398c3e34a4SDavid Howells 
408c3e34a4SDavid Howells 	for (p = rb_first(&conn->calls); p; p = rb_next(p)) {
418c3e34a4SDavid Howells 		call = rb_entry(p, struct rxrpc_call, conn_node);
428c3e34a4SDavid Howells 		write_lock(&call->state_lock);
438c3e34a4SDavid Howells 		if (call->state <= RXRPC_CALL_COMPLETE) {
448c3e34a4SDavid Howells 			call->state = state;
458c3e34a4SDavid Howells 			if (state == RXRPC_CALL_LOCALLY_ABORTED) {
468c3e34a4SDavid Howells 				call->local_abort = conn->local_abort;
478c3e34a4SDavid Howells 				set_bit(RXRPC_CALL_EV_CONN_ABORT, &call->events);
488c3e34a4SDavid Howells 			} else {
498c3e34a4SDavid Howells 				call->remote_abort = conn->remote_abort;
508c3e34a4SDavid Howells 				set_bit(RXRPC_CALL_EV_RCVD_ABORT, &call->events);
518c3e34a4SDavid Howells 			}
528c3e34a4SDavid Howells 			rxrpc_queue_call(call);
538c3e34a4SDavid Howells 		}
548c3e34a4SDavid Howells 		write_unlock(&call->state_lock);
558c3e34a4SDavid Howells 	}
568c3e34a4SDavid Howells 
578c3e34a4SDavid Howells 	read_unlock_bh(&conn->lock);
588c3e34a4SDavid Howells 	_leave("");
598c3e34a4SDavid Howells }
608c3e34a4SDavid Howells 
618c3e34a4SDavid Howells /*
628c3e34a4SDavid Howells  * generate a connection-level abort
638c3e34a4SDavid Howells  */
648c3e34a4SDavid Howells static int rxrpc_abort_connection(struct rxrpc_connection *conn,
658c3e34a4SDavid Howells 				  u32 error, u32 abort_code)
668c3e34a4SDavid Howells {
678c3e34a4SDavid Howells 	struct rxrpc_wire_header whdr;
688c3e34a4SDavid Howells 	struct msghdr msg;
698c3e34a4SDavid Howells 	struct kvec iov[2];
708c3e34a4SDavid Howells 	__be32 word;
718c3e34a4SDavid Howells 	size_t len;
728c3e34a4SDavid Howells 	u32 serial;
738c3e34a4SDavid Howells 	int ret;
748c3e34a4SDavid Howells 
758c3e34a4SDavid Howells 	_enter("%d,,%u,%u", conn->debug_id, error, abort_code);
768c3e34a4SDavid Howells 
778c3e34a4SDavid Howells 	/* generate a connection-level abort */
788c3e34a4SDavid Howells 	spin_lock_bh(&conn->state_lock);
798c3e34a4SDavid Howells 	if (conn->state < RXRPC_CONN_REMOTELY_ABORTED) {
808c3e34a4SDavid Howells 		conn->state = RXRPC_CONN_LOCALLY_ABORTED;
818c3e34a4SDavid Howells 		conn->error = error;
828c3e34a4SDavid Howells 		spin_unlock_bh(&conn->state_lock);
838c3e34a4SDavid Howells 	} else {
848c3e34a4SDavid Howells 		spin_unlock_bh(&conn->state_lock);
858c3e34a4SDavid Howells 		_leave(" = 0 [already dead]");
868c3e34a4SDavid Howells 		return 0;
878c3e34a4SDavid Howells 	}
888c3e34a4SDavid Howells 
898c3e34a4SDavid Howells 	rxrpc_abort_calls(conn, RXRPC_CALL_LOCALLY_ABORTED, abort_code);
908c3e34a4SDavid Howells 
918c3e34a4SDavid Howells 	msg.msg_name	= &conn->trans->peer->srx.transport;
928c3e34a4SDavid Howells 	msg.msg_namelen	= conn->trans->peer->srx.transport_len;
938c3e34a4SDavid Howells 	msg.msg_control	= NULL;
948c3e34a4SDavid Howells 	msg.msg_controllen = 0;
958c3e34a4SDavid Howells 	msg.msg_flags	= 0;
968c3e34a4SDavid Howells 
978c3e34a4SDavid Howells 	whdr.epoch	= htonl(conn->epoch);
988c3e34a4SDavid Howells 	whdr.cid	= htonl(conn->cid);
998c3e34a4SDavid Howells 	whdr.callNumber	= 0;
1008c3e34a4SDavid Howells 	whdr.seq	= 0;
1018c3e34a4SDavid Howells 	whdr.type	= RXRPC_PACKET_TYPE_ABORT;
1028c3e34a4SDavid Howells 	whdr.flags	= conn->out_clientflag;
1038c3e34a4SDavid Howells 	whdr.userStatus	= 0;
1048c3e34a4SDavid Howells 	whdr.securityIndex = conn->security_ix;
1058c3e34a4SDavid Howells 	whdr._rsvd	= 0;
1068c3e34a4SDavid Howells 	whdr.serviceId	= htons(conn->service_id);
1078c3e34a4SDavid Howells 
1088c3e34a4SDavid Howells 	word		= htonl(conn->local_abort);
1098c3e34a4SDavid Howells 
1108c3e34a4SDavid Howells 	iov[0].iov_base	= &whdr;
1118c3e34a4SDavid Howells 	iov[0].iov_len	= sizeof(whdr);
1128c3e34a4SDavid Howells 	iov[1].iov_base	= &word;
1138c3e34a4SDavid Howells 	iov[1].iov_len	= sizeof(word);
1148c3e34a4SDavid Howells 
1158c3e34a4SDavid Howells 	len = iov[0].iov_len + iov[1].iov_len;
1168c3e34a4SDavid Howells 
1178c3e34a4SDavid Howells 	serial = atomic_inc_return(&conn->serial);
1188c3e34a4SDavid Howells 	whdr.serial = htonl(serial);
1198c3e34a4SDavid Howells 	_proto("Tx CONN ABORT %%%u { %d }", serial, conn->local_abort);
1208c3e34a4SDavid Howells 
1218c3e34a4SDavid Howells 	ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
1228c3e34a4SDavid Howells 	if (ret < 0) {
1238c3e34a4SDavid Howells 		_debug("sendmsg failed: %d", ret);
1248c3e34a4SDavid Howells 		return -EAGAIN;
1258c3e34a4SDavid Howells 	}
1268c3e34a4SDavid Howells 
1278c3e34a4SDavid Howells 	_leave(" = 0");
1288c3e34a4SDavid Howells 	return 0;
1298c3e34a4SDavid Howells }
1308c3e34a4SDavid Howells 
1318c3e34a4SDavid Howells /*
1328c3e34a4SDavid Howells  * mark a call as being on a now-secured channel
1338c3e34a4SDavid Howells  * - must be called with softirqs disabled
1348c3e34a4SDavid Howells  */
1358c3e34a4SDavid Howells static void rxrpc_call_is_secure(struct rxrpc_call *call)
1368c3e34a4SDavid Howells {
1378c3e34a4SDavid Howells 	_enter("%p", call);
1388c3e34a4SDavid Howells 	if (call) {
1398c3e34a4SDavid Howells 		read_lock(&call->state_lock);
1408c3e34a4SDavid Howells 		if (call->state < RXRPC_CALL_COMPLETE &&
1418c3e34a4SDavid Howells 		    !test_and_set_bit(RXRPC_CALL_EV_SECURED, &call->events))
1428c3e34a4SDavid Howells 			rxrpc_queue_call(call);
1438c3e34a4SDavid Howells 		read_unlock(&call->state_lock);
1448c3e34a4SDavid Howells 	}
1458c3e34a4SDavid Howells }
1468c3e34a4SDavid Howells 
1478c3e34a4SDavid Howells /*
1488c3e34a4SDavid Howells  * connection-level Rx packet processor
1498c3e34a4SDavid Howells  */
1508c3e34a4SDavid Howells static int rxrpc_process_event(struct rxrpc_connection *conn,
1518c3e34a4SDavid Howells 			       struct sk_buff *skb,
1528c3e34a4SDavid Howells 			       u32 *_abort_code)
1538c3e34a4SDavid Howells {
1548c3e34a4SDavid Howells 	struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
1558c3e34a4SDavid Howells 	__be32 wtmp;
1568c3e34a4SDavid Howells 	u32 abort_code;
1578c3e34a4SDavid Howells 	int loop, ret;
1588c3e34a4SDavid Howells 
1598c3e34a4SDavid Howells 	if (conn->state >= RXRPC_CONN_REMOTELY_ABORTED) {
1608c3e34a4SDavid Howells 		kleave(" = -ECONNABORTED [%u]", conn->state);
1618c3e34a4SDavid Howells 		return -ECONNABORTED;
1628c3e34a4SDavid Howells 	}
1638c3e34a4SDavid Howells 
1648c3e34a4SDavid Howells 	_enter("{%d},{%u,%%%u},", conn->debug_id, sp->hdr.type, sp->hdr.serial);
1658c3e34a4SDavid Howells 
1668c3e34a4SDavid Howells 	switch (sp->hdr.type) {
1678c3e34a4SDavid Howells 	case RXRPC_PACKET_TYPE_ABORT:
1688c3e34a4SDavid Howells 		if (skb_copy_bits(skb, 0, &wtmp, sizeof(wtmp)) < 0)
1698c3e34a4SDavid Howells 			return -EPROTO;
1708c3e34a4SDavid Howells 		abort_code = ntohl(wtmp);
1718c3e34a4SDavid Howells 		_proto("Rx ABORT %%%u { ac=%d }", sp->hdr.serial, abort_code);
1728c3e34a4SDavid Howells 
1738c3e34a4SDavid Howells 		conn->state = RXRPC_CONN_REMOTELY_ABORTED;
1748c3e34a4SDavid Howells 		rxrpc_abort_calls(conn, RXRPC_CALL_REMOTELY_ABORTED,
1758c3e34a4SDavid Howells 				  abort_code);
1768c3e34a4SDavid Howells 		return -ECONNABORTED;
1778c3e34a4SDavid Howells 
1788c3e34a4SDavid Howells 	case RXRPC_PACKET_TYPE_CHALLENGE:
1798c3e34a4SDavid Howells 		return conn->security->respond_to_challenge(conn, skb,
1808c3e34a4SDavid Howells 							    _abort_code);
1818c3e34a4SDavid Howells 
1828c3e34a4SDavid Howells 	case RXRPC_PACKET_TYPE_RESPONSE:
1838c3e34a4SDavid Howells 		ret = conn->security->verify_response(conn, skb, _abort_code);
1848c3e34a4SDavid Howells 		if (ret < 0)
1858c3e34a4SDavid Howells 			return ret;
1868c3e34a4SDavid Howells 
1878c3e34a4SDavid Howells 		ret = conn->security->init_connection_security(conn);
1888c3e34a4SDavid Howells 		if (ret < 0)
1898c3e34a4SDavid Howells 			return ret;
1908c3e34a4SDavid Howells 
1918c3e34a4SDavid Howells 		conn->security->prime_packet_security(conn);
1928c3e34a4SDavid Howells 		read_lock_bh(&conn->lock);
1938c3e34a4SDavid Howells 		spin_lock(&conn->state_lock);
1948c3e34a4SDavid Howells 
1958c3e34a4SDavid Howells 		if (conn->state == RXRPC_CONN_SERVER_CHALLENGING) {
1968c3e34a4SDavid Howells 			conn->state = RXRPC_CONN_SERVER;
1978c3e34a4SDavid Howells 			for (loop = 0; loop < RXRPC_MAXCALLS; loop++)
1988c3e34a4SDavid Howells 				rxrpc_call_is_secure(conn->channels[loop]);
1998c3e34a4SDavid Howells 		}
2008c3e34a4SDavid Howells 
2018c3e34a4SDavid Howells 		spin_unlock(&conn->state_lock);
2028c3e34a4SDavid Howells 		read_unlock_bh(&conn->lock);
2038c3e34a4SDavid Howells 		return 0;
2048c3e34a4SDavid Howells 
2058c3e34a4SDavid Howells 	default:
2068c3e34a4SDavid Howells 		_leave(" = -EPROTO [%u]", sp->hdr.type);
2078c3e34a4SDavid Howells 		return -EPROTO;
2088c3e34a4SDavid Howells 	}
2098c3e34a4SDavid Howells }
2108c3e34a4SDavid Howells 
2118c3e34a4SDavid Howells /*
2128c3e34a4SDavid Howells  * set up security and issue a challenge
2138c3e34a4SDavid Howells  */
2148c3e34a4SDavid Howells static void rxrpc_secure_connection(struct rxrpc_connection *conn)
2158c3e34a4SDavid Howells {
2168c3e34a4SDavid Howells 	u32 abort_code;
2178c3e34a4SDavid Howells 	int ret;
2188c3e34a4SDavid Howells 
2198c3e34a4SDavid Howells 	_enter("{%d}", conn->debug_id);
2208c3e34a4SDavid Howells 
2218c3e34a4SDavid Howells 	ASSERT(conn->security_ix != 0);
2228c3e34a4SDavid Howells 
2238c3e34a4SDavid Howells 	if (!conn->key) {
2248c3e34a4SDavid Howells 		_debug("set up security");
2258c3e34a4SDavid Howells 		ret = rxrpc_init_server_conn_security(conn);
2268c3e34a4SDavid Howells 		switch (ret) {
2278c3e34a4SDavid Howells 		case 0:
2288c3e34a4SDavid Howells 			break;
2298c3e34a4SDavid Howells 		case -ENOENT:
2308c3e34a4SDavid Howells 			abort_code = RX_CALL_DEAD;
2318c3e34a4SDavid Howells 			goto abort;
2328c3e34a4SDavid Howells 		default:
2338c3e34a4SDavid Howells 			abort_code = RXKADNOAUTH;
2348c3e34a4SDavid Howells 			goto abort;
2358c3e34a4SDavid Howells 		}
2368c3e34a4SDavid Howells 	}
2378c3e34a4SDavid Howells 
2388c3e34a4SDavid Howells 	if (conn->security->issue_challenge(conn) < 0) {
2398c3e34a4SDavid Howells 		abort_code = RX_CALL_DEAD;
2408c3e34a4SDavid Howells 		ret = -ENOMEM;
2418c3e34a4SDavid Howells 		goto abort;
2428c3e34a4SDavid Howells 	}
2438c3e34a4SDavid Howells 
2448c3e34a4SDavid Howells 	_leave("");
2458c3e34a4SDavid Howells 	return;
2468c3e34a4SDavid Howells 
2478c3e34a4SDavid Howells abort:
2488c3e34a4SDavid Howells 	_debug("abort %d, %d", ret, abort_code);
2498c3e34a4SDavid Howells 	rxrpc_abort_connection(conn, -ret, abort_code);
2508c3e34a4SDavid Howells 	_leave(" [aborted]");
2518c3e34a4SDavid Howells }
2528c3e34a4SDavid Howells 
2538c3e34a4SDavid Howells /*
2548c3e34a4SDavid Howells  * connection-level event processor
2558c3e34a4SDavid Howells  */
2568c3e34a4SDavid Howells void rxrpc_process_connection(struct work_struct *work)
2578c3e34a4SDavid Howells {
2588c3e34a4SDavid Howells 	struct rxrpc_connection *conn =
2598c3e34a4SDavid Howells 		container_of(work, struct rxrpc_connection, processor);
2608c3e34a4SDavid Howells 	struct sk_buff *skb;
2618c3e34a4SDavid Howells 	u32 abort_code = RX_PROTOCOL_ERROR;
2628c3e34a4SDavid Howells 	int ret;
2638c3e34a4SDavid Howells 
2648c3e34a4SDavid Howells 	_enter("{%d}", conn->debug_id);
2658c3e34a4SDavid Howells 
2668c3e34a4SDavid Howells 	atomic_inc(&conn->usage);
2678c3e34a4SDavid Howells 
2688c3e34a4SDavid Howells 	if (test_and_clear_bit(RXRPC_CONN_CHALLENGE, &conn->events)) {
2698c3e34a4SDavid Howells 		rxrpc_secure_connection(conn);
2708c3e34a4SDavid Howells 		rxrpc_put_connection(conn);
2718c3e34a4SDavid Howells 	}
2728c3e34a4SDavid Howells 
2738c3e34a4SDavid Howells 	/* go through the conn-level event packets, releasing the ref on this
2748c3e34a4SDavid Howells 	 * connection that each one has when we've finished with it */
2758c3e34a4SDavid Howells 	while ((skb = skb_dequeue(&conn->rx_queue))) {
2768c3e34a4SDavid Howells 		ret = rxrpc_process_event(conn, skb, &abort_code);
2778c3e34a4SDavid Howells 		switch (ret) {
2788c3e34a4SDavid Howells 		case -EPROTO:
2798c3e34a4SDavid Howells 		case -EKEYEXPIRED:
2808c3e34a4SDavid Howells 		case -EKEYREJECTED:
2818c3e34a4SDavid Howells 			goto protocol_error;
2828c3e34a4SDavid Howells 		case -EAGAIN:
2838c3e34a4SDavid Howells 			goto requeue_and_leave;
2848c3e34a4SDavid Howells 		case -ECONNABORTED:
2858c3e34a4SDavid Howells 		default:
2868c3e34a4SDavid Howells 			rxrpc_put_connection(conn);
2878c3e34a4SDavid Howells 			rxrpc_free_skb(skb);
2888c3e34a4SDavid Howells 			break;
2898c3e34a4SDavid Howells 		}
2908c3e34a4SDavid Howells 	}
2918c3e34a4SDavid Howells 
2928c3e34a4SDavid Howells out:
2938c3e34a4SDavid Howells 	rxrpc_put_connection(conn);
2948c3e34a4SDavid Howells 	_leave("");
2958c3e34a4SDavid Howells 	return;
2968c3e34a4SDavid Howells 
2978c3e34a4SDavid Howells requeue_and_leave:
2988c3e34a4SDavid Howells 	skb_queue_head(&conn->rx_queue, skb);
2998c3e34a4SDavid Howells 	goto out;
3008c3e34a4SDavid Howells 
3018c3e34a4SDavid Howells protocol_error:
3028c3e34a4SDavid Howells 	if (rxrpc_abort_connection(conn, -ret, abort_code) < 0)
3038c3e34a4SDavid Howells 		goto requeue_and_leave;
3048c3e34a4SDavid Howells 	rxrpc_put_connection(conn);
3058c3e34a4SDavid Howells 	rxrpc_free_skb(skb);
3068c3e34a4SDavid Howells 	_leave(" [EPROTO]");
3078c3e34a4SDavid Howells 	goto out;
3088c3e34a4SDavid Howells }
3098c3e34a4SDavid Howells 
3108c3e34a4SDavid Howells /*
3118c3e34a4SDavid Howells  * put a packet up for transport-level abort
3128c3e34a4SDavid Howells  */
3138c3e34a4SDavid Howells void rxrpc_reject_packet(struct rxrpc_local *local, struct sk_buff *skb)
3148c3e34a4SDavid Howells {
3158c3e34a4SDavid Howells 	CHECK_SLAB_OKAY(&local->usage);
3168c3e34a4SDavid Howells 
3178c3e34a4SDavid Howells 	if (!atomic_inc_not_zero(&local->usage)) {
3188c3e34a4SDavid Howells 		printk("resurrected on reject\n");
3198c3e34a4SDavid Howells 		BUG();
3208c3e34a4SDavid Howells 	}
3218c3e34a4SDavid Howells 
3228c3e34a4SDavid Howells 	skb_queue_tail(&local->reject_queue, skb);
3238c3e34a4SDavid Howells 	rxrpc_queue_work(&local->rejecter);
3248c3e34a4SDavid Howells }
3258c3e34a4SDavid Howells 
3268c3e34a4SDavid Howells /*
3278c3e34a4SDavid Howells  * reject packets through the local endpoint
3288c3e34a4SDavid Howells  */
3298c3e34a4SDavid Howells void rxrpc_reject_packets(struct work_struct *work)
3308c3e34a4SDavid Howells {
3318c3e34a4SDavid Howells 	union {
3328c3e34a4SDavid Howells 		struct sockaddr sa;
3338c3e34a4SDavid Howells 		struct sockaddr_in sin;
3348c3e34a4SDavid Howells 	} sa;
3358c3e34a4SDavid Howells 	struct rxrpc_skb_priv *sp;
3368c3e34a4SDavid Howells 	struct rxrpc_wire_header whdr;
3378c3e34a4SDavid Howells 	struct rxrpc_local *local;
3388c3e34a4SDavid Howells 	struct sk_buff *skb;
3398c3e34a4SDavid Howells 	struct msghdr msg;
3408c3e34a4SDavid Howells 	struct kvec iov[2];
3418c3e34a4SDavid Howells 	size_t size;
3428c3e34a4SDavid Howells 	__be32 code;
3438c3e34a4SDavid Howells 
3448c3e34a4SDavid Howells 	local = container_of(work, struct rxrpc_local, rejecter);
3458c3e34a4SDavid Howells 	rxrpc_get_local(local);
3468c3e34a4SDavid Howells 
3478c3e34a4SDavid Howells 	_enter("%d", local->debug_id);
3488c3e34a4SDavid Howells 
3498c3e34a4SDavid Howells 	iov[0].iov_base = &whdr;
3508c3e34a4SDavid Howells 	iov[0].iov_len = sizeof(whdr);
3518c3e34a4SDavid Howells 	iov[1].iov_base = &code;
3528c3e34a4SDavid Howells 	iov[1].iov_len = sizeof(code);
3538c3e34a4SDavid Howells 	size = sizeof(whdr) + sizeof(code);
3548c3e34a4SDavid Howells 
3558c3e34a4SDavid Howells 	msg.msg_name = &sa;
3568c3e34a4SDavid Howells 	msg.msg_control = NULL;
3578c3e34a4SDavid Howells 	msg.msg_controllen = 0;
3588c3e34a4SDavid Howells 	msg.msg_flags = 0;
3598c3e34a4SDavid Howells 
3608c3e34a4SDavid Howells 	memset(&sa, 0, sizeof(sa));
3618c3e34a4SDavid Howells 	sa.sa.sa_family = local->srx.transport.family;
3628c3e34a4SDavid Howells 	switch (sa.sa.sa_family) {
3638c3e34a4SDavid Howells 	case AF_INET:
3648c3e34a4SDavid Howells 		msg.msg_namelen = sizeof(sa.sin);
3658c3e34a4SDavid Howells 		break;
3668c3e34a4SDavid Howells 	default:
3678c3e34a4SDavid Howells 		msg.msg_namelen = 0;
3688c3e34a4SDavid Howells 		break;
3698c3e34a4SDavid Howells 	}
3708c3e34a4SDavid Howells 
3718c3e34a4SDavid Howells 	memset(&whdr, 0, sizeof(whdr));
3728c3e34a4SDavid Howells 	whdr.type = RXRPC_PACKET_TYPE_ABORT;
3738c3e34a4SDavid Howells 
3748c3e34a4SDavid Howells 	while ((skb = skb_dequeue(&local->reject_queue))) {
3758c3e34a4SDavid Howells 		sp = rxrpc_skb(skb);
3768c3e34a4SDavid Howells 		switch (sa.sa.sa_family) {
3778c3e34a4SDavid Howells 		case AF_INET:
3788c3e34a4SDavid Howells 			sa.sin.sin_port = udp_hdr(skb)->source;
3798c3e34a4SDavid Howells 			sa.sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
3808c3e34a4SDavid Howells 			code = htonl(skb->priority);
3818c3e34a4SDavid Howells 
3828c3e34a4SDavid Howells 			whdr.epoch	= htonl(sp->hdr.epoch);
3838c3e34a4SDavid Howells 			whdr.cid	= htonl(sp->hdr.cid);
3848c3e34a4SDavid Howells 			whdr.callNumber	= htonl(sp->hdr.callNumber);
3858c3e34a4SDavid Howells 			whdr.serviceId	= htons(sp->hdr.serviceId);
3868c3e34a4SDavid Howells 			whdr.flags	= sp->hdr.flags;
3878c3e34a4SDavid Howells 			whdr.flags	^= RXRPC_CLIENT_INITIATED;
3888c3e34a4SDavid Howells 			whdr.flags	&= RXRPC_CLIENT_INITIATED;
3898c3e34a4SDavid Howells 
3908c3e34a4SDavid Howells 			kernel_sendmsg(local->socket, &msg, iov, 2, size);
3918c3e34a4SDavid Howells 			break;
3928c3e34a4SDavid Howells 
3938c3e34a4SDavid Howells 		default:
3948c3e34a4SDavid Howells 			break;
3958c3e34a4SDavid Howells 		}
3968c3e34a4SDavid Howells 
3978c3e34a4SDavid Howells 		rxrpc_free_skb(skb);
3988c3e34a4SDavid Howells 		rxrpc_put_local(local);
3998c3e34a4SDavid Howells 	}
4008c3e34a4SDavid Howells 
4018c3e34a4SDavid Howells 	rxrpc_put_local(local);
4028c3e34a4SDavid Howells 	_leave("");
4038c3e34a4SDavid Howells }
404