Fix not to bind sockets to network devices when pgpool-II doesn't has
authorYugo Nagata <nagata@sraoss.co.jp>
Mon, 17 Jun 2013 07:28:25 +0000 (16:28 +0900)
committerYugo Nagata <nagata@sraoss.co.jp>
Mon, 17 Jun 2013 07:28:25 +0000 (16:28 +0900)
root privilege.

SO_BINDTODEVICE socket option is used for binding sockets to network
devices and requires root privilege. However, this is not essential
for the lifecheck mechanism itself, so we use this function only when
pgpool-II has root privilege.

If pgpool-II has root privilege, log message says like;

    wd_create_hb_recv_socket: bind receive socket to device :eth0

otherwise,

    is_usable_bindtodevice: setsockopt(SO_BINDTODEVICE) requires root privilege
    wd_create_hb_recv_socket: couldn't bind receive socket to device :eth0

doc/pgpool-en.html
doc/pgpool-ja.html
pgpool.conf.sample
pgpool.conf.sample-master-slave
pgpool.conf.sample-replication
pgpool.conf.sample-stream
pool_config.c
pool_config.l
watchdog/wd_heartbeat.c

index 82e81e79e5523c4080682d3f5f6f9d8c1a07522c..aa149685edd15ac40f7e0991b232b82346942e39 100644 (file)
@@ -3843,11 +3843,11 @@ watchdog adds the following features to pgpool-II.
     </p>
     <ul>
     <li>
-    In heartbeat mode, watchdog monitors other pgpool-II process by using heartbeat signal.
+    In heartbeat mode, watchdog monitors other pgpool-II processes by using heartbeat signal.
     Watchdog receives heartbeat signals sent by other pgpool-II periodically.
-    If there are no signal for a certain period, watchdog regards it as failure of the pgpool-II.
-       For redundancy you can use multiple network interface devices for heartbeat exchange between pgpool-IIs.
-       This mode is default and recommended one.
+    If there are no signal for a certain period, watchdog regards this as failure of the pgpool-II.
+       For redundancy you can use multiple network connections for heartbeat exchange between pgpool-IIs.
+       This is the default mode and recommended.
     </li>
     <li>
     In query mode, watchdog monitors pgpool-II's service rather than process.
@@ -4204,15 +4204,13 @@ Configuration about virtual IP interface control
     </p>
     </dd>
 
-<dt><a name="HEARTBEAT_DEVICE"></a>heartbeat_device<font color="red">0</font> <span class="version">V3.3 -</span></dt>
+<dt><a name="HEARTBEAT_DESTINATION"></a>heartbeat_destination<font color="red">0</font> <span class="version">V3.3 -</span></dt>
     <dd>
     <p>
-    This option specifies the network device name for sending heartbeat signals.
-    You can use multiple devices.
-    The number at the end of the parameter name is referred as "device number",
+    This option specifies the destination of heartbeat signals bu IP address or hostname.
+    You can use multiple destination.
+    The number at the end of the parameter name is referred as "destination number",
     and it starts from 0.
-    If you want to set mutiple destination (<a href="HEARTBEAT_DESTINATION">heartbeat_destiationN</a>) for one device,
-    specify the device name repeatedly using different numbers.
     This works only heartbeat mode.
     </p>
     <p>
@@ -4220,12 +4218,15 @@ Configuration about virtual IP interface control
     </p>
     </dd>
 
-<dt><a name="HEARTBEAT_DESTINATION"></a>heartbeat_destination<font color="red">0</font> <span class="version">V3.3 -</span></dt>
+<dt><a name="HEARTBEAT_DESTINATION_PORT"></a>heartbeat_destination_port<font color="red">0</font> <span class="version">V3.3 -</span></dt>
     <dd>
     <p>
-    This option specifies the destination of heartbeat signals which is sent from the device specified by
-    <a href="HEARTBEAT_DEVICE">heartbeat_deviceX</a>. Use IP address or hostname.
-    The number at the end of the parameter name is referred as "device number",
+    This option specifies the port number of destination of heartbeat signals
+       which is specified by <a href="HEARTBEAT_DESTINATION">heartbeat_destinationX</a>.
+    This is usually the same value as <a href="WD_HEARTBEAT_PORT">wd_heartbeat_port</a>
+    You must use another value if the port number is unusable on a certain host or
+       there are more than two pgpool-IIs in a host.
+    The number at the end of the parameter name is referred as "destination number",
     and it starts from 0.
     This works only heartbeat mode.
     </p>
