buglwIP - A Lightweight TCP/IP stack - Bugs: bug #20147, getsockopt() with SO_ERROR option

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #20147: getsockopt() with SO_ERROR option

Submitter:  Srinivas Gollakota <gollakota>
Submitted:  Mon 11 Jun 2007 02:10:43 PM UTC
   
 
Category:  TCP Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  Fixed
Privacy:  Public Assigned to:  fbernon
Open/Closed:  Closed Planned Release:  None
lwIP version:  None

Jump to the original submission

Tue 12 Jun 2007 06:45:13 AM UTC, comment #9: 

Ok, and thank you to report that...

Frédéric Bernon <fbernon>
Group Member
Tue 12 Jun 2007 12:11:54 AM UTC, comment #8: 

Yes we can close this item. I'm getting ECONNABORTED error.
-Srinivas.

Srinivas Gollakota <gollakota>
Mon 11 Jun 2007 09:20:53 PM UTC, comment #7: 

No sure to understand: so, now, do you got a ECONNABORTED error, or EIO ? If it's ECONNABORTED, I think it's normal, and we can close this item. Can you confirm?

Frédéric Bernon <fbernon>
Group Member
Mon 11 Jun 2007 08:46:47 PM UTC, comment #6: 

Yes, err_tcp() gets invoked upon keep-alive timeout and sets ERR_ABRT for that connection. I do not have the fix for the err_to_errno() macro, with that update i get ECONNABORTED error.

Thanks.
-Srinivas.

Srinivas Gollakota <gollakota>
Mon 11 Jun 2007 08:18:37 PM UTC, comment #5: 

I have check in like said in comment #4...

Frédéric Bernon <fbernon>
Group Member
Mon 11 Jun 2007 06:12:08 PM UTC, comment #4: 

Is there any objects to change getsockopt(SO_ERROR) like this ?

case SO_ERROR:
if (sock->err==0) {
  sock_set_errno(sock, err_to_errno(sock->conn->err));
}
(int )optval = sock->err;
sock->err = 0;

Frédéric Bernon <fbernon>
Group Member
Mon 11 Jun 2007 05:25:03 PM UTC, comment #3: 

If I believe the tcp_abort code (call by the keepalive timeout code), you should got a ERR_ABRT error :

TCP_EVENT_ERR(errf, errf_arg, ERR_ABRT);

ERR_ABRT is matching to ECONNABORTED in err_to_errno_table.

I really would like to see your trace with "err" values. Can you display them and send us?



Frédéric Bernon <fbernon>
Group Member
Mon 11 Jun 2007 04:29:06 PM UTC, comment #2: 

(please, answer by the bug tracker to get a trace)

>Yup, the fix works good with a small correction.
>sock_set_errno(sock, err_to_errno(sock->conn->err)); /* PATCH
>note: sock->conn->err instead of conn->err*/


Yes you're right. Can you also confirm that err_tcp is called?


>But the returned socket error is EIO (0x5) which seems to be inconsistent with the error values returned by the standard getsockopt() error values. I guess we have to return EINVAL if connection is closed.
>http://compute.cnr.berkeley.edu/cgi-bin/man-cgi?getsockopt+3


There is a table to match lwip error code with BSD error code (at the beginning of sockets.c file). In this table, you could see:

EIO,           /* ERR_ARG     -8      Illegal argument.        */

Perhaps, if you display the "err" field in err_tcp(), perhaps the code is ERR_ARG. One other possibility is that the "err" code is not "inside" the err_to_errno_table (in such case, EIO seems to be the value). Can you display err from err_tcp, and sock->conn->err, and tell me your values?


Frédéric Bernon <fbernon>
Group Member
Mon 11 Jun 2007 02:40:45 PM UTC, comment #1: 

I think that conn->err is set to an error value (I suppose that err_tcp in api_msg.c is called, put a trace here to be sure).

But sock->err is not change until next send, recv, etc...

Perhaps you can test to patch sockets.c like this:

    case SO_ERROR:
      if (sock->err==0) {
        sock_set_errno(sock, err_to_errno(conn->err)); /*PATCH*/
      }
      (int )optval = sock->err;
      sock->err = 0;

Like this, you should keep the first error. Tell me if you got the trace in err_tcp, and if just patch is good for you...

Frédéric Bernon <fbernon>
Group Member
Mon 11 Jun 2007 02:10:43 PM UTC, original submission:  

socket error(sock->err) is not being set if connection is closed at the TCP level.

For example if keep-alive timer is enabled and timer expires we close the connection in tcp_slowtmr()/tcp_abort(). Socket layer is not aware of the closed connection. If application queries with getsockopt()/SO_ERROR option are'nt we suppose to return error(EINVAL?) if conn->err is set for the socket?
-Srinivas.

Srinivas Gollakota <gollakota>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by goldsimon (Updated the item)
  • -email is unavailable- added by fbernon (Posted a comment)
  • -email is unavailable- added by gollakota (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2007-06-18 goldsimon StatusIn Progress Fixed
    2007-06-12 fbernon Open/ClosedOpen Closed
    2007-06-11 fbernon StatusNone In Progress
        Assigned toNone fbernon

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code