Opened 9 years ago

Closed 8 years ago

Last modified 8 years ago

#12247 closed bug (no change required)

BNetworkAddress Equals false when SetTo IPv6 address

Reported by: kallisti5 Owned by: pulkomandy
Priority: normal Milestone: Unscheduled
Component: Kits/Network Kit Version: R1/Development
Keywords: ipv6 bunittest bnetlib Cc:
Blocked By: Blocking:
Platform: All

Description

BNetworkAddress v4AddressA("192.168.1.100");
BNetworkAddress v4AddressB("192.168.1.100");
BNetworkAddress v6AddressA("feed::dead:beef");
BNetworkAddress v6AddressB("feed::dead:beef");

ASSERT_TRUE(v4AddressA.Equals(v4AddressB)); // PASS
ASSERT_TRUE(v6AddressA.Equals(v6AddressB)); // FAIL

Change History (9)

comment:1 by kallisti5, 9 years ago

#include <NetworkAddress.h>
#include <stdio.h>

int
main()
{
  BNetworkAddress address;
  status_t result = address.SetTo(AF_INET6, "::1");
  status_t result = address.SetTo("::1");

  printf("result: %d\n", result);
}

Both status_t's fail with -1 (B_ERROR)

Looks like setting IPv6 addresses to BNetworkAddress fails.

comment:2 by kallisti5, 9 years ago

Looking at the network kit, example 2 is invalid. (you can only set addresses like that when you provide a family to BNetworkAddress. (although that would be a nice feature to auto-detect)

SetTo with AF_INET6 should work though.

comment:3 by kallisti5, 9 years ago

Debug.. resolver->InitCheck() always fails when BNetworkAddressResolver passed IPv6

comment:4 by kallisti5, 9 years ago

NetworkAddressResolver::SetTo getaddrinfo("::1", 0, "ai_flags == 1024 ai_family == 5,") errors out. uncaught return status ID 4

comment:5 by axeld, 9 years ago

Owner: changed from axeld to pulkomandy
Status: newassigned

Why did we switch to the new resolver library again? :-)

comment:6 by pulkomandy, 9 years ago

That was exactly the point of switching to netresolv, it will not use IPv6 addresses unless you have an IPv6 network interface configured. Do the test pass if you have an IPv6 address set up?

comment:7 by pulkomandy, 8 years ago

Resolution: no change required
Status: assignedclosed

In hrev51041 I added the test to BNetworkAddress tests. To get this working we need to pass B_UNCONFIGURED_ADDRESS_FAMILIES, or configure an IPv6 address to one of the network adapters on the machine (which is unconvenient in the case of the unit tests).

comment:8 by axeld, 8 years ago

Can't you setup a temporary loop device, and configure an IPv6 address for it for the test only? IIRC all devices starting with "loop" will automatically become loop devices.

comment:9 by pulkomandy, 8 years ago

We can do that, but to test the full functionality we should also delete any existing ipv6 interface to test that in that case, the IPv6 address indeed isn't accepted.

Also, I wonder if when specifying an address family explicitly, the B_UNCONFIGURED_ADDRESS_FAMILIES flag should be forced. Preferably before people start using that as a cheap way to test "is IPv6 available". If you force the address family, then there is little point in later rejecting it. Maybe we could do the same if the address is in IPv6 format, and use the flag only on addresses that require a DNS (or /etc/hosts) lookup?

Note: See TracTickets for help on using tickets.