Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1485627

[PATCH net-next 07/14] rxrpc: Fix the putting of client connections

From David Howells <dhowells@redhat.com>
Newsgroups linux.kernel
Subject [PATCH net-next 07/14] rxrpc: Fix the putting of client connections
Date 2016-09-18 01:20 +0200
Message-ID <six3Q-mU-11@gated-at.bofh.it> (permalink)
References <six3P-mU-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

Show all headers | View raw


In rxrpc_put_one_client_conn(), if a connection has RXRPC_CONN_COUNTED set
on it, then it's accounted for in rxrpc_nr_client_conns and may be on
various lists - and this is cleaned up correctly.

However, if the connection doesn't have RXRPC_CONN_COUNTED set on it, then
the put routine returns rather than just skipping the extra bit of cleanup.

Fix this by making the extra bit of clean up conditional instead and always
killing off the connection.

This manifests itself as connections with a zero usage count hanging around
in /proc/net/rxrpc_conns because the connection allocated, but discarded,
due to a race with another process that set up a parallel connection, which
was then shared instead.

Signed-off-by: David Howells <dhowells@redhat.com>
---

 net/rxrpc/conn_client.c |   28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/net/rxrpc/conn_client.c b/net/rxrpc/conn_client.c
index 9344a8416ceb..5a675c43cace 100644
--- a/net/rxrpc/conn_client.c
+++ b/net/rxrpc/conn_client.c
@@ -818,7 +818,7 @@ idle_connection:
 static struct rxrpc_connection *
 rxrpc_put_one_client_conn(struct rxrpc_connection *conn)
 {
-	struct rxrpc_connection *next;
+	struct rxrpc_connection *next = NULL;
 	struct rxrpc_local *local = conn->params.local;
 	unsigned int nr_conns;
 
@@ -834,24 +834,22 @@ rxrpc_put_one_client_conn(struct rxrpc_connection *conn)
 
 	ASSERTCMP(conn->cache_state, ==, RXRPC_CONN_CLIENT_INACTIVE);
 
-	if (!test_bit(RXRPC_CONN_COUNTED, &conn->flags))
-		return NULL;
-
-	spin_lock(&rxrpc_client_conn_cache_lock);
-	nr_conns = --rxrpc_nr_client_conns;
+	if (test_bit(RXRPC_CONN_COUNTED, &conn->flags)) {
+		spin_lock(&rxrpc_client_conn_cache_lock);
+		nr_conns = --rxrpc_nr_client_conns;
+
+		if (nr_conns < rxrpc_max_client_connections &&
+		    !list_empty(&rxrpc_waiting_client_conns)) {
+			next = list_entry(rxrpc_waiting_client_conns.next,
+					  struct rxrpc_connection, cache_link);
+			rxrpc_get_connection(next);
+			rxrpc_activate_conn(next);
+		}
 
-	next = NULL;
-	if (nr_conns < rxrpc_max_client_connections &&
-	    !list_empty(&rxrpc_waiting_client_conns)) {
-		next = list_entry(rxrpc_waiting_client_conns.next,
-				  struct rxrpc_connection, cache_link);
-		rxrpc_get_connection(next);
-		rxrpc_activate_conn(next);
+		spin_unlock(&rxrpc_client_conn_cache_lock);
 	}
 
-	spin_unlock(&rxrpc_client_conn_cache_lock);
 	rxrpc_kill_connection(conn);
-
 	if (next)
 		rxrpc_activate_channels(next);
 

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH net-next 00/14] rxrpc: Fixes & miscellany David Howells <dhowells@redhat.com> - 2016-09-18 01:20 +0200
  [PATCH net-next 09/14] rxrpc: Fix unexposed client conn release David Howells <dhowells@redhat.com> - 2016-09-18 01:20 +0200
  [PATCH net-next 12/14] rxrpc: Don't transmit an ACK if there's no  reason set David Howells <dhowells@redhat.com> - 2016-09-18 01:20 +0200
  [PATCH net-next 07/14] rxrpc: Fix the putting of client connections David Howells <dhowells@redhat.com> - 2016-09-18 01:20 +0200
  [PATCH net-next 14/14] rxrpc: Fix the basic transmit DATA packet  content size at 1412 bytes David Howells <dhowells@redhat.com> - 2016-09-18 01:20 +0200
  [PATCH net-next 06/14] rxrpc: Purge the to_be_accepted queue on  socket release David Howells <dhowells@redhat.com> - 2016-09-18 01:20 +0200
  [PATCH net-next 01/14] rxrpc: Remove some whitespace. David Howells <dhowells@redhat.com> - 2016-09-18 01:20 +0200
  [PATCH net-next 03/14] rxrpc: Check the return value of  rxrpc_locate_data() David Howells <dhowells@redhat.com> - 2016-09-18 01:20 +0200
  [PATCH net-next 11/14] rxrpc: Fix retransmission algorithm David Howells <dhowells@redhat.com> - 2016-09-18 01:30 +0200
  [PATCH net-next 05/14] rxrpc: Record calls that need to be accepted David Howells <dhowells@redhat.com> - 2016-09-18 01:30 +0200
  [PATCH net-next 13/14] rxrpc: Be consistent about switch value in  rxrpc_send_call_packet() David Howells <dhowells@redhat.com> - 2016-09-18 01:30 +0200
  [PATCH net-next 02/14] rxrpc: Move the check of rx_pkt_offset from  rxrpc_locate_data() to caller David Howells <dhowells@redhat.com> - 2016-09-18 01:30 +0200
  [PATCH net-next 10/14] rxrpc: Fix the parsing of soft-ACKs David Howells <dhowells@redhat.com> - 2016-09-18 01:30 +0200
  Re: [PATCH net-next 00/14] rxrpc: Fixes & miscellany David Miller <davem@davemloft.net> - 2016-09-18 13:30 +0200
  Re: [PATCH net-next 00/14] rxrpc: Fixes & miscellany David Miller <davem@davemloft.net> - 2016-09-19 08:00 +0200

csiph-web