* [PATCH] ipv4: don't call upper-layer disconnect function if not connected
@ 2006-08-01 19:48 Brian Haley
2006-08-01 22:07 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Brian Haley @ 2006-08-01 19:48 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: Type: text/plain, Size: 183 bytes --]
Calling connect() with AF_UNSPEC will disconnect a socket, but we don't
need to do any work if the socket isn't currently connected.
Signed-off-by: Brian Haley <brian.haley@hp.com>
[-- Attachment #2: disconn.patch --]
[-- Type: text/x-patch, Size: 1133 bytes --]
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index c84a320..b294b92 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -480,12 +480,16 @@ int inet_dgram_connect(struct socket *so
{
struct sock *sk = sock->sk;
- if (uaddr->sa_family == AF_UNSPEC)
- return sk->sk_prot->disconnect(sk, flags);
+ if (uaddr->sa_family == AF_UNSPEC) {
+ if (sock->state != SS_UNCONNECTED)
+ return sk->sk_prot->disconnect(sk, flags);
+ else
+ return 0;
+ }
if (!inet_sk(sk)->num && inet_autobind(sk))
return -EAGAIN;
- return sk->sk_prot->connect(sk, (struct sockaddr *)uaddr, addr_len);
+ return sk->sk_prot->connect(sk, uaddr, addr_len);
}
static long inet_wait_for_connect(struct sock *sk, long timeo)
@@ -525,8 +529,11 @@ int inet_stream_connect(struct socket *s
lock_sock(sk);
if (uaddr->sa_family == AF_UNSPEC) {
- err = sk->sk_prot->disconnect(sk, flags);
- sock->state = err ? SS_DISCONNECTING : SS_UNCONNECTED;
+ if (sock->state != SS_UNCONNECTED) {
+ err = sk->sk_prot->disconnect(sk, flags);
+ sock->state = err ? SS_DISCONNECTING : SS_UNCONNECTED;
+ } else
+ err = 0;
goto out;
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ipv4: don't call upper-layer disconnect function if not connected
2006-08-01 19:48 [PATCH] ipv4: don't call upper-layer disconnect function if not connected Brian Haley
@ 2006-08-01 22:07 ` David Miller
2006-08-02 16:04 ` Brian Haley
0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2006-08-01 22:07 UTC (permalink / raw)
To: brian.haley; +Cc: netdev
From: Brian Haley <brian.haley@hp.com>
Date: Tue, 01 Aug 2006 15:48:54 -0400
> Calling connect() with AF_UNSPEC will disconnect a socket, but we don't
> need to do any work if the socket isn't currently connected.
>
> Signed-off-by: Brian Haley <brian.haley@hp.com>
The socket could have been bind()'d to, in which case it will
not move to connected state and we still need to invoke
the disconnect methods such as udp_disconnect() to clear out
that binding.
You seem to be groveling in random areas of the ipv4 and ipv6 stack,
what are you working on?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ipv4: don't call upper-layer disconnect function if not connected
2006-08-01 22:07 ` David Miller
@ 2006-08-02 16:04 ` Brian Haley
0 siblings, 0 replies; 3+ messages in thread
From: Brian Haley @ 2006-08-02 16:04 UTC (permalink / raw)
To: David Miller; +Cc: netdev
> The socket could have been bind()'d to, in which case it will
> not move to connected state and we still need to invoke
> the disconnect methods such as udp_disconnect() to clear out
> that binding.
Ok.
> You seem to be groveling in random areas of the ipv4 and ipv6 stack,
> what are you working on?
Was looking into a customer-reported memory leak that seemed to be in
this code path. It wasn't, but this tweak seemed sane at the time.
-Brian
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-08-02 16:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-01 19:48 [PATCH] ipv4: don't call upper-layer disconnect function if not connected Brian Haley
2006-08-01 22:07 ` David Miller
2006-08-02 16:04 ` Brian Haley
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).