rxrpc: Miscellaneous fixes
Subsystems (4)
David Howells
maintainercover rxrpc: Miscellaneous fixes
Here some miscellaneous fixes for AF_RXRPC:
(1) The zero serial number has a special meaning in an ACK packet serial reference, so skip it when assigning serial numbers to transmitted packets.
(2) Don't set the reference serial number in a delayed ACK as the ACK cannot be used for RTT calculation.
(3) Don't emit a DUP ACK response to a PING RESPONSE ACK coming back to a call that completed in the meantime.
(4) Fix the counting of acks and nacks in ACK packet to better drive congestion management. We want to know if there have been new acks/nacks since the last ACK packet, not that there are still acks/nacks. This is more complicated as we have to save the old SACK table and compare it.
David
---
The patches can be found here also:
http://git.kernel.org/cgit/linux/kernel/git/dhowells/linux-fs.git/log/?h=rxrpc-fixes
David Howells (4):
rxrpc: Fix generation of serial numbers to skip zero
rxrpc: Fix delayed ACKs to not set the reference serial number
rxrpc: Fix response to PING RESPONSE ACKs to a dead call
rxrpc: Fix counting of new acks and nacks
include/trace/events/rxrpc.h | 8 ++- net/rxrpc/ar-internal.h | 37 ++++++++--- net/rxrpc/call_event.c | 12 ++-- net/rxrpc/call_object.c | 1 + net/rxrpc/conn_event.c | 10 ++- net/rxrpc/input.c | 115 +++++++++++++++++++++++++++++------ net/rxrpc/output.c | 8 +-- net/rxrpc/proc.c | 2 +- net/rxrpc/rxkad.c | 4 +- 9 files changed, 154 insertions(+), 43 deletions(-)
David Howells
maintainerPATCH 1/4 rxrpc: Fix generation of serial numbers to skip zero
In the Rx protocol, every packet generated is marked with a per-connection monotonically increasing serial number. This number can be referenced in an ACK packet generated in response to an incoming packet - thereby allowing the sender to use this for RTT determination, amongst other things.
However, if the reference field in the ACK is zero, it doesn't refer to any incoming packet (it could be a ping to find out if a packet got lost, for example) - so we shouldn't generate zero serial numbers.
Fix the generation of serial numbers to retry if it comes up with a zero.
Furthermore, since the serial numbers are only ever allocated within the I/O thread this connection is bound to, there's no need for atomics so remove that too.
--- net/rxrpc/ar-internal.h | 16 +++++++++++++++- net/rxrpc/conn_event.c | 2 +- net/rxrpc/output.c | 8 ++++---- net/rxrpc/proc.c | 2 +- net/rxrpc/rxkad.c | 4 ++-- 5 files changed, 23 insertions(+), 9 deletions(-)
net/rxrpc/ar-internal.h +15 -1
@@ -510,7 +510,7 @@ struct rxrpc_connection {enum rxrpc_call_completion completion;/* Completion condition */ s32 abort_code;/* Abort code of connection abort */ int debug_id;/* debug ID for printks */ -atomic_t serial;/* packet serial number counter */ +rxrpc_serial_t tx_serial;/* Outgoing packet serial number counter */ unsigned int hi_serial;/* highest serial number received */ u32 service_id;/* Service ID, possibly upgraded */ u32 security_level;/* Security level selected */
@@ -822,6 +822,20 @@ static inline bool rxrpc_sending_to_client(const struct rxrpc_txbuf *txb)#include <trace/events/rxrpc.h> +/* +* Allocate the next serial number on a connection. 0 must be skipped. +*/ +static inline rxrpc_serial_t rxrpc_get_next_serial (struct rxrpc_connection *conn) +{ +rxrpc_serial_t serial; + + serial = conn->tx_serial; +if (serial ==0 ) + serial =1 ; + conn->tx_serial = serial +1 ; +return serial; +} +/* * af_rxrpc.c */
net/rxrpc/conn_event.c +1 -1
@@ -117,7 +117,7 @@ void rxrpc_conn_retransmit_call(struct rxrpc_connection *conn, iov[2 ].iov_base = &ack_info; iov[2 ].iov_len =sizeof (ack_info); - serial =atomic_inc_return (&conn->serial); + serial =rxrpc_get_next_serial (conn); pkt.whdr.epoch =htonl (conn->proto.epoch); pkt.whdr.cid =htonl (conn->proto.cid | channel);
net/rxrpc/output.c +4 -4
@@ -216,7 +216,7 @@ int rxrpc_send_ack_packet(struct rxrpc_call *call, struct rxrpc_txbuf *txb) iov[0 ].iov_len =sizeof (txb->wire) +sizeof (txb->ack) + n; len = iov[0 ].iov_len; - serial =atomic_inc_return (&conn->serial); + serial =rxrpc_get_next_serial (conn); txb->wire.serial =htonl (serial); trace_rxrpc_tx_ack(call->debug_id, serial, ntohl(txb->ack.firstPacket),
@@ -302,7 +302,7 @@ int rxrpc_send_abort_packet(struct rxrpc_call *call) iov[0 ].iov_base = &pkt; iov[0 ].iov_len =sizeof (pkt); - serial =atomic_inc_return (&conn->serial); + serial =rxrpc_get_next_serial (conn); pkt.whdr.serial =htonl (serial);iov_iter_kvec (&msg.msg_iter,WRITE , iov,1 ,sizeof (pkt));
@@ -334,7 +334,7 @@ int rxrpc_send_data_packet(struct rxrpc_call *call, struct rxrpc_txbuf *txb)_enter ("%x,{%d}" , txb->seq, txb->len);/* Each transmission of a Tx packet needs a new serial number */ - serial =atomic_inc_return (&conn->serial); + serial =rxrpc_get_next_serial (conn); txb->wire.serial =htonl (serial); if (test_bit(RXRPC_CONN_PROBING_FOR_UPGRADE, &conn->flags) &&
@@ -558,7 +558,7 @@ void rxrpc_send_conn_abort(struct rxrpc_connection *conn) len = iov[0 ].iov_len + iov[1 ].iov_len; - serial =atomic_inc_return (&conn->serial); + serial =rxrpc_get_next_serial (conn); whdr.serial =htonl (serial);iov_iter_kvec (&msg.msg_iter,WRITE , iov,2 , len);
net/rxrpc/proc.c +1 -1
@@ -181,7 +181,7 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)atomic_read (&conn->active), state,key_serial (conn->key), -atomic_read (&conn->serial), + conn->tx_serial, conn->hi_serial, conn->channels[0 ].call_id, conn->channels[1].call_id,
net/rxrpc/rxkad.c +2 -2
@@ -664,7 +664,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn) len = iov[0 ].iov_len + iov[1 ].iov_len; - serial =atomic_inc_return (&conn->serial); + serial =rxrpc_get_next_serial (conn); whdr.serial =htonl (serial); ret =kernel_sendmsg (conn->local->socket, &msg, iov,2 , len);
@@ -721,7 +721,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn, len = iov[0 ].iov_len + iov[1 ].iov_len + iov[2 ].iov_len; - serial =atomic_inc_return (&conn->serial); + serial =rxrpc_get_next_serial (conn); whdr.serial =htonl (serial);rxrpc_local_dont_fragment (conn->local, false);
David Howells
maintainerPATCH 2/4 rxrpc: Fix delayed ACKs to not set the reference serial number
In reply to David HowellsFix the construction of delayed ACKs to not set the reference serial number as they can't be used as an RTT reference.
--- net/rxrpc/ar-internal.h | 1 - net/rxrpc/call_event.c | 6 +----- 2 files changed, 1 insertion(+), 6 deletions(-)
net/rxrpc/ar-internal.h +0 -1
@@ -696,7 +696,6 @@ struct rxrpc_call {/* Receive-phase ACK management (ACKs we send). */ u8 ackr_reason;/* reason to ACK */ u16 ackr_sack_base;/* Starting slot in SACK table ring */ -rxrpc_serial_t ackr_serial;/* serial of packet being ACK'd */ rxrpc_seq_t ackr_window;/* Base of SACK window */ rxrpc_seq_t ackr_wtop;/* Base of SACK window */ unsigned int ackr_nr_unacked;/* Number of unacked packets */
net/rxrpc/call_event.c +1 -5
@@ -43,8 +43,6 @@ void rxrpc_propose_delay_ACK(struct rxrpc_call *call, rxrpc_serial_t serial,unsigned long expiry = rxrpc_soft_ack_delay;unsigned long now = jiffies, ack_at; - call->ackr_serial = serial; -if (rxrpc_soft_ack_delay < expiry) expiry = rxrpc_soft_ack_delay;if (call->peer->srtt_us !=0 )
@@ -373,7 +371,6 @@ static void rxrpc_send_initial_ping(struct rxrpc_call *call)bool rxrpc_input_call_event (struct rxrpc_call *call,struct sk_buff *skb) {unsigned long now, next, t; -rxrpc_serial_t ackr_serial;bool resend = false, expired = false;s32 abort_code;
@@ -423,8 +420,7 @@ bool rxrpc_input_call_event(struct rxrpc_call *call, struct sk_buff *skb)if (time_after_eq (now, t)) {trace_rxrpc_timer (call, rxrpc_timer_exp_ack, now);cmpxchg (&call->delay_ack_at, t, now +MAX_JIFFY_OFFSET ); - ackr_serial =xchg (&call->ackr_serial,0 ); -rxrpc_send_ACK (call,RXRPC_ACK_DELAY , ackr_serial, +rxrpc_send_ACK (call,RXRPC_ACK_DELAY ,0 , rxrpc_propose_ack_ping_for_lost_ack); }
David Howells
maintainerPATCH 3/4 rxrpc: Fix response to PING RESPONSE ACKs to a dead call
In reply to David HowellsStop rxrpc from sending a DUP ACK in response to a PING RESPONSE ACK on a dead call. We may have initiated the ping but the call may have beaten the response to completion.
--- net/rxrpc/conn_event.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/rxrpc/conn_event.c +8 -0
@@ -95,6 +95,14 @@ void rxrpc_conn_retransmit_call(struct rxrpc_connection *conn,_enter ("%d" , conn->debug_id); +if (sp && sp->hdr.type ==RXRPC_PACKET_TYPE_ACK ) { +if (skb_copy_bits (skb,sizeof (struct rxrpc_wire_header ), + &pkt.ack,sizeof (pkt.ack)) <0 ) +return ; +if (pkt.ack.reason ==RXRPC_ACK_PING_RESPONSE ) +return ; + } + chan = &conn->channels[channel];/* If the last call got moved on whilst we were waiting to run, just
David Howells
maintainerPATCH 4/4 rxrpc: Fix counting of new acks and nacks
In reply to David HowellsFix the counting of new acks and nacks when parsing a packet - something that is used in congestion control.
As the code stands, it merely notes if there are any nacks whereas what we really should do is compare the previous SACK table to the new one, assuming we get two successive ACK packets with nacks in them. However, we really don't want to do that if we can avoid it as the tables might not correspond directly as one may be shifted from the other - something that will only get harder to deal with once extended ACK tables come into full use (with a capacity of up to 8192).
Instead, count the number of nacks shifted out of the old SACK, the number of nacks retained in the portion still active and the number of new acks and nacks in the new table then calculate what we need.
Note this ends up a bit of an estimate as the Rx protocol allows acks to be withdrawn by the receiver and packets requested to be retransmitted.
--- include/trace/events/rxrpc.h | 8 ++- net/rxrpc/ar-internal.h | 20 ++++-- net/rxrpc/call_event.c | 6 +- net/rxrpc/call_object.c | 1 + net/rxrpc/input.c | 115 +++++++++++++++++++++++++++++------ 5 files changed, 122 insertions(+), 28 deletions(-)
include/trace/events/rxrpc.h +5 -3
@@ -128,6 +128,7 @@ EM(rxrpc_skb_eaten_by_unshare_nomem, "ETN unshar-nm") \ EM(rxrpc_skb_get_conn_secured, "GET conn-secd") \ EM(rxrpc_skb_get_conn_work, "GET conn-work") \ + EM(rxrpc_skb_get_last_nack, "GET last-nack") \ EM(rxrpc_skb_get_local_work, "GET locl-work") \ EM(rxrpc_skb_get_reject_work, "GET rej-work ") \EM (rxrpc_skb_get_to_recvmsg,"GET to-recv " ) \
@@ -141,6 +142,7 @@ EM(rxrpc_skb_put_error_report, "PUT error-rep") \ EM(rxrpc_skb_put_input, "PUT input ") \ EM(rxrpc_skb_put_jumbo_subpacket, "PUT jumbo-sub") \ + EM(rxrpc_skb_put_last_nack, "PUT last-nack") \ EM(rxrpc_skb_put_purge, "PUT purge ") \ EM(rxrpc_skb_put_rotate, "PUT rotate ") \EM (rxrpc_skb_put_unknown,"PUT unknown " ) \
@@ -1552,7 +1554,7 @@ TRACE_EVENT(rxrpc_congest,memcpy (&__entry->sum, summary,sizeof (__entry->sum)); ), - TP_printk("c=%08x r=%08x %s q=%08x %s cw=%u ss=%u nA=%u,%u+%u r=%u b=%u u=%u d=%u l=%x%s%s%s", + TP_printk("c=%08x r=%08x %s q=%08x %s cw=%u ss=%u nA=%u,%u+%u,%u b=%u u=%u d=%u l=%x%s%s%s", __entry->call, __entry->ack_serial, __print_symbolic(__entry->sum.ack_reason, rxrpc_ack_names),
@@ -1560,9 +1562,9 @@ TRACE_EVENT(rxrpc_congest,__print_symbolic (__entry->sum.mode, rxrpc_congest_modes), __entry->sum.cwnd, __entry->sum.ssthresh, - __entry->sum.nr_acks, __entry->sum.saw_nacks, + __entry->sum.nr_acks, __entry->sum.nr_retained_nacks, __entry->sum.nr_new_acks, - __entry->sum.nr_rot_new_acks, + __entry->sum.nr_new_nacks, __entry->top - __entry->hard_ack, __entry->sum.cumulative_acks, __entry->sum.dup_acks,
net/rxrpc/ar-internal.h +15 -5
@@ -199,11 +199,19 @@ struct rxrpc_host_header {*/ struct rxrpc_skb_priv {struct rxrpc_connection *conn;/* Connection referred to (poke packet) */ -u16 offset;/* Offset of data */ -u16 len;/* Length of data */ -u8 flags; +union { +struct { +u16 offset;/* Offset of data */ +u16 len;/* Length of data */ +u8 flags;#define RXRPC_RX_VERIFIED 0x01 - + }; +struct { +rxrpc_seq_t first_ack;/* First packet in acks table */ +u8 nr_acks;/* Number of acks+nacks */ +u8 nr_nacks;/* Number of nacks */ + }; + };struct rxrpc_host_header hdr;/* RxRPC packet header from this packet */ };
@@ -692,6 +700,7 @@ struct rxrpc_call {u8 cong_dup_acks;/* Count of ACKs showing missing packets */ u8 cong_cumul_acks;/* Cumulative ACK count */ ktime_t cong_tstamp;/* Last time cwnd was changed */ +struct sk_buff *cong_last_nack;/* Last ACK with nacks received */ /* Receive-phase ACK management (ACKs we send). */ u8 ackr_reason;/* reason to ACK */
@@ -729,7 +738,8 @@ struct rxrpc_call {struct rxrpc_ack_summary {u16 nr_acks;/* Number of ACKs in packet */ u16 nr_new_acks;/* Number of new ACKs in packet */ -u16 nr_rot_new_acks;/* Number of rotated new ACKs */ +u16 nr_new_nacks;/* Number of new nacks in packet */ +u16 nr_retained_nacks;/* Number of nacks retained between ACKs */ u8 ack_reason;bool saw_nacks;/* Saw NACKs in packet */ bool new_low_nack;/* T if new low NACK found */
net/rxrpc/call_event.c +4 -2
@@ -112,6 +112,7 @@ static void rxrpc_congestion_timeout(struct rxrpc_call *call)void rxrpc_resend (struct rxrpc_call *call,struct sk_buff *ack_skb) {struct rxrpc_ackpacket *ack =NULL ; +struct rxrpc_skb_priv *sp;struct rxrpc_txbuf *txb;unsigned long resend_at;rxrpc_seq_t transmitted =READ_ONCE (call->tx_transmitted);
@@ -139,14 +140,15 @@ void rxrpc_resend(struct rxrpc_call *call, struct sk_buff *ack_skb)* explicitly NAK'd packets. */ if (ack_skb) { + sp =rxrpc_skb (ack_skb); ack = (void *)ack_skb->data +sizeof (struct rxrpc_wire_header ); -for (i =0 ; i < ack->nAcks; i++) { +for (i =0 ; i < sp->nr_acks; i++) {rxrpc_seq_t seq;if (ack->acks[i] &1 )continue ; - seq =ntohl (ack->firstPacket) + i; + seq = sp->first_ack + i;if (after (txb->seq, transmitted))break ;if (after (txb->seq, seq))
net/rxrpc/call_object.c +1 -0
@@ -686,6 +686,7 @@ static void rxrpc_destroy_call(struct work_struct *work)del_timer_sync (&call->timer); +rxrpc_free_skb (call->cong_last_nack, rxrpc_skb_put_last_nack);rxrpc_cleanup_ring (call);while ((txb =list_first_entry_or_null (&call->tx_sendmsg, struct rxrpc_txbuf, call_link))) {
net/rxrpc/input.c +97 -18
192 lines not on this page · raw message
This series was applied to netdev/net.git (main) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:
Quoted 10 lines · On Fri, 2 Feb 2024 15:19:12 +0000 you wrote:
Here some miscellaneous fixes for
AF_RXRPC:(1) The zero serial number has a special meaning in an ACK packet serial reference, so skip it when assigning serial numbers to transmitted packets.
(2) Don't set the reference serial number in a delayed ACK as the ACK cannot be used for RTT calculation.
[...]
Here is the summary with links:
- [net,1/4] rxrpc: Fix generation of serial numbers to skip zero
https://git.kernel.org/netdev/net/c/f31041417bf7 - [net,2/4] rxrpc: Fix delayed ACKs to not set the reference serial number https://git.kernel.org/netdev/net/c/e7870cf13d20 - [net,3/4] rxrpc: Fix response to PING RESPONSE ACKs to a dead call https://git.kernel.org/netdev/net/c/6f769f22822a - [net,4/4] rxrpc: Fix counting of new acks and nacks https://git.kernel.org/netdev/net/c/41b7fa157ea1
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html