BUG/MINOR: log: properly format IPv6 address when LOG_OPT_HEXA modifier is used.
authorRadek Zajic <radek.zajic@showmax.com>
Fri, 22 Mar 2019 10:21:54 +0000 (10:21 +0000)
committerWilly Tarreau <w@1wt.eu>
Fri, 22 Mar 2019 16:31:18 +0000 (17:31 +0100)
commit594c456d147b02dbe264566a5c9f52b85b36952d
treecf5cb6c8a3e7a231c95e2752c30b5330c4a1038a
parentbc34cd1de2ee80de63b5c4d319a501fc0d4ea2f5
BUG/MINOR: log: properly format IPv6 address when LOG_OPT_HEXA modifier is used.

In lf_ip(), when LOG_OPT_HEXA modifier is used, there is a code to format the
IP address as a hexadecimal string. This code does not properly handle cases
when the IP address is IPv6. In such case, the code only prints `00000000`.

This patch adds support for IPv6. For legacy IPv4, the format remains
unchanged. If IPv6 socket is used to accept IPv6 connection, the full IPv6
address is returned. For example, IPv6 localhost, ::1, is printed as
00000000000000000000000000000001.

If IPv6 socket accepts IPv4 connection, the IPv4 address is mapped by the
kernel into the IPv4-mapped-IPv6 address space (RFC4291, section 2.5.5.2)
and is formatted as such. For example, 127.0.0.1 becomes ::ffff:127.0.0.1,
which is printed as 00000000000000000000FFFF7F000001.

This should be backported to 1.9.
src/log.c