Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /* AF_RXRPC sendmsg() implementation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (C) 2007, 2016 Red Hat, Inc. All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Written by David Howells (dhowells@redhat.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/net.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/gfp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/skbuff.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/sched/signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <net/sock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <net/af_rxrpc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include "ar-internal.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * Return true if there's sufficient Tx queue space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) static bool rxrpc_check_tx_space(struct rxrpc_call *call, rxrpc_seq_t *_tx_win)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	unsigned int win_size =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 		min_t(unsigned int, call->tx_winsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 		      call->cong_cwnd + call->cong_extra);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	rxrpc_seq_t tx_win = READ_ONCE(call->tx_hard_ack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	if (_tx_win)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 		*_tx_win = tx_win;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	return call->tx_top - tx_win < win_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * Wait for space to appear in the Tx queue or a signal to occur.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) static int rxrpc_wait_for_tx_window_intr(struct rxrpc_sock *rx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 					 struct rxrpc_call *call,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 					 long *timeo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	for (;;) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 		set_current_state(TASK_INTERRUPTIBLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 		if (rxrpc_check_tx_space(call, NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 			return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 		if (call->state >= RXRPC_CALL_COMPLETE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 			return call->error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		if (signal_pending(current))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 			return sock_intr_errno(*timeo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 		trace_rxrpc_transmit(call, rxrpc_transmit_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		mutex_unlock(&call->user_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 		*timeo = schedule_timeout(*timeo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		if (mutex_lock_interruptible(&call->user_mutex) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 			return sock_intr_errno(*timeo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)  * Wait for space to appear in the Tx queue uninterruptibly, but with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)  * a timeout of 2*RTT if no progress was made and a signal occurred.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) static int rxrpc_wait_for_tx_window_waitall(struct rxrpc_sock *rx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 					    struct rxrpc_call *call)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	rxrpc_seq_t tx_start, tx_win;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	signed long rtt, timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	rtt = READ_ONCE(call->peer->srtt_us) >> 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	rtt = usecs_to_jiffies(rtt) * 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	if (rtt < 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		rtt = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	timeout = rtt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	tx_start = READ_ONCE(call->tx_hard_ack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	for (;;) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		set_current_state(TASK_UNINTERRUPTIBLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		tx_win = READ_ONCE(call->tx_hard_ack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		if (rxrpc_check_tx_space(call, &tx_win))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 			return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		if (call->state >= RXRPC_CALL_COMPLETE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 			return call->error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		if (timeout == 0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		    tx_win == tx_start && signal_pending(current))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 			return -EINTR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		if (tx_win != tx_start) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 			timeout = rtt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 			tx_start = tx_win;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		trace_rxrpc_transmit(call, rxrpc_transmit_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		timeout = schedule_timeout(timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  * Wait for space to appear in the Tx queue uninterruptibly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) static int rxrpc_wait_for_tx_window_nonintr(struct rxrpc_sock *rx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 					    struct rxrpc_call *call,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 					    long *timeo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	for (;;) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		set_current_state(TASK_UNINTERRUPTIBLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		if (rxrpc_check_tx_space(call, NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 			return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		if (call->state >= RXRPC_CALL_COMPLETE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 			return call->error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		trace_rxrpc_transmit(call, rxrpc_transmit_wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		*timeo = schedule_timeout(*timeo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)  * wait for space to appear in the transmit/ACK window
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)  * - caller holds the socket locked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) static int rxrpc_wait_for_tx_window(struct rxrpc_sock *rx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 				    struct rxrpc_call *call,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 				    long *timeo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 				    bool waitall)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	DECLARE_WAITQUEUE(myself, current);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	_enter(",{%u,%u,%u}",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	       call->tx_hard_ack, call->tx_top, call->tx_winsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	add_wait_queue(&call->waitq, &myself);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	switch (call->interruptibility) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	case RXRPC_INTERRUPTIBLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		if (waitall)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 			ret = rxrpc_wait_for_tx_window_waitall(rx, call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 			ret = rxrpc_wait_for_tx_window_intr(rx, call, timeo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	case RXRPC_PREINTERRUPTIBLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	case RXRPC_UNINTERRUPTIBLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		ret = rxrpc_wait_for_tx_window_nonintr(rx, call, timeo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	remove_wait_queue(&call->waitq, &myself);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	set_current_state(TASK_RUNNING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	_leave(" = %d", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  * Schedule an instant Tx resend.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) static inline void rxrpc_instant_resend(struct rxrpc_call *call, int ix)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	spin_lock_bh(&call->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	if (call->state < RXRPC_CALL_COMPLETE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		call->rxtx_annotations[ix] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 			(call->rxtx_annotations[ix] & RXRPC_TX_ANNO_LAST) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 			RXRPC_TX_ANNO_RETRANS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		if (!test_and_set_bit(RXRPC_CALL_EV_RESEND, &call->events))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 			rxrpc_queue_call(call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	spin_unlock_bh(&call->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)  * Notify the owner of the call that the transmit phase is ended and the last
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)  * packet has been queued.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) static void rxrpc_notify_end_tx(struct rxrpc_sock *rx, struct rxrpc_call *call,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 				rxrpc_notify_end_tx_t notify_end_tx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	if (notify_end_tx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		notify_end_tx(&rx->sk, call, call->user_call_ID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)  * Queue a DATA packet for transmission, set the resend timeout and send
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)  * the packet immediately.  Returns the error from rxrpc_send_data_packet()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)  * in case the caller wants to do something with it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) static int rxrpc_queue_packet(struct rxrpc_sock *rx, struct rxrpc_call *call,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 			      struct sk_buff *skb, bool last,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 			      rxrpc_notify_end_tx_t notify_end_tx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	unsigned long now;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	rxrpc_seq_t seq = sp->hdr.seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	int ret, ix;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	u8 annotation = RXRPC_TX_ANNO_UNACK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	_net("queue skb %p [%d]", skb, seq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	ASSERTCMP(seq, ==, call->tx_top + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	if (last)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		annotation |= RXRPC_TX_ANNO_LAST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	/* We have to set the timestamp before queueing as the retransmit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	 * algorithm can see the packet as soon as we queue it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	skb->tstamp = ktime_get_real();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	ix = seq & RXRPC_RXTX_BUFF_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	rxrpc_get_skb(skb, rxrpc_skb_got);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	call->rxtx_annotations[ix] = annotation;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	smp_wmb();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	call->rxtx_buffer[ix] = skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	call->tx_top = seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	if (last)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		trace_rxrpc_transmit(call, rxrpc_transmit_queue_last);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		trace_rxrpc_transmit(call, rxrpc_transmit_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	if (last || call->state == RXRPC_CALL_SERVER_ACK_REQUEST) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		_debug("________awaiting reply/ACK__________");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		write_lock_bh(&call->state_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		switch (call->state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		case RXRPC_CALL_CLIENT_SEND_REQUEST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 			call->state = RXRPC_CALL_CLIENT_AWAIT_REPLY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 			rxrpc_notify_end_tx(rx, call, notify_end_tx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		case RXRPC_CALL_SERVER_ACK_REQUEST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 			call->state = RXRPC_CALL_SERVER_SEND_REPLY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 			now = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 			WRITE_ONCE(call->ack_at, now + MAX_JIFFY_OFFSET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 			if (call->ackr_reason == RXRPC_ACK_DELAY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 				call->ackr_reason = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 			trace_rxrpc_timer(call, rxrpc_timer_init_for_send_reply, now);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 			if (!last)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 			fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		case RXRPC_CALL_SERVER_SEND_REPLY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 			call->state = RXRPC_CALL_SERVER_AWAIT_ACK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 			rxrpc_notify_end_tx(rx, call, notify_end_tx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		write_unlock_bh(&call->state_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	if (seq == 1 && rxrpc_is_client_call(call))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		rxrpc_expose_client_call(call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	ret = rxrpc_send_data_packet(call, skb, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		switch (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 		case -ENETUNREACH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 		case -EHOSTUNREACH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 		case -ECONNREFUSED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 			rxrpc_set_call_completion(call, RXRPC_CALL_LOCAL_ERROR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 						  0, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 		_debug("need instant resend %d", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 		rxrpc_instant_resend(call, ix);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		unsigned long now = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 		unsigned long resend_at = now + call->peer->rto_j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 		WRITE_ONCE(call->resend_at, resend_at);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 		rxrpc_reduce_call_timer(call, resend_at, now,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 					rxrpc_timer_set_for_send);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	rxrpc_free_skb(skb, rxrpc_skb_freed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	_leave(" = %d", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)  * send data through a socket
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)  * - must be called in process context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)  * - The caller holds the call user access mutex, but not the socket lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) static int rxrpc_send_data(struct rxrpc_sock *rx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 			   struct rxrpc_call *call,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 			   struct msghdr *msg, size_t len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 			   rxrpc_notify_end_tx_t notify_end_tx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	struct rxrpc_skb_priv *sp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	struct sk_buff *skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	struct sock *sk = &rx->sk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	long timeo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	bool more;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	int ret, copied;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	timeo = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	/* this should be in poll */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	if (sk->sk_shutdown & SEND_SHUTDOWN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 		return -EPIPE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	more = msg->msg_flags & MSG_MORE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	if (call->tx_total_len != -1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 		if (len > call->tx_total_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 			return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 		if (!more && len != call->tx_total_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 			return -EMSGSIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	skb = call->tx_pending;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	call->tx_pending = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	rxrpc_see_skb(skb, rxrpc_skb_seen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	copied = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 		/* Check to see if there's a ping ACK to reply to. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 		if (call->ackr_reason == RXRPC_ACK_PING_RESPONSE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 			rxrpc_send_ack_packet(call, false, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 		if (!skb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 			size_t size, chunk, max, space;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 			_debug("alloc");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 			if (!rxrpc_check_tx_space(call, NULL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 				ret = -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 				if (msg->msg_flags & MSG_DONTWAIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 					goto maybe_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 				ret = rxrpc_wait_for_tx_window(rx, call,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 							       &timeo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 							       msg->msg_flags & MSG_WAITALL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 				if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 					goto maybe_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 			max = RXRPC_JUMBO_DATALEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 			max -= call->conn->security_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 			max &= ~(call->conn->size_align - 1UL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 			chunk = max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 			if (chunk > msg_data_left(msg) && !more)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 				chunk = msg_data_left(msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 			space = chunk + call->conn->size_align;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 			space &= ~(call->conn->size_align - 1UL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 			size = space + call->conn->security_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 			_debug("SIZE: %zu/%zu/%zu", chunk, space, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 			/* create a buffer that we can retain until it's ACK'd */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 			skb = sock_alloc_send_skb(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 				sk, size, msg->msg_flags & MSG_DONTWAIT, &ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 			if (!skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 				goto maybe_error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 			sp = rxrpc_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 			sp->rx_flags |= RXRPC_SKB_TX_BUFFER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 			rxrpc_new_skb(skb, rxrpc_skb_new);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 			_debug("ALLOC SEND %p", skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 			ASSERTCMP(skb->mark, ==, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 			_debug("HS: %u", call->conn->security_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 			skb_reserve(skb, call->conn->security_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 			skb->len += call->conn->security_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 			sp->remain = chunk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 			if (sp->remain > skb_tailroom(skb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 				sp->remain = skb_tailroom(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 			_net("skb: hr %d, tr %d, hl %d, rm %d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 			       skb_headroom(skb),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 			       skb_tailroom(skb),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 			       skb_headlen(skb),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 			       sp->remain);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 			skb->ip_summed = CHECKSUM_UNNECESSARY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 		_debug("append");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 		sp = rxrpc_skb(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 		/* append next segment of data to the current buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 		if (msg_data_left(msg) > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 			int copy = skb_tailroom(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 			ASSERTCMP(copy, >, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 			if (copy > msg_data_left(msg))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 				copy = msg_data_left(msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 			if (copy > sp->remain)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 				copy = sp->remain;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 			_debug("add");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 			ret = skb_add_data(skb, &msg->msg_iter, copy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 			_debug("added");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 			if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 				goto efault;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 			sp->remain -= copy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 			skb->mark += copy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 			copied += copy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 			if (call->tx_total_len != -1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 				call->tx_total_len -= copy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 		/* check for the far side aborting the call or a network error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 		 * occurring */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 		if (call->state == RXRPC_CALL_COMPLETE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 			goto call_terminated;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 		/* add the packet to the send queue if it's now full */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 		if (sp->remain <= 0 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 		    (msg_data_left(msg) == 0 && !more)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 			struct rxrpc_connection *conn = call->conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 			uint32_t seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 			size_t pad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 			/* pad out if we're using security */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 			if (conn->security_ix) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 				pad = conn->security_size + skb->mark;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 				pad = conn->size_align - pad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 				pad &= conn->size_align - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 				_debug("pad %zu", pad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 				if (pad)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 					skb_put_zero(skb, pad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 			seq = call->tx_top + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 			sp->hdr.seq	= seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 			sp->hdr._rsvd	= 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 			sp->hdr.flags	= conn->out_clientflag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 			if (msg_data_left(msg) == 0 && !more)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 				sp->hdr.flags |= RXRPC_LAST_PACKET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 			else if (call->tx_top - call->tx_hard_ack <
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 				 call->tx_winsize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 				sp->hdr.flags |= RXRPC_MORE_PACKETS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 			ret = call->security->secure_packet(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 				call, skb, skb->mark, skb->head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 			if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 				goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 			ret = rxrpc_queue_packet(rx, call, skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 						 !msg_data_left(msg) && !more,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 						 notify_end_tx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 			/* Should check for failure here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 			skb = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 	} while (msg_data_left(msg) > 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) success:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 	ret = copied;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	call->tx_pending = skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	_leave(" = %d", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) call_terminated:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	rxrpc_free_skb(skb, rxrpc_skb_freed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	_leave(" = %d", call->error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 	return call->error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) maybe_error:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 	if (copied)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 		goto success;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) efault:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 	ret = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)  * extract control messages from the sendmsg() control buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) static int rxrpc_sendmsg_cmsg(struct msghdr *msg, struct rxrpc_send_params *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 	struct cmsghdr *cmsg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 	bool got_user_ID = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 	if (msg->msg_controllen == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 	for_each_cmsghdr(cmsg, msg) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 		if (!CMSG_OK(msg, cmsg))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 		len = cmsg->cmsg_len - sizeof(struct cmsghdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 		_debug("CMSG %d, %d, %d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 		       cmsg->cmsg_level, cmsg->cmsg_type, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 		if (cmsg->cmsg_level != SOL_RXRPC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 		switch (cmsg->cmsg_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 		case RXRPC_USER_CALL_ID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 			if (msg->msg_flags & MSG_CMSG_COMPAT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 				if (len != sizeof(u32))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 					return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 				p->call.user_call_ID = *(u32 *)CMSG_DATA(cmsg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 			} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 				if (len != sizeof(unsigned long))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 					return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 				p->call.user_call_ID = *(unsigned long *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 					CMSG_DATA(cmsg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 			got_user_ID = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 		case RXRPC_ABORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 			if (p->command != RXRPC_CMD_SEND_DATA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 				return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 			p->command = RXRPC_CMD_SEND_ABORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 			if (len != sizeof(p->abort_code))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 				return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 			p->abort_code = *(unsigned int *)CMSG_DATA(cmsg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 			if (p->abort_code == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 				return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 		case RXRPC_CHARGE_ACCEPT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 			if (p->command != RXRPC_CMD_SEND_DATA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 				return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 			p->command = RXRPC_CMD_CHARGE_ACCEPT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 			if (len != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 				return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 		case RXRPC_EXCLUSIVE_CALL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 			p->exclusive = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 			if (len != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 				return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 		case RXRPC_UPGRADE_SERVICE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 			p->upgrade = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 			if (len != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 				return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 		case RXRPC_TX_LENGTH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 			if (p->call.tx_total_len != -1 || len != sizeof(__s64))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 				return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 			p->call.tx_total_len = *(__s64 *)CMSG_DATA(cmsg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 			if (p->call.tx_total_len < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 				return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 		case RXRPC_SET_CALL_TIMEOUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 			if (len & 3 || len < 4 || len > 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 				return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 			memcpy(&p->call.timeouts, CMSG_DATA(cmsg), len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 			p->call.nr_timeouts = len / 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 			if (p->call.timeouts.hard > INT_MAX / HZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 				return -ERANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 			if (p->call.nr_timeouts >= 2 && p->call.timeouts.idle > 60 * 60 * 1000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 				return -ERANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 			if (p->call.nr_timeouts >= 3 && p->call.timeouts.normal > 60 * 60 * 1000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 				return -ERANGE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 	if (!got_user_ID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 	if (p->call.tx_total_len != -1 && p->command != RXRPC_CMD_SEND_DATA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 	_leave(" = 0");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588)  * Create a new client call for sendmsg().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589)  * - Called with the socket lock held, which it must release.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590)  * - If it returns a call, the call's lock will need releasing by the caller.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) static struct rxrpc_call *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) rxrpc_new_client_call_for_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 				  struct rxrpc_send_params *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 	__releases(&rx->sk.sk_lock.slock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 	__acquires(&call->user_mutex)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 	struct rxrpc_conn_parameters cp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 	struct rxrpc_call *call;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 	struct key *key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) 	DECLARE_SOCKADDR(struct sockaddr_rxrpc *, srx, msg->msg_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 	_enter("");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 	if (!msg->msg_name) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 		release_sock(&rx->sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 		return ERR_PTR(-EDESTADDRREQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 	key = rx->key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 	if (key && !rx->key->payload.data[0])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 		key = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 	memset(&cp, 0, sizeof(cp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 	cp.local		= rx->local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 	cp.key			= rx->key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 	cp.security_level	= rx->min_sec_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) 	cp.exclusive		= rx->exclusive | p->exclusive;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 	cp.upgrade		= p->upgrade;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 	cp.service_id		= srx->srx_service;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 	call = rxrpc_new_client_call(rx, &cp, srx, &p->call, GFP_KERNEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) 				     atomic_inc_return(&rxrpc_debug_id));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 	/* The socket is now unlocked */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) 	rxrpc_put_peer(cp.peer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) 	_leave(" = %p\n", call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) 	return call;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632)  * send a message forming part of a client call through an RxRPC socket
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633)  * - caller holds the socket locked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634)  * - the socket may be either a client socket or a server socket
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 	__releases(&rx->sk.sk_lock.slock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) 	__releases(&call->user_mutex)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) 	enum rxrpc_call_state state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) 	struct rxrpc_call *call;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) 	unsigned long now, j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 	struct rxrpc_send_params p = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 		.call.tx_total_len	= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) 		.call.user_call_ID	= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) 		.call.nr_timeouts	= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) 		.call.interruptibility	= RXRPC_INTERRUPTIBLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) 		.abort_code		= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) 		.command		= RXRPC_CMD_SEND_DATA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) 		.exclusive		= false,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) 		.upgrade		= false,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) 	_enter("");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) 	ret = rxrpc_sendmsg_cmsg(msg, &p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) 		goto error_release_sock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) 	if (p.command == RXRPC_CMD_CHARGE_ACCEPT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) 		ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) 		if (rx->sk.sk_state != RXRPC_SERVER_LISTENING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) 			goto error_release_sock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) 		ret = rxrpc_user_charge_accept(rx, p.call.user_call_ID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) 		goto error_release_sock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) 	call = rxrpc_find_call_by_user_ID(rx, p.call.user_call_ID);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) 	if (!call) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) 		ret = -EBADSLT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) 		if (p.command != RXRPC_CMD_SEND_DATA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) 			goto error_release_sock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) 		call = rxrpc_new_client_call_for_sendmsg(rx, msg, &p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) 		/* The socket is now unlocked... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) 		if (IS_ERR(call))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) 			return PTR_ERR(call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) 		/* ... and we have the call lock. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) 		ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) 		if (READ_ONCE(call->state) == RXRPC_CALL_COMPLETE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) 			goto out_put_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) 		switch (READ_ONCE(call->state)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) 		case RXRPC_CALL_UNINITIALISED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) 		case RXRPC_CALL_CLIENT_AWAIT_CONN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) 		case RXRPC_CALL_SERVER_PREALLOC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) 		case RXRPC_CALL_SERVER_SECURING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) 			rxrpc_put_call(call, rxrpc_call_put);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) 			ret = -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) 			goto error_release_sock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) 		ret = mutex_lock_interruptible(&call->user_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) 		release_sock(&rx->sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) 		if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) 			ret = -ERESTARTSYS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) 			goto error_put;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) 		if (p.call.tx_total_len != -1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) 			ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) 			if (call->tx_total_len != -1 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) 			    call->tx_pending ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) 			    call->tx_top != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) 				goto error_put;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) 			call->tx_total_len = p.call.tx_total_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) 	switch (p.call.nr_timeouts) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) 	case 3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) 		j = msecs_to_jiffies(p.call.timeouts.normal);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) 		if (p.call.timeouts.normal > 0 && j == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) 			j = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) 		WRITE_ONCE(call->next_rx_timo, j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) 		fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) 	case 2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) 		j = msecs_to_jiffies(p.call.timeouts.idle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) 		if (p.call.timeouts.idle > 0 && j == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) 			j = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) 		WRITE_ONCE(call->next_req_timo, j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) 		fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) 	case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) 		if (p.call.timeouts.hard > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) 			j = msecs_to_jiffies(p.call.timeouts.hard);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) 			now = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) 			j += now;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) 			WRITE_ONCE(call->expect_term_by, j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) 			rxrpc_reduce_call_timer(call, j, now,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) 						rxrpc_timer_set_for_hard);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) 	state = READ_ONCE(call->state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) 	_debug("CALL %d USR %lx ST %d on CONN %p",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) 	       call->debug_id, call->user_call_ID, state, call->conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) 	if (state >= RXRPC_CALL_COMPLETE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) 		/* it's too late for this call */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) 		ret = -ESHUTDOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) 	} else if (p.command == RXRPC_CMD_SEND_ABORT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) 		ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) 		if (rxrpc_abort_call("CMD", call, 0, p.abort_code, -ECONNABORTED))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) 			ret = rxrpc_send_abort_packet(call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) 	} else if (p.command != RXRPC_CMD_SEND_DATA) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) 		ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) 	} else if (rxrpc_is_client_call(call) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) 		   state != RXRPC_CALL_CLIENT_SEND_REQUEST) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) 		/* request phase complete for this client call */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) 		ret = -EPROTO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) 	} else if (rxrpc_is_service_call(call) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) 		   state != RXRPC_CALL_SERVER_ACK_REQUEST &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) 		   state != RXRPC_CALL_SERVER_SEND_REPLY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) 		/* Reply phase not begun or not complete for service call. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) 		ret = -EPROTO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) 		ret = rxrpc_send_data(rx, call, msg, len, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) out_put_unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) 	mutex_unlock(&call->user_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) error_put:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) 	rxrpc_put_call(call, rxrpc_call_put);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) 	_leave(" = %d", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) error_release_sock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) 	release_sock(&rx->sk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777)  * rxrpc_kernel_send_data - Allow a kernel service to send data on a call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778)  * @sock: The socket the call is on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779)  * @call: The call to send data through
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780)  * @msg: The data to send
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781)  * @len: The amount of data to send
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782)  * @notify_end_tx: Notification that the last packet is queued.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784)  * Allow a kernel service to send data on a call.  The call must be in an state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785)  * appropriate to sending data.  No control data should be supplied in @msg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786)  * nor should an address be supplied.  MSG_MORE should be flagged if there's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787)  * more data to come, otherwise this data will end the transmission phase.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) int rxrpc_kernel_send_data(struct socket *sock, struct rxrpc_call *call,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) 			   struct msghdr *msg, size_t len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) 			   rxrpc_notify_end_tx_t notify_end_tx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) 	_enter("{%d,%s},", call->debug_id, rxrpc_call_states[call->state]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) 	ASSERTCMP(msg->msg_name, ==, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) 	ASSERTCMP(msg->msg_control, ==, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) 	mutex_lock(&call->user_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) 	_debug("CALL %d USR %lx ST %d on CONN %p",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) 	       call->debug_id, call->user_call_ID, call->state, call->conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) 	switch (READ_ONCE(call->state)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) 	case RXRPC_CALL_CLIENT_SEND_REQUEST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) 	case RXRPC_CALL_SERVER_ACK_REQUEST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) 	case RXRPC_CALL_SERVER_SEND_REPLY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) 		ret = rxrpc_send_data(rxrpc_sk(sock->sk), call, msg, len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) 				      notify_end_tx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) 	case RXRPC_CALL_COMPLETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) 		read_lock_bh(&call->state_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) 		ret = call->error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) 		read_unlock_bh(&call->state_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) 		/* Request phase complete for this client call */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) 		trace_rxrpc_rx_eproto(call, 0, tracepoint_string("late_send"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) 		ret = -EPROTO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) 	mutex_unlock(&call->user_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) 	_leave(" = %d", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) EXPORT_SYMBOL(rxrpc_kernel_send_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831)  * rxrpc_kernel_abort_call - Allow a kernel service to abort a call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832)  * @sock: The socket the call is on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833)  * @call: The call to be aborted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834)  * @abort_code: The abort code to stick into the ABORT packet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835)  * @error: Local error value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836)  * @why: 3-char string indicating why.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838)  * Allow a kernel service to abort a call, if it's still in an abortable state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839)  * and return true if the call was aborted, false if it was already complete.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) bool rxrpc_kernel_abort_call(struct socket *sock, struct rxrpc_call *call,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) 			     u32 abort_code, int error, const char *why)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) 	bool aborted;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) 	_enter("{%d},%d,%d,%s", call->debug_id, abort_code, error, why);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) 	mutex_lock(&call->user_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) 	aborted = rxrpc_abort_call(why, call, 0, abort_code, error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) 	if (aborted)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) 		rxrpc_send_abort_packet(call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) 	mutex_unlock(&call->user_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) 	return aborted;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) EXPORT_SYMBOL(rxrpc_kernel_abort_call);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860)  * rxrpc_kernel_set_tx_length - Set the total Tx length on a call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861)  * @sock: The socket the call is on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862)  * @call: The call to be informed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863)  * @tx_total_len: The amount of data to be transmitted for this call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865)  * Allow a kernel service to set the total transmit length on a call.  This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866)  * allows buffer-to-packet encrypt-and-copy to be performed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868)  * This function is primarily for use for setting the reply length since the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869)  * request length can be set when beginning the call.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) void rxrpc_kernel_set_tx_length(struct socket *sock, struct rxrpc_call *call,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) 				s64 tx_total_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) 	WARN_ON(call->tx_total_len != -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) 	call->tx_total_len = tx_total_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) EXPORT_SYMBOL(rxrpc_kernel_set_tx_length);