patchlwIP - A Lightweight TCP/IP stack - Patches: patch #8358, Allow more combinations of...

 
 

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

patch #8358: Allow more combinations of listening PCB for IPv6

Submitter:  Philip Gladstone <pjsg>
Submitted:  Wed 26 Feb 2014 01:14:05 PM UTC
   
 
Category:  IPv6 Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  goldsimon Open/Closed:  Closed
Planned Release:  None

Jump to the original submission

Tue 05 Apr 2016 08:05:05 PM UTC, comment #6: 

Finally applied (though slightly changed due to the ip_addr changes since then...)

Simon Goldschmidt <goldsimon>
Group administrator
Wed 11 Mar 2015 09:54:17 PM UTC, comment #5: 

There's a great explanation on Stack Overflow of the different behaviors of SO_REUSEADDR and SO_REUSEPORT on different platforms:

http://stackoverflow.com/questions/14388706/socket-options-so-reuseaddr-and-so-reuseport-how-do-they-differ-do-they-mean-t

On a BSD system, SO_REUSEADDR does allow a socket bound to INADDR_ANY and a socket bound to a specific IP address at the same time.  The order of the socket binds doesn't matter.

On a Linux system, binding to INADDR_ANY first prevents a second bind to the same port with a specific IP.  But if the order of the binds are reversed, it's allowed.

The Linux behavior seems strange to me and I would guess we would want to adhere to the BSD behavior (grandfather of sockets)

Joel Cunningham <jcunningham>
Group Member
Sat 07 Mar 2015 07:47:56 PM UTC, comment #4: 

So in your example, you bind to a specific address first and then to ANY. (And I expect it works, I'm too lazy to start my linux VM to check.)

However, your patch would allow the other way round, too (first binding to ANY, then binding to a specific address). Does that work on linux/unix, too?

Simon Goldschmidt <goldsimon>
Group administrator
Sat 07 Mar 2015 04:48:50 AM UTC, comment #3: 

The topmost reuse.c can be built with

make reuse
./reuse

This shows the effect of SO_REUSEADDR on ipv6 UDP ports.

[I realized the the first version that I uploaded didn't demo quite what I wanted]

Philip Gladstone <pjsg>
Sat 07 Mar 2015 04:47:11 AM UTC, comment #2: 

I just added a piece of test code for linux which shows one of the uses of SO_REUSEADDR for UDP. Essentially it disables the address comparison checks when binding sockets so you can do more reuse.

In my use case, I have a UDP server and need to know which local address was used for the inbound packet. The standard unix approach is to bind a socket to each address for the same port, and then to bind a socket to the wildcard address (same port). If the packet arrives on the wildcard address socket, then you know that you are missing a local address in the list of sockets.

I have since realized that I could use one of the callback mechanisms in lwip with UDP to fid the local address, but I was porting some linux code....



(file #33274)

Philip Gladstone <pjsg>
Fri 06 Mar 2015 08:21:50 PM UTC, comment #1: 

While opengroup (not being very specific) says:

"should allow reuse of local addresses"

the linux man page says:

"When the listening socket is bound to INADDR_ANY with a specific port then it is not possible to bind to this port for any local address."

So this change would at least allow something linux doesn't allow. And as I read it, it would break IPv4, wouldn't it?

Why do you think this feature is required?

Simon Goldschmidt <goldsimon>
Group administrator
Wed 26 Feb 2014 01:14:05 PM UTC, original submission:  

This patch to udp.c allows the application to listen on both specific IPv6 address/port and the wildcard IPV6 address (assuming SO_REUSEADDR).

The incoming UDP matching rules are fixed to match a specific pcb in preference to a wildcard pcb.


Philip Gladstone <pjsg>

 

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

Attached Files
file #33274:  reuse.c added by pjsg (1KiB - application/octet-stream)
file #33273:  reuse.c added by pjsg (1015B - application/octet-stream - Sample code for linux)
file #30707:  udp-addr.patch added by pjsg (2KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jcunningham (Posted a comment)
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by pjsg (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-04-05 goldsimon StatusNone Done
        Assigned toNone goldsimon
        Open/ClosedOpen Closed
    2015-03-07 pjsg Attached File- Added reuse.c, #33274
    2015-03-07 pjsg Attached File- Added reuse.c, #33273
    2014-02-26 pjsg Attached File- Added udp-addr.patch, #30707

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code