@@ -4234,23 +4235,23 @@ Configuration about virtual IP interface control
     </p>
     </dd>
 
-<dt><a name="HEARTBEAT_DESTINATION_PORT"></a>heartbeat_destination_port<font color="red">0</font> <span class="version">V3.3 -</span></dt>
+<dt><a name="HEARTBEAT_DEVICE"></a>heartbeat_device<font color="red">0</font> <span class="version">V3.3 -</span></dt>
     <dd>
     <p>
-    This option specifies the port number of destination of heartbeat signals which is sent from the device specified by
-    <a href="HEARTBEAT_DEVICE">heartbeat_deviceX</a>. 
-    This is usually the same value of <a href="WD_HEARTBEAT_PORT">wd_heartbeat_port</a> 
-    You must set another value if the port number is unusable or there are more than two pgpool-IIs in a host.
-    The number at the end of the parameter name is referred as "device number",
+    This option specifies the network device name for sending heartbeat signals to
+       destination specified by <a href="HEARTBEAT_DESTINATION">heartbeat_destinationX</a>.
+    You can use the same device for different distinations.
+    The number at the end of the parameter name is referred as "destination number",
     and it starts from 0.
     This works only heartbeat mode.
+       In addition, this works only when pgpool-II has root privilege and are running on Linux,
+       because this uses SO_BINDTODEVICE socket option.
     </p>
     <p>
     You need to restart pgpool-II if you change this value.
     </p>
     </dd>
 </dl>
-</dl>
 
 <h4>Configuration of query mode</h4>
 
index e818952bc39d4c86ab2aaddac3c075faad8750b6..776348751267f051b3fb62d3e0c0ec3510b332a3 100644 (file)
@@ -3952,8 +3952,8 @@ watchdog は以下の機能を提供します。
 <ul>
 <li>
     ハートビートモードでは、watchdog はハートビート信号を用いて 他の pgpool-II プロセスの死活監視を行います。
-    watchdog は、他の pgpool-II の watchdog より定期的に送られるハートビート信号を受け取り、これが一定期間以上途切れた場合にはその pgpool-II プロセスに障害が発生したと判断します。
-       å\86\97é\95·æ\80§ã\82\92é«\98ã\82\81ã\82\8bã\81\9fã\82\81ã\80\81è¤\87æ\95°ã\81®ã\83\8dã\83\83ã\83\88ã\83¯ã\83¼ã\82¯ã\82¤ã\83³ã\82¿ã\83\95ã\82§ã\83¼ã\82¹ã\83\87ã\83\90ã\82¤ã\82¹を用いたハートビート交換が可能です。
+    watchdog は、他の pgpool-II の watchdog より定期的に送られるハートビート信号を受け取り、これが一定期間以上途切れた場合には当該 pgpool-II プロセスに障害が発生したと判断します。
+       å\86\97é\95·æ\80§ã\82\92é«\98ã\82\81ã\82\8bã\81\9fã\82\81ã\81«ã\80\81è¤\87æ\95°ã\81®ã\83\8dã\83\83ã\83\88ã\83¯ã\83¼ã\82¯を用いたハートビート交換が可能です。
        デフォルトではこのモードで動作し、これが推奨設定です。
     </li>
 <li>
@@ -4320,14 +4320,12 @@ pgpool-II が生きていて PostgreSQL と繋がっている場合でも、
     </p>
     </dd>
 
-<dt><a name="HEARTBEAT_DEVICE"></a>heartbeat_device<font color="red">0</font> <span class="version">V3.3 ~</span></dt>
+<dt><a name="HEARTBEAT_DESTINATION"></a>heartbeat_destination<font color="red">0</font> <span class="version">V3.3 ~</span></dt>
     <dd>
     <p>
