From: Brian Haley <brian.haley@hp.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: [PATCH] ipv4: don't call upper-layer disconnect function if not connected
Date: Tue, 01 Aug 2006 15:48:54 -0400 [thread overview]
Message-ID: <44CFB026.7050907@hp.com> (raw)
[-- 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;
}
next reply other threads:[~2006-08-01 19:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-01 19:48 Brian Haley [this message]
2006-08-01 22:07 ` [PATCH] ipv4: don't call upper-layer disconnect function if not connected David Miller
2006-08-02 16:04 ` Brian Haley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44CFB026.7050907@hp.com \
--to=brian.haley@hp.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).