2019-05-27 06:55:01 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2007-04-26 22:48:28 +00:00
|
|
|
/* RxRPC packet transmission
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
|
|
|
|
* Written by David Howells (dhowells@redhat.com)
|
|
|
|
*/
|
|
|
|
|
2016-06-02 19:08:52 +00:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2007-04-26 22:48:28 +00:00
|
|
|
#include <linux/net.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/gfp.h>
|
2007-04-26 22:48:28 +00:00
|
|
|
#include <linux/skbuff.h>
|
2011-07-15 15:47:34 +00:00
|
|
|
#include <linux/export.h>
|
2007-04-26 22:48:28 +00:00
|
|
|
#include <net/sock.h>
|
|
|
|
#include <net/af_rxrpc.h>
|
2022-03-22 11:07:20 +00:00
|
|
|
#include <net/udp.h>
|
2007-04-26 22:48:28 +00:00
|
|
|
#include "ar-internal.h"
|
|
|
|
|
2022-03-22 11:07:20 +00:00
|
|
|
extern int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len);
|
|
|
|
|
2022-11-11 16:00:21 +00:00
|
|
|
static ssize_t do_udp_sendmsg(struct socket *socket, struct msghdr *msg, size_t len)
|
2022-03-22 11:07:20 +00:00
|
|
|
{
|
|
|
|
struct sockaddr *sa = msg->msg_name;
|
2022-11-11 16:00:21 +00:00
|
|
|
struct sock *sk = socket->sk;
|
2022-03-22 11:07:20 +00:00
|
|
|
|
2022-11-11 16:00:21 +00:00
|
|
|
if (IS_ENABLED(CONFIG_AF_RXRPC_IPV6)) {
|
|
|
|
if (sa->sa_family == AF_INET6) {
|
|
|
|
if (sk->sk_family != AF_INET6) {
|
|
|
|
pr_warn("AF_INET6 address on AF_INET socket\n");
|
|
|
|
return -ENOPROTOOPT;
|
|
|
|
}
|
|
|
|
return udpv6_sendmsg(sk, msg, len);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return udp_sendmsg(sk, msg, len);
|
2022-03-22 11:07:20 +00:00
|
|
|
}
|
|
|
|
|
2016-10-06 07:11:49 +00:00
|
|
|
struct rxrpc_abort_buffer {
|
|
|
|
struct rxrpc_wire_header whdr;
|
|
|
|
__be32 abort_code;
|
|
|
|
};
|
|
|
|
|
2018-03-30 20:04:43 +00:00
|
|
|
static const char rxrpc_keepalive_string[] = "";
|
|
|
|
|
2018-11-01 13:39:53 +00:00
|
|
|
/*
|
|
|
|
* Increase Tx backoff on transmission failure and clear it on success.
|
|
|
|
*/
|
|
|
|
static void rxrpc_tx_backoff(struct rxrpc_call *call, int ret)
|
|
|
|
{
|
|
|
|
if (ret < 0) {
|
2024-01-30 21:37:16 +00:00
|
|
|
if (call->tx_backoff < 1000)
|
|
|
|
call->tx_backoff += 100;
|
2018-11-01 13:39:53 +00:00
|
|
|
} else {
|
2024-01-30 21:37:16 +00:00
|
|
|
call->tx_backoff = 0;
|
2018-11-01 13:39:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-24 10:18:42 +00:00
|
|
|
/*
|
|
|
|
* Arrange for a keepalive ping a certain time after we last transmitted. This
|
|
|
|
* lets the far side know we're still interested in this call and helps keep
|
|
|
|
* the route through any intervening firewall open.
|
|
|
|
*
|
|
|
|
* Receiving a response to the ping will prevent the ->expect_rx_by timer from
|
|
|
|
* expiring.
|
|
|
|
*/
|
2024-01-31 11:03:52 +00:00
|
|
|
static void rxrpc_set_keepalive(struct rxrpc_call *call, ktime_t now)
|
2017-11-24 10:18:42 +00:00
|
|
|
{
|
2024-01-30 21:37:16 +00:00
|
|
|
ktime_t delay = ms_to_ktime(READ_ONCE(call->next_rx_timo) / 6);
|
2017-11-24 10:18:42 +00:00
|
|
|
|
2024-01-30 21:37:16 +00:00
|
|
|
call->keepalive_at = ktime_add(ktime_get_real(), delay);
|
|
|
|
trace_rxrpc_timer_set(call, delay, rxrpc_timer_trace_keepalive);
|
2017-11-24 10:18:42 +00:00
|
|
|
}
|
|
|
|
|
2024-12-04 07:47:00 +00:00
|
|
|
/*
|
|
|
|
* Allocate transmission buffers for an ACK and attach them to local->kv[].
|
|
|
|
*/
|
|
|
|
static int rxrpc_alloc_ack(struct rxrpc_call *call, size_t sack_size)
|
|
|
|
{
|
|
|
|
struct rxrpc_wire_header *whdr;
|
|
|
|
struct rxrpc_acktrailer *trailer;
|
|
|
|
struct rxrpc_ackpacket *ack;
|
|
|
|
struct kvec *kv = call->local->kvec;
|
|
|
|
gfp_t gfp = rcu_read_lock_held() ? GFP_ATOMIC | __GFP_NOWARN : GFP_NOFS;
|
|
|
|
void *buf, *buf2 = NULL;
|
|
|
|
u8 *filler;
|
|
|
|
|
|
|
|
buf = page_frag_alloc(&call->local->tx_alloc,
|
|
|
|
sizeof(*whdr) + sizeof(*ack) + 1 + 3 + sizeof(*trailer), gfp);
|
|
|
|
if (!buf)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
if (sack_size) {
|
|
|
|
buf2 = page_frag_alloc(&call->local->tx_alloc, sack_size, gfp);
|
|
|
|
if (!buf2) {
|
|
|
|
page_frag_free(buf);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
whdr = buf;
|
|
|
|
ack = buf + sizeof(*whdr);
|
|
|
|
filler = buf + sizeof(*whdr) + sizeof(*ack) + 1;
|
|
|
|
trailer = buf + sizeof(*whdr) + sizeof(*ack) + 1 + 3;
|
|
|
|
|
|
|
|
kv[0].iov_base = whdr;
|
|
|
|
kv[0].iov_len = sizeof(*whdr) + sizeof(*ack);
|
|
|
|
kv[1].iov_base = buf2;
|
|
|
|
kv[1].iov_len = sack_size;
|
|
|
|
kv[2].iov_base = filler;
|
|
|
|
kv[2].iov_len = 3 + sizeof(*trailer);
|
|
|
|
return 3; /* Number of kvec[] used. */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rxrpc_free_ack(struct rxrpc_call *call)
|
|
|
|
{
|
|
|
|
page_frag_free(call->local->kvec[0].iov_base);
|
|
|
|
if (call->local->kvec[1].iov_base)
|
|
|
|
page_frag_free(call->local->kvec[1].iov_base);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Record the beginning of an RTT probe.
|
|
|
|
*/
|
|
|
|
static void rxrpc_begin_rtt_probe(struct rxrpc_call *call, rxrpc_serial_t serial,
|
|
|
|
ktime_t now, enum rxrpc_rtt_tx_trace why)
|
|
|
|
{
|
|
|
|
unsigned long avail = call->rtt_avail;
|
|
|
|
int rtt_slot = 9;
|
|
|
|
|
|
|
|
if (!(avail & RXRPC_CALL_RTT_AVAIL_MASK))
|
|
|
|
goto no_slot;
|
|
|
|
|
|
|
|
rtt_slot = __ffs(avail & RXRPC_CALL_RTT_AVAIL_MASK);
|
|
|
|
if (!test_and_clear_bit(rtt_slot, &call->rtt_avail))
|
|
|
|
goto no_slot;
|
|
|
|
|
|
|
|
call->rtt_serial[rtt_slot] = serial;
|
|
|
|
call->rtt_sent_at[rtt_slot] = now;
|
|
|
|
smp_wmb(); /* Write data before avail bit */
|
|
|
|
set_bit(rtt_slot + RXRPC_CALL_RTT_PEND_SHIFT, &call->rtt_avail);
|
|
|
|
|
|
|
|
trace_rxrpc_rtt_tx(call, why, rtt_slot, serial);
|
|
|
|
return;
|
|
|
|
|
|
|
|
no_slot:
|
|
|
|
trace_rxrpc_rtt_tx(call, rxrpc_rtt_tx_no_slot, rtt_slot, serial);
|
|
|
|
}
|
|
|
|
|
2016-09-07 08:19:31 +00:00
|
|
|
/*
|
|
|
|
* Fill out an ACK packet.
|
|
|
|
*/
|
2024-12-04 07:47:00 +00:00
|
|
|
static int rxrpc_fill_out_ack(struct rxrpc_call *call, int nr_kv, u8 ack_reason,
|
|
|
|
rxrpc_serial_t serial_to_ack, rxrpc_serial_t *_ack_serial)
|
2016-09-07 08:19:31 +00:00
|
|
|
{
|
2024-12-04 07:47:00 +00:00
|
|
|
struct kvec *kv = call->local->kvec;
|
|
|
|
struct rxrpc_wire_header *whdr = kv[0].iov_base;
|
|
|
|
struct rxrpc_acktrailer *trailer = kv[2].iov_base + 3;
|
2024-01-30 08:44:40 +00:00
|
|
|
struct rxrpc_ackpacket *ack = (struct rxrpc_ackpacket *)(whdr + 1);
|
2024-12-04 07:46:37 +00:00
|
|
|
unsigned int qsize, sack, wrap, to, max_mtu, if_mtu;
|
2022-10-16 07:01:32 +00:00
|
|
|
rxrpc_seq_t window, wtop;
|
2024-12-04 07:47:00 +00:00
|
|
|
ktime_t now = ktime_get_real();
|
2022-08-27 13:27:56 +00:00
|
|
|
int rsize;
|
2024-12-04 07:47:00 +00:00
|
|
|
u8 *filler = kv[2].iov_base;
|
|
|
|
u8 *sackp = kv[1].iov_base;
|
2016-09-07 08:19:31 +00:00
|
|
|
|
2022-05-11 13:01:25 +00:00
|
|
|
rxrpc_inc_stat(call->rxnet, stat_tx_ack_fill);
|
2022-05-21 08:03:31 +00:00
|
|
|
|
2022-10-17 10:44:22 +00:00
|
|
|
window = call->ackr_window;
|
|
|
|
wtop = call->ackr_wtop;
|
2022-10-16 07:01:32 +00:00
|
|
|
sack = call->ackr_sack_base % RXRPC_SACK_SIZE;
|
2024-01-30 08:44:40 +00:00
|
|
|
|
2024-12-04 07:47:00 +00:00
|
|
|
*_ack_serial = rxrpc_get_next_serial(call->conn);
|
|
|
|
|
|
|
|
whdr->epoch = htonl(call->conn->proto.epoch);
|
|
|
|
whdr->cid = htonl(call->cid);
|
|
|
|
whdr->callNumber = htonl(call->call_id);
|
|
|
|
whdr->serial = htonl(*_ack_serial);
|
2024-01-30 08:44:40 +00:00
|
|
|
whdr->seq = 0;
|
|
|
|
whdr->type = RXRPC_PACKET_TYPE_ACK;
|
2024-12-04 07:47:00 +00:00
|
|
|
whdr->flags = call->conn->out_clientflag | RXRPC_SLOW_START_OK;
|
|
|
|
whdr->userStatus = 0;
|
|
|
|
whdr->securityIndex = call->security_ix;
|
|
|
|
whdr->_rsvd = 0;
|
|
|
|
whdr->serviceId = htons(call->dest_srx.srx_service);
|
|
|
|
|
2024-01-30 08:44:40 +00:00
|
|
|
ack->bufferSpace = 0;
|
|
|
|
ack->maxSkew = 0;
|
|
|
|
ack->firstPacket = htonl(window);
|
|
|
|
ack->previousPacket = htonl(call->rx_highest_seq);
|
2024-12-04 07:47:00 +00:00
|
|
|
ack->serial = htonl(serial_to_ack);
|
2024-01-30 08:44:40 +00:00
|
|
|
ack->reason = ack_reason;
|
|
|
|
ack->nAcks = wtop - window;
|
2024-01-29 23:47:57 +00:00
|
|
|
filler[0] = 0;
|
|
|
|
filler[1] = 0;
|
|
|
|
filler[2] = 0;
|
|
|
|
|
|
|
|
if (ack_reason == RXRPC_ACK_PING)
|
2024-12-04 07:47:00 +00:00
|
|
|
whdr->flags |= RXRPC_REQUEST_ACK;
|
2022-08-27 13:27:56 +00:00
|
|
|
|
|
|
|
if (after(wtop, window)) {
|
2024-12-04 07:47:00 +00:00
|
|
|
kv[1].iov_len = ack->nAcks;
|
2024-01-29 23:47:57 +00:00
|
|
|
|
2022-10-16 07:01:32 +00:00
|
|
|
wrap = RXRPC_SACK_SIZE - sack;
|
2024-12-04 07:46:31 +00:00
|
|
|
to = umin(ack->nAcks, RXRPC_SACK_SIZE);
|
2022-08-27 13:27:56 +00:00
|
|
|
|
2024-01-30 08:44:40 +00:00
|
|
|
if (sack + ack->nAcks <= RXRPC_SACK_SIZE) {
|
2024-01-29 23:47:57 +00:00
|
|
|
memcpy(sackp, call->ackr_sack_table + sack, ack->nAcks);
|
2022-08-27 13:27:56 +00:00
|
|
|
} else {
|
2024-01-29 23:47:57 +00:00
|
|
|
memcpy(sackp, call->ackr_sack_table + sack, wrap);
|
|
|
|
memcpy(sackp + wrap, call->ackr_sack_table, to - wrap);
|
2022-08-27 13:27:56 +00:00
|
|
|
}
|
|
|
|
} else if (before(wtop, window)) {
|
|
|
|
pr_warn("ack window backward %x %x", window, wtop);
|
2024-01-30 08:44:40 +00:00
|
|
|
} else if (ack->reason == RXRPC_ACK_DELAY) {
|
|
|
|
ack->reason = RXRPC_ACK_IDLE;
|
rxrpc: Rewrite the data and ack handling code
Rewrite the data and ack handling code such that:
(1) Parsing of received ACK and ABORT packets and the distribution and the
filing of DATA packets happens entirely within the data_ready context
called from the UDP socket. This allows us to process and discard ACK
and ABORT packets much more quickly (they're no longer stashed on a
queue for a background thread to process).
(2) We avoid calling skb_clone(), pskb_pull() and pskb_trim(). We instead
keep track of the offset and length of the content of each packet in
the sk_buff metadata. This means we don't do any allocation in the
receive path.
(3) Jumbo DATA packet parsing is now done in data_ready context. Rather
than cloning the packet once for each subpacket and pulling/trimming
it, we file the packet multiple times with an annotation for each
indicating which subpacket is there. From that we can directly
calculate the offset and length.
(4) A call's receive queue can be accessed without taking locks (memory
barriers do have to be used, though).
(5) Incoming calls are set up from preallocated resources and immediately
made live. They can than have packets queued upon them and ACKs
generated. If insufficient resources exist, DATA packet #1 is given a
BUSY reply and other DATA packets are discarded).
(6) sk_buffs no longer take a ref on their parent call.
To make this work, the following changes are made:
(1) Each call's receive buffer is now a circular buffer of sk_buff
pointers (rxtx_buffer) rather than a number of sk_buff_heads spread
between the call and the socket. This permits each sk_buff to be in
the buffer multiple times. The receive buffer is reused for the
transmit buffer.
(2) A circular buffer of annotations (rxtx_annotations) is kept parallel
to the data buffer. Transmission phase annotations indicate whether a
buffered packet has been ACK'd or not and whether it needs
retransmission.
Receive phase annotations indicate whether a slot holds a whole packet
or a jumbo subpacket and, if the latter, which subpacket. They also
note whether the packet has been decrypted in place.
(3) DATA packet window tracking is much simplified. Each phase has just
two numbers representing the window (rx_hard_ack/rx_top and
tx_hard_ack/tx_top).
The hard_ack number is the sequence number before base of the window,
representing the last packet the other side says it has consumed.
hard_ack starts from 0 and the first packet is sequence number 1.
The top number is the sequence number of the highest-numbered packet
residing in the buffer. Packets between hard_ack+1 and top are
soft-ACK'd to indicate they've been received, but not yet consumed.
Four macros, before(), before_eq(), after() and after_eq() are added
to compare sequence numbers within the window. This allows for the
top of the window to wrap when the hard-ack sequence number gets close
to the limit.
Two flags, RXRPC_CALL_RX_LAST and RXRPC_CALL_TX_LAST, are added also
to indicate when rx_top and tx_top point at the packets with the
LAST_PACKET bit set, indicating the end of the phase.
(4) Calls are queued on the socket 'receive queue' rather than packets.
This means that we don't need have to invent dummy packets to queue to
indicate abnormal/terminal states and we don't have to keep metadata
packets (such as ABORTs) around
(5) The offset and length of a (sub)packet's content are now passed to
the verify_packet security op. This is currently expected to decrypt
the packet in place and validate it.
However, there's now nowhere to store the revised offset and length of
the actual data within the decrypted blob (there may be a header and
padding to skip) because an sk_buff may represent multiple packets, so
a locate_data security op is added to retrieve these details from the
sk_buff content when needed.
(6) recvmsg() now has to handle jumbo subpackets, where each subpacket is
individually secured and needs to be individually decrypted. The code
to do this is broken out into rxrpc_recvmsg_data() and shared with the
kernel API. It now iterates over the call's receive buffer rather
than walking the socket receive queue.
Additional changes:
(1) The timers are condensed to a single timer that is set for the soonest
of three timeouts (delayed ACK generation, DATA retransmission and
call lifespan).
(2) Transmission of ACK and ABORT packets is effected immediately from
process-context socket ops/kernel API calls that cause them instead of
them being punted off to a background work item. The data_ready
handler still has to defer to the background, though.
(3) A shutdown op is added to the AF_RXRPC socket so that the AFS
filesystem can shut down the socket and flush its own work items
before closing the socket to deal with any in-progress service calls.
Future additional changes that will need to be considered:
(1) Make sure that a call doesn't hog the front of the queue by receiving
data from the network as fast as userspace is consuming it to the
exclusion of other calls.
(2) Transmit delayed ACKs from within recvmsg() when we've consumed
sufficiently more packets to avoid the background work item needing to
run.
Signed-off-by: David Howells <dhowells@redhat.com>
2016-09-08 10:10:12 +00:00
|
|
|
}
|
2016-09-07 08:19:31 +00:00
|
|
|
|
2022-08-27 13:27:56 +00:00
|
|
|
qsize = (window - 1) - call->rx_consumed;
|
|
|
|
rsize = max_t(int, call->rx_winsize - qsize, 0);
|
2024-12-04 07:46:37 +00:00
|
|
|
|
|
|
|
if_mtu = call->peer->if_mtu - call->peer->hdrsize;
|
|
|
|
if (call->peer->ackr_adv_pmtud) {
|
|
|
|
max_mtu = umax(call->peer->max_data, rxrpc_rx_mtu);
|
|
|
|
} else {
|
|
|
|
if_mtu = umin(if_mtu, 1444);
|
|
|
|
max_mtu = if_mtu;
|
|
|
|
}
|
|
|
|
|
|
|
|
trailer->maxMTU = htonl(max_mtu);
|
|
|
|
trailer->ifMTU = htonl(if_mtu);
|
2024-01-29 23:47:57 +00:00
|
|
|
trailer->rwind = htonl(rsize);
|
2024-12-04 07:46:37 +00:00
|
|
|
trailer->jumbo_max = 0; /* Advertise pmtu discovery */
|
2016-09-07 08:19:31 +00:00
|
|
|
|
2024-12-04 07:47:00 +00:00
|
|
|
if (ack_reason == RXRPC_ACK_PING)
|
|
|
|
rxrpc_begin_rtt_probe(call, *_ack_serial, now, rxrpc_rtt_tx_ping);
|
|
|
|
if (whdr->flags & RXRPC_REQUEST_ACK)
|
2024-12-04 07:47:05 +00:00
|
|
|
call->rtt_last_req = now;
|
2024-12-04 07:47:00 +00:00
|
|
|
rxrpc_set_keepalive(call, now);
|
|
|
|
return nr_kv;
|
rxrpc: Fix loss of RTT samples due to interposed ACK
The Rx protocol has a mechanism to help generate RTT samples that works by
a client transmitting a REQUESTED-type ACK when it receives a DATA packet
that has the REQUEST_ACK flag set.
The peer, however, may interpose other ACKs before transmitting the
REQUESTED-ACK, as can be seen in the following trace excerpt:
rxrpc_tx_data: c=00000044 DATA d0b5ece8:00000001 00000001 q=00000001 fl=07
rxrpc_rx_ack: c=00000044 00000001 PNG r=00000000 f=00000002 p=00000000 n=0
rxrpc_rx_ack: c=00000044 00000002 REQ r=00000001 f=00000002 p=00000001 n=0
...
DATA packet 1 (q=xx) has REQUEST_ACK set (bit 1 of fl=xx). The incoming
ping (labelled PNG) hard-acks the request DATA packet (f=xx exceeds the
sequence number of the DATA packet), causing it to be discarded from the Tx
ring. The ACK that was requested (labelled REQ, r=xx references the serial
of the DATA packet) comes after the ping, but the sk_buff holding the
timestamp has gone and the RTT sample is lost.
This is particularly noticeable on RPC calls used to probe the service
offered by the peer. A lot of peers end up with an unknown RTT because we
only ever sent a single RPC. This confuses the server rotation algorithm.
Fix this by caching the information about the outgoing packet in RTT
calculations in the rxrpc_call struct rather than looking in the Tx ring.
A four-deep buffer is maintained and both REQUEST_ACK-flagged DATA and
PING-ACK transmissions are recorded in there. When the appropriate
response ACK is received, the buffer is checked for a match and, if found,
an RTT sample is recorded.
If a received ACK refers to a packet with a later serial number than an
entry in the cache, that entry is presumed lost and the entry is made
available to record a new transmission.
ACKs types other than REQUESTED-type and PING-type cause any matching
sample to be cancelled as they don't necessarily represent a useful
measurement.
If there's no space in the buffer on ping/data transmission, the sample
base is discarded.
Fixes: 50235c4b5a2f ("rxrpc: Obtain RTT data by requesting ACKs on DATA packets")
Signed-off-by: David Howells <dhowells@redhat.com>
2020-08-19 22:29:16 +00:00
|
|
|
}
|
|
|
|
|
2016-09-07 08:19:31 +00:00
|
|
|
/*
|
2020-01-30 21:48:13 +00:00
|
|
|
* Transmit an ACK packet.
|
2016-09-07 08:19:31 +00:00
|
|
|
*/
|
2024-12-04 07:47:00 +00:00
|
|
|
static void rxrpc_send_ack_packet(struct rxrpc_call *call, int nr_kv, size_t len,
|
|
|
|
rxrpc_serial_t serial, enum rxrpc_propose_ack_trace why)
|
2016-09-07 08:19:31 +00:00
|
|
|
{
|
2024-12-04 07:46:36 +00:00
|
|
|
struct kvec *kv = call->local->kvec;
|
|
|
|
struct rxrpc_wire_header *whdr = kv[0].iov_base;
|
2024-12-04 07:47:00 +00:00
|
|
|
struct rxrpc_acktrailer *trailer = kv[2].iov_base + 3;
|
2020-01-30 21:50:36 +00:00
|
|
|
struct rxrpc_connection *conn;
|
2024-01-30 08:44:40 +00:00
|
|
|
struct rxrpc_ackpacket *ack = (struct rxrpc_ackpacket *)(whdr + 1);
|
2016-09-07 08:19:31 +00:00
|
|
|
struct msghdr msg;
|
2024-01-31 11:03:52 +00:00
|
|
|
int ret;
|
2016-09-07 08:19:31 +00:00
|
|
|
|
2020-01-30 21:50:36 +00:00
|
|
|
if (test_bit(RXRPC_CALL_DISCONNECTED, &call->flags))
|
2024-01-29 23:47:57 +00:00
|
|
|
return;
|
2016-09-07 08:19:31 +00:00
|
|
|
|
2020-01-30 21:50:36 +00:00
|
|
|
conn = call->conn;
|
2016-09-07 08:19:31 +00:00
|
|
|
|
|
|
|
msg.msg_name = &call->peer->srx.transport;
|
|
|
|
msg.msg_namelen = call->peer->srx.transport_len;
|
|
|
|
msg.msg_control = NULL;
|
|
|
|
msg.msg_controllen = 0;
|
2024-01-29 23:47:57 +00:00
|
|
|
msg.msg_flags = MSG_SPLICE_PAGES;
|
2016-09-07 08:19:31 +00:00
|
|
|
|
2024-12-04 07:47:00 +00:00
|
|
|
trace_rxrpc_tx_ack(call->debug_id, serial,
|
2024-01-30 08:44:40 +00:00
|
|
|
ntohl(ack->firstPacket),
|
|
|
|
ntohl(ack->serial), ack->reason, ack->nAcks,
|
2024-12-04 07:47:04 +00:00
|
|
|
ntohl(trailer->rwind), why);
|
2016-09-23 14:08:48 +00:00
|
|
|
|
2022-05-11 13:01:25 +00:00
|
|
|
rxrpc_inc_stat(call->rxnet, stat_tx_ack_send);
|
2022-03-22 11:07:20 +00:00
|
|
|
|
2024-12-04 07:47:00 +00:00
|
|
|
iov_iter_kvec(&msg.msg_iter, WRITE, kv, nr_kv, len);
|
2024-12-04 07:46:37 +00:00
|
|
|
rxrpc_local_dont_fragment(conn->local, why == rxrpc_propose_ack_ping_for_mtu_probe);
|
2024-12-04 07:46:36 +00:00
|
|
|
|
2024-12-04 07:47:00 +00:00
|
|
|
ret = do_udp_sendmsg(conn->local->socket, &msg, len);
|
2022-03-22 11:07:20 +00:00
|
|
|
call->peer->last_tx_at = ktime_get_seconds();
|
2022-10-17 09:55:41 +00:00
|
|
|
if (ret < 0) {
|
2024-12-04 07:47:00 +00:00
|
|
|
trace_rxrpc_tx_fail(call->debug_id, serial, ret,
|
2018-07-23 16:18:37 +00:00
|
|
|
rxrpc_tx_point_call_ack);
|
2024-12-04 07:46:37 +00:00
|
|
|
if (why == rxrpc_propose_ack_ping_for_mtu_probe &&
|
|
|
|
ret == -EMSGSIZE)
|
2024-12-04 07:47:00 +00:00
|
|
|
rxrpc_input_probe_for_pmtud(conn, serial, true);
|
2022-10-17 09:55:41 +00:00
|
|
|
} else {
|
2024-01-30 08:44:40 +00:00
|
|
|
trace_rxrpc_tx_packet(call->debug_id, whdr,
|
2018-07-23 16:18:37 +00:00
|
|
|
rxrpc_tx_point_call_ack);
|
2024-12-04 07:46:37 +00:00
|
|
|
if (why == rxrpc_propose_ack_ping_for_mtu_probe) {
|
|
|
|
call->peer->pmtud_pending = false;
|
|
|
|
call->peer->pmtud_probing = true;
|
2024-12-04 07:47:00 +00:00
|
|
|
call->conn->pmtud_probe = serial;
|
2024-12-04 07:46:37 +00:00
|
|
|
call->conn->pmtud_call = call->debug_id;
|
|
|
|
trace_rxrpc_pmtud_tx(call);
|
|
|
|
}
|
2022-10-17 09:55:41 +00:00
|
|
|
}
|
2018-11-01 13:39:53 +00:00
|
|
|
rxrpc_tx_backoff(call, ret);
|
2016-09-07 08:19:31 +00:00
|
|
|
}
|
|
|
|
|
2024-01-30 08:35:25 +00:00
|
|
|
/*
|
|
|
|
* Queue an ACK for immediate transmission.
|
|
|
|
*/
|
|
|
|
void rxrpc_send_ACK(struct rxrpc_call *call, u8 ack_reason,
|
2024-12-04 07:47:00 +00:00
|
|
|
rxrpc_serial_t serial_to_ack, enum rxrpc_propose_ack_trace why)
|
2024-01-30 08:35:25 +00:00
|
|
|
{
|
2024-12-04 07:46:36 +00:00
|
|
|
struct kvec *kv = call->local->kvec;
|
2024-12-04 07:47:00 +00:00
|
|
|
rxrpc_serial_t ack_serial;
|
|
|
|
size_t len;
|
2024-12-04 07:46:36 +00:00
|
|
|
int nr_kv;
|
2024-01-30 08:35:25 +00:00
|
|
|
|
|
|
|
if (test_bit(RXRPC_CALL_DISCONNECTED, &call->flags))
|
|
|
|
return;
|
|
|
|
|
|
|
|
rxrpc_inc_stat(call->rxnet, stat_tx_acks[ack_reason]);
|
|
|
|
|
2024-12-04 07:47:00 +00:00
|
|
|
nr_kv = rxrpc_alloc_ack(call, call->ackr_wtop - call->ackr_window);
|
|
|
|
if (nr_kv < 0) {
|
2024-01-30 08:35:25 +00:00
|
|
|
kleave(" = -ENOMEM");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-12-04 07:47:00 +00:00
|
|
|
nr_kv = rxrpc_fill_out_ack(call, nr_kv, ack_reason, serial_to_ack, &ack_serial);
|
|
|
|
len = kv[0].iov_len;
|
|
|
|
len += kv[1].iov_len;
|
|
|
|
len += kv[2].iov_len;
|
2024-12-04 07:46:36 +00:00
|
|
|
|
2024-12-04 07:46:37 +00:00
|
|
|
/* Extend a path MTU probe ACK. */
|
|
|
|
if (why == rxrpc_propose_ack_ping_for_mtu_probe) {
|
|
|
|
size_t probe_mtu = call->peer->pmtud_trial + sizeof(struct rxrpc_wire_header);
|
|
|
|
|
2024-12-04 07:47:00 +00:00
|
|
|
if (len > probe_mtu)
|
2024-12-04 07:46:37 +00:00
|
|
|
goto skip;
|
2024-12-04 07:47:00 +00:00
|
|
|
while (len < probe_mtu) {
|
|
|
|
size_t part = umin(probe_mtu - len, PAGE_SIZE);
|
2024-12-04 07:46:37 +00:00
|
|
|
|
|
|
|
kv[nr_kv].iov_base = page_address(ZERO_PAGE(0));
|
|
|
|
kv[nr_kv].iov_len = part;
|
2024-12-04 07:47:00 +00:00
|
|
|
len += part;
|
2024-12-04 07:46:37 +00:00
|
|
|
nr_kv++;
|
|
|
|
}
|
|
|
|
}
|
2024-12-04 07:46:36 +00:00
|
|
|
|
2024-01-29 23:47:57 +00:00
|
|
|
call->ackr_nr_unacked = 0;
|
|
|
|
atomic_set(&call->ackr_nr_consumed, 0);
|
|
|
|
clear_bit(RXRPC_CALL_RX_IS_IDLE, &call->flags);
|
2024-01-30 08:35:25 +00:00
|
|
|
|
2024-12-04 07:47:00 +00:00
|
|
|
trace_rxrpc_send_ack(call, why, ack_reason, ack_serial);
|
|
|
|
rxrpc_send_ack_packet(call, nr_kv, len, ack_serial, why);
|
2024-12-04 07:46:37 +00:00
|
|
|
skip:
|
2024-12-04 07:47:00 +00:00
|
|
|
rxrpc_free_ack(call);
|
2024-01-30 08:35:25 +00:00
|
|
|
}
|
|
|
|
|
2024-12-04 07:46:37 +00:00
|
|
|
/*
|
|
|
|
* Send an ACK probe for path MTU discovery.
|
|
|
|
*/
|
|
|
|
void rxrpc_send_probe_for_pmtud(struct rxrpc_call *call)
|
|
|
|
{
|
|
|
|
rxrpc_send_ACK(call, RXRPC_ACK_PING, 0,
|
|
|
|
rxrpc_propose_ack_ping_for_mtu_probe);
|
|
|
|
}
|
|
|
|
|
2016-10-06 07:11:49 +00:00
|
|
|
/*
|
|
|
|
* Send an ABORT call packet.
|
|
|
|
*/
|
|
|
|
int rxrpc_send_abort_packet(struct rxrpc_call *call)
|
|
|
|
{
|
2020-01-30 21:50:36 +00:00
|
|
|
struct rxrpc_connection *conn;
|
2016-10-06 07:11:49 +00:00
|
|
|
struct rxrpc_abort_buffer pkt;
|
|
|
|
struct msghdr msg;
|
|
|
|
struct kvec iov[1];
|
|
|
|
rxrpc_serial_t serial;
|
|
|
|
int ret;
|
|
|
|
|
2017-11-02 15:06:26 +00:00
|
|
|
/* Don't bother sending aborts for a client call once the server has
|
|
|
|
* hard-ACK'd all of its request data. After that point, we're not
|
|
|
|
* going to stop the operation proceeding, and whilst we might limit
|
|
|
|
* the reply, it's not worth it if we can send a new call on the same
|
|
|
|
* channel instead, thereby closing off this call.
|
|
|
|
*/
|
|
|
|
if (rxrpc_is_client_call(call) &&
|
2022-03-31 22:55:08 +00:00
|
|
|
test_bit(RXRPC_CALL_TX_ALL_ACKED, &call->flags))
|
2017-11-02 15:06:26 +00:00
|
|
|
return 0;
|
|
|
|
|
2020-01-30 21:50:36 +00:00
|
|
|
if (test_bit(RXRPC_CALL_DISCONNECTED, &call->flags))
|
2016-10-06 07:11:49 +00:00
|
|
|
return -ECONNRESET;
|
|
|
|
|
2020-01-30 21:50:36 +00:00
|
|
|
conn = call->conn;
|
|
|
|
|
2016-10-06 07:11:49 +00:00
|
|
|
msg.msg_name = &call->peer->srx.transport;
|
|
|
|
msg.msg_namelen = call->peer->srx.transport_len;
|
|
|
|
msg.msg_control = NULL;
|
|
|
|
msg.msg_controllen = 0;
|
|
|
|
msg.msg_flags = 0;
|
|
|
|
|
|
|
|
pkt.whdr.epoch = htonl(conn->proto.epoch);
|
|
|
|
pkt.whdr.cid = htonl(call->cid);
|
|
|
|
pkt.whdr.callNumber = htonl(call->call_id);
|
|
|
|
pkt.whdr.seq = 0;
|
|
|
|
pkt.whdr.type = RXRPC_PACKET_TYPE_ABORT;
|
|
|
|
pkt.whdr.flags = conn->out_clientflag;
|
|
|
|
pkt.whdr.userStatus = 0;
|
|
|
|
pkt.whdr.securityIndex = call->security_ix;
|
|
|
|
pkt.whdr._rsvd = 0;
|
2022-10-20 20:58:36 +00:00
|
|
|
pkt.whdr.serviceId = htons(call->dest_srx.srx_service);
|
2016-10-06 07:11:49 +00:00
|
|
|
pkt.abort_code = htonl(call->abort_code);
|
|
|
|
|
|
|
|
iov[0].iov_base = &pkt;
|
|
|
|
iov[0].iov_len = sizeof(pkt);
|
|
|
|
|
2024-02-02 15:19:13 +00:00
|
|
|
serial = rxrpc_get_next_serial(conn);
|
2016-10-06 07:11:49 +00:00
|
|
|
pkt.whdr.serial = htonl(serial);
|
|
|
|
|
2022-03-22 11:07:20 +00:00
|
|
|
iov_iter_kvec(&msg.msg_iter, WRITE, iov, 1, sizeof(pkt));
|
2022-10-19 12:49:02 +00:00
|
|
|
ret = do_udp_sendmsg(conn->local->socket, &msg, sizeof(pkt));
|
|
|
|
conn->peer->last_tx_at = ktime_get_seconds();
|
2018-05-10 22:26:01 +00:00
|
|
|
if (ret < 0)
|
|
|
|
trace_rxrpc_tx_fail(call->debug_id, serial, ret,
|
2018-07-23 16:18:37 +00:00
|
|
|
rxrpc_tx_point_call_abort);
|
|
|
|
else
|
|
|
|
trace_rxrpc_tx_packet(call->debug_id, &pkt.whdr,
|
|
|
|
rxrpc_tx_point_call_abort);
|
2018-11-01 13:39:53 +00:00
|
|
|
rxrpc_tx_backoff(call, ret);
|
2016-10-06 07:11:49 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-04-26 22:48:28 +00:00
|
|
|
/*
|
2024-01-26 10:47:39 +00:00
|
|
|
* Prepare a (sub)packet for transmission.
|
2007-04-26 22:48:28 +00:00
|
|
|
*/
|
2024-12-04 07:46:46 +00:00
|
|
|
static size_t rxrpc_prepare_data_subpacket(struct rxrpc_call *call,
|
|
|
|
struct rxrpc_send_data_req *req,
|
|
|
|
struct rxrpc_txbuf *txb,
|
|
|
|
rxrpc_serial_t serial, int subpkt)
|
2007-04-26 22:48:28 +00:00
|
|
|
{
|
2024-01-26 10:47:39 +00:00
|
|
|
struct rxrpc_wire_header *whdr = txb->kvec[0].iov_base;
|
2024-12-04 07:46:39 +00:00
|
|
|
struct rxrpc_jumbo_header *jumbo = (void *)(whdr + 1) - sizeof(*jumbo);
|
2024-01-29 22:49:19 +00:00
|
|
|
enum rxrpc_req_ack_trace why;
|
2024-01-26 10:47:39 +00:00
|
|
|
struct rxrpc_connection *conn = call->conn;
|
2024-12-04 07:46:36 +00:00
|
|
|
struct kvec *kv = &call->local->kvec[subpkt];
|
2024-12-04 07:46:38 +00:00
|
|
|
size_t len = txb->pkt_len;
|
2024-12-04 07:46:46 +00:00
|
|
|
bool last;
|
2024-12-04 07:46:32 +00:00
|
|
|
u8 flags;
|
2007-04-26 22:48:28 +00:00
|
|
|
|
2024-12-04 07:46:38 +00:00
|
|
|
_enter("%x,%zd", txb->seq, len);
|
2007-04-26 22:48:28 +00:00
|
|
|
|
2024-01-26 10:47:39 +00:00
|
|
|
txb->serial = serial;
|
2016-09-21 23:29:31 +00:00
|
|
|
|
2017-06-05 13:30:49 +00:00
|
|
|
if (test_bit(RXRPC_CONN_PROBING_FOR_UPGRADE, &conn->flags) &&
|
2022-03-31 22:55:08 +00:00
|
|
|
txb->seq == 1)
|
2024-01-30 08:44:40 +00:00
|
|
|
whdr->userStatus = RXRPC_USERSTATUS_SERVICE_UPGRADE;
|
2017-06-05 13:30:49 +00:00
|
|
|
|
2024-12-04 07:46:32 +00:00
|
|
|
txb->flags &= ~RXRPC_REQUEST_ACK;
|
|
|
|
flags = txb->flags & RXRPC_TXBUF_WIRE_FLAGS;
|
|
|
|
last = txb->flags & RXRPC_LAST_PACKET;
|
|
|
|
|
2024-12-04 07:46:46 +00:00
|
|
|
if (subpkt < req->n - 1) {
|
2024-12-04 07:46:39 +00:00
|
|
|
len = RXRPC_JUMBO_DATALEN;
|
|
|
|
goto dont_set_request_ack;
|
|
|
|
}
|
|
|
|
|
2016-09-24 17:05:27 +00:00
|
|
|
/* If our RTT cache needs working on, request an ACK. Also request
|
|
|
|
* ACKs if a DATA packet appears to have been lost.
|
2018-09-27 14:13:08 +00:00
|
|
|
*
|
|
|
|
* However, we mustn't request an ACK on the last reply packet of a
|
|
|
|
* service call, lest OpenAFS incorrectly send us an ACK with some
|
|
|
|
* soft-ACKs in it and then never follow up with a proper hard ACK.
|
2016-09-24 17:05:27 +00:00
|
|
|
*/
|
2024-12-04 07:46:32 +00:00
|
|
|
if (last && rxrpc_sending_to_client(txb))
|
2022-04-05 20:48:48 +00:00
|
|
|
why = rxrpc_reqack_no_srv_last;
|
|
|
|
else if (test_and_clear_bit(RXRPC_CALL_EV_ACK_LOST, &call->events))
|
|
|
|
why = rxrpc_reqack_ack_lost;
|
2024-01-29 15:01:10 +00:00
|
|
|
else if (txb->flags & RXRPC_TXBUF_RESENT)
|
2022-04-05 20:48:48 +00:00
|
|
|
why = rxrpc_reqack_retrans;
|
2024-12-04 07:47:06 +00:00
|
|
|
else if (call->cong_ca_state == RXRPC_CA_SLOW_START && call->cong_cwnd <= RXRPC_MIN_CWND)
|
2022-04-05 20:48:48 +00:00
|
|
|
why = rxrpc_reqack_slow_start;
|
|
|
|
else if (call->tx_winsize <= 2)
|
|
|
|
why = rxrpc_reqack_small_txwin;
|
2024-12-04 07:47:05 +00:00
|
|
|
else if (call->rtt_count < 3)
|
2022-04-05 20:48:48 +00:00
|
|
|
why = rxrpc_reqack_more_rtt;
|
2024-12-04 07:47:05 +00:00
|
|
|
else if (ktime_before(ktime_add_ms(call->rtt_last_req, 1000), ktime_get_real()))
|
2022-04-05 20:48:48 +00:00
|
|
|
why = rxrpc_reqack_old_rtt;
|
2024-12-04 07:46:46 +00:00
|
|
|
else if (!last && !after(READ_ONCE(call->send_top), txb->seq))
|
2024-12-04 07:46:35 +00:00
|
|
|
why = rxrpc_reqack_app_stall;
|
2022-04-05 20:48:48 +00:00
|
|
|
else
|
|
|
|
goto dont_set_request_ack;
|
|
|
|
|
2022-08-18 10:52:36 +00:00
|
|
|
rxrpc_inc_stat(call->rxnet, stat_why_req_ack[why]);
|
2022-03-31 22:55:08 +00:00
|
|
|
trace_rxrpc_req_ack(call->debug_id, txb->seq, why);
|
2024-12-04 07:46:32 +00:00
|
|
|
if (why != rxrpc_reqack_no_srv_last) {
|
|
|
|
flags |= RXRPC_REQUEST_ACK;
|
2024-12-04 07:46:52 +00:00
|
|
|
trace_rxrpc_rtt_tx(call, rxrpc_rtt_tx_data, -1, serial);
|
2024-12-04 07:47:05 +00:00
|
|
|
call->rtt_last_req = req->now;
|
2024-12-04 07:46:32 +00:00
|
|
|
}
|
2022-04-05 20:48:48 +00:00
|
|
|
dont_set_request_ack:
|
2016-09-21 23:29:31 +00:00
|
|
|
|
2024-12-04 07:46:39 +00:00
|
|
|
/* The jumbo header overlays the wire header in the txbuf. */
|
2024-12-04 07:46:46 +00:00
|
|
|
if (subpkt < req->n - 1)
|
2024-12-04 07:46:39 +00:00
|
|
|
flags |= RXRPC_JUMBO_PACKET;
|
|
|
|
else
|
|
|
|
flags &= ~RXRPC_JUMBO_PACKET;
|
|
|
|
if (subpkt == 0) {
|
|
|
|
whdr->flags = flags;
|
|
|
|
whdr->serial = htonl(txb->serial);
|
|
|
|
whdr->cksum = txb->cksum;
|
|
|
|
whdr->serviceId = htons(conn->service_id);
|
|
|
|
kv->iov_base = whdr;
|
|
|
|
len += sizeof(*whdr);
|
|
|
|
} else {
|
|
|
|
jumbo->flags = flags;
|
|
|
|
jumbo->pad = 0;
|
|
|
|
jumbo->cksum = txb->cksum;
|
|
|
|
kv->iov_base = jumbo;
|
|
|
|
len += sizeof(*jumbo);
|
|
|
|
}
|
2024-01-26 10:47:39 +00:00
|
|
|
|
2024-12-04 07:47:03 +00:00
|
|
|
trace_rxrpc_tx_data(call, txb->seq, txb->serial, flags, req->trace);
|
2024-12-04 07:46:36 +00:00
|
|
|
kv->iov_len = len;
|
|
|
|
return len;
|
2024-01-26 10:47:39 +00:00
|
|
|
}
|
|
|
|
|
2024-12-04 07:46:46 +00:00
|
|
|
/*
|
|
|
|
* Prepare a transmission queue object for initial transmission. Returns the
|
|
|
|
* number of microseconds since the transmission queue base timestamp.
|
|
|
|
*/
|
|
|
|
static unsigned int rxrpc_prepare_txqueue(struct rxrpc_txqueue *tq,
|
|
|
|
struct rxrpc_send_data_req *req)
|
|
|
|
{
|
|
|
|
if (!tq)
|
|
|
|
return 0;
|
|
|
|
if (tq->xmit_ts_base == KTIME_MIN) {
|
|
|
|
tq->xmit_ts_base = req->now;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return ktime_to_us(ktime_sub(req->now, tq->xmit_ts_base));
|
|
|
|
}
|
|
|
|
|
2024-01-26 10:47:39 +00:00
|
|
|
/*
|
2024-12-04 07:46:39 +00:00
|
|
|
* Prepare a (jumbo) packet for transmission.
|
2024-01-26 10:47:39 +00:00
|
|
|
*/
|
2024-12-04 07:46:46 +00:00
|
|
|
static size_t rxrpc_prepare_data_packet(struct rxrpc_call *call, struct rxrpc_send_data_req *req)
|
2024-01-26 10:47:39 +00:00
|
|
|
{
|
2024-12-04 07:46:46 +00:00
|
|
|
struct rxrpc_txqueue *tq = req->tq;
|
2024-01-26 10:47:39 +00:00
|
|
|
rxrpc_serial_t serial;
|
2024-12-04 07:46:46 +00:00
|
|
|
unsigned int xmit_ts;
|
|
|
|
rxrpc_seq_t seq = req->seq;
|
2024-12-04 07:46:36 +00:00
|
|
|
size_t len = 0;
|
2024-12-04 07:47:07 +00:00
|
|
|
bool start_tlp = false;
|
2024-01-26 10:47:39 +00:00
|
|
|
|
2024-12-04 07:46:46 +00:00
|
|
|
trace_rxrpc_tq(call, tq, seq, rxrpc_tq_transmit);
|
|
|
|
|
2024-01-26 10:47:39 +00:00
|
|
|
/* Each transmission of a Tx packet needs a new serial number */
|
2024-12-04 07:46:46 +00:00
|
|
|
serial = rxrpc_get_next_serials(call->conn, req->n);
|
2024-01-26 10:47:39 +00:00
|
|
|
|
2024-12-04 07:47:07 +00:00
|
|
|
call->tx_last_serial = serial + req->n - 1;
|
2024-12-04 07:46:46 +00:00
|
|
|
call->tx_last_sent = req->now;
|
|
|
|
xmit_ts = rxrpc_prepare_txqueue(tq, req);
|
|
|
|
prefetch(tq->next);
|
2024-01-26 10:47:39 +00:00
|
|
|
|
2024-12-04 07:46:46 +00:00
|
|
|
for (int i = 0;;) {
|
|
|
|
int ix = seq & RXRPC_TXQ_MASK;
|
|
|
|
struct rxrpc_txbuf *txb = tq->bufs[seq & RXRPC_TXQ_MASK];
|
2024-01-31 11:03:52 +00:00
|
|
|
|
2024-12-04 07:46:46 +00:00
|
|
|
_debug("prep[%u] tq=%x q=%x", i, tq->qbase, seq);
|
2024-12-04 07:47:07 +00:00
|
|
|
|
|
|
|
/* Record (re-)transmission for RACK [RFC8985 6.1]. */
|
|
|
|
if (__test_and_clear_bit(ix, &tq->segment_lost))
|
|
|
|
call->tx_nr_lost--;
|
|
|
|
if (req->retrans) {
|
|
|
|
__set_bit(ix, &tq->ever_retransmitted);
|
|
|
|
__set_bit(ix, &tq->segment_retransmitted);
|
|
|
|
call->tx_nr_resent++;
|
|
|
|
} else {
|
|
|
|
call->tx_nr_sent++;
|
|
|
|
start_tlp = true;
|
|
|
|
}
|
2024-12-04 07:46:46 +00:00
|
|
|
tq->segment_xmit_ts[ix] = xmit_ts;
|
2024-12-04 07:46:52 +00:00
|
|
|
tq->segment_serial[ix] = serial;
|
|
|
|
if (i + 1 == req->n)
|
|
|
|
/* Only sample the last subpacket in a jumbo. */
|
|
|
|
__set_bit(ix, &tq->rtt_samples);
|
2024-12-04 07:46:46 +00:00
|
|
|
len += rxrpc_prepare_data_subpacket(call, req, txb, serial, i);
|
|
|
|
serial++;
|
|
|
|
seq++;
|
|
|
|
i++;
|
|
|
|
if (i >= req->n)
|
|
|
|
break;
|
|
|
|
if (!(seq & RXRPC_TXQ_MASK)) {
|
|
|
|
tq = tq->next;
|
|
|
|
trace_rxrpc_tq(call, tq, seq, rxrpc_tq_transmit_advance);
|
|
|
|
xmit_ts = rxrpc_prepare_txqueue(tq, req);
|
|
|
|
}
|
2024-01-31 11:03:52 +00:00
|
|
|
}
|
|
|
|
|
2024-12-04 07:46:46 +00:00
|
|
|
/* Set timeouts */
|
2024-12-04 07:47:07 +00:00
|
|
|
if (req->tlp_probe) {
|
|
|
|
/* Sending TLP loss probe [RFC8985 7.3]. */
|
|
|
|
call->tlp_serial = serial - 1;
|
|
|
|
call->tlp_seq = seq - 1;
|
|
|
|
} else if (start_tlp) {
|
|
|
|
/* Schedule TLP loss probe [RFC8985 7.2]. */
|
|
|
|
ktime_t pto;
|
|
|
|
|
|
|
|
if (!test_bit(RXRPC_CALL_BEGAN_RX_TIMER, &call->flags))
|
|
|
|
/* The first packet may take longer to elicit a response. */
|
|
|
|
pto = NSEC_PER_SEC;
|
|
|
|
else
|
|
|
|
pto = rxrpc_tlp_calc_pto(call, req->now);
|
|
|
|
|
|
|
|
call->rack_timer_mode = RXRPC_CALL_RACKTIMER_TLP_PTO;
|
|
|
|
call->rack_timo_at = ktime_add(req->now, pto);
|
|
|
|
trace_rxrpc_rack_timer(call, pto, false);
|
|
|
|
trace_rxrpc_timer_set(call, pto, rxrpc_timer_trace_rack_tlp_pto);
|
2024-12-04 07:46:51 +00:00
|
|
|
}
|
|
|
|
|
2024-01-31 11:03:52 +00:00
|
|
|
if (!test_and_set_bit(RXRPC_CALL_BEGAN_RX_TIMER, &call->flags)) {
|
|
|
|
ktime_t delay = ms_to_ktime(READ_ONCE(call->next_rx_timo));
|
|
|
|
|
2024-12-04 07:46:46 +00:00
|
|
|
call->expect_rx_by = ktime_add(req->now, delay);
|
2024-01-31 11:03:52 +00:00
|
|
|
trace_rxrpc_timer_set(call, delay, rxrpc_timer_trace_expect_rx);
|
|
|
|
}
|
|
|
|
|
2024-12-04 07:46:46 +00:00
|
|
|
rxrpc_set_keepalive(call, req->now);
|
2024-12-04 07:46:44 +00:00
|
|
|
return len;
|
2024-01-26 10:47:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2024-12-04 07:46:46 +00:00
|
|
|
* Send one or more packets through the transport endpoint
|
2024-01-26 10:47:39 +00:00
|
|
|
*/
|
2024-12-04 07:46:46 +00:00
|
|
|
void rxrpc_send_data_packet(struct rxrpc_call *call, struct rxrpc_send_data_req *req)
|
2024-01-26 10:47:39 +00:00
|
|
|
{
|
|
|
|
struct rxrpc_connection *conn = call->conn;
|
|
|
|
enum rxrpc_tx_point frag;
|
2024-12-04 07:46:46 +00:00
|
|
|
struct rxrpc_txqueue *tq = req->tq;
|
|
|
|
struct rxrpc_txbuf *txb;
|
2024-01-26 10:47:39 +00:00
|
|
|
struct msghdr msg;
|
2024-12-04 07:46:46 +00:00
|
|
|
rxrpc_seq_t seq = req->seq;
|
2024-01-26 10:47:39 +00:00
|
|
|
size_t len;
|
2024-12-04 07:46:44 +00:00
|
|
|
bool new_call = test_bit(RXRPC_CALL_BEGAN_RX_TIMER, &call->flags);
|
2024-12-04 07:46:49 +00:00
|
|
|
int ret, stat_ix;
|
2024-01-26 10:47:39 +00:00
|
|
|
|
2024-12-04 07:46:46 +00:00
|
|
|
_enter("%x,%x-%x", tq->qbase, seq, seq + req->n - 1);
|
2024-01-26 10:47:39 +00:00
|
|
|
|
2024-12-04 07:46:49 +00:00
|
|
|
stat_ix = umin(req->n, ARRAY_SIZE(call->rxnet->stat_tx_jumbo)) - 1;
|
|
|
|
atomic_inc(&call->rxnet->stat_tx_jumbo[stat_ix]);
|
|
|
|
|
2024-12-04 07:46:46 +00:00
|
|
|
len = rxrpc_prepare_data_packet(call, req);
|
|
|
|
txb = tq->bufs[seq & RXRPC_TXQ_MASK];
|
2024-01-26 10:47:39 +00:00
|
|
|
|
2024-12-04 07:46:46 +00:00
|
|
|
iov_iter_kvec(&msg.msg_iter, WRITE, call->local->kvec, req->n, len);
|
2024-01-26 10:47:39 +00:00
|
|
|
|
|
|
|
msg.msg_name = &call->peer->srx.transport;
|
|
|
|
msg.msg_namelen = call->peer->srx.transport_len;
|
|
|
|
msg.msg_control = NULL;
|
|
|
|
msg.msg_controllen = 0;
|
2024-01-29 23:47:57 +00:00
|
|
|
msg.msg_flags = MSG_SPLICE_PAGES;
|
2022-03-31 22:55:08 +00:00
|
|
|
|
2024-12-04 07:46:43 +00:00
|
|
|
/* Send the packet with the don't fragment bit set unless we think it's
|
|
|
|
* too big or if this is a retransmission.
|
2022-03-31 22:55:08 +00:00
|
|
|
*/
|
2024-12-04 07:46:46 +00:00
|
|
|
if (seq == call->tx_transmitted + 1 &&
|
2024-12-04 07:46:43 +00:00
|
|
|
len >= sizeof(struct rxrpc_wire_header) + call->peer->max_data) {
|
2024-01-29 22:49:19 +00:00
|
|
|
rxrpc_local_dont_fragment(conn->local, false);
|
|
|
|
frag = rxrpc_tx_point_call_data_frag;
|
|
|
|
} else {
|
|
|
|
rxrpc_local_dont_fragment(conn->local, true);
|
|
|
|
frag = rxrpc_tx_point_call_data_nofrag;
|
|
|
|
}
|
2016-09-21 23:29:31 +00:00
|
|
|
|
2024-12-04 07:46:43 +00:00
|
|
|
/* Track what we've attempted to transmit at least once so that the
|
|
|
|
* retransmission algorithm doesn't try to resend what we haven't sent
|
|
|
|
* yet.
|
|
|
|
*/
|
2024-12-04 07:46:46 +00:00
|
|
|
if (seq == call->tx_transmitted + 1)
|
|
|
|
call->tx_transmitted = seq + req->n - 1;
|
2024-12-04 07:46:43 +00:00
|
|
|
|
2024-12-04 07:46:42 +00:00
|
|
|
if (IS_ENABLED(CONFIG_AF_RXRPC_INJECT_LOSS)) {
|
|
|
|
static int lose;
|
|
|
|
|
|
|
|
if ((lose++ & 7) == 7) {
|
|
|
|
ret = 0;
|
2024-12-04 07:47:03 +00:00
|
|
|
trace_rxrpc_tx_data(call, txb->seq, txb->serial, txb->flags,
|
|
|
|
rxrpc_txdata_inject_loss);
|
2024-12-04 07:46:51 +00:00
|
|
|
conn->peer->last_tx_at = ktime_get_seconds();
|
2024-12-04 07:46:42 +00:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-21 23:29:31 +00:00
|
|
|
/* send the packet by UDP
|
|
|
|
* - returns -EMSGSIZE if UDP would have to fragment the packet
|
|
|
|
* to go out of the interface
|
|
|
|
* - in which case, we'll have processed the ICMP error
|
|
|
|
* message and update the peer record
|
|
|
|
*/
|
2022-05-11 13:01:25 +00:00
|
|
|
rxrpc_inc_stat(call->rxnet, stat_tx_data_send);
|
2022-10-19 12:49:02 +00:00
|
|
|
ret = do_udp_sendmsg(conn->local->socket, &msg, len);
|
|
|
|
conn->peer->last_tx_at = ktime_get_seconds();
|
2016-09-21 23:29:31 +00:00
|
|
|
|
2024-12-04 07:46:43 +00:00
|
|
|
if (ret == -EMSGSIZE) {
|
|
|
|
rxrpc_inc_stat(call->rxnet, stat_tx_data_send_msgsize);
|
|
|
|
trace_rxrpc_tx_packet(call->debug_id, call->local->kvec[0].iov_base, frag);
|
|
|
|
ret = 0;
|
|
|
|
} else if (ret < 0) {
|
2022-11-11 13:47:35 +00:00
|
|
|
rxrpc_inc_stat(call->rxnet, stat_tx_data_send_fail);
|
2024-01-26 10:47:39 +00:00
|
|
|
trace_rxrpc_tx_fail(call->debug_id, txb->serial, ret, frag);
|
rxrpc: Fix loss of RTT samples due to interposed ACK
The Rx protocol has a mechanism to help generate RTT samples that works by
a client transmitting a REQUESTED-type ACK when it receives a DATA packet
that has the REQUEST_ACK flag set.
The peer, however, may interpose other ACKs before transmitting the
REQUESTED-ACK, as can be seen in the following trace excerpt:
rxrpc_tx_data: c=00000044 DATA d0b5ece8:00000001 00000001 q=00000001 fl=07
rxrpc_rx_ack: c=00000044 00000001 PNG r=00000000 f=00000002 p=00000000 n=0
rxrpc_rx_ack: c=00000044 00000002 REQ r=00000001 f=00000002 p=00000001 n=0
...
DATA packet 1 (q=xx) has REQUEST_ACK set (bit 1 of fl=xx). The incoming
ping (labelled PNG) hard-acks the request DATA packet (f=xx exceeds the
sequence number of the DATA packet), causing it to be discarded from the Tx
ring. The ACK that was requested (labelled REQ, r=xx references the serial
of the DATA packet) comes after the ping, but the sk_buff holding the
timestamp has gone and the RTT sample is lost.
This is particularly noticeable on RPC calls used to probe the service
offered by the peer. A lot of peers end up with an unknown RTT because we
only ever sent a single RPC. This confuses the server rotation algorithm.
Fix this by caching the information about the outgoing packet in RTT
calculations in the rxrpc_call struct rather than looking in the Tx ring.
A four-deep buffer is maintained and both REQUEST_ACK-flagged DATA and
PING-ACK transmissions are recorded in there. When the appropriate
response ACK is received, the buffer is checked for a match and, if found,
an RTT sample is recorded.
If a received ACK refers to a packet with a later serial number than an
entry in the cache, that entry is presumed lost and the entry is made
available to record a new transmission.
ACKs types other than REQUESTED-type and PING-type cause any matching
sample to be cancelled as they don't necessarily represent a useful
measurement.
If there's no space in the buffer on ping/data transmission, the sample
base is discarded.
Fixes: 50235c4b5a2f ("rxrpc: Obtain RTT data by requesting ACKs on DATA packets")
Signed-off-by: David Howells <dhowells@redhat.com>
2020-08-19 22:29:16 +00:00
|
|
|
} else {
|
2024-12-04 07:46:36 +00:00
|
|
|
trace_rxrpc_tx_packet(call->debug_id, call->local->kvec[0].iov_base, frag);
|
rxrpc: Fix loss of RTT samples due to interposed ACK
The Rx protocol has a mechanism to help generate RTT samples that works by
a client transmitting a REQUESTED-type ACK when it receives a DATA packet
that has the REQUEST_ACK flag set.
The peer, however, may interpose other ACKs before transmitting the
REQUESTED-ACK, as can be seen in the following trace excerpt:
rxrpc_tx_data: c=00000044 DATA d0b5ece8:00000001 00000001 q=00000001 fl=07
rxrpc_rx_ack: c=00000044 00000001 PNG r=00000000 f=00000002 p=00000000 n=0
rxrpc_rx_ack: c=00000044 00000002 REQ r=00000001 f=00000002 p=00000001 n=0
...
DATA packet 1 (q=xx) has REQUEST_ACK set (bit 1 of fl=xx). The incoming
ping (labelled PNG) hard-acks the request DATA packet (f=xx exceeds the
sequence number of the DATA packet), causing it to be discarded from the Tx
ring. The ACK that was requested (labelled REQ, r=xx references the serial
of the DATA packet) comes after the ping, but the sk_buff holding the
timestamp has gone and the RTT sample is lost.
This is particularly noticeable on RPC calls used to probe the service
offered by the peer. A lot of peers end up with an unknown RTT because we
only ever sent a single RPC. This confuses the server rotation algorithm.
Fix this by caching the information about the outgoing packet in RTT
calculations in the rxrpc_call struct rather than looking in the Tx ring.
A four-deep buffer is maintained and both REQUEST_ACK-flagged DATA and
PING-ACK transmissions are recorded in there. When the appropriate
response ACK is received, the buffer is checked for a match and, if found,
an RTT sample is recorded.
If a received ACK refers to a packet with a later serial number than an
entry in the cache, that entry is presumed lost and the entry is made
available to record a new transmission.
ACKs types other than REQUESTED-type and PING-type cause any matching
sample to be cancelled as they don't necessarily represent a useful
measurement.
If there's no space in the buffer on ping/data transmission, the sample
base is discarded.
Fixes: 50235c4b5a2f ("rxrpc: Obtain RTT data by requesting ACKs on DATA packets")
Signed-off-by: David Howells <dhowells@redhat.com>
2020-08-19 22:29:16 +00:00
|
|
|
}
|
|
|
|
|
2018-11-01 13:39:53 +00:00
|
|
|
rxrpc_tx_backoff(call, ret);
|
2016-09-21 23:29:31 +00:00
|
|
|
|
2024-12-04 07:46:44 +00:00
|
|
|
if (ret < 0) {
|
2024-12-04 07:46:46 +00:00
|
|
|
/* Cancel the call if the initial transmission fails or if we
|
|
|
|
* hit due to network routing issues that aren't going away
|
|
|
|
* anytime soon. The layer above can arrange the
|
|
|
|
* retransmission.
|
2018-11-01 13:39:53 +00:00
|
|
|
*/
|
2024-12-04 07:46:46 +00:00
|
|
|
if (new_call ||
|
|
|
|
ret == -ENETUNREACH ||
|
|
|
|
ret == -EHOSTUNREACH ||
|
|
|
|
ret == -ECONNREFUSED)
|
2018-11-01 13:39:53 +00:00
|
|
|
rxrpc_set_call_completion(call, RXRPC_CALL_LOCAL_ERROR,
|
|
|
|
RX_USER_ABORT, ret);
|
|
|
|
}
|
2017-11-24 10:18:42 +00:00
|
|
|
|
2024-12-04 07:46:44 +00:00
|
|
|
done:
|
2024-12-04 07:46:37 +00:00
|
|
|
_leave(" = %d [%u]", ret, call->peer->max_data);
|
2007-04-26 22:48:28 +00:00
|
|
|
}
|
rxrpc: Rewrite the data and ack handling code
Rewrite the data and ack handling code such that:
(1) Parsing of received ACK and ABORT packets and the distribution and the
filing of DATA packets happens entirely within the data_ready context
called from the UDP socket. This allows us to process and discard ACK
and ABORT packets much more quickly (they're no longer stashed on a
queue for a background thread to process).
(2) We avoid calling skb_clone(), pskb_pull() and pskb_trim(). We instead
keep track of the offset and length of the content of each packet in
the sk_buff metadata. This means we don't do any allocation in the
receive path.
(3) Jumbo DATA packet parsing is now done in data_ready context. Rather
than cloning the packet once for each subpacket and pulling/trimming
it, we file the packet multiple times with an annotation for each
indicating which subpacket is there. From that we can directly
calculate the offset and length.
(4) A call's receive queue can be accessed without taking locks (memory
barriers do have to be used, though).
(5) Incoming calls are set up from preallocated resources and immediately
made live. They can than have packets queued upon them and ACKs
generated. If insufficient resources exist, DATA packet #1 is given a
BUSY reply and other DATA packets are discarded).
(6) sk_buffs no longer take a ref on their parent call.
To make this work, the following changes are made:
(1) Each call's receive buffer is now a circular buffer of sk_buff
pointers (rxtx_buffer) rather than a number of sk_buff_heads spread
between the call and the socket. This permits each sk_buff to be in
the buffer multiple times. The receive buffer is reused for the
transmit buffer.
(2) A circular buffer of annotations (rxtx_annotations) is kept parallel
to the data buffer. Transmission phase annotations indicate whether a
buffered packet has been ACK'd or not and whether it needs
retransmission.
Receive phase annotations indicate whether a slot holds a whole packet
or a jumbo subpacket and, if the latter, which subpacket. They also
note whether the packet has been decrypted in place.
(3) DATA packet window tracking is much simplified. Each phase has just
two numbers representing the window (rx_hard_ack/rx_top and
tx_hard_ack/tx_top).
The hard_ack number is the sequence number before base of the window,
representing the last packet the other side says it has consumed.
hard_ack starts from 0 and the first packet is sequence number 1.
The top number is the sequence number of the highest-numbered packet
residing in the buffer. Packets between hard_ack+1 and top are
soft-ACK'd to indicate they've been received, but not yet consumed.
Four macros, before(), before_eq(), after() and after_eq() are added
to compare sequence numbers within the window. This allows for the
top of the window to wrap when the hard-ack sequence number gets close
to the limit.
Two flags, RXRPC_CALL_RX_LAST and RXRPC_CALL_TX_LAST, are added also
to indicate when rx_top and tx_top point at the packets with the
LAST_PACKET bit set, indicating the end of the phase.
(4) Calls are queued on the socket 'receive queue' rather than packets.
This means that we don't need have to invent dummy packets to queue to
indicate abnormal/terminal states and we don't have to keep metadata
packets (such as ABORTs) around
(5) The offset and length of a (sub)packet's content are now passed to
the verify_packet security op. This is currently expected to decrypt
the packet in place and validate it.
However, there's now nowhere to store the revised offset and length of
the actual data within the decrypted blob (there may be a header and
padding to skip) because an sk_buff may represent multiple packets, so
a locate_data security op is added to retrieve these details from the
sk_buff content when needed.
(6) recvmsg() now has to handle jumbo subpackets, where each subpacket is
individually secured and needs to be individually decrypted. The code
to do this is broken out into rxrpc_recvmsg_data() and shared with the
kernel API. It now iterates over the call's receive buffer rather
than walking the socket receive queue.
Additional changes:
(1) The timers are condensed to a single timer that is set for the soonest
of three timeouts (delayed ACK generation, DATA retransmission and
call lifespan).
(2) Transmission of ACK and ABORT packets is effected immediately from
process-context socket ops/kernel API calls that cause them instead of
them being punted off to a background work item. The data_ready
handler still has to defer to the background, though.
(3) A shutdown op is added to the AF_RXRPC socket so that the AFS
filesystem can shut down the socket and flush its own work items
before closing the socket to deal with any in-progress service calls.
Future additional changes that will need to be considered:
(1) Make sure that a call doesn't hog the front of the queue by receiving
data from the network as fast as userspace is consuming it to the
exclusion of other calls.
(2) Transmit delayed ACKs from within recvmsg() when we've consumed
sufficiently more packets to avoid the background work item needing to
run.
Signed-off-by: David Howells <dhowells@redhat.com>
2016-09-08 10:10:12 +00:00
|
|
|
|
2022-10-20 08:56:36 +00:00
|
|
|
/*
|
|
|
|
* Transmit a connection-level abort.
|
|
|
|
*/
|
|
|
|
void rxrpc_send_conn_abort(struct rxrpc_connection *conn)
|
|
|
|
{
|
|
|
|
struct rxrpc_wire_header whdr;
|
|
|
|
struct msghdr msg;
|
|
|
|
struct kvec iov[2];
|
|
|
|
__be32 word;
|
|
|
|
size_t len;
|
|
|
|
u32 serial;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
msg.msg_name = &conn->peer->srx.transport;
|
|
|
|
msg.msg_namelen = conn->peer->srx.transport_len;
|
|
|
|
msg.msg_control = NULL;
|
|
|
|
msg.msg_controllen = 0;
|
|
|
|
msg.msg_flags = 0;
|
|
|
|
|
|
|
|
whdr.epoch = htonl(conn->proto.epoch);
|
|
|
|
whdr.cid = htonl(conn->proto.cid);
|
|
|
|
whdr.callNumber = 0;
|
|
|
|
whdr.seq = 0;
|
|
|
|
whdr.type = RXRPC_PACKET_TYPE_ABORT;
|
|
|
|
whdr.flags = conn->out_clientflag;
|
|
|
|
whdr.userStatus = 0;
|
|
|
|
whdr.securityIndex = conn->security_ix;
|
|
|
|
whdr._rsvd = 0;
|
|
|
|
whdr.serviceId = htons(conn->service_id);
|
|
|
|
|
|
|
|
word = htonl(conn->abort_code);
|
|
|
|
|
|
|
|
iov[0].iov_base = &whdr;
|
|
|
|
iov[0].iov_len = sizeof(whdr);
|
|
|
|
iov[1].iov_base = &word;
|
|
|
|
iov[1].iov_len = sizeof(word);
|
|
|
|
|
|
|
|
len = iov[0].iov_len + iov[1].iov_len;
|
|
|
|
|
2024-02-02 15:19:13 +00:00
|
|
|
serial = rxrpc_get_next_serial(conn);
|
2022-10-20 08:56:36 +00:00
|
|
|
whdr.serial = htonl(serial);
|
|
|
|
|
|
|
|
iov_iter_kvec(&msg.msg_iter, WRITE, iov, 2, len);
|
|
|
|
ret = do_udp_sendmsg(conn->local->socket, &msg, len);
|
|
|
|
if (ret < 0) {
|
|
|
|
trace_rxrpc_tx_fail(conn->debug_id, serial, ret,
|
|
|
|
rxrpc_tx_point_conn_abort);
|
|
|
|
_debug("sendmsg failed: %d", ret);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
trace_rxrpc_tx_packet(conn->debug_id, &whdr, rxrpc_tx_point_conn_abort);
|
|
|
|
|
|
|
|
conn->peer->last_tx_at = ktime_get_seconds();
|
|
|
|
}
|
|
|
|
|
rxrpc: Rewrite the data and ack handling code
Rewrite the data and ack handling code such that:
(1) Parsing of received ACK and ABORT packets and the distribution and the
filing of DATA packets happens entirely within the data_ready context
called from the UDP socket. This allows us to process and discard ACK
and ABORT packets much more quickly (they're no longer stashed on a
queue for a background thread to process).
(2) We avoid calling skb_clone(), pskb_pull() and pskb_trim(). We instead
keep track of the offset and length of the content of each packet in
the sk_buff metadata. This means we don't do any allocation in the
receive path.
(3) Jumbo DATA packet parsing is now done in data_ready context. Rather
than cloning the packet once for each subpacket and pulling/trimming
it, we file the packet multiple times with an annotation for each
indicating which subpacket is there. From that we can directly
calculate the offset and length.
(4) A call's receive queue can be accessed without taking locks (memory
barriers do have to be used, though).
(5) Incoming calls are set up from preallocated resources and immediately
made live. They can than have packets queued upon them and ACKs
generated. If insufficient resources exist, DATA packet #1 is given a
BUSY reply and other DATA packets are discarded).
(6) sk_buffs no longer take a ref on their parent call.
To make this work, the following changes are made:
(1) Each call's receive buffer is now a circular buffer of sk_buff
pointers (rxtx_buffer) rather than a number of sk_buff_heads spread
between the call and the socket. This permits each sk_buff to be in
the buffer multiple times. The receive buffer is reused for the
transmit buffer.
(2) A circular buffer of annotations (rxtx_annotations) is kept parallel
to the data buffer. Transmission phase annotations indicate whether a
buffered packet has been ACK'd or not and whether it needs
retransmission.
Receive phase annotations indicate whether a slot holds a whole packet
or a jumbo subpacket and, if the latter, which subpacket. They also
note whether the packet has been decrypted in place.
(3) DATA packet window tracking is much simplified. Each phase has just
two numbers representing the window (rx_hard_ack/rx_top and
tx_hard_ack/tx_top).
The hard_ack number is the sequence number before base of the window,
representing the last packet the other side says it has consumed.
hard_ack starts from 0 and the first packet is sequence number 1.
The top number is the sequence number of the highest-numbered packet
residing in the buffer. Packets between hard_ack+1 and top are
soft-ACK'd to indicate they've been received, but not yet consumed.
Four macros, before(), before_eq(), after() and after_eq() are added
to compare sequence numbers within the window. This allows for the
top of the window to wrap when the hard-ack sequence number gets close
to the limit.
Two flags, RXRPC_CALL_RX_LAST and RXRPC_CALL_TX_LAST, are added also
to indicate when rx_top and tx_top point at the packets with the
LAST_PACKET bit set, indicating the end of the phase.
(4) Calls are queued on the socket 'receive queue' rather than packets.
This means that we don't need have to invent dummy packets to queue to
indicate abnormal/terminal states and we don't have to keep metadata
packets (such as ABORTs) around
(5) The offset and length of a (sub)packet's content are now passed to
the verify_packet security op. This is currently expected to decrypt
the packet in place and validate it.
However, there's now nowhere to store the revised offset and length of
the actual data within the decrypted blob (there may be a header and
padding to skip) because an sk_buff may represent multiple packets, so
a locate_data security op is added to retrieve these details from the
sk_buff content when needed.
(6) recvmsg() now has to handle jumbo subpackets, where each subpacket is
individually secured and needs to be individually decrypted. The code
to do this is broken out into rxrpc_recvmsg_data() and shared with the
kernel API. It now iterates over the call's receive buffer rather
than walking the socket receive queue.
Additional changes:
(1) The timers are condensed to a single timer that is set for the soonest
of three timeouts (delayed ACK generation, DATA retransmission and
call lifespan).
(2) Transmission of ACK and ABORT packets is effected immediately from
process-context socket ops/kernel API calls that cause them instead of
them being punted off to a background work item. The data_ready
handler still has to defer to the background, though.
(3) A shutdown op is added to the AF_RXRPC socket so that the AFS
filesystem can shut down the socket and flush its own work items
before closing the socket to deal with any in-progress service calls.
Future additional changes that will need to be considered:
(1) Make sure that a call doesn't hog the front of the queue by receiving
data from the network as fast as userspace is consuming it to the
exclusion of other calls.
(2) Transmit delayed ACKs from within recvmsg() when we've consumed
sufficiently more packets to avoid the background work item needing to
run.
Signed-off-by: David Howells <dhowells@redhat.com>
2016-09-08 10:10:12 +00:00
|
|
|
/*
|
2020-01-23 13:13:41 +00:00
|
|
|
* Reject a packet through the local endpoint.
|
rxrpc: Rewrite the data and ack handling code
Rewrite the data and ack handling code such that:
(1) Parsing of received ACK and ABORT packets and the distribution and the
filing of DATA packets happens entirely within the data_ready context
called from the UDP socket. This allows us to process and discard ACK
and ABORT packets much more quickly (they're no longer stashed on a
queue for a background thread to process).
(2) We avoid calling skb_clone(), pskb_pull() and pskb_trim(). We instead
keep track of the offset and length of the content of each packet in
the sk_buff metadata. This means we don't do any allocation in the
receive path.
(3) Jumbo DATA packet parsing is now done in data_ready context. Rather
than cloning the packet once for each subpacket and pulling/trimming
it, we file the packet multiple times with an annotation for each
indicating which subpacket is there. From that we can directly
calculate the offset and length.
(4) A call's receive queue can be accessed without taking locks (memory
barriers do have to be used, though).
(5) Incoming calls are set up from preallocated resources and immediately
made live. They can than have packets queued upon them and ACKs
generated. If insufficient resources exist, DATA packet #1 is given a
BUSY reply and other DATA packets are discarded).
(6) sk_buffs no longer take a ref on their parent call.
To make this work, the following changes are made:
(1) Each call's receive buffer is now a circular buffer of sk_buff
pointers (rxtx_buffer) rather than a number of sk_buff_heads spread
between the call and the socket. This permits each sk_buff to be in
the buffer multiple times. The receive buffer is reused for the
transmit buffer.
(2) A circular buffer of annotations (rxtx_annotations) is kept parallel
to the data buffer. Transmission phase annotations indicate whether a
buffered packet has been ACK'd or not and whether it needs
retransmission.
Receive phase annotations indicate whether a slot holds a whole packet
or a jumbo subpacket and, if the latter, which subpacket. They also
note whether the packet has been decrypted in place.
(3) DATA packet window tracking is much simplified. Each phase has just
two numbers representing the window (rx_hard_ack/rx_top and
tx_hard_ack/tx_top).
The hard_ack number is the sequence number before base of the window,
representing the last packet the other side says it has consumed.
hard_ack starts from 0 and the first packet is sequence number 1.
The top number is the sequence number of the highest-numbered packet
residing in the buffer. Packets between hard_ack+1 and top are
soft-ACK'd to indicate they've been received, but not yet consumed.
Four macros, before(), before_eq(), after() and after_eq() are added
to compare sequence numbers within the window. This allows for the
top of the window to wrap when the hard-ack sequence number gets close
to the limit.
Two flags, RXRPC_CALL_RX_LAST and RXRPC_CALL_TX_LAST, are added also
to indicate when rx_top and tx_top point at the packets with the
LAST_PACKET bit set, indicating the end of the phase.
(4) Calls are queued on the socket 'receive queue' rather than packets.
This means that we don't need have to invent dummy packets to queue to
indicate abnormal/terminal states and we don't have to keep metadata
packets (such as ABORTs) around
(5) The offset and length of a (sub)packet's content are now passed to
the verify_packet security op. This is currently expected to decrypt
the packet in place and validate it.
However, there's now nowhere to store the revised offset and length of
the actual data within the decrypted blob (there may be a header and
padding to skip) because an sk_buff may represent multiple packets, so
a locate_data security op is added to retrieve these details from the
sk_buff content when needed.
(6) recvmsg() now has to handle jumbo subpackets, where each subpacket is
individually secured and needs to be individually decrypted. The code
to do this is broken out into rxrpc_recvmsg_data() and shared with the
kernel API. It now iterates over the call's receive buffer rather
than walking the socket receive queue.
Additional changes:
(1) The timers are condensed to a single timer that is set for the soonest
of three timeouts (delayed ACK generation, DATA retransmission and
call lifespan).
(2) Transmission of ACK and ABORT packets is effected immediately from
process-context socket ops/kernel API calls that cause them instead of
them being punted off to a background work item. The data_ready
handler still has to defer to the background, though.
(3) A shutdown op is added to the AF_RXRPC socket so that the AFS
filesystem can shut down the socket and flush its own work items
before closing the socket to deal with any in-progress service calls.
Future additional changes that will need to be considered:
(1) Make sure that a call doesn't hog the front of the queue by receiving
data from the network as fast as userspace is consuming it to the
exclusion of other calls.
(2) Transmit delayed ACKs from within recvmsg() when we've consumed
sufficiently more packets to avoid the background work item needing to
run.
Signed-off-by: David Howells <dhowells@redhat.com>
2016-09-08 10:10:12 +00:00
|
|
|
*/
|
2020-01-23 13:13:41 +00:00
|
|
|
void rxrpc_reject_packet(struct rxrpc_local *local, struct sk_buff *skb)
|
rxrpc: Rewrite the data and ack handling code
Rewrite the data and ack handling code such that:
(1) Parsing of received ACK and ABORT packets and the distribution and the
filing of DATA packets happens entirely within the data_ready context
called from the UDP socket. This allows us to process and discard ACK
and ABORT packets much more quickly (they're no longer stashed on a
queue for a background thread to process).
(2) We avoid calling skb_clone(), pskb_pull() and pskb_trim(). We instead
keep track of the offset and length of the content of each packet in
the sk_buff metadata. This means we don't do any allocation in the
receive path.
(3) Jumbo DATA packet parsing is now done in data_ready context. Rather
than cloning the packet once for each subpacket and pulling/trimming
it, we file the packet multiple times with an annotation for each
indicating which subpacket is there. From that we can directly
calculate the offset and length.
(4) A call's receive queue can be accessed without taking locks (memory
barriers do have to be used, though).
(5) Incoming calls are set up from preallocated resources and immediately
made live. They can than have packets queued upon them and ACKs
generated. If insufficient resources exist, DATA packet #1 is given a
BUSY reply and other DATA packets are discarded).
(6) sk_buffs no longer take a ref on their parent call.
To make this work, the following changes are made:
(1) Each call's receive buffer is now a circular buffer of sk_buff
pointers (rxtx_buffer) rather than a number of sk_buff_heads spread
between the call and the socket. This permits each sk_buff to be in
the buffer multiple times. The receive buffer is reused for the
transmit buffer.
(2) A circular buffer of annotations (rxtx_annotations) is kept parallel
to the data buffer. Transmission phase annotations indicate whether a
buffered packet has been ACK'd or not and whether it needs
retransmission.
Receive phase annotations indicate whether a slot holds a whole packet
or a jumbo subpacket and, if the latter, which subpacket. They also
note whether the packet has been decrypted in place.
(3) DATA packet window tracking is much simplified. Each phase has just
two numbers representing the window (rx_hard_ack/rx_top and
tx_hard_ack/tx_top).
The hard_ack number is the sequence number before base of the window,
representing the last packet the other side says it has consumed.
hard_ack starts from 0 and the first packet is sequence number 1.
The top number is the sequence number of the highest-numbered packet
residing in the buffer. Packets between hard_ack+1 and top are
soft-ACK'd to indicate they've been received, but not yet consumed.
Four macros, before(), before_eq(), after() and after_eq() are added
to compare sequence numbers within the window. This allows for the
top of the window to wrap when the hard-ack sequence number gets close
to the limit.
Two flags, RXRPC_CALL_RX_LAST and RXRPC_CALL_TX_LAST, are added also
to indicate when rx_top and tx_top point at the packets with the
LAST_PACKET bit set, indicating the end of the phase.
(4) Calls are queued on the socket 'receive queue' rather than packets.
This means that we don't need have to invent dummy packets to queue to
indicate abnormal/terminal states and we don't have to keep metadata
packets (such as ABORTs) around
(5) The offset and length of a (sub)packet's content are now passed to
the verify_packet security op. This is currently expected to decrypt
the packet in place and validate it.
However, there's now nowhere to store the revised offset and length of
the actual data within the decrypted blob (there may be a header and
padding to skip) because an sk_buff may represent multiple packets, so
a locate_data security op is added to retrieve these details from the
sk_buff content when needed.
(6) recvmsg() now has to handle jumbo subpackets, where each subpacket is
individually secured and needs to be individually decrypted. The code
to do this is broken out into rxrpc_recvmsg_data() and shared with the
kernel API. It now iterates over the call's receive buffer rather
than walking the socket receive queue.
Additional changes:
(1) The timers are condensed to a single timer that is set for the soonest
of three timeouts (delayed ACK generation, DATA retransmission and
call lifespan).
(2) Transmission of ACK and ABORT packets is effected immediately from
process-context socket ops/kernel API calls that cause them instead of
them being punted off to a background work item. The data_ready
handler still has to defer to the background, though.
(3) A shutdown op is added to the AF_RXRPC socket so that the AFS
filesystem can shut down the socket and flush its own work items
before closing the socket to deal with any in-progress service calls.
Future additional changes that will need to be considered:
(1) Make sure that a call doesn't hog the front of the queue by receiving
data from the network as fast as userspace is consuming it to the
exclusion of other calls.
(2) Transmit delayed ACKs from within recvmsg() when we've consumed
sufficiently more packets to avoid the background work item needing to
run.
Signed-off-by: David Howells <dhowells@redhat.com>
2016-09-08 10:10:12 +00:00
|
|
|
{
|
|
|
|
struct rxrpc_wire_header whdr;
|
2020-01-23 13:13:41 +00:00
|
|
|
struct sockaddr_rxrpc srx;
|
|
|
|
struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
|
rxrpc: Rewrite the data and ack handling code
Rewrite the data and ack handling code such that:
(1) Parsing of received ACK and ABORT packets and the distribution and the
filing of DATA packets happens entirely within the data_ready context
called from the UDP socket. This allows us to process and discard ACK
and ABORT packets much more quickly (they're no longer stashed on a
queue for a background thread to process).
(2) We avoid calling skb_clone(), pskb_pull() and pskb_trim(). We instead
keep track of the offset and length of the content of each packet in
the sk_buff metadata. This means we don't do any allocation in the
receive path.
(3) Jumbo DATA packet parsing is now done in data_ready context. Rather
than cloning the packet once for each subpacket and pulling/trimming
it, we file the packet multiple times with an annotation for each
indicating which subpacket is there. From that we can directly
calculate the offset and length.
(4) A call's receive queue can be accessed without taking locks (memory
barriers do have to be used, though).
(5) Incoming calls are set up from preallocated resources and immediately
made live. They can than have packets queued upon them and ACKs
generated. If insufficient resources exist, DATA packet #1 is given a
BUSY reply and other DATA packets are discarded).
(6) sk_buffs no longer take a ref on their parent call.
To make this work, the following changes are made:
(1) Each call's receive buffer is now a circular buffer of sk_buff
pointers (rxtx_buffer) rather than a number of sk_buff_heads spread
between the call and the socket. This permits each sk_buff to be in
the buffer multiple times. The receive buffer is reused for the
transmit buffer.
(2) A circular buffer of annotations (rxtx_annotations) is kept parallel
to the data buffer. Transmission phase annotations indicate whether a
buffered packet has been ACK'd or not and whether it needs
retransmission.
Receive phase annotations indicate whether a slot holds a whole packet
or a jumbo subpacket and, if the latter, which subpacket. They also
note whether the packet has been decrypted in place.
(3) DATA packet window tracking is much simplified. Each phase has just
two numbers representing the window (rx_hard_ack/rx_top and
tx_hard_ack/tx_top).
The hard_ack number is the sequence number before base of the window,
representing the last packet the other side says it has consumed.
hard_ack starts from 0 and the first packet is sequence number 1.
The top number is the sequence number of the highest-numbered packet
residing in the buffer. Packets between hard_ack+1 and top are
soft-ACK'd to indicate they've been received, but not yet consumed.
Four macros, before(), before_eq(), after() and after_eq() are added
to compare sequence numbers within the window. This allows for the
top of the window to wrap when the hard-ack sequence number gets close
to the limit.
Two flags, RXRPC_CALL_RX_LAST and RXRPC_CALL_TX_LAST, are added also
to indicate when rx_top and tx_top point at the packets with the
LAST_PACKET bit set, indicating the end of the phase.
(4) Calls are queued on the socket 'receive queue' rather than packets.
This means that we don't need have to invent dummy packets to queue to
indicate abnormal/terminal states and we don't have to keep metadata
packets (such as ABORTs) around
(5) The offset and length of a (sub)packet's content are now passed to
the verify_packet security op. This is currently expected to decrypt
the packet in place and validate it.
However, there's now nowhere to store the revised offset and length of
the actual data within the decrypted blob (there may be a header and
padding to skip) because an sk_buff may represent multiple packets, so
a locate_data security op is added to retrieve these details from the
sk_buff content when needed.
(6) recvmsg() now has to handle jumbo subpackets, where each subpacket is
individually secured and needs to be individually decrypted. The code
to do this is broken out into rxrpc_recvmsg_data() and shared with the
kernel API. It now iterates over the call's receive buffer rather
than walking the socket receive queue.
Additional changes:
(1) The timers are condensed to a single timer that is set for the soonest
of three timeouts (delayed ACK generation, DATA retransmission and
call lifespan).
(2) Transmission of ACK and ABORT packets is effected immediately from
process-context socket ops/kernel API calls that cause them instead of
them being punted off to a background work item. The data_ready
handler still has to defer to the background, though.
(3) A shutdown op is added to the AF_RXRPC socket so that the AFS
filesystem can shut down the socket and flush its own work items
before closing the socket to deal with any in-progress service calls.
Future additional changes that will need to be considered:
(1) Make sure that a call doesn't hog the front of the queue by receiving
data from the network as fast as userspace is consuming it to the
exclusion of other calls.
(2) Transmit delayed ACKs from within recvmsg() when we've consumed
sufficiently more packets to avoid the background work item needing to
run.
Signed-off-by: David Howells <dhowells@redhat.com>
2016-09-08 10:10:12 +00:00
|
|
|
struct msghdr msg;
|
|
|
|
struct kvec iov[2];
|
|
|
|
size_t size;
|
|
|
|
__be32 code;
|
rxrpc: Emit BUSY packets when supposed to rather than ABORTs
In the input path, a received sk_buff can be marked for rejection by
setting RXRPC_SKB_MARK_* in skb->mark and, if needed, some auxiliary data
(such as an abort code) in skb->priority. The rejection is handled by
queueing the sk_buff up for dealing with in process context. The output
code reads the mark and priority and, theoretically, generates an
appropriate response packet.
However, if RXRPC_SKB_MARK_BUSY is set, this isn't noticed and an ABORT
message with a random abort code is generated (since skb->priority wasn't
set to anything).
Fix this by outputting the appropriate sort of packet.
Also, whilst we're at it, most of the marks are no longer used, so remove
them and rename the remaining two to something more obvious.
Fixes: 248f219cb8bc ("rxrpc: Rewrite the data and ack handling code")
Signed-off-by: David Howells <dhowells@redhat.com>
2018-09-27 14:13:08 +00:00
|
|
|
int ret, ioc;
|
rxrpc: Rewrite the data and ack handling code
Rewrite the data and ack handling code such that:
(1) Parsing of received ACK and ABORT packets and the distribution and the
filing of DATA packets happens entirely within the data_ready context
called from the UDP socket. This allows us to process and discard ACK
and ABORT packets much more quickly (they're no longer stashed on a
queue for a background thread to process).
(2) We avoid calling skb_clone(), pskb_pull() and pskb_trim(). We instead
keep track of the offset and length of the content of each packet in
the sk_buff metadata. This means we don't do any allocation in the
receive path.
(3) Jumbo DATA packet parsing is now done in data_ready context. Rather
than cloning the packet once for each subpacket and pulling/trimming
it, we file the packet multiple times with an annotation for each
indicating which subpacket is there. From that we can directly
calculate the offset and length.
(4) A call's receive queue can be accessed without taking locks (memory
barriers do have to be used, though).
(5) Incoming calls are set up from preallocated resources and immediately
made live. They can than have packets queued upon them and ACKs
generated. If insufficient resources exist, DATA packet #1 is given a
BUSY reply and other DATA packets are discarded).
(6) sk_buffs no longer take a ref on their parent call.
To make this work, the following changes are made:
(1) Each call's receive buffer is now a circular buffer of sk_buff
pointers (rxtx_buffer) rather than a number of sk_buff_heads spread
between the call and the socket. This permits each sk_buff to be in
the buffer multiple times. The receive buffer is reused for the
transmit buffer.
(2) A circular buffer of annotations (rxtx_annotations) is kept parallel
to the data buffer. Transmission phase annotations indicate whether a
buffered packet has been ACK'd or not and whether it needs
retransmission.
Receive phase annotations indicate whether a slot holds a whole packet
or a jumbo subpacket and, if the latter, which subpacket. They also
note whether the packet has been decrypted in place.
(3) DATA packet window tracking is much simplified. Each phase has just
two numbers representing the window (rx_hard_ack/rx_top and
tx_hard_ack/tx_top).
The hard_ack number is the sequence number before base of the window,
representing the last packet the other side says it has consumed.
hard_ack starts from 0 and the first packet is sequence number 1.
The top number is the sequence number of the highest-numbered packet
residing in the buffer. Packets between hard_ack+1 and top are
soft-ACK'd to indicate they've been received, but not yet consumed.
Four macros, before(), before_eq(), after() and after_eq() are added
to compare sequence numbers within the window. This allows for the
top of the window to wrap when the hard-ack sequence number gets close
to the limit.
Two flags, RXRPC_CALL_RX_LAST and RXRPC_CALL_TX_LAST, are added also
to indicate when rx_top and tx_top point at the packets with the
LAST_PACKET bit set, indicating the end of the phase.
(4) Calls are queued on the socket 'receive queue' rather than packets.
This means that we don't need have to invent dummy packets to queue to
indicate abnormal/terminal states and we don't have to keep metadata
packets (such as ABORTs) around
(5) The offset and length of a (sub)packet's content are now passed to
the verify_packet security op. This is currently expected to decrypt
the packet in place and validate it.
However, there's now nowhere to store the revised offset and length of
the actual data within the decrypted blob (there may be a header and
padding to skip) because an sk_buff may represent multiple packets, so
a locate_data security op is added to retrieve these details from the
sk_buff content when needed.
(6) recvmsg() now has to handle jumbo subpackets, where each subpacket is
individually secured and needs to be individually decrypted. The code
to do this is broken out into rxrpc_recvmsg_data() and shared with the
kernel API. It now iterates over the call's receive buffer rather
than walking the socket receive queue.
Additional changes:
(1) The timers are condensed to a single timer that is set for the soonest
of three timeouts (delayed ACK generation, DATA retransmission and
call lifespan).
(2) Transmission of ACK and ABORT packets is effected immediately from
process-context socket ops/kernel API calls that cause them instead of
them being punted off to a background work item. The data_ready
handler still has to defer to the background, though.
(3) A shutdown op is added to the AF_RXRPC socket so that the AFS
filesystem can shut down the socket and flush its own work items
before closing the socket to deal with any in-progress service calls.
Future additional changes that will need to be considered:
(1) Make sure that a call doesn't hog the front of the queue by receiving
data from the network as fast as userspace is consuming it to the
exclusion of other calls.
(2) Transmit delayed ACKs from within recvmsg() when we've consumed
sufficiently more packets to avoid the background work item needing to
run.
Signed-off-by: David Howells <dhowells@redhat.com>
2016-09-08 10:10:12 +00:00
|
|
|
|
2020-01-23 13:13:41 +00:00
|
|
|
rxrpc_see_skb(skb, rxrpc_skb_see_reject);
|
rxrpc: Rewrite the data and ack handling code
Rewrite the data and ack handling code such that:
(1) Parsing of received ACK and ABORT packets and the distribution and the
filing of DATA packets happens entirely within the data_ready context
called from the UDP socket. This allows us to process and discard ACK
and ABORT packets much more quickly (they're no longer stashed on a
queue for a background thread to process).
(2) We avoid calling skb_clone(), pskb_pull() and pskb_trim(). We instead
keep track of the offset and length of the content of each packet in
the sk_buff metadata. This means we don't do any allocation in the
receive path.
(3) Jumbo DATA packet parsing is now done in data_ready context. Rather
than cloning the packet once for each subpacket and pulling/trimming
it, we file the packet multiple times with an annotation for each
indicating which subpacket is there. From that we can directly
calculate the offset and length.
(4) A call's receive queue can be accessed without taking locks (memory
barriers do have to be used, though).
(5) Incoming calls are set up from preallocated resources and immediately
made live. They can than have packets queued upon them and ACKs
generated. If insufficient resources exist, DATA packet #1 is given a
BUSY reply and other DATA packets are discarded).
(6) sk_buffs no longer take a ref on their parent call.
To make this work, the following changes are made:
(1) Each call's receive buffer is now a circular buffer of sk_buff
pointers (rxtx_buffer) rather than a number of sk_buff_heads spread
between the call and the socket. This permits each sk_buff to be in
the buffer multiple times. The receive buffer is reused for the
transmit buffer.
(2) A circular buffer of annotations (rxtx_annotations) is kept parallel
to the data buffer. Transmission phase annotations indicate whether a
buffered packet has been ACK'd or not and whether it needs
retransmission.
Receive phase annotations indicate whether a slot holds a whole packet
or a jumbo subpacket and, if the latter, which subpacket. They also
note whether the packet has been decrypted in place.
(3) DATA packet window tracking is much simplified. Each phase has just
two numbers representing the window (rx_hard_ack/rx_top and
tx_hard_ack/tx_top).
The hard_ack number is the sequence number before base of the window,
representing the last packet the other side says it has consumed.
hard_ack starts from 0 and the first packet is sequence number 1.
The top number is the sequence number of the highest-numbered packet
residing in the buffer. Packets between hard_ack+1 and top are
soft-ACK'd to indicate they've been received, but not yet consumed.
Four macros, before(), before_eq(), after() and after_eq() are added
to compare sequence numbers within the window. This allows for the
top of the window to wrap when the hard-ack sequence number gets close
to the limit.
Two flags, RXRPC_CALL_RX_LAST and RXRPC_CALL_TX_LAST, are added also
to indicate when rx_top and tx_top point at the packets with the
LAST_PACKET bit set, indicating the end of the phase.
(4) Calls are queued on the socket 'receive queue' rather than packets.
This means that we don't need have to invent dummy packets to queue to
indicate abnormal/terminal states and we don't have to keep metadata
packets (such as ABORTs) around
(5) The offset and length of a (sub)packet's content are now passed to
the verify_packet security op. This is currently expected to decrypt
the packet in place and validate it.
However, there's now nowhere to store the revised offset and length of
the actual data within the decrypted blob (there may be a header and
padding to skip) because an sk_buff may represent multiple packets, so
a locate_data security op is added to retrieve these details from the
sk_buff content when needed.
(6) recvmsg() now has to handle jumbo subpackets, where each subpacket is
individually secured and needs to be individually decrypted. The code
to do this is broken out into rxrpc_recvmsg_data() and shared with the
kernel API. It now iterates over the call's receive buffer rather
than walking the socket receive queue.
Additional changes:
(1) The timers are condensed to a single timer that is set for the soonest
of three timeouts (delayed ACK generation, DATA retransmission and
call lifespan).
(2) Transmission of ACK and ABORT packets is effected immediately from
process-context socket ops/kernel API calls that cause them instead of
them being punted off to a background work item. The data_ready
handler still has to defer to the background, though.
(3) A shutdown op is added to the AF_RXRPC socket so that the AFS
filesystem can shut down the socket and flush its own work items
before closing the socket to deal with any in-progress service calls.
Future additional changes that will need to be considered:
(1) Make sure that a call doesn't hog the front of the queue by receiving
data from the network as fast as userspace is consuming it to the
exclusion of other calls.
(2) Transmit delayed ACKs from within recvmsg() when we've consumed
sufficiently more packets to avoid the background work item needing to
run.
Signed-off-by: David Howells <dhowells@redhat.com>
2016-09-08 10:10:12 +00:00
|
|
|
|
|
|
|
iov[0].iov_base = &whdr;
|
|
|
|
iov[0].iov_len = sizeof(whdr);
|
|
|
|
iov[1].iov_base = &code;
|
|
|
|
iov[1].iov_len = sizeof(code);
|
|
|
|
|
2016-09-13 07:49:05 +00:00
|
|
|
msg.msg_name = &srx.transport;
|
rxrpc: Rewrite the data and ack handling code
Rewrite the data and ack handling code such that:
(1) Parsing of received ACK and ABORT packets and the distribution and the
filing of DATA packets happens entirely within the data_ready context
called from the UDP socket. This allows us to process and discard ACK
and ABORT packets much more quickly (they're no longer stashed on a
queue for a background thread to process).
(2) We avoid calling skb_clone(), pskb_pull() and pskb_trim(). We instead
keep track of the offset and length of the content of each packet in
the sk_buff metadata. This means we don't do any allocation in the
receive path.
(3) Jumbo DATA packet parsing is now done in data_ready context. Rather
than cloning the packet once for each subpacket and pulling/trimming
it, we file the packet multiple times with an annotation for each
indicating which subpacket is there. From that we can directly
calculate the offset and length.
(4) A call's receive queue can be accessed without taking locks (memory
barriers do have to be used, though).
(5) Incoming calls are set up from preallocated resources and immediately
made live. They can than have packets queued upon them and ACKs
generated. If insufficient resources exist, DATA packet #1 is given a
BUSY reply and other DATA packets are discarded).
(6) sk_buffs no longer take a ref on their parent call.
To make this work, the following changes are made:
(1) Each call's receive buffer is now a circular buffer of sk_buff
pointers (rxtx_buffer) rather than a number of sk_buff_heads spread
between the call and the socket. This permits each sk_buff to be in
the buffer multiple times. The receive buffer is reused for the
transmit buffer.
(2) A circular buffer of annotations (rxtx_annotations) is kept parallel
to the data buffer. Transmission phase annotations indicate whether a
buffered packet has been ACK'd or not and whether it needs
retransmission.
Receive phase annotations indicate whether a slot holds a whole packet
or a jumbo subpacket and, if the latter, which subpacket. They also
note whether the packet has been decrypted in place.
(3) DATA packet window tracking is much simplified. Each phase has just
two numbers representing the window (rx_hard_ack/rx_top and
tx_hard_ack/tx_top).
The hard_ack number is the sequence number before base of the window,
representing the last packet the other side says it has consumed.
hard_ack starts from 0 and the first packet is sequence number 1.
The top number is the sequence number of the highest-numbered packet
residing in the buffer. Packets between hard_ack+1 and top are
soft-ACK'd to indicate they've been received, but not yet consumed.
Four macros, before(), before_eq(), after() and after_eq() are added
to compare sequence numbers within the window. This allows for the
top of the window to wrap when the hard-ack sequence number gets close
to the limit.
Two flags, RXRPC_CALL_RX_LAST and RXRPC_CALL_TX_LAST, are added also
to indicate when rx_top and tx_top point at the packets with the
LAST_PACKET bit set, indicating the end of the phase.
(4) Calls are queued on the socket 'receive queue' rather than packets.
This means that we don't need have to invent dummy packets to queue to
indicate abnormal/terminal states and we don't have to keep metadata
packets (such as ABORTs) around
(5) The offset and length of a (sub)packet's content are now passed to
the verify_packet security op. This is currently expected to decrypt
the packet in place and validate it.
However, there's now nowhere to store the revised offset and length of
the actual data within the decrypted blob (there may be a header and
padding to skip) because an sk_buff may represent multiple packets, so
a locate_data security op is added to retrieve these details from the
sk_buff content when needed.
(6) recvmsg() now has to handle jumbo subpackets, where each subpacket is
individually secured and needs to be individually decrypted. The code
to do this is broken out into rxrpc_recvmsg_data() and shared with the
kernel API. It now iterates over the call's receive buffer rather
than walking the socket receive queue.
Additional changes:
(1) The timers are condensed to a single timer that is set for the soonest
of three timeouts (delayed ACK generation, DATA retransmission and
call lifespan).
(2) Transmission of ACK and ABORT packets is effected immediately from
process-context socket ops/kernel API calls that cause them instead of
them being punted off to a background work item. The data_ready
handler still has to defer to the background, though.
(3) A shutdown op is added to the AF_RXRPC socket so that the AFS
filesystem can shut down the socket and flush its own work items
before closing the socket to deal with any in-progress service calls.
Future additional changes that will need to be considered:
(1) Make sure that a call doesn't hog the front of the queue by receiving
data from the network as fast as userspace is consuming it to the
exclusion of other calls.
(2) Transmit delayed ACKs from within recvmsg() when we've consumed
sufficiently more packets to avoid the background work item needing to
run.
Signed-off-by: David Howells <dhowells@redhat.com>
2016-09-08 10:10:12 +00:00
|
|
|
msg.msg_control = NULL;
|
|
|
|
msg.msg_controllen = 0;
|
|
|
|
msg.msg_flags = 0;
|
|
|
|
|
|
|
|
memset(&whdr, 0, sizeof(whdr));
|
|
|
|
|
2020-01-23 13:13:41 +00:00
|
|
|
switch (skb->mark) {
|
|
|
|
case RXRPC_SKB_MARK_REJECT_BUSY:
|
|
|
|
whdr.type = RXRPC_PACKET_TYPE_BUSY;
|
|
|
|
size = sizeof(whdr);
|
|
|
|
ioc = 1;
|
|
|
|
break;
|
|
|
|
case RXRPC_SKB_MARK_REJECT_ABORT:
|
|
|
|
whdr.type = RXRPC_PACKET_TYPE_ABORT;
|
|
|
|
code = htonl(skb->priority);
|
|
|
|
size = sizeof(whdr) + sizeof(code);
|
|
|
|
ioc = 2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
2016-09-13 07:49:05 +00:00
|
|
|
|
2020-01-23 13:13:41 +00:00
|
|
|
if (rxrpc_extract_addr_from_skb(&srx, skb) == 0) {
|
|
|
|
msg.msg_namelen = srx.transport_len;
|
rxrpc: Emit BUSY packets when supposed to rather than ABORTs
In the input path, a received sk_buff can be marked for rejection by
setting RXRPC_SKB_MARK_* in skb->mark and, if needed, some auxiliary data
(such as an abort code) in skb->priority. The rejection is handled by
queueing the sk_buff up for dealing with in process context. The output
code reads the mark and priority and, theoretically, generates an
appropriate response packet.
However, if RXRPC_SKB_MARK_BUSY is set, this isn't noticed and an ABORT
message with a random abort code is generated (since skb->priority wasn't
set to anything).
Fix this by outputting the appropriate sort of packet.
Also, whilst we're at it, most of the marks are no longer used, so remove
them and rename the remaining two to something more obvious.
Fixes: 248f219cb8bc ("rxrpc: Rewrite the data and ack handling code")
Signed-off-by: David Howells <dhowells@redhat.com>
2018-09-27 14:13:08 +00:00
|
|
|
|
2020-01-23 13:13:41 +00:00
|
|
|
whdr.epoch = htonl(sp->hdr.epoch);
|
|
|
|
whdr.cid = htonl(sp->hdr.cid);
|
|
|
|
whdr.callNumber = htonl(sp->hdr.callNumber);
|
|
|
|
whdr.serviceId = htons(sp->hdr.serviceId);
|
|
|
|
whdr.flags = sp->hdr.flags;
|
|
|
|
whdr.flags ^= RXRPC_CLIENT_INITIATED;
|
|
|
|
whdr.flags &= RXRPC_CLIENT_INITIATED;
|
rxrpc: Rewrite the data and ack handling code
Rewrite the data and ack handling code such that:
(1) Parsing of received ACK and ABORT packets and the distribution and the
filing of DATA packets happens entirely within the data_ready context
called from the UDP socket. This allows us to process and discard ACK
and ABORT packets much more quickly (they're no longer stashed on a
queue for a background thread to process).
(2) We avoid calling skb_clone(), pskb_pull() and pskb_trim(). We instead
keep track of the offset and length of the content of each packet in
the sk_buff metadata. This means we don't do any allocation in the
receive path.
(3) Jumbo DATA packet parsing is now done in data_ready context. Rather
than cloning the packet once for each subpacket and pulling/trimming
it, we file the packet multiple times with an annotation for each
indicating which subpacket is there. From that we can directly
calculate the offset and length.
(4) A call's receive queue can be accessed without taking locks (memory
barriers do have to be used, though).
(5) Incoming calls are set up from preallocated resources and immediately
made live. They can than have packets queued upon them and ACKs
generated. If insufficient resources exist, DATA packet #1 is given a
BUSY reply and other DATA packets are discarded).
(6) sk_buffs no longer take a ref on their parent call.
To make this work, the following changes are made:
(1) Each call's receive buffer is now a circular buffer of sk_buff
pointers (rxtx_buffer) rather than a number of sk_buff_heads spread
between the call and the socket. This permits each sk_buff to be in
the buffer multiple times. The receive buffer is reused for the
transmit buffer.
(2) A circular buffer of annotations (rxtx_annotations) is kept parallel
to the data buffer. Transmission phase annotations indicate whether a
buffered packet has been ACK'd or not and whether it needs
retransmission.
Receive phase annotations indicate whether a slot holds a whole packet
or a jumbo subpacket and, if the latter, which subpacket. They also
note whether the packet has been decrypted in place.
(3) DATA packet window tracking is much simplified. Each phase has just
two numbers representing the window (rx_hard_ack/rx_top and
tx_hard_ack/tx_top).
The hard_ack number is the sequence number before base of the window,
representing the last packet the other side says it has consumed.
hard_ack starts from 0 and the first packet is sequence number 1.
The top number is the sequence number of the highest-numbered packet
residing in the buffer. Packets between hard_ack+1 and top are
soft-ACK'd to indicate they've been received, but not yet consumed.
Four macros, before(), before_eq(), after() and after_eq() are added
to compare sequence numbers within the window. This allows for the
top of the window to wrap when the hard-ack sequence number gets close
to the limit.
Two flags, RXRPC_CALL_RX_LAST and RXRPC_CALL_TX_LAST, are added also
to indicate when rx_top and tx_top point at the packets with the
LAST_PACKET bit set, indicating the end of the phase.
(4) Calls are queued on the socket 'receive queue' rather than packets.
This means that we don't need have to invent dummy packets to queue to
indicate abnormal/terminal states and we don't have to keep metadata
packets (such as ABORTs) around
(5) The offset and length of a (sub)packet's content are now passed to
the verify_packet security op. This is currently expected to decrypt
the packet in place and validate it.
However, there's now nowhere to store the revised offset and length of
the actual data within the decrypted blob (there may be a header and
padding to skip) because an sk_buff may represent multiple packets, so
a locate_data security op is added to retrieve these details from the
sk_buff content when needed.
(6) recvmsg() now has to handle jumbo subpackets, where each subpacket is
individually secured and needs to be individually decrypted. The code
to do this is broken out into rxrpc_recvmsg_data() and shared with the
kernel API. It now iterates over the call's receive buffer rather
than walking the socket receive queue.
Additional changes:
(1) The timers are condensed to a single timer that is set for the soonest
of three timeouts (delayed ACK generation, DATA retransmission and
call lifespan).
(2) Transmission of ACK and ABORT packets is effected immediately from
process-context socket ops/kernel API calls that cause them instead of
them being punted off to a background work item. The data_ready
handler still has to defer to the background, though.
(3) A shutdown op is added to the AF_RXRPC socket so that the AFS
filesystem can shut down the socket and flush its own work items
before closing the socket to deal with any in-progress service calls.
Future additional changes that will need to be considered:
(1) Make sure that a call doesn't hog the front of the queue by receiving
data from the network as fast as userspace is consuming it to the
exclusion of other calls.
(2) Transmit delayed ACKs from within recvmsg() when we've consumed
sufficiently more packets to avoid the background work item needing to
run.
Signed-off-by: David Howells <dhowells@redhat.com>
2016-09-08 10:10:12 +00:00
|
|
|
|
2020-01-23 13:13:41 +00:00
|
|
|
iov_iter_kvec(&msg.msg_iter, WRITE, iov, ioc, size);
|
|
|
|
ret = do_udp_sendmsg(local->socket, &msg, size);
|
|
|
|
if (ret < 0)
|
|
|
|
trace_rxrpc_tx_fail(local->debug_id, 0, ret,
|
|
|
|
rxrpc_tx_point_reject);
|
|
|
|
else
|
|
|
|
trace_rxrpc_tx_packet(local->debug_id, &whdr,
|
|
|
|
rxrpc_tx_point_reject);
|
rxrpc: Rewrite the data and ack handling code
Rewrite the data and ack handling code such that:
(1) Parsing of received ACK and ABORT packets and the distribution and the
filing of DATA packets happens entirely within the data_ready context
called from the UDP socket. This allows us to process and discard ACK
and ABORT packets much more quickly (they're no longer stashed on a
queue for a background thread to process).
(2) We avoid calling skb_clone(), pskb_pull() and pskb_trim(). We instead
keep track of the offset and length of the content of each packet in
the sk_buff metadata. This means we don't do any allocation in the
receive path.
(3) Jumbo DATA packet parsing is now done in data_ready context. Rather
than cloning the packet once for each subpacket and pulling/trimming
it, we file the packet multiple times with an annotation for each
indicating which subpacket is there. From that we can directly
calculate the offset and length.
(4) A call's receive queue can be accessed without taking locks (memory
barriers do have to be used, though).
(5) Incoming calls are set up from preallocated resources and immediately
made live. They can than have packets queued upon them and ACKs
generated. If insufficient resources exist, DATA packet #1 is given a
BUSY reply and other DATA packets are discarded).
(6) sk_buffs no longer take a ref on their parent call.
To make this work, the following changes are made:
(1) Each call's receive buffer is now a circular buffer of sk_buff
pointers (rxtx_buffer) rather than a number of sk_buff_heads spread
between the call and the socket. This permits each sk_buff to be in
the buffer multiple times. The receive buffer is reused for the
transmit buffer.
(2) A circular buffer of annotations (rxtx_annotations) is kept parallel
to the data buffer. Transmission phase annotations indicate whether a
buffered packet has been ACK'd or not and whether it needs
retransmission.
Receive phase annotations indicate whether a slot holds a whole packet
or a jumbo subpacket and, if the latter, which subpacket. They also
note whether the packet has been decrypted in place.
(3) DATA packet window tracking is much simplified. Each phase has just
two numbers representing the window (rx_hard_ack/rx_top and
tx_hard_ack/tx_top).
The hard_ack number is the sequence number before base of the window,
representing the last packet the other side says it has consumed.
hard_ack starts from 0 and the first packet is sequence number 1.
The top number is the sequence number of the highest-numbered packet
residing in the buffer. Packets between hard_ack+1 and top are
soft-ACK'd to indicate they've been received, but not yet consumed.
Four macros, before(), before_eq(), after() and after_eq() are added
to compare sequence numbers within the window. This allows for the
top of the window to wrap when the hard-ack sequence number gets close
to the limit.
Two flags, RXRPC_CALL_RX_LAST and RXRPC_CALL_TX_LAST, are added also
to indicate when rx_top and tx_top point at the packets with the
LAST_PACKET bit set, indicating the end of the phase.
(4) Calls are queued on the socket 'receive queue' rather than packets.
This means that we don't need have to invent dummy packets to queue to
indicate abnormal/terminal states and we don't have to keep metadata
packets (such as ABORTs) around
(5) The offset and length of a (sub)packet's content are now passed to
the verify_packet security op. This is currently expected to decrypt
the packet in place and validate it.
However, there's now nowhere to store the revised offset and length of
the actual data within the decrypted blob (there may be a header and
padding to skip) because an sk_buff may represent multiple packets, so
a locate_data security op is added to retrieve these details from the
sk_buff content when needed.
(6) recvmsg() now has to handle jumbo subpackets, where each subpacket is
individually secured and needs to be individually decrypted. The code
to do this is broken out into rxrpc_recvmsg_data() and shared with the
kernel API. It now iterates over the call's receive buffer rather
than walking the socket receive queue.
Additional changes:
(1) The timers are condensed to a single timer that is set for the soonest
of three timeouts (delayed ACK generation, DATA retransmission and
call lifespan).
(2) Transmission of ACK and ABORT packets is effected immediately from
process-context socket ops/kernel API calls that cause them instead of
them being punted off to a background work item. The data_ready
handler still has to defer to the background, though.
(3) A shutdown op is added to the AF_RXRPC socket so that the AFS
filesystem can shut down the socket and flush its own work items
before closing the socket to deal with any in-progress service calls.
Future additional changes that will need to be considered:
(1) Make sure that a call doesn't hog the front of the queue by receiving
data from the network as fast as userspace is consuming it to the
exclusion of other calls.
(2) Transmit delayed ACKs from within recvmsg() when we've consumed
sufficiently more packets to avoid the background work item needing to
run.
Signed-off-by: David Howells <dhowells@redhat.com>
2016-09-08 10:10:12 +00:00
|
|
|
}
|
|
|
|
}
|
2018-03-30 20:04:43 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Send a VERSION reply to a peer as a keepalive.
|
|
|
|
*/
|
|
|
|
void rxrpc_send_keepalive(struct rxrpc_peer *peer)
|
|
|
|
{
|
|
|
|
struct rxrpc_wire_header whdr;
|
|
|
|
struct msghdr msg;
|
|
|
|
struct kvec iov[2];
|
|
|
|
size_t len;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
_enter("");
|
|
|
|
|
|
|
|
msg.msg_name = &peer->srx.transport;
|
|
|
|
msg.msg_namelen = peer->srx.transport_len;
|
|
|
|
msg.msg_control = NULL;
|
|
|
|
msg.msg_controllen = 0;
|
|
|
|
msg.msg_flags = 0;
|
|
|
|
|
|
|
|
whdr.epoch = htonl(peer->local->rxnet->epoch);
|
|
|
|
whdr.cid = 0;
|
|
|
|
whdr.callNumber = 0;
|
|
|
|
whdr.seq = 0;
|
|
|
|
whdr.serial = 0;
|
|
|
|
whdr.type = RXRPC_PACKET_TYPE_VERSION; /* Not client-initiated */
|
|
|
|
whdr.flags = RXRPC_LAST_PACKET;
|
|
|
|
whdr.userStatus = 0;
|
|
|
|
whdr.securityIndex = 0;
|
|
|
|
whdr._rsvd = 0;
|
|
|
|
whdr.serviceId = 0;
|
|
|
|
|
|
|
|
iov[0].iov_base = &whdr;
|
|
|
|
iov[0].iov_len = sizeof(whdr);
|
|
|
|
iov[1].iov_base = (char *)rxrpc_keepalive_string;
|
|
|
|
iov[1].iov_len = sizeof(rxrpc_keepalive_string);
|
|
|
|
|
|
|
|
len = iov[0].iov_len + iov[1].iov_len;
|
|
|
|
|
2022-03-22 11:07:20 +00:00
|
|
|
iov_iter_kvec(&msg.msg_iter, WRITE, iov, 2, len);
|
|
|
|
ret = do_udp_sendmsg(peer->local->socket, &msg, len);
|
2018-03-30 20:04:43 +00:00
|
|
|
if (ret < 0)
|
2018-05-10 22:26:01 +00:00
|
|
|
trace_rxrpc_tx_fail(peer->debug_id, 0, ret,
|
2018-07-23 16:18:37 +00:00
|
|
|
rxrpc_tx_point_version_keepalive);
|
|
|
|
else
|
|
|
|
trace_rxrpc_tx_packet(peer->debug_id, &whdr,
|
|
|
|
rxrpc_tx_point_version_keepalive);
|
2018-03-30 20:04:43 +00:00
|
|
|
|
2018-08-08 10:30:02 +00:00
|
|
|
peer->last_tx_at = ktime_get_seconds();
|
2018-03-30 20:04:43 +00:00
|
|
|
_leave("");
|
|
|
|
}
|