-    ハートビートの送受信に用いるネットワークデバイス名を指定します。
-    複数のデバイスが設定可能です。
-    数値の部分はデバイスの番号です。
-    デバイス毎に 0 からの連番にします。
-    1つのデバイスに複数のハートビート送信先(<a href="HEARTBEAT_DESTINATION">heartbeat_destiationN</a>)を設定する場合は、重複するデバイス名を異なる番号で指定してください。
+    ハートビート信号の送り先を、ホスト名か IP で指定します。
+       複数の送り先が指定可能です。
+    数値の部分は送り先の番号です。0 からの連番にします。
     ハートビートモードの場合のみ有効です。
     </p>
     <p>
@@ -4335,12 +4333,13 @@ pgpool-II が生きていて PostgreSQL と繋がっている場合でも、
     </p>
     </dd>
 
-<dt><a name="HEARTBEAT_DESTINATION"></a>heartbeat_destination<font color="red">0</font> <span class="version">V3.3 ~</span></dt>
+<dt><a name="HEARTBEAT_DESTINATION_PORT"></a>heartbeat_destination_port<font color="red">0</font> <span class="version">V3.3 ~</span></dt>
     <dd>
     <p>
-    <a href="HEARTBEAT_DEVICE">heartbeat_deviceX</a>に指定したデバイスから送るハートビート信号の宛先を、ホスト名か IP で指定します。
-    数値の部分はデバイスの番号です。
-    デバイス毎に 0 からの連番にします。
+    <a href="HEARTBEAT_DESTINATION">heartbeat_destinationX</a>に指定したハートビート信号の送り先のポート番号を指定します。
+    通常は <a href="WD_HEARTBEAT_PORT">wd_heartbeat_port</a> と同じ値を指定します。
+    そのポート番号が使用できないホストや、同じホストで複数の pgpool-II を動作させる場合には、異なる値を指定する必要があります。
+    数値の部分は送り先の番号です。0 からの連番にします。
     ハートビートモードの場合のみ有効です。
     </p>
     <p>
@@ -4348,15 +4347,14 @@ pgpool-II が生きていて PostgreSQL と繋がっている場合でも、
     </p>
     </dd>
 
-<dt><a name="HEARTBEAT_DESTINATION_PORT"></a>heartbeat_destination_port<font color="red">0</font> <span class="version">V3.3 ~</span></dt>
+<dt><a name="HEARTBEAT_DEVICE"></a>heartbeat_device<font color="red">0</font> <span class="version">V3.3 ~</span></dt>
     <dd>
     <p>
-    <a href="HEARTBEAT_DEVICE">heartbeat_deviceX</a>に指定したデバイスから送るハートビート信号の宛先のポート番号を指定します。
-    通常は <a href="WD_HEARTBEAT_PORT">wd_heartbeat_port</a> と同じ値を指定します。
-    そのポート番号が使用できないホストや、同じホストで複数の pgpool-II を動作させる場合には、異なる値を指定する必要があります。
-    数値の部分はデバイスの番号です。
-    デバイス毎に 0 からの連番にします。
+    <a href="HEARTBEAT_DESTINATION">heartbeat_destinationX</a>に指定した送り先とのハートビートの送受信に用いるネットワークデバイス名を指定します。
+    数値の部分は送り先の番号です。デバイス毎に 0 からの連番にします。
+    複数の異なる送り先に同じデバイスを設定することが可能です。
     ハートビートモードの場合のみ有効です。
+       また、SO_BINDTODEVICE ソケットオプションを使用しているため、pgpool-II が Linux で root 権限で起動している場合のみ有効です。
     </p>
     <p>
     このパラメータを変更した時には pgpool-II を再起動してください。
index 86244baa7c6123dc4b32379c37708bc3c4c4a9ba..a50092f6e0fe0a58243aca88db3134b925cfb3c5 100644 (file)
@@ -517,22 +517,25 @@ wd_heartbeat_keepalive = 2
 wd_heartbeat_deadtime = 30
                                     # Deadtime interval for heartbeat signal (sec)
                                     # (change requires restart)
-heartbeat_device0 = 'eth0'
-                                    # Name of NIC device 0 using for
-                                    # sending/receiving heartbeat signal
-                                    # (change requires restart)
-heartbeat_destination_ip0 = 'host0_ip1'
-                                    # Destination host name or IP address
-                                    # for sending heartbeat signal using NIC device 0.
+heartbeat_destination = 'host0_ip1'
+                                    # Host name or IP address of destination 0
+                                    # for sending heartbeat signal.
                                     # (change requires restart)
 heartbeat_destination_port0 = 9694 
