PATCH: Add ipv6 support to libhpmud
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
HPLIP |
New
|
Undecided
|
Unassigned |
Bug Description
libhpmud currently only connects to IPv4 hosts. However, newer HP printers fully support IPv6. The attached patch allows using an IPv6 address or a hostname that only resolves to IPv6 in HP URIs. It does not touch any of the discovery protocols which probably only support IPv4 anyway.
With the attached patch, instead of manually creating the socket address and trying to resolve with gethostbyname, the getaddrinfo API is used to perform the task of finding an address to connect to. This makes it possible to use ipv4 addresses, ipv6 addresses or hostnames just the same. The system's C library automatically selects the appropriate addresses (for example, it omits ipv6 addresses if there is no ipv6 connectivity).
Unfortunately, things are not that easy in practice as they might be in theory. The patch just aimlessly connects to things in a loop which can easily break.
I just want to note this, as I dealt with this in APT. APT did the looping and connect thing, albeit with timeouts, so a bit better than this. Still, we had plenty of reports from users with broken IPv6 networking where apt failed to connect in a reasonable timeframe.
What we ended up doing in apt was implementing a draft of happy-eyeballs 2: Basically
1. we take the address list returned by the system
2. we re-order it so that it alternates between preferred and other address families
4. loop: we add more connection attempts and select() on them every 200ms
The first connection attempt that succeeds wins.