netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] tcp: bind() fix autoselection to share ports
@ 2012-01-25 18:34 Flavio Leitner
  2012-01-25 18:34 ` [PATCH 2/2] tcp: bind() optimize port allocation Flavio Leitner
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Flavio Leitner @ 2012-01-25 18:34 UTC (permalink / raw)
  To: netdev; +Cc: Marcelo Leitner, Eric Dumazet, Flavio Leitner

The current code checks for conflicts when the application
requests a specific port.  If there is no conflict, then
the request is granted.

On the other hand, the port autoselection done by the kernel
fails when all ports are bound even when there is a port
with no conflict available.

The fix changes port autoselection to check if there is a
conflict and use it if not.

Signed-off-by: Flavio Leitner <fbl@redhat.com>
---
 net/ipv4/inet_connection_sock.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index 2e4e244..ecd19b5 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -128,6 +128,11 @@ again:
 							goto have_snum;
 						}
 					}
+					if (!inet_csk(sk)->icsk_af_ops->bind_conflict(sk, tb)) {
+						spin_unlock(&head->lock);
+						snum = rover;
+						goto have_snum;
+					}
 					goto next;
 				}
 			break;
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] tcp: bind() optimize port allocation
  2012-01-25 18:34 [PATCH 1/2] tcp: bind() fix autoselection to share ports Flavio Leitner
@ 2012-01-25 18:34 ` Flavio Leitner
  2012-01-25 18:36   ` Marcelo Leitner
                     ` (2 more replies)
  2012-01-25 18:36 ` [PATCH 1/2] tcp: bind() fix autoselection to share ports Marcelo Leitner
                   ` (2 subsequent siblings)
  3 siblings, 3 replies; 8+ messages in thread
From: Flavio Leitner @ 2012-01-25 18:34 UTC (permalink / raw)
  To: netdev; +Cc: Marcelo Leitner, Eric Dumazet, Flavio Leitner

Port autoselection finds a port and then drop the lock,
then right after that, gets the hash bucket again and lock it.

Fix it to go direct.

Signed-off-by: Flavio Leitner <fbl@redhat.com>
---
 net/ipv4/inet_connection_sock.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index ecd19b5..19d66ce 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -123,15 +123,13 @@ again:
 						smallest_size = tb->num_owners;
 						smallest_rover = rover;
 						if (atomic_read(&hashinfo->bsockets) > (high - low) + 1) {
-							spin_unlock(&head->lock);
 							snum = smallest_rover;
-							goto have_snum;
+							goto tb_found;
 						}
 					}
 					if (!inet_csk(sk)->icsk_af_ops->bind_conflict(sk, tb)) {
-						spin_unlock(&head->lock);
 						snum = rover;
-						goto have_snum;
+						goto tb_found;
 					}
 					goto next;
 				}
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] tcp: bind() fix autoselection to share ports
  2012-01-25 18:34 [PATCH 1/2] tcp: bind() fix autoselection to share ports Flavio Leitner
  2012-01-25 18:34 ` [PATCH 2/2] tcp: bind() optimize port allocation Flavio Leitner
@ 2012-01-25 18:36 ` Marcelo Leitner
  2012-01-25 18:47 ` Eric Dumazet
  2012-01-26  2:50 ` David Miller
  3 siblings, 0 replies; 8+ messages in thread
From: Marcelo Leitner @ 2012-01-25 18:36 UTC (permalink / raw)
  To: Flavio Leitner; +Cc: netdev, Eric Dumazet

On 01/25/2012 04:34 PM, Flavio Leitner wrote:
> The current code checks for conflicts when the application
> requests a specific port.  If there is no conflict, then
> the request is granted.
>
> On the other hand, the port autoselection done by the kernel
> fails when all ports are bound even when there is a port
> with no conflict available.
>
> The fix changes port autoselection to check if there is a
> conflict and use it if not.
>
> Signed-off-by: Flavio Leitner<fbl@redhat.com>

Signed-off-by: Marcelo Ricardo Leitner <mleitner@redhat.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] tcp: bind() optimize port allocation
  2012-01-25 18:34 ` [PATCH 2/2] tcp: bind() optimize port allocation Flavio Leitner
@ 2012-01-25 18:36   ` Marcelo Leitner
  2012-01-25 18:48   ` Eric Dumazet
  2012-01-26  2:51   ` David Miller
  2 siblings, 0 replies; 8+ messages in thread
From: Marcelo Leitner @ 2012-01-25 18:36 UTC (permalink / raw)
  To: Flavio Leitner; +Cc: netdev, Eric Dumazet

On 01/25/2012 04:34 PM, Flavio Leitner wrote:
> Port autoselection finds a port and then drop the lock,
> then right after that, gets the hash bucket again and lock it.
>
> Fix it to go direct.
>
> Signed-off-by: Flavio Leitner<fbl@redhat.com>

Signed-off-by: Marcelo Ricardo Leitner <mleitner@redhat.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] tcp: bind() fix autoselection to share ports
  2012-01-25 18:34 [PATCH 1/2] tcp: bind() fix autoselection to share ports Flavio Leitner
  2012-01-25 18:34 ` [PATCH 2/2] tcp: bind() optimize port allocation Flavio Leitner
  2012-01-25 18:36 ` [PATCH 1/2] tcp: bind() fix autoselection to share ports Marcelo Leitner