-                                    # Destination port number for sending heartbeat
-                                    # signal to destination 0. Usually this is the
-                                    # same of wd_heartbeat_port.
+                                    # Port number of destination 0 for sending
+                                    # heartbeat signal. Usually this is the
+                                    # same as wd_heartbeat_port.
                                     # (change requires restart)
-#heartbeat_device1 = 'eth1'
+heartbeat_device0 = 'eth0'
+                                    # Name of NIC device using for
+                                    # sending/receiving heartbeat signal
+                                    # to/from destination 0.
+                                    # This works only when pgpool has root privilege.
+                                    # (change requires restart)
+
 #heartbeat_destination_ip1 = 'host0_ip2'
 #heartbeat_destination_port1 = 9694
+#heartbeat_device1 = 'eth1'
 
 # -- query mode --
 
index a83baaa0a2a3eb386284f6ea4ccbc131a0219479..e4b975500a1ca13e56c736dd9c543ccafa69f036 100644 (file)
@@ -517,22 +517,25 @@ wd_heartbeat_keepalive = 2
 wd_heartbeat_deadtime = 30
                                     # Deadtime interval for heartbeat signal (sec)
                                     # (change requires restart)
-heartbeat_device0 = 'eth0'
-                                    # Name of NIC device 0 using for
-                                    # sending/receiving heartbeat signal
-                                    # (change requires restart)
-heartbeat_destination0 = 'host0_ip1'
-                                    # Destination host name or IP address
-                                    # for sending heartbeat signal using NIC device 0.
+heartbeat_destination = 'host0_ip1'
+                                    # Host name or IP address of destination 0
+                                    # for sending heartbeat signal.
                                     # (change requires restart)
 heartbeat_destination_port0 = 9694 
-                                    # Destination port number for sending heartbeat
-                                    # signal to destination 0. Usually this is the
-                                    # same of wd_heartbeat_port.
+                                    # Port number of destination 0 for sending
+                                    # heartbeat signal. Usually this is the
+                                    # same as wd_heartbeat_port.
                                     # (change requires restart)
-#heartbeat_device1 = 'eth1'
-#heartbeat_destination1 = 'host0_ip2'
+heartbeat_device0 = 'eth0'
+                                    # Name of NIC device using for
+                                    # sending/receiving heartbeat signal
+                                    # to/from destination 0.
+                                    # This works only when pgpool has root privilege.
+                                    # (change requires restart)
+
+#heartbeat_destination_ip1 = 'host0_ip2'
 #heartbeat_destination_port1 = 9694
+#heartbeat_device1 = 'eth1'
 
 # -- query mode --
 
index 9d5fb6fd6d061e158915cfe64063488efefe2503..114a8114a48b43552488a81450f8226bfa4b5bc7 100644 (file)
@@ -516,22 +516,25 @@ wd_heartbeat_keepalive = 2
 wd_heartbeat_deadtime = 30
                                     # Deadtime interval for heartbeat signal (sec)
                                     # (change requires restart)
-heartbeat_device0 = 'eth0'
-                                    # Name of NIC device 0 using for
-                                    # sending/receiving heartbeat signal
-                                    # (change requires restart)
-heartbeat_destination0 = 'host0_ip1'
-                                    # Destination host name or IP address
-                                    # for sending heartbeat signal using NIC device 0.
+heartbeat_destination = 'host0_ip1'
+                                    # Host name or IP address of destination 0
+                                    # for sending heartbeat signal.
                                     # (change requires restart)
 heartbeat_destination_port0 = 9694 
-                                    # Destination port number for sending heartbeat
-                                    # signal to destination 0. Usually this is the
-                                    # same of wd_heartbeat_port.
+                                    # Port number of destination 0 for sending
+                                    # heartbeat signal. Usually this is the
+                                    # same as wd_heartbeat_port.
                                     # (change requires restart)
-#heartbeat_device1 = 'eth1'
-#heartbeat_destination1 = 'host0_ip2'
+heartbeat_device0 = 'eth0'
+                                    # Name of NIC device using for
+                                    # sending/receiving heartbeat signal
+                                    # to/from destination 0.
+                                    # This works only when pgpool has root privilege.
+                                    # (change requires restart)
+
+#heartbeat_destination_ip1 = 'host0_ip2'
 #heartbeat_destination_port1 = 9694
