For each address a forwarding destination resolves to,
make_forw_socket_array() creates a socket bound to the address of each
listening socket and connects it to the destination. The same
<laddr, raddr> pair can come up more than once for one rule: the
resolver may return an address twice, e.g. when a host name appears on
several /etc/hosts lines for one IP, and several listening sockets may
be bound to one address. connect() then fails with EADDRINUSE.
maybe_dup_forw_socket() only searches the rules parsed earlier, so the
casper process exits and syslogd dies with "Failed to xfer
configuration nvlist" on every start and reload.
Skip address pairs the rule already has a socket for. A second socket
would add nothing, and with -A it would send each message twice.
Reported by: Marcos Mendoza
Fixes: ae4f708f0b38 ("syslogd: Ensure that forwarded messages are sent from port 514")
See also: https://redmine.pfsense.org/issues/16966
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")