Skip to content

Fix destination port extraction for client queries

The current logic for determining the address of the socket to which a client sent its query is:

  1. Get the address:port tuple from the netmgr handle using isc_nmhandle_localaddr().

  2. Convert the address:port tuple from step 1 into an isc_netaddr_t using isc_netaddr_fromsockaddr().

  3. Convert the address from step 2 back into a socket address with the port set to 0 using isc_sockaddr_fromnetaddr().

Note that the port number (readily available in the netmgr handle) is needlessly lost in the process, preventing it from being recorded in dnstap captures of client traffic produced by named.

Fix by first storing the address:port tuple returned by isc_nmhandle_localaddr() in client->destsockaddr and then creating an isc_netaddr_t from that structure. This allows the port number to be retained in client->destsockaddr, which is what subsequently gets passed to dns_dt_send().

Closes #3309 (closed)

Merge request reports