summaryrefslogtreecommitdiffstats
path: root/net/rxrpc/output.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2016-09-17 11:49:15 +0200
committerDavid Howells <dhowells@redhat.com>2016-09-17 12:24:04 +0200
commit8a681c360559f75a80b37e6a6a9590457361ccb0 (patch)
tree12f2fa34048a73aae064a02fa15417b4c70b3573 /net/rxrpc/output.c
parentrxrpc: Improve skb tracing (diff)
downloadlinux-8a681c360559f75a80b37e6a6a9590457361ccb0.tar.xz
linux-8a681c360559f75a80b37e6a6a9590457361ccb0.zip
rxrpc: Add config to inject packet loss
Add a configuration option to inject packet loss by discarding approximately every 8th packet received and approximately every 8th DATA packet transmitted. Note that no locking is used, but it shouldn't really matter. Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'net/rxrpc/output.c')
-rw-r--r--net/rxrpc/output.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/net/rxrpc/output.c b/net/rxrpc/output.c
index a2cad5ce7416..16e18a94ffa6 100644
--- a/net/rxrpc/output.c
+++ b/net/rxrpc/output.c
@@ -225,6 +225,15 @@ int rxrpc_send_data_packet(struct rxrpc_connection *conn, struct sk_buff *skb)
msg.msg_controllen = 0;
msg.msg_flags = 0;
+ if (IS_ENABLED(CONFIG_AF_RXRPC_INJECT_LOSS)) {
+ static int lose;
+ if ((lose++ & 7) == 7) {
+ rxrpc_lose_skb(skb, rxrpc_skb_tx_lost);
+ _leave(" = 0 [lose]");
+ return 0;
+ }
+ }
+
/* send the packet with the don't fragment bit set if we currently
* think it's small enough */
if (skb->len - sizeof(struct rxrpc_wire_header) < conn->params.peer->maxdata) {