I was seeing random disconnects while testing NBD over loopback.  This turned
out to be because NBD sets pfmemalloc on it's socket, however the receiving side
is a user space application so does not have pfmemalloc set on its socket.  This
means that sk_filter_trim_cap will simply drop this packet, under the assumption
that the other side will simply retransmit.  Well we do retransmit, and then the
packet is just dropped again for the same reason.  To keep this from happening
simply clear skb->pfmemalloc on transmit so that we don't drop the packet on the
receive side.

Signed-off-by: Josef Bacik <jba...@fb.com>
---
 drivers/net/loopback.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index 1e05b7c..13c9126 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -81,6 +81,13 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb,
         */
        skb_dst_force(skb);
 
+       /* If our transmitter was a pfmemalloc socket we need to clear
+        * pfmemalloc here, otherwise the receiving socket may not be
+        * pfmemalloc, and if this is a tcp packet then it'll get dropped and
+        * all traffic will halt.
+        */
+       skb->pfmemalloc = false;
+
        skb->protocol = eth_type_trans(skb, dev);
 
        /* it's OK to use per_cpu_ptr() because BHs are off */
-- 
2.7.4

Reply via email to