xref: /OK3568_Linux_fs/kernel/net/rxrpc/output.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0-or-later
2*4882a593Smuzhiyun /* RxRPC packet transmission
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
5*4882a593Smuzhiyun  * Written by David Howells (dhowells@redhat.com)
6*4882a593Smuzhiyun  */
7*4882a593Smuzhiyun 
8*4882a593Smuzhiyun #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun #include <linux/net.h>
11*4882a593Smuzhiyun #include <linux/gfp.h>
12*4882a593Smuzhiyun #include <linux/skbuff.h>
13*4882a593Smuzhiyun #include <linux/export.h>
14*4882a593Smuzhiyun #include <net/sock.h>
15*4882a593Smuzhiyun #include <net/af_rxrpc.h>
16*4882a593Smuzhiyun #include "ar-internal.h"
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun struct rxrpc_ack_buffer {
19*4882a593Smuzhiyun 	struct rxrpc_wire_header whdr;
20*4882a593Smuzhiyun 	struct rxrpc_ackpacket ack;
21*4882a593Smuzhiyun 	u8 acks[255];
22*4882a593Smuzhiyun 	u8 pad[3];
23*4882a593Smuzhiyun 	struct rxrpc_ackinfo ackinfo;
24*4882a593Smuzhiyun };
25*4882a593Smuzhiyun 
26*4882a593Smuzhiyun struct rxrpc_abort_buffer {
27*4882a593Smuzhiyun 	struct rxrpc_wire_header whdr;
28*4882a593Smuzhiyun 	__be32 abort_code;
29*4882a593Smuzhiyun };
30*4882a593Smuzhiyun 
31*4882a593Smuzhiyun static const char rxrpc_keepalive_string[] = "";
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun /*
34*4882a593Smuzhiyun  * Increase Tx backoff on transmission failure and clear it on success.
35*4882a593Smuzhiyun  */
rxrpc_tx_backoff(struct rxrpc_call * call,int ret)36*4882a593Smuzhiyun static void rxrpc_tx_backoff(struct rxrpc_call *call, int ret)
37*4882a593Smuzhiyun {
38*4882a593Smuzhiyun 	if (ret < 0) {
39*4882a593Smuzhiyun 		u16 tx_backoff = READ_ONCE(call->tx_backoff);
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun 		if (tx_backoff < HZ)
42*4882a593Smuzhiyun 			WRITE_ONCE(call->tx_backoff, tx_backoff + 1);
43*4882a593Smuzhiyun 	} else {
44*4882a593Smuzhiyun 		WRITE_ONCE(call->tx_backoff, 0);
45*4882a593Smuzhiyun 	}
46*4882a593Smuzhiyun }
47*4882a593Smuzhiyun 
48*4882a593Smuzhiyun /*
49*4882a593Smuzhiyun  * Arrange for a keepalive ping a certain time after we last transmitted.  This
50*4882a593Smuzhiyun  * lets the far side know we're still interested in this call and helps keep
51*4882a593Smuzhiyun  * the route through any intervening firewall open.
52*4882a593Smuzhiyun  *
53*4882a593Smuzhiyun  * Receiving a response to the ping will prevent the ->expect_rx_by timer from
54*4882a593Smuzhiyun  * expiring.
55*4882a593Smuzhiyun  */
rxrpc_set_keepalive(struct rxrpc_call * call)56*4882a593Smuzhiyun static void rxrpc_set_keepalive(struct rxrpc_call *call)
57*4882a593Smuzhiyun {
58*4882a593Smuzhiyun 	unsigned long now = jiffies, keepalive_at = call->next_rx_timo / 6;
59*4882a593Smuzhiyun 
60*4882a593Smuzhiyun 	keepalive_at += now;
61*4882a593Smuzhiyun 	WRITE_ONCE(call->keepalive_at, keepalive_at);
62*4882a593Smuzhiyun 	rxrpc_reduce_call_timer(call, keepalive_at, now,
63*4882a593Smuzhiyun 				rxrpc_timer_set_for_keepalive);
64*4882a593Smuzhiyun }
65*4882a593Smuzhiyun 
66*4882a593Smuzhiyun /*
67*4882a593Smuzhiyun  * Fill out an ACK packet.
68*4882a593Smuzhiyun  */
rxrpc_fill_out_ack(struct rxrpc_connection * conn,struct rxrpc_call * call,struct rxrpc_ack_buffer * pkt,rxrpc_seq_t * _hard_ack,rxrpc_seq_t * _top,u8 reason)69*4882a593Smuzhiyun static size_t rxrpc_fill_out_ack(struct rxrpc_connection *conn,
70*4882a593Smuzhiyun 				 struct rxrpc_call *call,
71*4882a593Smuzhiyun 				 struct rxrpc_ack_buffer *pkt,
72*4882a593Smuzhiyun 				 rxrpc_seq_t *_hard_ack,
73*4882a593Smuzhiyun 				 rxrpc_seq_t *_top,
74*4882a593Smuzhiyun 				 u8 reason)
75*4882a593Smuzhiyun {
76*4882a593Smuzhiyun 	rxrpc_serial_t serial;
77*4882a593Smuzhiyun 	unsigned int tmp;
78*4882a593Smuzhiyun 	rxrpc_seq_t hard_ack, top, seq;
79*4882a593Smuzhiyun 	int ix;
80*4882a593Smuzhiyun 	u32 mtu, jmax;
81*4882a593Smuzhiyun 	u8 *ackp = pkt->acks;
82*4882a593Smuzhiyun 
83*4882a593Smuzhiyun 	tmp = atomic_xchg(&call->ackr_nr_unacked, 0);
84*4882a593Smuzhiyun 	tmp |= atomic_xchg(&call->ackr_nr_consumed, 0);
85*4882a593Smuzhiyun 	if (!tmp && (reason == RXRPC_ACK_DELAY ||
86*4882a593Smuzhiyun 		     reason == RXRPC_ACK_IDLE))
87*4882a593Smuzhiyun 		return 0;
88*4882a593Smuzhiyun 
89*4882a593Smuzhiyun 	/* Barrier against rxrpc_input_data(). */
90*4882a593Smuzhiyun 	serial = call->ackr_serial;
91*4882a593Smuzhiyun 	hard_ack = READ_ONCE(call->rx_hard_ack);
92*4882a593Smuzhiyun 	top = smp_load_acquire(&call->rx_top);
93*4882a593Smuzhiyun 	*_hard_ack = hard_ack;
94*4882a593Smuzhiyun 	*_top = top;
95*4882a593Smuzhiyun 
96*4882a593Smuzhiyun 	pkt->ack.bufferSpace	= htons(8);
97*4882a593Smuzhiyun 	pkt->ack.maxSkew	= htons(0);
98*4882a593Smuzhiyun 	pkt->ack.firstPacket	= htonl(hard_ack + 1);
99*4882a593Smuzhiyun 	pkt->ack.previousPacket	= htonl(call->ackr_highest_seq);
100*4882a593Smuzhiyun 	pkt->ack.serial		= htonl(serial);
101*4882a593Smuzhiyun 	pkt->ack.reason		= reason;
102*4882a593Smuzhiyun 	pkt->ack.nAcks		= top - hard_ack;
103*4882a593Smuzhiyun 
104*4882a593Smuzhiyun 	if (reason == RXRPC_ACK_PING)
105*4882a593Smuzhiyun 		pkt->whdr.flags |= RXRPC_REQUEST_ACK;
106*4882a593Smuzhiyun 
107*4882a593Smuzhiyun 	if (after(top, hard_ack)) {
108*4882a593Smuzhiyun 		seq = hard_ack + 1;
109*4882a593Smuzhiyun 		do {
110*4882a593Smuzhiyun 			ix = seq & RXRPC_RXTX_BUFF_MASK;
111*4882a593Smuzhiyun 			if (call->rxtx_buffer[ix])
112*4882a593Smuzhiyun 				*ackp++ = RXRPC_ACK_TYPE_ACK;
113*4882a593Smuzhiyun 			else
114*4882a593Smuzhiyun 				*ackp++ = RXRPC_ACK_TYPE_NACK;
115*4882a593Smuzhiyun 			seq++;
116*4882a593Smuzhiyun 		} while (before_eq(seq, top));
117*4882a593Smuzhiyun 	}
118*4882a593Smuzhiyun 
119*4882a593Smuzhiyun 	mtu = conn->params.peer->if_mtu;
120*4882a593Smuzhiyun 	mtu -= conn->params.peer->hdrsize;
121*4882a593Smuzhiyun 	jmax = (call->nr_jumbo_bad > 3) ? 1 : rxrpc_rx_jumbo_max;
122*4882a593Smuzhiyun 	pkt->ackinfo.rxMTU	= htonl(rxrpc_rx_mtu);
123*4882a593Smuzhiyun 	pkt->ackinfo.maxMTU	= htonl(mtu);
124*4882a593Smuzhiyun 	pkt->ackinfo.rwind	= htonl(call->rx_winsize);
125*4882a593Smuzhiyun 	pkt->ackinfo.jumbo_max	= htonl(jmax);
126*4882a593Smuzhiyun 
127*4882a593Smuzhiyun 	*ackp++ = 0;
128*4882a593Smuzhiyun 	*ackp++ = 0;
129*4882a593Smuzhiyun 	*ackp++ = 0;
130*4882a593Smuzhiyun 	return top - hard_ack + 3;
131*4882a593Smuzhiyun }
132*4882a593Smuzhiyun 
133*4882a593Smuzhiyun /*
134*4882a593Smuzhiyun  * Record the beginning of an RTT probe.
135*4882a593Smuzhiyun  */
rxrpc_begin_rtt_probe(struct rxrpc_call * call,rxrpc_serial_t serial,enum rxrpc_rtt_tx_trace why)136*4882a593Smuzhiyun static int rxrpc_begin_rtt_probe(struct rxrpc_call *call, rxrpc_serial_t serial,
137*4882a593Smuzhiyun 				 enum rxrpc_rtt_tx_trace why)
138*4882a593Smuzhiyun {
139*4882a593Smuzhiyun 	unsigned long avail = call->rtt_avail;
140*4882a593Smuzhiyun 	int rtt_slot = 9;
141*4882a593Smuzhiyun 
142*4882a593Smuzhiyun 	if (!(avail & RXRPC_CALL_RTT_AVAIL_MASK))
143*4882a593Smuzhiyun 		goto no_slot;
144*4882a593Smuzhiyun 
145*4882a593Smuzhiyun 	rtt_slot = __ffs(avail & RXRPC_CALL_RTT_AVAIL_MASK);
146*4882a593Smuzhiyun 	if (!test_and_clear_bit(rtt_slot, &call->rtt_avail))
147*4882a593Smuzhiyun 		goto no_slot;
148*4882a593Smuzhiyun 
149*4882a593Smuzhiyun 	call->rtt_serial[rtt_slot] = serial;
150*4882a593Smuzhiyun 	call->rtt_sent_at[rtt_slot] = ktime_get_real();
151*4882a593Smuzhiyun 	smp_wmb(); /* Write data before avail bit */
152*4882a593Smuzhiyun 	set_bit(rtt_slot + RXRPC_CALL_RTT_PEND_SHIFT, &call->rtt_avail);
153*4882a593Smuzhiyun 
154*4882a593Smuzhiyun 	trace_rxrpc_rtt_tx(call, why, rtt_slot, serial);
155*4882a593Smuzhiyun 	return rtt_slot;
156*4882a593Smuzhiyun 
157*4882a593Smuzhiyun no_slot:
158*4882a593Smuzhiyun 	trace_rxrpc_rtt_tx(call, rxrpc_rtt_tx_no_slot, rtt_slot, serial);
159*4882a593Smuzhiyun 	return -1;
160*4882a593Smuzhiyun }
161*4882a593Smuzhiyun 
162*4882a593Smuzhiyun /*
163*4882a593Smuzhiyun  * Cancel an RTT probe.
164*4882a593Smuzhiyun  */
rxrpc_cancel_rtt_probe(struct rxrpc_call * call,rxrpc_serial_t serial,int rtt_slot)165*4882a593Smuzhiyun static void rxrpc_cancel_rtt_probe(struct rxrpc_call *call,
166*4882a593Smuzhiyun 				   rxrpc_serial_t serial, int rtt_slot)
167*4882a593Smuzhiyun {
168*4882a593Smuzhiyun 	if (rtt_slot != -1) {
169*4882a593Smuzhiyun 		clear_bit(rtt_slot + RXRPC_CALL_RTT_PEND_SHIFT, &call->rtt_avail);
170*4882a593Smuzhiyun 		smp_wmb(); /* Clear pending bit before setting slot */
171*4882a593Smuzhiyun 		set_bit(rtt_slot, &call->rtt_avail);
172*4882a593Smuzhiyun 		trace_rxrpc_rtt_tx(call, rxrpc_rtt_tx_cancel, rtt_slot, serial);
173*4882a593Smuzhiyun 	}
174*4882a593Smuzhiyun }
175*4882a593Smuzhiyun 
176*4882a593Smuzhiyun /*
177*4882a593Smuzhiyun  * Send an ACK call packet.
178*4882a593Smuzhiyun  */
rxrpc_send_ack_packet(struct rxrpc_call * call,bool ping,rxrpc_serial_t * _serial)179*4882a593Smuzhiyun int rxrpc_send_ack_packet(struct rxrpc_call *call, bool ping,
180*4882a593Smuzhiyun 			  rxrpc_serial_t *_serial)
181*4882a593Smuzhiyun {
182*4882a593Smuzhiyun 	struct rxrpc_connection *conn;
183*4882a593Smuzhiyun 	struct rxrpc_ack_buffer *pkt;
184*4882a593Smuzhiyun 	struct msghdr msg;
185*4882a593Smuzhiyun 	struct kvec iov[2];
186*4882a593Smuzhiyun 	rxrpc_serial_t serial;
187*4882a593Smuzhiyun 	rxrpc_seq_t hard_ack, top;
188*4882a593Smuzhiyun 	size_t len, n;
189*4882a593Smuzhiyun 	int ret, rtt_slot = -1;
190*4882a593Smuzhiyun 	u8 reason;
191*4882a593Smuzhiyun 
192*4882a593Smuzhiyun 	if (test_bit(RXRPC_CALL_DISCONNECTED, &call->flags))
193*4882a593Smuzhiyun 		return -ECONNRESET;
194*4882a593Smuzhiyun 
195*4882a593Smuzhiyun 	pkt = kzalloc(sizeof(*pkt), GFP_KERNEL);
196*4882a593Smuzhiyun 	if (!pkt)
197*4882a593Smuzhiyun 		return -ENOMEM;
198*4882a593Smuzhiyun 
199*4882a593Smuzhiyun 	conn = call->conn;
200*4882a593Smuzhiyun 
201*4882a593Smuzhiyun 	msg.msg_name	= &call->peer->srx.transport;
202*4882a593Smuzhiyun 	msg.msg_namelen	= call->peer->srx.transport_len;
203*4882a593Smuzhiyun 	msg.msg_control	= NULL;
204*4882a593Smuzhiyun 	msg.msg_controllen = 0;
205*4882a593Smuzhiyun 	msg.msg_flags	= 0;
206*4882a593Smuzhiyun 
207*4882a593Smuzhiyun 	pkt->whdr.epoch		= htonl(conn->proto.epoch);
208*4882a593Smuzhiyun 	pkt->whdr.cid		= htonl(call->cid);
209*4882a593Smuzhiyun 	pkt->whdr.callNumber	= htonl(call->call_id);
210*4882a593Smuzhiyun 	pkt->whdr.seq		= 0;
211*4882a593Smuzhiyun 	pkt->whdr.type		= RXRPC_PACKET_TYPE_ACK;
212*4882a593Smuzhiyun 	pkt->whdr.flags		= RXRPC_SLOW_START_OK | conn->out_clientflag;
213*4882a593Smuzhiyun 	pkt->whdr.userStatus	= 0;
214*4882a593Smuzhiyun 	pkt->whdr.securityIndex	= call->security_ix;
215*4882a593Smuzhiyun 	pkt->whdr._rsvd		= 0;
216*4882a593Smuzhiyun 	pkt->whdr.serviceId	= htons(call->service_id);
217*4882a593Smuzhiyun 
218*4882a593Smuzhiyun 	spin_lock_bh(&call->lock);
219*4882a593Smuzhiyun 	if (ping) {
220*4882a593Smuzhiyun 		reason = RXRPC_ACK_PING;
221*4882a593Smuzhiyun 	} else {
222*4882a593Smuzhiyun 		reason = call->ackr_reason;
223*4882a593Smuzhiyun 		if (!call->ackr_reason) {
224*4882a593Smuzhiyun 			spin_unlock_bh(&call->lock);
225*4882a593Smuzhiyun 			ret = 0;
226*4882a593Smuzhiyun 			goto out;
227*4882a593Smuzhiyun 		}
228*4882a593Smuzhiyun 		call->ackr_reason = 0;
229*4882a593Smuzhiyun 	}
230*4882a593Smuzhiyun 	n = rxrpc_fill_out_ack(conn, call, pkt, &hard_ack, &top, reason);
231*4882a593Smuzhiyun 
232*4882a593Smuzhiyun 	spin_unlock_bh(&call->lock);
233*4882a593Smuzhiyun 	if (n == 0) {
234*4882a593Smuzhiyun 		kfree(pkt);
235*4882a593Smuzhiyun 		return 0;
236*4882a593Smuzhiyun 	}
237*4882a593Smuzhiyun 
238*4882a593Smuzhiyun 	iov[0].iov_base	= pkt;
239*4882a593Smuzhiyun 	iov[0].iov_len	= sizeof(pkt->whdr) + sizeof(pkt->ack) + n;
240*4882a593Smuzhiyun 	iov[1].iov_base = &pkt->ackinfo;
241*4882a593Smuzhiyun 	iov[1].iov_len	= sizeof(pkt->ackinfo);
242*4882a593Smuzhiyun 	len = iov[0].iov_len + iov[1].iov_len;
243*4882a593Smuzhiyun 
244*4882a593Smuzhiyun 	serial = atomic_inc_return(&conn->serial);
245*4882a593Smuzhiyun 	pkt->whdr.serial = htonl(serial);
246*4882a593Smuzhiyun 	trace_rxrpc_tx_ack(call->debug_id, serial,
247*4882a593Smuzhiyun 			   ntohl(pkt->ack.firstPacket),
248*4882a593Smuzhiyun 			   ntohl(pkt->ack.serial),
249*4882a593Smuzhiyun 			   pkt->ack.reason, pkt->ack.nAcks);
250*4882a593Smuzhiyun 	if (_serial)
251*4882a593Smuzhiyun 		*_serial = serial;
252*4882a593Smuzhiyun 
253*4882a593Smuzhiyun 	if (ping)
254*4882a593Smuzhiyun 		rtt_slot = rxrpc_begin_rtt_probe(call, serial, rxrpc_rtt_tx_ping);
255*4882a593Smuzhiyun 
256*4882a593Smuzhiyun 	ret = kernel_sendmsg(conn->params.local->socket, &msg, iov, 2, len);
257*4882a593Smuzhiyun 	conn->params.peer->last_tx_at = ktime_get_seconds();
258*4882a593Smuzhiyun 	if (ret < 0)
259*4882a593Smuzhiyun 		trace_rxrpc_tx_fail(call->debug_id, serial, ret,
260*4882a593Smuzhiyun 				    rxrpc_tx_point_call_ack);
261*4882a593Smuzhiyun 	else
262*4882a593Smuzhiyun 		trace_rxrpc_tx_packet(call->debug_id, &pkt->whdr,
263*4882a593Smuzhiyun 				      rxrpc_tx_point_call_ack);
264*4882a593Smuzhiyun 	rxrpc_tx_backoff(call, ret);
265*4882a593Smuzhiyun 
266*4882a593Smuzhiyun 	if (call->state < RXRPC_CALL_COMPLETE) {
267*4882a593Smuzhiyun 		if (ret < 0) {
268*4882a593Smuzhiyun 			rxrpc_cancel_rtt_probe(call, serial, rtt_slot);
269*4882a593Smuzhiyun 			rxrpc_propose_ACK(call, pkt->ack.reason,
270*4882a593Smuzhiyun 					  ntohl(pkt->ack.serial),
271*4882a593Smuzhiyun 					  false, true,
272*4882a593Smuzhiyun 					  rxrpc_propose_ack_retry_tx);
273*4882a593Smuzhiyun 		}
274*4882a593Smuzhiyun 
275*4882a593Smuzhiyun 		rxrpc_set_keepalive(call);
276*4882a593Smuzhiyun 	}
277*4882a593Smuzhiyun 
278*4882a593Smuzhiyun out:
279*4882a593Smuzhiyun 	kfree(pkt);
280*4882a593Smuzhiyun 	return ret;
281*4882a593Smuzhiyun }
282*4882a593Smuzhiyun 
283*4882a593Smuzhiyun /*
284*4882a593Smuzhiyun  * Send an ABORT call packet.
285*4882a593Smuzhiyun  */
rxrpc_send_abort_packet(struct rxrpc_call * call)286*4882a593Smuzhiyun int rxrpc_send_abort_packet(struct rxrpc_call *call)
287*4882a593Smuzhiyun {
288*4882a593Smuzhiyun 	struct rxrpc_connection *conn;
289*4882a593Smuzhiyun 	struct rxrpc_abort_buffer pkt;
290*4882a593Smuzhiyun 	struct msghdr msg;
291*4882a593Smuzhiyun 	struct kvec iov[1];
292*4882a593Smuzhiyun 	rxrpc_serial_t serial;
293*4882a593Smuzhiyun 	int ret;
294*4882a593Smuzhiyun 
295*4882a593Smuzhiyun 	/* Don't bother sending aborts for a client call once the server has
296*4882a593Smuzhiyun 	 * hard-ACK'd all of its request data.  After that point, we're not
297*4882a593Smuzhiyun 	 * going to stop the operation proceeding, and whilst we might limit
298*4882a593Smuzhiyun 	 * the reply, it's not worth it if we can send a new call on the same
299*4882a593Smuzhiyun 	 * channel instead, thereby closing off this call.
300*4882a593Smuzhiyun 	 */
301*4882a593Smuzhiyun 	if (rxrpc_is_client_call(call) &&
302*4882a593Smuzhiyun 	    test_bit(RXRPC_CALL_TX_LAST, &call->flags))
303*4882a593Smuzhiyun 		return 0;
304*4882a593Smuzhiyun 
305*4882a593Smuzhiyun 	if (test_bit(RXRPC_CALL_DISCONNECTED, &call->flags))
306*4882a593Smuzhiyun 		return -ECONNRESET;
307*4882a593Smuzhiyun 
308*4882a593Smuzhiyun 	conn = call->conn;
309*4882a593Smuzhiyun 
310*4882a593Smuzhiyun 	msg.msg_name	= &call->peer->srx.transport;
311*4882a593Smuzhiyun 	msg.msg_namelen	= call->peer->srx.transport_len;
312*4882a593Smuzhiyun 	msg.msg_control	= NULL;
313*4882a593Smuzhiyun 	msg.msg_controllen = 0;
314*4882a593Smuzhiyun 	msg.msg_flags	= 0;
315*4882a593Smuzhiyun 
316*4882a593Smuzhiyun 	pkt.whdr.epoch		= htonl(conn->proto.epoch);
317*4882a593Smuzhiyun 	pkt.whdr.cid		= htonl(call->cid);
318*4882a593Smuzhiyun 	pkt.whdr.callNumber	= htonl(call->call_id);
319*4882a593Smuzhiyun 	pkt.whdr.seq		= 0;
320*4882a593Smuzhiyun 	pkt.whdr.type		= RXRPC_PACKET_TYPE_ABORT;
321*4882a593Smuzhiyun 	pkt.whdr.flags		= conn->out_clientflag;
322*4882a593Smuzhiyun 	pkt.whdr.userStatus	= 0;
323*4882a593Smuzhiyun 	pkt.whdr.securityIndex	= call->security_ix;
324*4882a593Smuzhiyun 	pkt.whdr._rsvd		= 0;
325*4882a593Smuzhiyun 	pkt.whdr.serviceId	= htons(call->service_id);
326*4882a593Smuzhiyun 	pkt.abort_code		= htonl(call->abort_code);
327*4882a593Smuzhiyun 
328*4882a593Smuzhiyun 	iov[0].iov_base	= &pkt;
329*4882a593Smuzhiyun 	iov[0].iov_len	= sizeof(pkt);
330*4882a593Smuzhiyun 
331*4882a593Smuzhiyun 	serial = atomic_inc_return(&conn->serial);
332*4882a593Smuzhiyun 	pkt.whdr.serial = htonl(serial);
333*4882a593Smuzhiyun 
334*4882a593Smuzhiyun 	ret = kernel_sendmsg(conn->params.local->socket,
335*4882a593Smuzhiyun 			     &msg, iov, 1, sizeof(pkt));
336*4882a593Smuzhiyun 	conn->params.peer->last_tx_at = ktime_get_seconds();
337*4882a593Smuzhiyun 	if (ret < 0)
338*4882a593Smuzhiyun 		trace_rxrpc_tx_fail(call->debug_id, serial, ret,
339*4882a593Smuzhiyun 				    rxrpc_tx_point_call_abort);
340*4882a593Smuzhiyun 	else
341*4882a593Smuzhiyun 		trace_rxrpc_tx_packet(call->debug_id, &pkt.whdr,
342*4882a593Smuzhiyun 				      rxrpc_tx_point_call_abort);
343*4882a593Smuzhiyun 	rxrpc_tx_backoff(call, ret);
344*4882a593Smuzhiyun 	return ret;
345*4882a593Smuzhiyun }
346*4882a593Smuzhiyun 
347*4882a593Smuzhiyun /*
348*4882a593Smuzhiyun  * send a packet through the transport endpoint
349*4882a593Smuzhiyun  */
rxrpc_send_data_packet(struct rxrpc_call * call,struct sk_buff * skb,bool retrans)350*4882a593Smuzhiyun int rxrpc_send_data_packet(struct rxrpc_call *call, struct sk_buff *skb,
351*4882a593Smuzhiyun 			   bool retrans)
352*4882a593Smuzhiyun {
353*4882a593Smuzhiyun 	struct rxrpc_connection *conn = call->conn;
354*4882a593Smuzhiyun 	struct rxrpc_wire_header whdr;
355*4882a593Smuzhiyun 	struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
356*4882a593Smuzhiyun 	struct msghdr msg;
357*4882a593Smuzhiyun 	struct kvec iov[2];
358*4882a593Smuzhiyun 	rxrpc_serial_t serial;
359*4882a593Smuzhiyun 	size_t len;
360*4882a593Smuzhiyun 	int ret, rtt_slot = -1;
361*4882a593Smuzhiyun 
362*4882a593Smuzhiyun 	_enter(",{%d}", skb->len);
363*4882a593Smuzhiyun 
364*4882a593Smuzhiyun 	if (hlist_unhashed(&call->error_link)) {
365*4882a593Smuzhiyun 		spin_lock_bh(&call->peer->lock);
366*4882a593Smuzhiyun 		hlist_add_head_rcu(&call->error_link, &call->peer->error_targets);
367*4882a593Smuzhiyun 		spin_unlock_bh(&call->peer->lock);
368*4882a593Smuzhiyun 	}
369*4882a593Smuzhiyun 
370*4882a593Smuzhiyun 	/* Each transmission of a Tx packet needs a new serial number */
371*4882a593Smuzhiyun 	serial = atomic_inc_return(&conn->serial);
372*4882a593Smuzhiyun 
373*4882a593Smuzhiyun 	whdr.epoch	= htonl(conn->proto.epoch);
374*4882a593Smuzhiyun 	whdr.cid	= htonl(call->cid);
375*4882a593Smuzhiyun 	whdr.callNumber	= htonl(call->call_id);
376*4882a593Smuzhiyun 	whdr.seq	= htonl(sp->hdr.seq);
377*4882a593Smuzhiyun 	whdr.serial	= htonl(serial);
378*4882a593Smuzhiyun 	whdr.type	= RXRPC_PACKET_TYPE_DATA;
379*4882a593Smuzhiyun 	whdr.flags	= sp->hdr.flags;
380*4882a593Smuzhiyun 	whdr.userStatus	= 0;
381*4882a593Smuzhiyun 	whdr.securityIndex = call->security_ix;
382*4882a593Smuzhiyun 	whdr._rsvd	= htons(sp->hdr._rsvd);
383*4882a593Smuzhiyun 	whdr.serviceId	= htons(call->service_id);
384*4882a593Smuzhiyun 
385*4882a593Smuzhiyun 	if (test_bit(RXRPC_CONN_PROBING_FOR_UPGRADE, &conn->flags) &&
386*4882a593Smuzhiyun 	    sp->hdr.seq == 1)
387*4882a593Smuzhiyun 		whdr.userStatus	= RXRPC_USERSTATUS_SERVICE_UPGRADE;
388*4882a593Smuzhiyun 
389*4882a593Smuzhiyun 	iov[0].iov_base = &whdr;
390*4882a593Smuzhiyun 	iov[0].iov_len = sizeof(whdr);
391*4882a593Smuzhiyun 	iov[1].iov_base = skb->head;
392*4882a593Smuzhiyun 	iov[1].iov_len = skb->len;
393*4882a593Smuzhiyun 	len = iov[0].iov_len + iov[1].iov_len;
394*4882a593Smuzhiyun 
395*4882a593Smuzhiyun 	msg.msg_name = &call->peer->srx.transport;
396*4882a593Smuzhiyun 	msg.msg_namelen = call->peer->srx.transport_len;
397*4882a593Smuzhiyun 	msg.msg_control = NULL;
398*4882a593Smuzhiyun 	msg.msg_controllen = 0;
399*4882a593Smuzhiyun 	msg.msg_flags = 0;
400*4882a593Smuzhiyun 
401*4882a593Smuzhiyun 	/* If our RTT cache needs working on, request an ACK.  Also request
402*4882a593Smuzhiyun 	 * ACKs if a DATA packet appears to have been lost.
403*4882a593Smuzhiyun 	 *
404*4882a593Smuzhiyun 	 * However, we mustn't request an ACK on the last reply packet of a
405*4882a593Smuzhiyun 	 * service call, lest OpenAFS incorrectly send us an ACK with some
406*4882a593Smuzhiyun 	 * soft-ACKs in it and then never follow up with a proper hard ACK.
407*4882a593Smuzhiyun 	 */
408*4882a593Smuzhiyun 	if ((!(sp->hdr.flags & RXRPC_LAST_PACKET) ||
409*4882a593Smuzhiyun 	     rxrpc_to_server(sp)
410*4882a593Smuzhiyun 	     ) &&
411*4882a593Smuzhiyun 	    (test_and_clear_bit(RXRPC_CALL_EV_ACK_LOST, &call->events) ||
412*4882a593Smuzhiyun 	     retrans ||
413*4882a593Smuzhiyun 	     call->cong_mode == RXRPC_CALL_SLOW_START ||
414*4882a593Smuzhiyun 	     (call->peer->rtt_count < 3 && sp->hdr.seq & 1) ||
415*4882a593Smuzhiyun 	     ktime_before(ktime_add_ms(call->peer->rtt_last_req, 1000),
416*4882a593Smuzhiyun 			  ktime_get_real())))
417*4882a593Smuzhiyun 		whdr.flags |= RXRPC_REQUEST_ACK;
418*4882a593Smuzhiyun 
419*4882a593Smuzhiyun 	if (IS_ENABLED(CONFIG_AF_RXRPC_INJECT_LOSS)) {
420*4882a593Smuzhiyun 		static int lose;
421*4882a593Smuzhiyun 		if ((lose++ & 7) == 7) {
422*4882a593Smuzhiyun 			ret = 0;
423*4882a593Smuzhiyun 			trace_rxrpc_tx_data(call, sp->hdr.seq, serial,
424*4882a593Smuzhiyun 					    whdr.flags, retrans, true);
425*4882a593Smuzhiyun 			goto done;
426*4882a593Smuzhiyun 		}
427*4882a593Smuzhiyun 	}
428*4882a593Smuzhiyun 
429*4882a593Smuzhiyun 	trace_rxrpc_tx_data(call, sp->hdr.seq, serial, whdr.flags, retrans,
430*4882a593Smuzhiyun 			    false);
431*4882a593Smuzhiyun 
432*4882a593Smuzhiyun 	/* send the packet with the don't fragment bit set if we currently
433*4882a593Smuzhiyun 	 * think it's small enough */
434*4882a593Smuzhiyun 	if (iov[1].iov_len >= call->peer->maxdata)
435*4882a593Smuzhiyun 		goto send_fragmentable;
436*4882a593Smuzhiyun 
437*4882a593Smuzhiyun 	down_read(&conn->params.local->defrag_sem);
438*4882a593Smuzhiyun 
439*4882a593Smuzhiyun 	sp->hdr.serial = serial;
440*4882a593Smuzhiyun 	smp_wmb(); /* Set serial before timestamp */
441*4882a593Smuzhiyun 	skb->tstamp = ktime_get_real();
442*4882a593Smuzhiyun 	if (whdr.flags & RXRPC_REQUEST_ACK)
443*4882a593Smuzhiyun 		rtt_slot = rxrpc_begin_rtt_probe(call, serial, rxrpc_rtt_tx_data);
444*4882a593Smuzhiyun 
445*4882a593Smuzhiyun 	/* send the packet by UDP
446*4882a593Smuzhiyun 	 * - returns -EMSGSIZE if UDP would have to fragment the packet
447*4882a593Smuzhiyun 	 *   to go out of the interface
448*4882a593Smuzhiyun 	 *   - in which case, we'll have processed the ICMP error
449*4882a593Smuzhiyun 	 *     message and update the peer record
450*4882a593Smuzhiyun 	 */
451*4882a593Smuzhiyun 	ret = kernel_sendmsg(conn->params.local->socket, &msg, iov, 2, len);
452*4882a593Smuzhiyun 	conn->params.peer->last_tx_at = ktime_get_seconds();
453*4882a593Smuzhiyun 
454*4882a593Smuzhiyun 	up_read(&conn->params.local->defrag_sem);
455*4882a593Smuzhiyun 	if (ret < 0) {
456*4882a593Smuzhiyun 		rxrpc_cancel_rtt_probe(call, serial, rtt_slot);
457*4882a593Smuzhiyun 		trace_rxrpc_tx_fail(call->debug_id, serial, ret,
458*4882a593Smuzhiyun 				    rxrpc_tx_point_call_data_nofrag);
459*4882a593Smuzhiyun 	} else {
460*4882a593Smuzhiyun 		trace_rxrpc_tx_packet(call->debug_id, &whdr,
461*4882a593Smuzhiyun 				      rxrpc_tx_point_call_data_nofrag);
462*4882a593Smuzhiyun 	}
463*4882a593Smuzhiyun 
464*4882a593Smuzhiyun 	rxrpc_tx_backoff(call, ret);
465*4882a593Smuzhiyun 	if (ret == -EMSGSIZE)
466*4882a593Smuzhiyun 		goto send_fragmentable;
467*4882a593Smuzhiyun 
468*4882a593Smuzhiyun done:
469*4882a593Smuzhiyun 	if (ret >= 0) {
470*4882a593Smuzhiyun 		if (whdr.flags & RXRPC_REQUEST_ACK) {
471*4882a593Smuzhiyun 			call->peer->rtt_last_req = skb->tstamp;
472*4882a593Smuzhiyun 			if (call->peer->rtt_count > 1) {
473*4882a593Smuzhiyun 				unsigned long nowj = jiffies, ack_lost_at;
474*4882a593Smuzhiyun 
475*4882a593Smuzhiyun 				ack_lost_at = rxrpc_get_rto_backoff(call->peer, false);
476*4882a593Smuzhiyun 				ack_lost_at += nowj;
477*4882a593Smuzhiyun 				WRITE_ONCE(call->ack_lost_at, ack_lost_at);
478*4882a593Smuzhiyun 				rxrpc_reduce_call_timer(call, ack_lost_at, nowj,
479*4882a593Smuzhiyun 							rxrpc_timer_set_for_lost_ack);
480*4882a593Smuzhiyun 			}
481*4882a593Smuzhiyun 		}
482*4882a593Smuzhiyun 
483*4882a593Smuzhiyun 		if (sp->hdr.seq == 1 &&
484*4882a593Smuzhiyun 		    !test_and_set_bit(RXRPC_CALL_BEGAN_RX_TIMER,
485*4882a593Smuzhiyun 				      &call->flags)) {
486*4882a593Smuzhiyun 			unsigned long nowj = jiffies, expect_rx_by;
487*4882a593Smuzhiyun 
488*4882a593Smuzhiyun 			expect_rx_by = nowj + call->next_rx_timo;
489*4882a593Smuzhiyun 			WRITE_ONCE(call->expect_rx_by, expect_rx_by);
490*4882a593Smuzhiyun 			rxrpc_reduce_call_timer(call, expect_rx_by, nowj,
491*4882a593Smuzhiyun 						rxrpc_timer_set_for_normal);
492*4882a593Smuzhiyun 		}
493*4882a593Smuzhiyun 
494*4882a593Smuzhiyun 		rxrpc_set_keepalive(call);
495*4882a593Smuzhiyun 	} else {
496*4882a593Smuzhiyun 		/* Cancel the call if the initial transmission fails,
497*4882a593Smuzhiyun 		 * particularly if that's due to network routing issues that
498*4882a593Smuzhiyun 		 * aren't going away anytime soon.  The layer above can arrange
499*4882a593Smuzhiyun 		 * the retransmission.
500*4882a593Smuzhiyun 		 */
501*4882a593Smuzhiyun 		if (!test_and_set_bit(RXRPC_CALL_BEGAN_RX_TIMER, &call->flags))
502*4882a593Smuzhiyun 			rxrpc_set_call_completion(call, RXRPC_CALL_LOCAL_ERROR,
503*4882a593Smuzhiyun 						  RX_USER_ABORT, ret);
504*4882a593Smuzhiyun 	}
505*4882a593Smuzhiyun 
506*4882a593Smuzhiyun 	_leave(" = %d [%u]", ret, call->peer->maxdata);
507*4882a593Smuzhiyun 	return ret;
508*4882a593Smuzhiyun 
509*4882a593Smuzhiyun send_fragmentable:
510*4882a593Smuzhiyun 	/* attempt to send this message with fragmentation enabled */
511*4882a593Smuzhiyun 	_debug("send fragment");
512*4882a593Smuzhiyun 
513*4882a593Smuzhiyun 	down_write(&conn->params.local->defrag_sem);
514*4882a593Smuzhiyun 
515*4882a593Smuzhiyun 	sp->hdr.serial = serial;
516*4882a593Smuzhiyun 	smp_wmb(); /* Set serial before timestamp */
517*4882a593Smuzhiyun 	skb->tstamp = ktime_get_real();
518*4882a593Smuzhiyun 	if (whdr.flags & RXRPC_REQUEST_ACK)
519*4882a593Smuzhiyun 		rtt_slot = rxrpc_begin_rtt_probe(call, serial, rxrpc_rtt_tx_data);
520*4882a593Smuzhiyun 
521*4882a593Smuzhiyun 	switch (conn->params.local->srx.transport.family) {
522*4882a593Smuzhiyun 	case AF_INET6:
523*4882a593Smuzhiyun 	case AF_INET:
524*4882a593Smuzhiyun 		ip_sock_set_mtu_discover(conn->params.local->socket->sk,
525*4882a593Smuzhiyun 				IP_PMTUDISC_DONT);
526*4882a593Smuzhiyun 		ret = kernel_sendmsg(conn->params.local->socket, &msg,
527*4882a593Smuzhiyun 				     iov, 2, len);
528*4882a593Smuzhiyun 		conn->params.peer->last_tx_at = ktime_get_seconds();
529*4882a593Smuzhiyun 
530*4882a593Smuzhiyun 		ip_sock_set_mtu_discover(conn->params.local->socket->sk,
531*4882a593Smuzhiyun 				IP_PMTUDISC_DO);
532*4882a593Smuzhiyun 		break;
533*4882a593Smuzhiyun 
534*4882a593Smuzhiyun 	default:
535*4882a593Smuzhiyun 		BUG();
536*4882a593Smuzhiyun 	}
537*4882a593Smuzhiyun 
538*4882a593Smuzhiyun 	if (ret < 0) {
539*4882a593Smuzhiyun 		rxrpc_cancel_rtt_probe(call, serial, rtt_slot);
540*4882a593Smuzhiyun 		trace_rxrpc_tx_fail(call->debug_id, serial, ret,
541*4882a593Smuzhiyun 				    rxrpc_tx_point_call_data_frag);
542*4882a593Smuzhiyun 	} else {
543*4882a593Smuzhiyun 		trace_rxrpc_tx_packet(call->debug_id, &whdr,
544*4882a593Smuzhiyun 				      rxrpc_tx_point_call_data_frag);
545*4882a593Smuzhiyun 	}
546*4882a593Smuzhiyun 	rxrpc_tx_backoff(call, ret);
547*4882a593Smuzhiyun 
548*4882a593Smuzhiyun 	up_write(&conn->params.local->defrag_sem);
549*4882a593Smuzhiyun 	goto done;
550*4882a593Smuzhiyun }
551*4882a593Smuzhiyun 
552*4882a593Smuzhiyun /*
553*4882a593Smuzhiyun  * reject packets through the local endpoint
554*4882a593Smuzhiyun  */
rxrpc_reject_packets(struct rxrpc_local * local)555*4882a593Smuzhiyun void rxrpc_reject_packets(struct rxrpc_local *local)
556*4882a593Smuzhiyun {
557*4882a593Smuzhiyun 	struct sockaddr_rxrpc srx;
558*4882a593Smuzhiyun 	struct rxrpc_skb_priv *sp;
559*4882a593Smuzhiyun 	struct rxrpc_wire_header whdr;
560*4882a593Smuzhiyun 	struct sk_buff *skb;
561*4882a593Smuzhiyun 	struct msghdr msg;
562*4882a593Smuzhiyun 	struct kvec iov[2];
563*4882a593Smuzhiyun 	size_t size;
564*4882a593Smuzhiyun 	__be32 code;
565*4882a593Smuzhiyun 	int ret, ioc;
566*4882a593Smuzhiyun 
567*4882a593Smuzhiyun 	_enter("%d", local->debug_id);
568*4882a593Smuzhiyun 
569*4882a593Smuzhiyun 	iov[0].iov_base = &whdr;
570*4882a593Smuzhiyun 	iov[0].iov_len = sizeof(whdr);
571*4882a593Smuzhiyun 	iov[1].iov_base = &code;
572*4882a593Smuzhiyun 	iov[1].iov_len = sizeof(code);
573*4882a593Smuzhiyun 
574*4882a593Smuzhiyun 	msg.msg_name = &srx.transport;
575*4882a593Smuzhiyun 	msg.msg_control = NULL;
576*4882a593Smuzhiyun 	msg.msg_controllen = 0;
577*4882a593Smuzhiyun 	msg.msg_flags = 0;
578*4882a593Smuzhiyun 
579*4882a593Smuzhiyun 	memset(&whdr, 0, sizeof(whdr));
580*4882a593Smuzhiyun 
581*4882a593Smuzhiyun 	while ((skb = skb_dequeue(&local->reject_queue))) {
582*4882a593Smuzhiyun 		rxrpc_see_skb(skb, rxrpc_skb_seen);
583*4882a593Smuzhiyun 		sp = rxrpc_skb(skb);
584*4882a593Smuzhiyun 
585*4882a593Smuzhiyun 		switch (skb->mark) {
586*4882a593Smuzhiyun 		case RXRPC_SKB_MARK_REJECT_BUSY:
587*4882a593Smuzhiyun 			whdr.type = RXRPC_PACKET_TYPE_BUSY;
588*4882a593Smuzhiyun 			size = sizeof(whdr);
589*4882a593Smuzhiyun 			ioc = 1;
590*4882a593Smuzhiyun 			break;
591*4882a593Smuzhiyun 		case RXRPC_SKB_MARK_REJECT_ABORT:
592*4882a593Smuzhiyun 			whdr.type = RXRPC_PACKET_TYPE_ABORT;
593*4882a593Smuzhiyun 			code = htonl(skb->priority);
594*4882a593Smuzhiyun 			size = sizeof(whdr) + sizeof(code);
595*4882a593Smuzhiyun 			ioc = 2;
596*4882a593Smuzhiyun 			break;
597*4882a593Smuzhiyun 		default:
598*4882a593Smuzhiyun 			rxrpc_free_skb(skb, rxrpc_skb_freed);
599*4882a593Smuzhiyun 			continue;
600*4882a593Smuzhiyun 		}
601*4882a593Smuzhiyun 
602*4882a593Smuzhiyun 		if (rxrpc_extract_addr_from_skb(&srx, skb) == 0) {
603*4882a593Smuzhiyun 			msg.msg_namelen = srx.transport_len;
604*4882a593Smuzhiyun 
605*4882a593Smuzhiyun 			whdr.epoch	= htonl(sp->hdr.epoch);
606*4882a593Smuzhiyun 			whdr.cid	= htonl(sp->hdr.cid);
607*4882a593Smuzhiyun 			whdr.callNumber	= htonl(sp->hdr.callNumber);
608*4882a593Smuzhiyun 			whdr.serviceId	= htons(sp->hdr.serviceId);
609*4882a593Smuzhiyun 			whdr.flags	= sp->hdr.flags;
610*4882a593Smuzhiyun 			whdr.flags	^= RXRPC_CLIENT_INITIATED;
611*4882a593Smuzhiyun 			whdr.flags	&= RXRPC_CLIENT_INITIATED;
612*4882a593Smuzhiyun 
613*4882a593Smuzhiyun 			ret = kernel_sendmsg(local->socket, &msg,
614*4882a593Smuzhiyun 					     iov, ioc, size);
615*4882a593Smuzhiyun 			if (ret < 0)
616*4882a593Smuzhiyun 				trace_rxrpc_tx_fail(local->debug_id, 0, ret,
617*4882a593Smuzhiyun 						    rxrpc_tx_point_reject);
618*4882a593Smuzhiyun 			else
619*4882a593Smuzhiyun 				trace_rxrpc_tx_packet(local->debug_id, &whdr,
620*4882a593Smuzhiyun 						      rxrpc_tx_point_reject);
621*4882a593Smuzhiyun 		}
622*4882a593Smuzhiyun 
623*4882a593Smuzhiyun 		rxrpc_free_skb(skb, rxrpc_skb_freed);
624*4882a593Smuzhiyun 	}
625*4882a593Smuzhiyun 
626*4882a593Smuzhiyun 	_leave("");
627*4882a593Smuzhiyun }
628*4882a593Smuzhiyun 
629*4882a593Smuzhiyun /*
630*4882a593Smuzhiyun  * Send a VERSION reply to a peer as a keepalive.
631*4882a593Smuzhiyun  */
rxrpc_send_keepalive(struct rxrpc_peer * peer)632*4882a593Smuzhiyun void rxrpc_send_keepalive(struct rxrpc_peer *peer)
633*4882a593Smuzhiyun {
634*4882a593Smuzhiyun 	struct rxrpc_wire_header whdr;
635*4882a593Smuzhiyun 	struct msghdr msg;
636*4882a593Smuzhiyun 	struct kvec iov[2];
637*4882a593Smuzhiyun 	size_t len;
638*4882a593Smuzhiyun 	int ret;
639*4882a593Smuzhiyun 
640*4882a593Smuzhiyun 	_enter("");
641*4882a593Smuzhiyun 
642*4882a593Smuzhiyun 	msg.msg_name	= &peer->srx.transport;
643*4882a593Smuzhiyun 	msg.msg_namelen	= peer->srx.transport_len;
644*4882a593Smuzhiyun 	msg.msg_control	= NULL;
645*4882a593Smuzhiyun 	msg.msg_controllen = 0;
646*4882a593Smuzhiyun 	msg.msg_flags	= 0;
647*4882a593Smuzhiyun 
648*4882a593Smuzhiyun 	whdr.epoch	= htonl(peer->local->rxnet->epoch);
649*4882a593Smuzhiyun 	whdr.cid	= 0;
650*4882a593Smuzhiyun 	whdr.callNumber	= 0;
651*4882a593Smuzhiyun 	whdr.seq	= 0;
652*4882a593Smuzhiyun 	whdr.serial	= 0;
653*4882a593Smuzhiyun 	whdr.type	= RXRPC_PACKET_TYPE_VERSION; /* Not client-initiated */
654*4882a593Smuzhiyun 	whdr.flags	= RXRPC_LAST_PACKET;
655*4882a593Smuzhiyun 	whdr.userStatus	= 0;
656*4882a593Smuzhiyun 	whdr.securityIndex = 0;
657*4882a593Smuzhiyun 	whdr._rsvd	= 0;
658*4882a593Smuzhiyun 	whdr.serviceId	= 0;
659*4882a593Smuzhiyun 
660*4882a593Smuzhiyun 	iov[0].iov_base	= &whdr;
661*4882a593Smuzhiyun 	iov[0].iov_len	= sizeof(whdr);
662*4882a593Smuzhiyun 	iov[1].iov_base	= (char *)rxrpc_keepalive_string;
663*4882a593Smuzhiyun 	iov[1].iov_len	= sizeof(rxrpc_keepalive_string);
664*4882a593Smuzhiyun 
665*4882a593Smuzhiyun 	len = iov[0].iov_len + iov[1].iov_len;
666*4882a593Smuzhiyun 
667*4882a593Smuzhiyun 	_proto("Tx VERSION (keepalive)");
668*4882a593Smuzhiyun 
669*4882a593Smuzhiyun 	ret = kernel_sendmsg(peer->local->socket, &msg, iov, 2, len);
670*4882a593Smuzhiyun 	if (ret < 0)
671*4882a593Smuzhiyun 		trace_rxrpc_tx_fail(peer->debug_id, 0, ret,
672*4882a593Smuzhiyun 				    rxrpc_tx_point_version_keepalive);
673*4882a593Smuzhiyun 	else
674*4882a593Smuzhiyun 		trace_rxrpc_tx_packet(peer->debug_id, &whdr,
675*4882a593Smuzhiyun 				      rxrpc_tx_point_version_keepalive);
676*4882a593Smuzhiyun 
677*4882a593Smuzhiyun 	peer->last_tx_at = ktime_get_seconds();
678*4882a593Smuzhiyun 	_leave("");
679*4882a593Smuzhiyun }
680