0

Accept IPv6 addresses in CUPS status lookups

When doing a direct printer connection for IPP status lookups, Chrome
resolves printer hostnames with AF_INET.  When the CUPS IPP backend
looks up the printer to submit a job, it uses AF_UNSPEC.  This causes
different sets of addresses to be returned if a printer has an IPv6
address, which can leave the status indicator out of sync with the
ability to submit a print job.

Make these consistent by passing AF_UNSPEC on the Chrome side as well.
The backend filters responses to AF_INET and AF_INET6, so this does not
introduce the possibility of getting unexpected protocols in the name
lookups.

Bug: b:251014607
Change-Id: I100db1c2273d98595c988dc78f3e65b9e5692ea4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4023804
Reviewed-by: Piotr Pawliczek <pawliczek@chromium.org>
Commit-Queue: Benjamin Gordon <bmgordon@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1070482}
This commit is contained in:
Benjamin Gordon
2022-11-11 20:59:48 +00:00
committed by Chromium LUCI CQ
parent 4294b8518a
commit e3896bb94b

@ -535,14 +535,14 @@ PrinterQueryResult GetPrinterInfo(const std::string& address,
// Lookup the printer IP address.
http_addrlist_t* addr_list = httpAddrGetList(
address.c_str(), AF_INET, base::NumberToString(port).c_str());
address.c_str(), AF_UNSPEC, base::NumberToString(port).c_str());
if (!addr_list) {
LOG(WARNING) << "Unable to resolve IP address from hostname";
return PrinterQueryResult::kHostnameResolution;
}
ScopedHttpPtr http = ScopedHttpPtr(httpConnect2(
address.c_str(), port, addr_list, AF_INET,
address.c_str(), port, addr_list, AF_UNSPEC,
encrypted ? HTTP_ENCRYPTION_ALWAYS : HTTP_ENCRYPTION_IF_REQUESTED, 0,
kHttpConnectTimeoutMs, nullptr));
if (!http) {