diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2005-12-02 23:43:26 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2005-12-02 23:43:26 -0500 |
commit | 86c8f9d158f68538a971a47206a46a22c7479bac (patch) | |
tree | 2c68c64d7fa7387700354cd24ba07486bd00104e /net | |
parent | 24c6927505ca77ee4ac25fb31dcd56f6506979ed (diff) |
[IPV4] Fix EPROTONOSUPPORT error in inet_create
There is a coding error in inet_create that causes it to always return
ESOCKTNOSUPPORT. It should return EPROTONOSUPPORT when there are
protocols registered for a given socket type but none of them match
the requested protocol.
This is based on a patch by Jayachandran C.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/af_inet.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index eaa150c33b04..d368cf249000 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -228,13 +228,14 @@ static int inet_create(struct socket *sock, int protocol) | |||
228 | unsigned char answer_flags; | 228 | unsigned char answer_flags; |
229 | char answer_no_check; | 229 | char answer_no_check; |
230 | int try_loading_module = 0; | 230 | int try_loading_module = 0; |
231 | int err = -ESOCKTNOSUPPORT; | 231 | int err; |
232 | 232 | ||
233 | sock->state = SS_UNCONNECTED; | 233 | sock->state = SS_UNCONNECTED; |
234 | 234 | ||
235 | /* Look for the requested type/protocol pair. */ | 235 | /* Look for the requested type/protocol pair. */ |
236 | answer = NULL; | 236 | answer = NULL; |
237 | lookup_protocol: | 237 | lookup_protocol: |
238 | err = -ESOCKTNOSUPPORT; | ||
238 | rcu_read_lock(); | 239 | rcu_read_lock(); |
239 | list_for_each_rcu(p, &inetsw[sock->type]) { | 240 | list_for_each_rcu(p, &inetsw[sock->type]) { |
240 | answer = list_entry(p, struct inet_protosw, list); | 241 | answer = list_entry(p, struct inet_protosw, list); |
@@ -252,6 +253,7 @@ lookup_protocol: | |||
252 | if (IPPROTO_IP == answer->protocol) | 253 | if (IPPROTO_IP == answer->protocol) |
253 | break; | 254 | break; |
254 | } | 255 | } |
256 | err = -EPROTONOSUPPORT; | ||
255 | answer = NULL; | 257 | answer = NULL; |
256 | } | 258 | } |
257 | 259 | ||
@@ -280,9 +282,6 @@ lookup_protocol: | |||
280 | err = -EPERM; | 282 | err = -EPERM; |
281 | if (answer->capability > 0 && !capable(answer->capability)) | 283 | if (answer->capability > 0 && !capable(answer->capability)) |
282 | goto out_rcu_unlock; | 284 | goto out_rcu_unlock; |
283 | err = -EPROTONOSUPPORT; | ||
284 | if (!protocol) | ||
285 | goto out_rcu_unlock; | ||
286 | 285 | ||
287 | sock->ops = answer->ops; | 286 | sock->ops = answer->ops; |
288 | answer_prot = answer->prot; | 287 | answer_prot = answer->prot; |