@ 2012-01-25 18:47 ` Eric Dumazet
  2012-01-26  2:50 ` David Miller
  3 siblings, 0 replies; 8+ messages in thread
From: Eric Dumazet @ 2012-01-25 18:47 UTC (permalink / raw)
  To: Flavio Leitner; +Cc: netdev, Marcelo Leitner

Le mercredi 25 janvier 2012 à 16:34 -0200, Flavio Leitner a écrit :
> The current code checks for conflicts when the application
> requests a specific port.  If there is no conflict, then
> the request is granted.
> 
> On the other hand, the port autoselection done by the kernel
> fails when all ports are bound even when there is a port
> with no conflict available.
> 
> The fix changes port autoselection to check if there is a
> conflict and use it if not.
> 
> Signed-off-by: Flavio Leitner <fbl@redhat.com>
> ---
>  net/ipv4/inet_connection_sock.c |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
> index 2e4e244..ecd19b5 100644
> --- a/net/ipv4/inet_connection_sock.c
> +++ b/net/ipv4/inet_connection_sock.c
> @@ -128,6 +128,11 @@ again:
>  							goto have_snum;
>  						}
>  					}
> +					if (!inet_csk(sk)->icsk_af_ops->bind_conflict(sk, tb)) {
> +						spin_unlock(&head->lock);
> +						snum = rover;
> +						goto have_snum;
> +					}
>  					goto next;
>  				}
>  			break;



Acked-by: Eric Dumazet <eric.dumazet@gmail.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] tcp: bind() optimize port allocation
  2012-01-25 18:34 ` [PATCH 2/2] tcp: bind() optimize port allocation Flavio Leitner
  2012-01-25 18:36   ` Marcelo Leitner
@ 2012-01-25 18:48   ` Eric Dumazet
  2012-01-26  2:51   ` David Miller
  2 siblings, 0 replies; 8+ messages in thread
From: Eric Dumazet @ 2012-01-25 18:48 UTC (permalink / raw)
  To: Flavio Leitner; +Cc: netdev, Marcelo Leitner

Le mercredi 25 janvier 2012 à 16:34 -0200, Flavio Leitner a écrit :
> Port autoselection finds a port and then drop the lock,
> then right after that, gets the hash bucket again and lock it.
> 
> Fix it to go direct.
> 
> Signed-off-by: Flavio Leitner <fbl@redhat.com>
> ---

Acked-by: Eric Dumazet <eric.dumazet@gmail.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] tcp: bind() fix autoselection to share ports
  2012-01-25 18:34 [PATCH 1/2] tcp: bind() fix autoselection to share ports Flavio Leitner
                   ` (2 preceding siblings ...)
  2012-01-25 18:47 ` Eric Dumazet
@ 2012-01-26  2:50 ` David Miller
  3 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2012-01-26  2:50 UTC (permalink / raw)
  To: fbl; +Cc: netdev, mleitner, eric.dumazet

From: Flavio Leitner <fbl@redhat.com>
Date: Wed, 25 Jan 2012 16:34:51 -0200

> The current code checks for conflicts when the application
> requests a specific port.  If there is no conflict, then
> the request is granted.
> 
> On the other hand, the port autoselection done by the kernel
> fails when all ports are bound even when there is a port
> with no conflict available.
> 
> The fix changes port autoselection to check if there is a
> conflict and use it if not.
> 
> Signed-off-by: Flavio Leitner <fbl@redhat.com>

Applied.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] tcp: bind() optimize port allocation
  2012-01-25 18:34 ` [PATCH 2/2] tcp: bind() optimize port allocation Flavio Leitner
  2012-01-25 18:36   ` Marcelo Leitner
  2012-01-25 18:48   ` Eric Dumazet
@ 2012-01-26  2:51   ` David Miller
  2 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2012-01-26  2:51 UTC (permalink / raw)
  To: fbl; +Cc: netdev, mleitner, eric.dumazet

From: Flavio Leitner <fbl@redhat.com>
Date: Wed, 25 Jan 2012 16:34:52 -0200

> Port autoselection finds a port and then drop the lock,
> then right after that, gets the hash bucket again and lock it.
> 
> Fix it to go direct.
> 
> Signed-off-by: Flavio Leitner <fbl@redhat.com>

Applied, great work Flavio.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-01-26  2:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-25 18:34 [PATCH 1/2] tcp: bind() fix autoselection to share ports Flavio Leitner
2012-01-25 18:34 ` [PATCH 2/2] tcp: bind() optimize port allocation Flavio Leitner
2012-01-25 18:36   ` Marcelo Leitner
2012-01-25 18:48   ` Eric Dumazet
2012-01-26  2:51   ` David Miller
2012-01-25 18:36 ` [PATCH 1/2] tcp: bind() fix autoselection to share ports Marcelo Leitner
2012-01-25 18:47 ` Eric Dumazet
2012-01-26  2:50 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).