+#heartbeat_device1 = 'eth1'
 
 # -- query mode --
 
index a8e8ddb277809427153ceb074fe2e9f55630476c..8d74931af8068b1fa7f24f500c57e9ed3f10d1d1 100644 (file)
@@ -516,22 +516,25 @@ wd_heartbeat_keepalive = 2
 wd_heartbeat_deadtime = 30
                                     # Deadtime interval for heartbeat signal (sec)
                                     # (change requires restart)
-heartbeat_device0 = 'eth0'
-                                    # Name of NIC device 0 using for
-                                    # sending/receiving heartbeat signal
-                                    # (change requires restart)
-heartbeat_destination0 = 'host0_ip1'
-                                    # Destination host name or IP address
-                                    # for sending heartbeat signal using NIC device 0.
+heartbeat_destination = 'host0_ip1'
+                                    # Host name or IP address of destination 0
+                                    # for sending heartbeat signal.
                                     # (change requires restart)
 heartbeat_destination_port0 = 9694 
-                                    # Destination port number for sending heartbeat
-                                    # signal to destination 0. Usually this is the
-                                    # same of wd_heartbeat_port.
+                                    # Port number of destination 0 for sending
+                                    # heartbeat signal. Usually this is the
+                                    # same as wd_heartbeat_port.
                                     # (change requires restart)
-#heartbeat_device1 = 'eth1'
-#heartbeat_destination1 = 'host0_ip2'
+heartbeat_device0 = 'eth0'
+                                    # Name of NIC device using for
+                                    # sending/receiving heartbeat signal
+                                    # to/from destination 0.
+                                    # This works only when pgpool has root privilege.
+                                    # (change requires restart)
+
+#heartbeat_destination_ip1 = 'host0_ip2'
 #heartbeat_destination_port1 = 9694
+#heartbeat_device1 = 'eth1'
 
 # -- query mode --
 
index d98b3dad575e7c78b15ac9fc5957af4cb53187a7..b2101a0811898961725964fc522945467474b040 100644 (file)
@@ -3944,10 +3944,7 @@ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context)
                                return(-1);
                        }
                        if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
-                       {
                                strlcpy(WD_HB_IF(slot).if_name, str, WD_MAX_IF_NAME_LEN);
-                               pool_config->num_hb_if = slot + 1;
-                       }
 
                }
                /* this must be prior to hertbeat_destination */
@@ -3966,7 +3963,10 @@ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context)
                        }
 
                        if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
+                       {
                                WD_HB_IF(slot).dest_port = atoi(yytext);
+                               pool_config->num_hb_if = slot + 1;
+                       }
                }
                else if (!strncmp(key, "heartbeat_destination", 21) &&
                                 CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
index 556c41e3e5993c839c27725b07c7e55be3fb3e06..2026f2c1f8e24f75474bc8df7bb718182b0247e2 100644 (file)
@@ -2397,10 +2397,7 @@ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context)
                                return(-1);
                        }
                        if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
-                       {
                                strlcpy(WD_HB_IF(slot).if_name, str, WD_MAX_IF_NAME_LEN);
-                               pool_config->num_hb_if = slot + 1;
-                       }
 
                }
                /* this must be prior to hertbeat_destination */
@@ -2419,7 +2416,10 @@ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context)
                        }
 
                        if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
+                       {
                                WD_HB_IF(slot).dest_port = atoi(yytext);
+                               pool_config->num_hb_if = slot + 1;
+                       }
                }
                else if (!strncmp(key, "heartbeat_destination", 21) &&
                                 CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
index bee5ce616d7a57bcc73fc3c9645f1899ec0a48ff..d9034c273cbe2310baff5194a6f5aa5e88f7ee42 100644 (file)
@@ -57,6 +57,7 @@ static RETSIGTYPE hb_receiver_exit(int sig);
 static int hton_wd_hb_packet(WdHbPacket * to, WdHbPacket * from);
 static int ntoh_wd_hb_packet(WdHbPacket * to, WdHbPacket * from);
 static int packet_to_string_hb(WdHbPacket pkt, char *str, int maxlen);
+static bool is_usable_bindtodevice(void);
 
 /* create socket for sending heartbeat */
 int
@@ -83,8 +84,8 @@ wd_create_hb_send_socket(WdHbIf hb_if)
                close(sock);
                return -1;
        }
