Skip to content

Commit 75e4212

Browse files
committed
rxrpc: Correctly initialise, limit and transmit call->rx_winsize
call->rx_winsize should be initialised to the sysctl setting and the sysctl setting should be limited to the maximum we want to permit. Further, we need to place this in the ACK info instead of the sysctl setting. Furthermore, discard the idea of accepting the subpackets of a jumbo packet that lie beyond the receive window when the first packet of the jumbo is within the window. Just discard the excess subpackets instead. This allows the receive window to be opened up right to the buffer size less one for the dead slot. Signed-off-by: David Howells <[email protected]>
1 parent 3432a75 commit 75e4212

File tree

6 files changed

+26
-13
lines changed

6 files changed

+26
-13
lines changed

net/rxrpc/ar-internal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ struct rxrpc_call {
498498
*/
499499
#define RXRPC_RXTX_BUFF_SIZE 64
500500
#define RXRPC_RXTX_BUFF_MASK (RXRPC_RXTX_BUFF_SIZE - 1)
501+
#define RXRPC_INIT_RX_WINDOW_SIZE 32
501502
struct sk_buff **rxtx_buffer;
502503
u8 *rxtx_annotations;
503504
#define RXRPC_TX_ANNO_ACK 0
@@ -518,7 +519,7 @@ struct rxrpc_call {
518519
rxrpc_seq_t rx_expect_next; /* Expected next packet sequence number */
519520
u8 rx_winsize; /* Size of Rx window */
520521
u8 tx_winsize; /* Maximum size of Tx window */
521-
u8 nr_jumbo_dup; /* Number of jumbo duplicates */
522+
u8 nr_jumbo_bad; /* Number of jumbo dups/exceeds-windows */
522523

523524
/* receive-phase ACK management */
524525
u8 ackr_reason; /* reason to ACK */

net/rxrpc/call_object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
152152
memset(&call->sock_node, 0xed, sizeof(call->sock_node));
153153

154154
/* Leave space in the ring to handle a maxed-out jumbo packet */
155-
call->rx_winsize = RXRPC_RXTX_BUFF_SIZE - 1 - 46;
155+
call->rx_winsize = rxrpc_rx_window_size;
156156
call->tx_winsize = 16;
157157
call->rx_expect_next = 1;
158158
return call;

net/rxrpc/input.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static bool rxrpc_validate_jumbo(struct sk_buff *skb)
164164
* (that information is encoded in the ACK packet).
165165
*/
166166
static void rxrpc_input_dup_data(struct rxrpc_call *call, rxrpc_seq_t seq,
167-
u8 annotation, bool *_jumbo_dup)
167+
u8 annotation, bool *_jumbo_bad)
168168
{
169169
/* Discard normal packets that are duplicates. */
170170
if (annotation == 0)
@@ -174,9 +174,9 @@ static void rxrpc_input_dup_data(struct rxrpc_call *call, rxrpc_seq_t seq,
174174
* more partially duplicate jumbo packets, we refuse to take any more
175175
* jumbos for this call.
176176
*/
177-
if (!*_jumbo_dup) {
178-
call->nr_jumbo_dup++;
179-
*_jumbo_dup = true;
177+
if (!*_jumbo_bad) {
178+
call->nr_jumbo_bad++;
179+
*_jumbo_bad = true;
180180
}
181181
}
182182

@@ -191,7 +191,7 @@ static void rxrpc_input_data(struct rxrpc_call *call, struct sk_buff *skb,
191191
unsigned int ix;
192192
rxrpc_serial_t serial = sp->hdr.serial, ack_serial = 0;
193193
rxrpc_seq_t seq = sp->hdr.seq, hard_ack;
194-
bool immediate_ack = false, jumbo_dup = false, queued;
194+
bool immediate_ack = false, jumbo_bad = false, queued;
195195
u16 len;
196196
u8 ack = 0, flags, annotation = 0;
197197

@@ -222,7 +222,7 @@ static void rxrpc_input_data(struct rxrpc_call *call, struct sk_buff *skb,
222222

223223
flags = sp->hdr.flags;
224224
if (flags & RXRPC_JUMBO_PACKET) {
225-
if (call->nr_jumbo_dup > 3) {
225+
if (call->nr_jumbo_bad > 3) {
226226
ack = RXRPC_ACK_NOSPACE;
227227
ack_serial = serial;
228228
goto ack;
@@ -259,7 +259,7 @@ static void rxrpc_input_data(struct rxrpc_call *call, struct sk_buff *skb,
259259
}
260260

261261
if (call->rxtx_buffer[ix]) {
262-
rxrpc_input_dup_data(call, seq, annotation, &jumbo_dup);
262+
rxrpc_input_dup_data(call, seq, annotation, &jumbo_bad);
263263
if (ack != RXRPC_ACK_DUPLICATE) {
264264
ack = RXRPC_ACK_DUPLICATE;
265265
ack_serial = serial;
@@ -304,6 +304,15 @@ static void rxrpc_input_data(struct rxrpc_call *call, struct sk_buff *skb,
304304
annotation++;
305305
if (flags & RXRPC_JUMBO_PACKET)
306306
annotation |= RXRPC_RX_ANNO_JLAST;
307+
if (after(seq, hard_ack + call->rx_winsize)) {
308+
ack = RXRPC_ACK_EXCEEDS_WINDOW;
309+
ack_serial = serial;
310+
if (!jumbo_bad) {
311+
call->nr_jumbo_bad++;
312+
jumbo_bad = true;
313+
}
314+
goto ack;
315+
}
307316

308317
_proto("Rx DATA Jumbo %%%u", serial);
309318
goto next_subpacket;

net/rxrpc/misc.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ unsigned int rxrpc_idle_ack_delay = 0.5 * HZ;
5050
* limit is hit, we should generate an EXCEEDS_WINDOW ACK and discard further
5151
* packets.
5252
*/
53-
unsigned int rxrpc_rx_window_size = RXRPC_RXTX_BUFF_SIZE - 46;
53+
unsigned int rxrpc_rx_window_size = RXRPC_INIT_RX_WINDOW_SIZE;
54+
#if (RXRPC_RXTX_BUFF_SIZE - 1) < RXRPC_INIT_RX_WINDOW_SIZE
55+
#error Need to reduce RXRPC_INIT_RX_WINDOW_SIZE
56+
#endif
5457

5558
/*
5659
* Maximum Rx MTU size. This indicates to the sender the size of jumbo packet

net/rxrpc/output.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ static size_t rxrpc_fill_out_ack(struct rxrpc_call *call,
7171

7272
mtu = call->conn->params.peer->if_mtu;
7373
mtu -= call->conn->params.peer->hdrsize;
74-
jmax = (call->nr_jumbo_dup > 3) ? 1 : rxrpc_rx_jumbo_max;
74+
jmax = (call->nr_jumbo_bad > 3) ? 1 : rxrpc_rx_jumbo_max;
7575
pkt->ackinfo.rxMTU = htonl(rxrpc_rx_mtu);
7676
pkt->ackinfo.maxMTU = htonl(mtu);
77-
pkt->ackinfo.rwind = htonl(rxrpc_rx_window_size);
77+
pkt->ackinfo.rwind = htonl(call->rx_winsize);
7878
pkt->ackinfo.jumbo_max = htonl(jmax);
7979

8080
*ackp++ = 0;

net/rxrpc/sysctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ static const unsigned int one = 1;
2020
static const unsigned int four = 4;
2121
static const unsigned int thirtytwo = 32;
2222
static const unsigned int n_65535 = 65535;
23-
static const unsigned int n_max_acks = RXRPC_MAXACKS;
23+
static const unsigned int n_max_acks = RXRPC_RXTX_BUFF_SIZE - 1;
2424

2525
/*
2626
* RxRPC operating parameters.

0 commit comments

Comments
 (0)