Opened 4 years ago

Closed 2 years ago

Last modified 2 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:
Has a Patch: no Platform: All


BNetworkAddress v4AddressA("");
BNetworkAddress v4AddressB("");
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 Changed 3 years ago by kallisti5

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

  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 Changed 3 years ago by kallisti5

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 Changed 3 years ago by kallisti5

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

comment:4 Changed 3 years ago by kallisti5

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

comment:5 Changed 3 years ago by axeld

Owner: changed from axeld to pulkomandy
Status: newassigned

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

comment:6 Changed 3 years ago by pulkomandy

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 Changed 2 years ago by pulkomandy

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 Changed 2 years ago by axeld

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 Changed 2 years ago by pulkomandy

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.