-/*
-#if defined(SO_BINDTODEVICE)
+
+       if (is_usable_bindtodevice())
        {
                struct ifreq i;
                strlcpy(i.ifr_name, hb_if.if_name, sizeof(i.ifr_name));
@@ -98,8 +99,9 @@ wd_create_hb_send_socket(WdHbIf hb_if)
                }
                pool_log("wd_create_hb_send_socket: bind send socket to device: %s", i.ifr_name);
        }
-#endif
-*/
+       else
+               pool_log("wd_create_hb_send_socket: couldn't bind send socket to device: %s", hb_if.if_name);
+
 #if defined(SO_REUSEPORT)
        {
                int one = 1;
@@ -155,8 +157,8 @@ wd_create_hb_recv_socket(WdHbIf hb_if)
                close(sock);
                return -1;
        }
-/*
-#if defined(SO_BINDTODEVICE)
+
+       if (is_usable_bindtodevice())
        {
                struct ifreq i;
                strlcpy(i.ifr_name, hb_if.if_name, sizeof(i.ifr_name));
@@ -170,8 +172,8 @@ wd_create_hb_recv_socket(WdHbIf hb_if)
                }
                pool_log("wd_create_hb_recv_socket: bind receive socket to device: %s", i.ifr_name);
        }
-#endif
-*/
+       else
+               pool_log("wd_create_hb_recv_socket: couldn't bind receive socket to device: %s", hb_if.if_name);
 
 #if defined(SO_REUSEPORT)
        {
@@ -212,10 +214,7 @@ wd_create_hb_recv_socket(WdHbIf hb_if)
 
        if (fcntl(sock, F_SETFD, FD_CLOEXEC) < 0) {
                pool_error("wd_create_hb_recv_socket: setting close-on-exec flag failed. reason: %s",
-                          strerror(errno));
-               close(sock);
-               return -1;
-       }
+                          strerror(errno)); close(sock); return -1; }
 
        return sock;
 }
@@ -294,7 +293,8 @@ wd_hb_recv(int sock, WdHbPacket * pkt)
 }
 
 /* fork heartbeat receiver child */
-pid_t wd_hb_receiver(int fork_wait_time, WdHbIf hb_if)
+pid_t
+wd_hb_receiver(int fork_wait_time, WdHbIf hb_if)
 {
        int sock;
        pid_t pid = 0;
@@ -397,7 +397,8 @@ pid_t wd_hb_receiver(int fork_wait_time, WdHbIf hb_if)
 }
 
 /* fork heartbeat sender child */
-pid_t wd_hb_sender(int fork_wait_time, WdHbIf hb_if)
+pid_t
+wd_hb_sender(int fork_wait_time, WdHbIf hb_if)
 {
        int sock;
        pid_t pid = 0;
@@ -541,7 +542,8 @@ ntoh_wd_hb_packet(WdHbPacket * to, WdHbPacket * from)
 }
 
 /* convert packet to string and return length of the string */
-static int packet_to_string_hb(WdHbPacket pkt, char *str, int maxlen)
+static int
+packet_to_string_hb(WdHbPacket pkt, char *str, int maxlen)
 {
        int len;
        len = snprintf(str, maxlen, "status=%d tv_sec=%ld tv_usec=%ld from=%s",
@@ -549,3 +551,22 @@ static int packet_to_string_hb(WdHbPacket pkt, char *str, int maxlen)
 
        return len;
 }
+
+static bool
+is_usable_bindtodevice(void)
+{
+#if defined(SO_BINDTODEVICE)
+       if (geteuid() != 0)
+       {
+               pool_log("is_usable_bindtodevice: setsockopt(SO_BINDTODEVICE) requies root privilege");
+               return false;
+       }
+       else
+       {
+               return true;
+       }
+#else
+       pool_log("is_usable_bindtodevice: couldn't setsockopt(SO_BINDTODEVICE) in this platform");
+       return false;
+#endif
+}