blob: d568c96f526234865336f555e3ce1429ef049c14 [file] [log] [blame]
David Howells17926a72007-04-26 15:48:28 -07001/* RxRPC packet transmission
2 *
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
Joe Perches9b6d5392016-06-02 12:08:52 -070012#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13
David Howells17926a72007-04-26 15:48:28 -070014#include <linux/net.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090015#include <linux/gfp.h>
David Howells17926a72007-04-26 15:48:28 -070016#include <linux/skbuff.h>
Paul Gortmakerbc3b2d72011-07-15 11:47:34 -040017#include <linux/export.h>
David Howells17926a72007-04-26 15:48:28 -070018#include <net/sock.h>
19#include <net/af_rxrpc.h>
20#include "ar-internal.h"
21
David Howells26cb02a2016-10-06 08:11:49 +010022struct rxrpc_ack_buffer {
David Howells8d94aa32016-09-07 09:19:31 +010023 struct rxrpc_wire_header whdr;
David Howells26cb02a2016-10-06 08:11:49 +010024 struct rxrpc_ackpacket ack;
25 u8 acks[255];
26 u8 pad[3];
David Howells8d94aa32016-09-07 09:19:31 +010027 struct rxrpc_ackinfo ackinfo;
28};
29
David Howells26cb02a2016-10-06 08:11:49 +010030struct rxrpc_abort_buffer {
31 struct rxrpc_wire_header whdr;
32 __be32 abort_code;
33};
34
David Howells8d94aa32016-09-07 09:19:31 +010035/*
36 * Fill out an ACK packet.
37 */
38static size_t rxrpc_fill_out_ack(struct rxrpc_call *call,
David Howells26cb02a2016-10-06 08:11:49 +010039 struct rxrpc_ack_buffer *pkt,
David Howells805b21b2016-09-24 18:05:26 +010040 rxrpc_seq_t *_hard_ack,
David Howellsa5af7e12016-10-06 08:11:49 +010041 rxrpc_seq_t *_top,
42 u8 reason)
David Howells8d94aa32016-09-07 09:19:31 +010043{
David Howellsf3639df2016-09-17 10:49:13 +010044 rxrpc_serial_t serial;
David Howells248f2192016-09-08 11:10:12 +010045 rxrpc_seq_t hard_ack, top, seq;
46 int ix;
David Howells8d94aa32016-09-07 09:19:31 +010047 u32 mtu, jmax;
48 u8 *ackp = pkt->acks;
49
David Howells248f2192016-09-08 11:10:12 +010050 /* Barrier against rxrpc_input_data(). */
David Howellsf3639df2016-09-17 10:49:13 +010051 serial = call->ackr_serial;
David Howells248f2192016-09-08 11:10:12 +010052 hard_ack = READ_ONCE(call->rx_hard_ack);
53 top = smp_load_acquire(&call->rx_top);
David Howells805b21b2016-09-24 18:05:26 +010054 *_hard_ack = hard_ack;
55 *_top = top;
David Howells248f2192016-09-08 11:10:12 +010056
David Howells8d94aa32016-09-07 09:19:31 +010057 pkt->ack.bufferSpace = htons(8);
David Howells248f2192016-09-08 11:10:12 +010058 pkt->ack.maxSkew = htons(call->ackr_skew);
59 pkt->ack.firstPacket = htonl(hard_ack + 1);
David Howells8d94aa32016-09-07 09:19:31 +010060 pkt->ack.previousPacket = htonl(call->ackr_prev_seq);
David Howellsf3639df2016-09-17 10:49:13 +010061 pkt->ack.serial = htonl(serial);
David Howellsa5af7e12016-10-06 08:11:49 +010062 pkt->ack.reason = reason;
David Howells248f2192016-09-08 11:10:12 +010063 pkt->ack.nAcks = top - hard_ack;
David Howells8d94aa32016-09-07 09:19:31 +010064
David Howellsa5af7e12016-10-06 08:11:49 +010065 if (reason == RXRPC_ACK_PING)
David Howells8e831342016-09-22 00:29:31 +010066 pkt->whdr.flags |= RXRPC_REQUEST_ACK;
67
David Howells248f2192016-09-08 11:10:12 +010068 if (after(top, hard_ack)) {
69 seq = hard_ack + 1;
70 do {
71 ix = seq & RXRPC_RXTX_BUFF_MASK;
72 if (call->rxtx_buffer[ix])
73 *ackp++ = RXRPC_ACK_TYPE_ACK;
74 else
75 *ackp++ = RXRPC_ACK_TYPE_NACK;
76 seq++;
77 } while (before_eq(seq, top));
78 }
79
80 mtu = call->conn->params.peer->if_mtu;
81 mtu -= call->conn->params.peer->hdrsize;
David Howells75e42122016-09-13 22:36:22 +010082 jmax = (call->nr_jumbo_bad > 3) ? 1 : rxrpc_rx_jumbo_max;
David Howells8d94aa32016-09-07 09:19:31 +010083 pkt->ackinfo.rxMTU = htonl(rxrpc_rx_mtu);
84 pkt->ackinfo.maxMTU = htonl(mtu);
David Howells75e42122016-09-13 22:36:22 +010085 pkt->ackinfo.rwind = htonl(call->rx_winsize);
David Howells8d94aa32016-09-07 09:19:31 +010086 pkt->ackinfo.jumbo_max = htonl(jmax);
87
88 *ackp++ = 0;
89 *ackp++ = 0;
90 *ackp++ = 0;
David Howells248f2192016-09-08 11:10:12 +010091 return top - hard_ack + 3;
David Howells8d94aa32016-09-07 09:19:31 +010092}
93
94/*
David Howells26cb02a2016-10-06 08:11:49 +010095 * Send an ACK call packet.
David Howells8d94aa32016-09-07 09:19:31 +010096 */
David Howellsa5af7e12016-10-06 08:11:49 +010097int rxrpc_send_ack_packet(struct rxrpc_call *call, bool ping)
David Howells8d94aa32016-09-07 09:19:31 +010098{
David Howellsae9cd072020-01-30 21:50:36 +000099 struct rxrpc_connection *conn;
David Howells26cb02a2016-10-06 08:11:49 +0100100 struct rxrpc_ack_buffer *pkt;
David Howells8d94aa32016-09-07 09:19:31 +0100101 struct msghdr msg;
102 struct kvec iov[2];
103 rxrpc_serial_t serial;
David Howells805b21b2016-09-24 18:05:26 +0100104 rxrpc_seq_t hard_ack, top;
David Howells8d94aa32016-09-07 09:19:31 +0100105 size_t len, n;
David Howells26cb02a2016-10-06 08:11:49 +0100106 int ret;
David Howellsa5af7e12016-10-06 08:11:49 +0100107 u8 reason;
David Howells8d94aa32016-09-07 09:19:31 +0100108
David Howellsae9cd072020-01-30 21:50:36 +0000109 if (test_bit(RXRPC_CALL_DISCONNECTED, &call->flags))
David Howells8d94aa32016-09-07 09:19:31 +0100110 return -ECONNRESET;
111
112 pkt = kzalloc(sizeof(*pkt), GFP_KERNEL);
David Howellsae9cd072020-01-30 21:50:36 +0000113 if (!pkt)
David Howells8d94aa32016-09-07 09:19:31 +0100114 return -ENOMEM;
David Howellsae9cd072020-01-30 21:50:36 +0000115
116 conn = call->conn;
David Howells8d94aa32016-09-07 09:19:31 +0100117
David Howells8d94aa32016-09-07 09:19:31 +0100118 msg.msg_name = &call->peer->srx.transport;
119 msg.msg_namelen = call->peer->srx.transport_len;
120 msg.msg_control = NULL;
121 msg.msg_controllen = 0;
122 msg.msg_flags = 0;
123
124 pkt->whdr.epoch = htonl(conn->proto.epoch);
125 pkt->whdr.cid = htonl(call->cid);
126 pkt->whdr.callNumber = htonl(call->call_id);
127 pkt->whdr.seq = 0;
David Howells26cb02a2016-10-06 08:11:49 +0100128 pkt->whdr.type = RXRPC_PACKET_TYPE_ACK;
129 pkt->whdr.flags = RXRPC_SLOW_START_OK | conn->out_clientflag;
David Howells8d94aa32016-09-07 09:19:31 +0100130 pkt->whdr.userStatus = 0;
131 pkt->whdr.securityIndex = call->security_ix;
132 pkt->whdr._rsvd = 0;
133 pkt->whdr.serviceId = htons(call->service_id);
134
David Howells26cb02a2016-10-06 08:11:49 +0100135 spin_lock_bh(&call->lock);
David Howellsa5af7e12016-10-06 08:11:49 +0100136 if (ping) {
137 reason = RXRPC_ACK_PING;
138 } else {
139 reason = call->ackr_reason;
140 if (!call->ackr_reason) {
141 spin_unlock_bh(&call->lock);
142 ret = 0;
143 goto out;
144 }
145 call->ackr_reason = 0;
David Howells8d94aa32016-09-07 09:19:31 +0100146 }
David Howellsa5af7e12016-10-06 08:11:49 +0100147 n = rxrpc_fill_out_ack(call, pkt, &hard_ack, &top, reason);
David Howells26cb02a2016-10-06 08:11:49 +0100148
149 spin_unlock_bh(&call->lock);
150
151 iov[0].iov_base = pkt;
152 iov[0].iov_len = sizeof(pkt->whdr) + sizeof(pkt->ack) + n;
153 iov[1].iov_base = &pkt->ackinfo;
154 iov[1].iov_len = sizeof(pkt->ackinfo);
155 len = iov[0].iov_len + iov[1].iov_len;
David Howells8d94aa32016-09-07 09:19:31 +0100156
David Howellsb86e2182016-09-23 15:08:48 +0100157 serial = atomic_inc_return(&conn->serial);
158 pkt->whdr.serial = htonl(serial);
David Howells26cb02a2016-10-06 08:11:49 +0100159 trace_rxrpc_tx_ack(call, serial,
160 ntohl(pkt->ack.firstPacket),
161 ntohl(pkt->ack.serial),
162 pkt->ack.reason, pkt->ack.nAcks);
David Howellsb86e2182016-09-23 15:08:48 +0100163
David Howells8e831342016-09-22 00:29:31 +0100164 if (ping) {
David Howellsa5af7e12016-10-06 08:11:49 +0100165 call->ping_serial = serial;
David Howells8e831342016-09-22 00:29:31 +0100166 smp_wmb();
167 /* We need to stick a time in before we send the packet in case
168 * the reply gets back before kernel_sendmsg() completes - but
169 * asking UDP to send the packet can take a relatively long
170 * time, so we update the time after, on the assumption that
171 * the packet transmission is more likely to happen towards the
172 * end of the kernel_sendmsg() call.
173 */
David Howellsa5af7e12016-10-06 08:11:49 +0100174 call->ping_time = ktime_get_real();
David Howells8e831342016-09-22 00:29:31 +0100175 set_bit(RXRPC_CALL_PINGING, &call->flags);
176 trace_rxrpc_rtt_tx(call, rxrpc_rtt_tx_ping, serial);
177 }
David Howells26cb02a2016-10-06 08:11:49 +0100178
179 ret = kernel_sendmsg(conn->params.local->socket, &msg, iov, 2, len);
David Howells8e831342016-09-22 00:29:31 +0100180 if (ping)
David Howellsa5af7e12016-10-06 08:11:49 +0100181 call->ping_time = ktime_get_real();
David Howells8d94aa32016-09-07 09:19:31 +0100182
David Howells26cb02a2016-10-06 08:11:49 +0100183 if (call->state < RXRPC_CALL_COMPLETE) {
David Howells805b21b2016-09-24 18:05:26 +0100184 if (ret < 0) {
David Howellsa5af7e12016-10-06 08:11:49 +0100185 if (ping)
186 clear_bit(RXRPC_CALL_PINGING, &call->flags);
David Howells248f2192016-09-08 11:10:12 +0100187 rxrpc_propose_ACK(call, pkt->ack.reason,
188 ntohs(pkt->ack.maxSkew),
189 ntohl(pkt->ack.serial),
David Howells9c7ad432016-09-23 13:50:40 +0100190 true, true,
191 rxrpc_propose_ack_retry_tx);
David Howells805b21b2016-09-24 18:05:26 +0100192 } else {
193 spin_lock_bh(&call->lock);
194 if (after(hard_ack, call->ackr_consumed))
195 call->ackr_consumed = hard_ack;
196 if (after(top, call->ackr_seen))
197 call->ackr_seen = top;
198 spin_unlock_bh(&call->lock);
David Howells248f2192016-09-08 11:10:12 +0100199 }
200 }
201
David Howells8d94aa32016-09-07 09:19:31 +0100202out:
David Howells8d94aa32016-09-07 09:19:31 +0100203 kfree(pkt);
204 return ret;
205}
206
David Howells5873c082014-02-07 18:58:44 +0000207/*
David Howells26cb02a2016-10-06 08:11:49 +0100208 * Send an ABORT call packet.
209 */
210int rxrpc_send_abort_packet(struct rxrpc_call *call)
211{
David Howellsae9cd072020-01-30 21:50:36 +0000212 struct rxrpc_connection *conn;
David Howells26cb02a2016-10-06 08:11:49 +0100213 struct rxrpc_abort_buffer pkt;
214 struct msghdr msg;
215 struct kvec iov[1];
216 rxrpc_serial_t serial;
217 int ret;
218
David Howellsae9cd072020-01-30 21:50:36 +0000219 if (test_bit(RXRPC_CALL_DISCONNECTED, &call->flags))
David Howells26cb02a2016-10-06 08:11:49 +0100220 return -ECONNRESET;
221
David Howellsae9cd072020-01-30 21:50:36 +0000222 conn = call->conn;
223
David Howells26cb02a2016-10-06 08:11:49 +0100224 msg.msg_name = &call->peer->srx.transport;
225 msg.msg_namelen = call->peer->srx.transport_len;
226 msg.msg_control = NULL;
227 msg.msg_controllen = 0;
228 msg.msg_flags = 0;
229
230 pkt.whdr.epoch = htonl(conn->proto.epoch);
231 pkt.whdr.cid = htonl(call->cid);
232 pkt.whdr.callNumber = htonl(call->call_id);
233 pkt.whdr.seq = 0;
234 pkt.whdr.type = RXRPC_PACKET_TYPE_ABORT;
235 pkt.whdr.flags = conn->out_clientflag;
236 pkt.whdr.userStatus = 0;
237 pkt.whdr.securityIndex = call->security_ix;
238 pkt.whdr._rsvd = 0;
239 pkt.whdr.serviceId = htons(call->service_id);
240 pkt.abort_code = htonl(call->abort_code);
241
242 iov[0].iov_base = &pkt;
243 iov[0].iov_len = sizeof(pkt);
244
245 serial = atomic_inc_return(&conn->serial);
246 pkt.whdr.serial = htonl(serial);
247
248 ret = kernel_sendmsg(conn->params.local->socket,
249 &msg, iov, 1, sizeof(pkt));
250
David Howells26cb02a2016-10-06 08:11:49 +0100251 return ret;
252}
253
254/*
David Howells17926a72007-04-26 15:48:28 -0700255 * send a packet through the transport endpoint
256 */
David Howellsa1767072016-09-29 22:37:15 +0100257int rxrpc_send_data_packet(struct rxrpc_call *call, struct sk_buff *skb,
258 bool retrans)
David Howells17926a72007-04-26 15:48:28 -0700259{
David Howells5a924b82016-09-22 00:29:31 +0100260 struct rxrpc_connection *conn = call->conn;
261 struct rxrpc_wire_header whdr;
262 struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
David Howells17926a72007-04-26 15:48:28 -0700263 struct msghdr msg;
David Howells5a924b82016-09-22 00:29:31 +0100264 struct kvec iov[2];
265 rxrpc_serial_t serial;
266 size_t len;
David Howellsa1767072016-09-29 22:37:15 +0100267 bool lost = false;
David Howells17926a72007-04-26 15:48:28 -0700268 int ret, opt;
269
270 _enter(",{%d}", skb->len);
271
David Howells5a924b82016-09-22 00:29:31 +0100272 /* Each transmission of a Tx packet needs a new serial number */
273 serial = atomic_inc_return(&conn->serial);
David Howells17926a72007-04-26 15:48:28 -0700274
David Howells5a924b82016-09-22 00:29:31 +0100275 whdr.epoch = htonl(conn->proto.epoch);
276 whdr.cid = htonl(call->cid);
277 whdr.callNumber = htonl(call->call_id);
278 whdr.seq = htonl(sp->hdr.seq);
279 whdr.serial = htonl(serial);
280 whdr.type = RXRPC_PACKET_TYPE_DATA;
281 whdr.flags = sp->hdr.flags;
282 whdr.userStatus = 0;
283 whdr.securityIndex = call->security_ix;
284 whdr._rsvd = htons(sp->hdr._rsvd);
285 whdr.serviceId = htons(call->service_id);
286
287 iov[0].iov_base = &whdr;
288 iov[0].iov_len = sizeof(whdr);
289 iov[1].iov_base = skb->head;
290 iov[1].iov_len = skb->len;
291 len = iov[0].iov_len + iov[1].iov_len;
292
293 msg.msg_name = &call->peer->srx.transport;
294 msg.msg_namelen = call->peer->srx.transport_len;
David Howells17926a72007-04-26 15:48:28 -0700295 msg.msg_control = NULL;
296 msg.msg_controllen = 0;
297 msg.msg_flags = 0;
298
David Howells57494342016-09-24 18:05:27 +0100299 /* If our RTT cache needs working on, request an ACK. Also request
300 * ACKs if a DATA packet appears to have been lost.
301 */
David Howellsbf7d6202016-10-06 08:11:51 +0100302 if (!(sp->hdr.flags & RXRPC_LAST_PACKET) &&
303 (retrans ||
304 call->cong_mode == RXRPC_CALL_SLOW_START ||
305 (call->peer->rtt_usage < 3 && sp->hdr.seq & 1) ||
306 ktime_before(ktime_add_ms(call->peer->rtt_last_req, 1000),
307 ktime_get_real())))
David Howells0d4b1032016-09-22 00:29:31 +0100308 whdr.flags |= RXRPC_REQUEST_ACK;
309
David Howells8a681c362016-09-17 10:49:15 +0100310 if (IS_ENABLED(CONFIG_AF_RXRPC_INJECT_LOSS)) {
311 static int lose;
312 if ((lose++ & 7) == 7) {
David Howellsa1767072016-09-29 22:37:15 +0100313 ret = 0;
314 lost = true;
315 goto done;
David Howells8a681c362016-09-17 10:49:15 +0100316 }
317 }
318
David Howells5a924b82016-09-22 00:29:31 +0100319 _proto("Tx DATA %%%u { #%u }", serial, sp->hdr.seq);
320
David Howells17926a72007-04-26 15:48:28 -0700321 /* send the packet with the don't fragment bit set if we currently
322 * think it's small enough */
David Howells5a924b82016-09-22 00:29:31 +0100323 if (iov[1].iov_len >= call->peer->maxdata)
324 goto send_fragmentable;
David Howells17926a72007-04-26 15:48:28 -0700325
David Howells5a924b82016-09-22 00:29:31 +0100326 down_read(&conn->params.local->defrag_sem);
327 /* send the packet by UDP
328 * - returns -EMSGSIZE if UDP would have to fragment the packet
329 * to go out of the interface
330 * - in which case, we'll have processed the ICMP error
331 * message and update the peer record
332 */
333 ret = kernel_sendmsg(conn->params.local->socket, &msg, iov, 2, len);
David Howells17926a72007-04-26 15:48:28 -0700334
David Howells5a924b82016-09-22 00:29:31 +0100335 up_read(&conn->params.local->defrag_sem);
336 if (ret == -EMSGSIZE)
337 goto send_fragmentable;
338
339done:
David Howellsa1767072016-09-29 22:37:15 +0100340 trace_rxrpc_tx_data(call, sp->hdr.seq, serial, whdr.flags,
341 retrans, lost);
David Howells50235c42016-09-22 00:29:31 +0100342 if (ret >= 0) {
David Howells0d4b1032016-09-22 00:29:31 +0100343 ktime_t now = ktime_get_real();
344 skb->tstamp = now;
David Howells50235c42016-09-22 00:29:31 +0100345 smp_wmb();
David Howells5a924b82016-09-22 00:29:31 +0100346 sp->hdr.serial = serial;
David Howells0d4b1032016-09-22 00:29:31 +0100347 if (whdr.flags & RXRPC_REQUEST_ACK) {
348 call->peer->rtt_last_req = now;
David Howells50235c42016-09-22 00:29:31 +0100349 trace_rxrpc_rtt_tx(call, rxrpc_rtt_tx_data, serial);
David Howells0d4b1032016-09-22 00:29:31 +0100350 }
David Howells17926a72007-04-26 15:48:28 -0700351 }
David Howells5a924b82016-09-22 00:29:31 +0100352 _leave(" = %d [%u]", ret, call->peer->maxdata);
353 return ret;
David Howells17926a72007-04-26 15:48:28 -0700354
355send_fragmentable:
356 /* attempt to send this message with fragmentation enabled */
357 _debug("send fragment");
358
David Howells985a5c82016-06-17 11:53:37 +0100359 down_write(&conn->params.local->defrag_sem);
David Howells17926a72007-04-26 15:48:28 -0700360
David Howells985a5c82016-06-17 11:53:37 +0100361 switch (conn->params.local->srx.transport.family) {
362 case AF_INET:
363 opt = IP_PMTUDISC_DONT;
364 ret = kernel_setsockopt(conn->params.local->socket,
365 SOL_IP, IP_MTU_DISCOVER,
366 (char *)&opt, sizeof(opt));
367 if (ret == 0) {
David Howells5a924b82016-09-22 00:29:31 +0100368 ret = kernel_sendmsg(conn->params.local->socket, &msg,
369 iov, 2, len);
David Howells985a5c82016-06-17 11:53:37 +0100370
371 opt = IP_PMTUDISC_DO;
372 kernel_setsockopt(conn->params.local->socket, SOL_IP,
373 IP_MTU_DISCOVER,
374 (char *)&opt, sizeof(opt));
375 }
376 break;
David Howells75b54cb2016-09-13 08:49:05 +0100377
David Howellsd1912742016-09-17 07:26:01 +0100378#ifdef CONFIG_AF_RXRPC_IPV6
David Howells75b54cb2016-09-13 08:49:05 +0100379 case AF_INET6:
380 opt = IPV6_PMTUDISC_DONT;
381 ret = kernel_setsockopt(conn->params.local->socket,
382 SOL_IPV6, IPV6_MTU_DISCOVER,
383 (char *)&opt, sizeof(opt));
384 if (ret == 0) {
385 ret = kernel_sendmsg(conn->params.local->socket, &msg,
David Howells85924b82018-02-22 14:38:14 +0000386 iov, 2, len);
David Howells75b54cb2016-09-13 08:49:05 +0100387
388 opt = IPV6_PMTUDISC_DO;
389 kernel_setsockopt(conn->params.local->socket,
390 SOL_IPV6, IPV6_MTU_DISCOVER,
391 (char *)&opt, sizeof(opt));
392 }
393 break;
David Howellsd1912742016-09-17 07:26:01 +0100394#endif
David Howellsffc58642019-07-02 15:55:28 +0100395
396 default:
397 BUG();
David Howells17926a72007-04-26 15:48:28 -0700398 }
399
David Howells985a5c82016-06-17 11:53:37 +0100400 up_write(&conn->params.local->defrag_sem);
David Howells5a924b82016-09-22 00:29:31 +0100401 goto done;
David Howells17926a72007-04-26 15:48:28 -0700402}
David Howells248f2192016-09-08 11:10:12 +0100403
404/*
405 * reject packets through the local endpoint
406 */
407void rxrpc_reject_packets(struct rxrpc_local *local)
408{
David Howells1c2bc7b2016-09-13 08:49:05 +0100409 struct sockaddr_rxrpc srx;
David Howells248f2192016-09-08 11:10:12 +0100410 struct rxrpc_skb_priv *sp;
411 struct rxrpc_wire_header whdr;
412 struct sk_buff *skb;
413 struct msghdr msg;
414 struct kvec iov[2];
415 size_t size;
416 __be32 code;
417
418 _enter("%d", local->debug_id);
419
420 iov[0].iov_base = &whdr;
421 iov[0].iov_len = sizeof(whdr);
422 iov[1].iov_base = &code;
423 iov[1].iov_len = sizeof(code);
424 size = sizeof(whdr) + sizeof(code);
425
David Howells1c2bc7b2016-09-13 08:49:05 +0100426 msg.msg_name = &srx.transport;
David Howells248f2192016-09-08 11:10:12 +0100427 msg.msg_control = NULL;
428 msg.msg_controllen = 0;
429 msg.msg_flags = 0;
430
David Howells248f2192016-09-08 11:10:12 +0100431 memset(&whdr, 0, sizeof(whdr));
432 whdr.type = RXRPC_PACKET_TYPE_ABORT;
433
434 while ((skb = skb_dequeue(&local->reject_queue))) {
David Howells71f3ca42016-09-17 10:49:14 +0100435 rxrpc_see_skb(skb, rxrpc_skb_rx_seen);
David Howells248f2192016-09-08 11:10:12 +0100436 sp = rxrpc_skb(skb);
David Howells1c2bc7b2016-09-13 08:49:05 +0100437
438 if (rxrpc_extract_addr_from_skb(&srx, skb) == 0) {
439 msg.msg_namelen = srx.transport_len;
440
David Howells248f2192016-09-08 11:10:12 +0100441 code = htonl(skb->priority);
442
443 whdr.epoch = htonl(sp->hdr.epoch);
444 whdr.cid = htonl(sp->hdr.cid);
445 whdr.callNumber = htonl(sp->hdr.callNumber);
446 whdr.serviceId = htons(sp->hdr.serviceId);
447 whdr.flags = sp->hdr.flags;
448 whdr.flags ^= RXRPC_CLIENT_INITIATED;
449 whdr.flags &= RXRPC_CLIENT_INITIATED;
450
451 kernel_sendmsg(local->socket, &msg, iov, 2, size);
David Howells248f2192016-09-08 11:10:12 +0100452 }
453
David Howells71f3ca42016-09-17 10:49:14 +0100454 rxrpc_free_skb(skb, rxrpc_skb_rx_freed);
David Howells248f2192016-09-08 11:10:12 +0100455 }
456
457 _leave("");
458}