Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1485643
| From | David Howells <dhowells@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH net-next 11/11] rxrpc: Add config to inject packet loss |
| Date | 2016-09-18 01:30 +0200 |
| Message-ID | <sixdw-qm-31@gated-at.bofh.it> (permalink) |
| References | <sixdw-qm-3@gated-at.bofh.it> |
| Organization | Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 |
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>
---
net/rxrpc/Kconfig | 7 +++++++
net/rxrpc/input.c | 8 ++++++++
net/rxrpc/output.c | 9 +++++++++
3 files changed, 24 insertions(+)
diff --git a/net/rxrpc/Kconfig b/net/rxrpc/Kconfig
index 13396c74b5c1..86f8853a038c 100644
--- a/net/rxrpc/Kconfig
+++ b/net/rxrpc/Kconfig
@@ -26,6 +26,13 @@ config AF_RXRPC_IPV6
Say Y here to allow AF_RXRPC to use IPV6 UDP as well as IPV4 UDP as
its network transport.
+config AF_RXRPC_INJECT_LOSS
+ bool "Inject packet loss into RxRPC packet stream"
+ depends on AF_RXRPC
+ help
+ Say Y here to inject packet loss by discarding some received and some
+ transmitted packets.
+
config AF_RXRPC_DEBUG
bool "RxRPC dynamic debugging"
diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c
index 84bb16d47b85..7ac1edf3aac7 100644
--- a/net/rxrpc/input.c
+++ b/net/rxrpc/input.c
@@ -712,6 +712,14 @@ void rxrpc_data_ready(struct sock *udp_sk)
skb_orphan(skb);
sp = rxrpc_skb(skb);
+ if (IS_ENABLED(CONFIG_AF_RXRPC_INJECT_LOSS)) {
+ static int lose;
+ if ((lose++ & 7) == 7) {
+ rxrpc_lose_skb(skb, rxrpc_skb_rx_lost);
+ return;
+ }
+ }
+
_net("Rx UDP packet from %08x:%04hu",
ntohl(ip_hdr(skb)->saddr), ntohs(udp_hdr(skb)->source));
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) {
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH net-next 00/11] rxrpc: Tracepoint addition and improvement David Howells <dhowells@redhat.com> - 2016-09-18 01:30 +0200
[PATCH net-next 04/11] rxrpc: Add a tracepoint to follow the life of a packet in the Tx buffer David Howells <dhowells@redhat.com> - 2016-09-18 01:30 +0200
[PATCH net-next 08/11] rxrpc: Add a tracepoint to follow what recvmsg does David Howells <dhowells@redhat.com> - 2016-09-18 01:30 +0200
[PATCH net-next 05/11] rxrpc: Add a tracepoint to log received ACK packets David Howells <dhowells@redhat.com> - 2016-09-18 01:30 +0200
[PATCH net-next 01/11] rxrpc: Print the packet type name in the Rx packet trace David Howells <dhowells@redhat.com> - 2016-09-18 01:30 +0200
[PATCH net-next 11/11] rxrpc: Add config to inject packet loss David Howells <dhowells@redhat.com> - 2016-09-18 01:30 +0200
Re: [PATCH net-next 11/11] rxrpc: Add config to inject packet loss Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2016-09-18 13:50 +0200
[PATCH net-next 10/11] rxrpc: Improve skb tracing David Howells <dhowells@redhat.com> - 2016-09-18 01:30 +0200
[PATCH net-next 06/11] rxrpc: Add a tracepoint to log ACK transmission David Howells <dhowells@redhat.com> - 2016-09-18 01:30 +0200
[PATCH net-next 03/11] rxrpc: Add connection tracepoint and client conn state tracepoint David Howells <dhowells@redhat.com> - 2016-09-18 01:30 +0200
Re: [PATCH net-next 00/11] rxrpc: Tracepoint addition and improvement David Miller <davem@davemloft.net> - 2016-09-19 08:00 +0200
csiph-web