summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2019-08-19 04:25:37 -0400
committerDavid Howells <dhowells@redhat.com>2019-08-27 04:48:37 -0400
commitc3c9e3df49f8d83db09d1f61c8bed54e7fed8662 (patch)
tree693139ea0c2fa31cbb88ad32702db92725be1405
parentcfef46d692efd852a0da6803f920cc756eea2855 (diff)
rxrpc: Improve jumbo packet counting
Improve the information stored about jumbo packets so that we don't need to reparse them so much later. Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: Jeffrey Altman <jaltman@auristor.com>
-rw-r--r--net/rxrpc/ar-internal.h10
-rw-r--r--net/rxrpc/input.c23
-rw-r--r--net/rxrpc/protocol.h9
3 files changed, 30 insertions, 12 deletions
diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index 145335611af6..87cff6c218b6 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -185,11 +185,15 @@ struct rxrpc_host_header {
185 * - max 48 bytes (struct sk_buff::cb) 185 * - max 48 bytes (struct sk_buff::cb)
186 */ 186 */
187struct rxrpc_skb_priv { 187struct rxrpc_skb_priv {
188 union { 188 u8 nr_subpackets; /* Number of subpackets */
189 u8 nr_jumbo; /* Number of jumbo subpackets */ 189 u8 rx_flags; /* Received packet flags */
190 }; 190#define RXRPC_SKB_INCL_LAST 0x01 /* - Includes last packet */
191 union { 191 union {
192 int remain; /* amount of space remaining for next write */ 192 int remain; /* amount of space remaining for next write */
193
194 /* List of requested ACKs on subpackets */
195 unsigned long rx_req_ack[(RXRPC_MAX_NR_JUMBO + BITS_PER_LONG - 1) /
196 BITS_PER_LONG];
193 }; 197 };
194 198
195 struct rxrpc_host_header hdr; /* RxRPC packet header from this packet */ 199 struct rxrpc_host_header hdr; /* RxRPC packet header from this packet */
diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c
index dd47d465d1d3..ffcec5117954 100644
--- a/net/rxrpc/input.c
+++ b/net/rxrpc/input.c
@@ -347,7 +347,7 @@ static bool rxrpc_receiving_reply(struct rxrpc_call *call)
347} 347}
348 348
349/* 349/*
350 * Scan a jumbo packet to validate its structure and to work out how many 350 * Scan a data packet to validate its structure and to work out how many
351 * subpackets it contains. 351 * subpackets it contains.
352 * 352 *
353 * A jumbo packet is a collection of consecutive packets glued together with 353 * A jumbo packet is a collection of consecutive packets glued together with
@@ -358,16 +358,21 @@ static bool rxrpc_receiving_reply(struct rxrpc_call *call)
358 * the last are RXRPC_JUMBO_DATALEN in size. The last subpacket may be of any 358 * the last are RXRPC_JUMBO_DATALEN in size. The last subpacket may be of any
359 * size. 359 * size.
360 */ 360 */
361static bool rxrpc_validate_jumbo(struct sk_buff *skb) 361static bool rxrpc_validate_data(struct sk_buff *skb)
362{ 362{
363 struct rxrpc_skb_priv *sp = rxrpc_skb(skb); 363 struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
364 unsigned int offset = sizeof(struct rxrpc_wire_header); 364 unsigned int offset = sizeof(struct rxrpc_wire_header);
365 unsigned int len = skb->len; 365 unsigned int len = skb->len;
366 int nr_jumbo = 1;
367 u8 flags = sp->hdr.flags; 366 u8 flags = sp->hdr.flags;
368 367
369 do { 368 for (;;) {
370 nr_jumbo++; 369 if (flags & RXRPC_REQUEST_ACK)
370 __set_bit(sp->nr_subpackets, sp->rx_req_ack);
371 sp->nr_subpackets++;
372
373 if (!(flags & RXRPC_JUMBO_PACKET))
374 break;
375
371 if (len - offset < RXRPC_JUMBO_SUBPKTLEN) 376 if (len - offset < RXRPC_JUMBO_SUBPKTLEN)
372 goto protocol_error; 377 goto protocol_error;
373 if (flags & RXRPC_LAST_PACKET) 378 if (flags & RXRPC_LAST_PACKET)
@@ -376,9 +381,10 @@ static bool rxrpc_validate_jumbo(struct sk_buff *skb)
376 if (skb_copy_bits(skb, offset, &flags, 1) < 0) 381 if (skb_copy_bits(skb, offset, &flags, 1) < 0)
377 goto protocol_error; 382 goto protocol_error;
378 offset += sizeof(struct rxrpc_jumbo_header); 383 offset += sizeof(struct rxrpc_jumbo_header);
379 } while (flags & RXRPC_JUMBO_PACKET); 384 }
380 385
381 sp->nr_jumbo = nr_jumbo; 386 if (flags & RXRPC_LAST_PACKET)
387 sp->rx_flags |= RXRPC_SKB_INCL_LAST;
382 return true; 388 return true;
383 389
384protocol_error: 390protocol_error:
@@ -1237,8 +1243,7 @@ int rxrpc_input_packet(struct sock *udp_sk, struct sk_buff *skb)
1237 if (sp->hdr.callNumber == 0 || 1243 if (sp->hdr.callNumber == 0 ||
1238 sp->hdr.seq == 0) 1244 sp->hdr.seq == 0)
1239 goto bad_message; 1245 goto bad_message;
1240 if (sp->hdr.flags & RXRPC_JUMBO_PACKET && 1246 if (!rxrpc_validate_data(skb))
1241 !rxrpc_validate_jumbo(skb))
1242 goto bad_message; 1247 goto bad_message;
1243 break; 1248 break;
1244 1249
diff --git a/net/rxrpc/protocol.h b/net/rxrpc/protocol.h
index 99ce322d7caa..49bb972539aa 100644
--- a/net/rxrpc/protocol.h
+++ b/net/rxrpc/protocol.h
@@ -89,6 +89,15 @@ struct rxrpc_jumbo_header {
89#define RXRPC_JUMBO_DATALEN 1412 /* non-terminal jumbo packet data length */ 89#define RXRPC_JUMBO_DATALEN 1412 /* non-terminal jumbo packet data length */
90#define RXRPC_JUMBO_SUBPKTLEN (RXRPC_JUMBO_DATALEN + sizeof(struct rxrpc_jumbo_header)) 90#define RXRPC_JUMBO_SUBPKTLEN (RXRPC_JUMBO_DATALEN + sizeof(struct rxrpc_jumbo_header))
91 91
92/*
93 * The maximum number of subpackets that can possibly fit in a UDP packet is:
94 *
95 * ((max_IP - IP_hdr - UDP_hdr) / RXRPC_JUMBO_SUBPKTLEN) + 1
96 * = ((65535 - 28 - 28) / 1416) + 1
97 * = 46 non-terminal packets and 1 terminal packet.
98 */
99#define RXRPC_MAX_NR_JUMBO 47
100
92/*****************************************************************************/ 101/*****************************************************************************/
93/* 102/*
94 * on-the-wire Rx ACK packet data payload 103 * on-the-wire Rx ACK packet data payload