buglwIP - A Lightweight TCP/IP stack - Bugs: bug #41700, Call to tcp_listen_dual() should...

 
 

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

bug #41700: Call to tcp_listen_dual() should not accept IPv4 listen PCB args

Submitter:  Drew Stebbins <astebbin>
Submitted:  Tue 25 Feb 2014 10:38:52 PM UTC
   
 
Category:  IPv6 Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  Fixed
Privacy:  Public Assigned to:  dziegel
Open/Closed:  Closed Planned Release:  None
lwIP version:  1.3.1

Fri 04 Mar 2016 07:41:25 AM UTC, comment #5: 

Not applicable any more since dual-stack API has changed: tcp_listen_dual was removed.

One has to decide at PCB creation time now whether dual-stack is desired (tcp_new_ip_type(IPADDR_ANY_TYPE))

Dirk Ziegelmeier <dziegel>
Group administrator
Wed 18 Mar 2015 06:05:23 PM UTC, comment #4: 

I'm postponing working on this until we decide how to represend ipv4/ipv6 addresses, and possibly create a dual ANY type (a catch all type)

Ivan Delamer <idelamer>
Group Member
Thu 26 Feb 2015 08:34:08 PM UTC, comment #3: 

Partly fixed by checking that the port is available, but only if the PCB is bound before calling listen().

Cehcking this I found that this currently cannot be fully fixed as tcp_bind() (and tcp_connect()) take 'ip_addr_t' arguments (and we have to fix 'ipX_addr_t' first to include an 'isv6' flag.

-> This is an IPv6 issue.

Simon Goldschmidt <goldsimon>
Group administrator
Fri 28 Feb 2014 07:57:21 PM UTC, comment #2: 

Already switched to tcp_listen in my code base. To save future developers some grief, let's eliminate the edge case here. Having tcp_listen_dual check for existing listeners on all relevant port/IP combinations sounds reasonable. I'd further suggest that calls to tcp_listen_dual be atomic, so the caller doesn't have to check after a successful call to ensure their PCBs are listening on all of the desired port/IP combinations.

Drew Stebbins <astebbin>
Thu 27 Feb 2014 08:40:51 PM UTC, comment #1: 

How would you know a connection is IPv4-only? We only have a single boolean 'isipv6'. If we interpreted this as 'one-or-the-other' in tcp_listen_dual, how would you ever listen to both IP versions?

I'd rather suggest to not call tcp_listen_dual here. Or we would need to check that we are allowed to listen on this port/IP version and not enable accept_any_ip_version if an IPv4-only or IPv6-only pcb is already blocking the port.

Simon Goldschmidt <goldsimon>
Group administrator
Tue 25 Feb 2014 10:38:52 PM UTC, original submission:  

tcp_listen_dual() should fail and return NULL when its pcb arg is IPv4-only. Currently, tcp_listen_dual() will incorrectly make lwip listen for IPv4 OR IPv6 connections to a given IPv4-only PCB, disregarding this PCB's 'isipv6' value of 0.

Allowing IPv4 listen PCBs to accept IPv6 connections also has the side-effect of decrementing pending_accepts on the wrong PCB in tcp_pcb_purge(), in the case where an IPv6 listen PCB is bound to the same port. This is because tcp_pcb_purge() matches its active PCB arg to its listen PCB parent with a by-value comparison. The active PCB which was created to handle the IPv4 listen PCB's accepted connection has isipv6 == 1, whereas its listen PCB parent has isipv6 == 0. This causes tcp_pcb_purge() to decrement pending_accepts for the wrong listen PCB, in some cases wrapping this field around to its maximum value.

Drew Stebbins <astebbin>

 

(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 dziegel (Posted a comment)
  • -email is unavailable- added by idelamer (Posted a comment)
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by astebbin (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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-03-04 dziegel StatusPostponed Fixed
        Assigned togoldsimon dziegel
        Open/ClosedOpen Closed
    2015-02-26 goldsimon CategoryTCP IPv6
        StatusWorks For Me Postponed
        Assigned toNone goldsimon
    2014-02-27 goldsimon StatusNone Works For Me

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code