[pgpool-hackers: 4609] Re: heartbeat and SO_BINDTODEVICE

Tatsuo Ishii ishii at postgresql.org
Sat Jun 14 20:31:13 JST 2025


> wd_create_hb_recv_socket() and wd_create_hb_send_socket() calls
> setsockopt(2) like this:
> 
> 	struct ifreq i;
> 	strlcpy(i.ifr_name, hb_if->if_name, sizeof(i.ifr_name));
> 	if (setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, &i, sizeof(i)) == -1)
> 	:
> 
> I think this is not quite correct since the 4th arugument should be
> just a null terminated string (device name), not struct ifreq. From
> socket(7) man page:
> 
>        SO_BINDTODEVICE
>               Bind this socket to a particular device like “eth0”,
>               as specified in the passed interface name.  If the name
>               is an empty string or the option length is zero, the
>               socket device binding is removed.  The passed option is
>               a variable- length null-terminated interface name string
>               with the maximum size of IFNAMSIZ.
> 
> Patch attached.

Fix pushed.

Best regards,
--
Tatsuo Ishii
SRA OSS K.K.
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp


More information about the pgpool-hackers mailing list