* [PATCH v2] tipc: set sk_err correctly when connection fails
@ 2013-08-28 7:29 erik.hugne
2013-08-29 15:03 ` Paul Gortmaker
0 siblings, 1 reply; 3+ messages in thread
From: erik.hugne @ 2013-08-28 7:29 UTC (permalink / raw)
To: netdev, paul.gortmaker, ying.xue, jon.maloy
Cc: tipc-discussion, nhan.tt.vo, Erik Hugne
From: Erik Hugne <erik.hugne@ericsson.com>
Should a connect fail, if the publication/server is unavailable or
due to some other error, a positive value will be returned and errno
is never set. If the application code checks for an explicit zero
return from connect (success) or a negative return (failure), it
will not catch the error and subsequent send() calls will fail as
shown from the strace snippet below.
socket(0x1e /* PF_??? */, SOCK_SEQPACKET, 0) = 3
connect(3, {sa_family=0x1e /* AF_??? */, sa_data="\2\1\322\4\0\0\322\4\0\0\0\0\0\0"}, 16) = 111
sendto(3, "test", 4, 0, NULL, 0) = -1 EPIPE (Broken pipe)
The reason for this behaviour is that TIPC wrongly inverts error
codes set in sk_err.
Signed-off-by: Erik Hugne <erik.hugne@ericsson.com>
---
[v2: add more details to commit message]
net/tipc/socket.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index ce8249c..6cc7ddd 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -1257,7 +1257,7 @@ static u32 filter_connect(struct tipc_sock *tsock, struct sk_buff **buf)
/* Accept only ACK or NACK message */
if (unlikely(msg_errcode(msg))) {
sock->state = SS_DISCONNECTING;
- sk->sk_err = -ECONNREFUSED;
+ sk->sk_err = ECONNREFUSED;
retval = TIPC_OK;
break;
}
@@ -1268,7 +1268,7 @@ static u32 filter_connect(struct tipc_sock *tsock, struct sk_buff **buf)
res = auto_connect(sock, msg);
if (res) {
sock->state = SS_DISCONNECTING;
- sk->sk_err = res;
+ sk->sk_err = -res;
retval = TIPC_OK;
break;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] tipc: set sk_err correctly when connection fails
2013-08-28 7:29 [PATCH v2] tipc: set sk_err correctly when connection fails erik.hugne
@ 2013-08-29 15:03 ` Paul Gortmaker
2013-08-30 20:07 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Paul Gortmaker @ 2013-08-29 15:03 UTC (permalink / raw)
To: erik.hugne; +Cc: netdev, ying.xue, jon.maloy, tipc-discussion, nhan.tt.vo
On 13-08-28 03:29 AM, erik.hugne@ericsson.com wrote:
> From: Erik Hugne <erik.hugne@ericsson.com>
>
> Should a connect fail, if the publication/server is unavailable or
> due to some other error, a positive value will be returned and errno
> is never set. If the application code checks for an explicit zero
> return from connect (success) or a negative return (failure), it
> will not catch the error and subsequent send() calls will fail as
> shown from the strace snippet below.
>
> socket(0x1e /* PF_??? */, SOCK_SEQPACKET, 0) = 3
> connect(3, {sa_family=0x1e /* AF_??? */, sa_data="\2\1\322\4\0\0\322\4\0\0\0\0\0\0"}, 16) = 111
> sendto(3, "test", 4, 0, NULL, 0) = -1 EPIPE (Broken pipe)
>
> The reason for this behaviour is that TIPC wrongly inverts error
> codes set in sk_err.
>
> Signed-off-by: Erik Hugne <erik.hugne@ericsson.com>
> ---
>
> [v2: add more details to commit message]
Thanks -- this now conveys the required triplet: 1) user visible symptom,
2) underlying technical cause, and 3) the why and how of the fix.
Paul.
--
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] tipc: set sk_err correctly when connection fails
2013-08-29 15:03 ` Paul Gortmaker
@ 2013-08-30 20:07 ` David Miller
0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2013-08-30 20:07 UTC (permalink / raw)
To: paul.gortmaker
Cc: erik.hugne, netdev, ying.xue, jon.maloy, tipc-discussion,
nhan.tt.vo
From: Paul Gortmaker <paul.gortmaker@windriver.com>
Date: Thu, 29 Aug 2013 11:03:10 -0400
> On 13-08-28 03:29 AM, erik.hugne@ericsson.com wrote:
>> From: Erik Hugne <erik.hugne@ericsson.com>
>>
>> Should a connect fail, if the publication/server is unavailable or
>> due to some other error, a positive value will be returned and errno
>> is never set. If the application code checks for an explicit zero
>> return from connect (success) or a negative return (failure), it
>> will not catch the error and subsequent send() calls will fail as
>> shown from the strace snippet below.
>>
>> socket(0x1e /* PF_??? */, SOCK_SEQPACKET, 0) = 3
>> connect(3, {sa_family=0x1e /* AF_??? */, sa_data="\2\1\322\4\0\0\322\4\0\0\0\0\0\0"}, 16) = 111
>> sendto(3, "test", 4, 0, NULL, 0) = -1 EPIPE (Broken pipe)
>>
>> The reason for this behaviour is that TIPC wrongly inverts error
>> codes set in sk_err.
>>
>> Signed-off-by: Erik Hugne <erik.hugne@ericsson.com>
>> ---
>>
>> [v2: add more details to commit message]
>
> Thanks -- this now conveys the required triplet: 1) user visible symptom,
> 2) underlying technical cause, and 3) the why and how of the fix.
Applied and queued up for -stable, thanks everyone.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-08-30 20:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-28 7:29 [PATCH v2] tipc: set sk_err correctly when connection fails erik.hugne
2013-08-29 15:03 ` Paul Gortmaker
2013-08-30 20:07 ` 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).