inetstack icon indicating copy to clipboard operation
inetstack copied to clipboard

[ip] `INADDR_ANY` Should Be Supported As The Wildcard Address

Open BrianZill opened this issue 2 years ago • 1 comments

Description

The standard socket API normally accepts INADDR_ANY (the all-zeroes address) as the wildcard (or "unspecified") address, meaning it matches all addresses. We don't appear to currently support this.

Expected Behavior

When a socket is bound to INADDR_ANY and some port X, it should receive all packets that arrive at the host for port X, regardless of which of the host's IP addresses it was addressed to.

Note the above statement is assuming that the arriving packets are addressed to an IP address assigned to the same interface upon which the packets are arriving (if the host is implementing the "strong host" model), or any one of the host's IP addresses (if the host is implementing the "weak host" model). The strong/weak host model distinction is currently immaterial for our implementation, as we only support a single interface (with only a single address!) at the moment.

Note also that while INADDR_ANY is typically used with the bind API, the concept of an unspecified address for either the local or remote address on a socket is used in multiple places. The matching of incoming packets to a receiving socket (which may have an unspecified local address as described above) is one such place. Another is when performing an active open (i.e., "connect") on an unbound (i.e., has an unspecified local address) socket to a given remote address, the stack must assign a local address to use for connecting to the remote address in question.

Related Issues

  • https://github.com/demikernel/inetstack/issues/165
  • https://github.com/demikernel/inetstack/issues/199

BrianZill avatar May 27 '22 07:05 BrianZill