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

Submitted by:  Drew Stebbins <astebbin>
Submitted on:  Tue 25 Feb 2014 10:38:52 PM UTC  
 
Category: IPv6Severity: 3 - Normal
Item Group: Faulty BehaviourStatus: Fixed
Privacy: PublicAssigned to: Dirk Ziegelmeier <dziegel>
Open/Closed: ClosedPlanned 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>
Project MemberIn charge of this item.
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>
Project 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>
Project 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>
Project 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>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by dziegel (Posted a comment)
  • -unavailable- added by idelamer (Posted a comment)
  • -unavailable- added by goldsimon (Posted a comment)
  • -unavailable- added by astebbin (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 7 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 04 Mar 2016 07:41:25 AM UTCdziegelStatusPostponed=>Fixed
      Assigned togoldsimon=>dziegel
      Open/ClosedOpen=>Closed
    Thu 26 Feb 2015 08:34:08 PM UTCgoldsimonCategoryTCP=>IPv6
      StatusWorks For Me=>Postponed
      Assigned toNone=>goldsimon
    Thu 27 Feb 2014 08:40:51 PM UTCgoldsimonStatusNone=>Works For Me

    Back to the top


    Powered by Savane 3.1-cleanup1