sleep(5);
}
}
+
+#ifdef HAVE_AF_PACKET
+
+bool ctdb_sys_check_iface_exists(const char *iface)
+{
+ int s;
+ struct ifreq ifr;
+
+ s = socket(AF_PACKET, SOCK_RAW, 0);
+ if (s == -1){
+ /* We don't know if the interface exists, so assume yes */
+ DBG_ERR("Failed to open raw socket\n");
+ return true;
+ }
+
+ strlcpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name));
+ if (ioctl(s, SIOCGIFINDEX, &ifr) < 0 && errno == ENODEV) {
+ DBG_ERR("Interface '%s' not found\n", iface);
+ close(s);
+ return false;
+ }
+ close(s);
+
+ return true;
+}
+
+#else /* HAVE_AF_PACKET */
+
+bool ctdb_sys_check_iface_exists(const char *iface)
+{
+ /* Not implemented: Interface always considered present */
+ return true;
+}
+
+#endif /* HAVE_AF_PACKET */
ctdb_sock_addr *src, ctdb_sock_addr *dst,
uint32_t *ack_seq, uint32_t *seq,
int *rst, uint16_t *window);
-bool ctdb_sys_check_iface_exists(const char *iface);
int ctdb_get_peer_pid(const int fd, pid_t *peer_pid);
/* From system_util.c */
void ctdb_wait_for_process_to_exit(pid_t pid);
+bool ctdb_sys_check_iface_exists(const char *iface);
+
#endif /* __CTDB_SYSTEM_H__ */
return -1;
}
-
-bool ctdb_sys_check_iface_exists(const char *iface)
-{
- /* FIXME AIX: Interface always considered present */
- return true;
-}
-
int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
{
struct peercred_struct cr;
return -1;
}
-bool ctdb_sys_check_iface_exists(const char *iface)
-{
- /* FIXME FreeBSD: Interface always considered present */
- return true;
-}
-
int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
{
/* FIXME FreeBSD: get_peer_pid not implemented */
return -1;
}
-bool ctdb_sys_check_iface_exists(const char *iface)
-{
- /* FIXME GNU/Hurd: Interface always considered present */
- return true;
-}
-
int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
{
/* FIXME GNU/Hurd: get_peer_pid not implemented */
return -1;
}
-bool ctdb_sys_check_iface_exists(const char *iface)
-{
- /* FIXME kFreeBSD: Interface always considered present */
- return true;
-}
-
int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
{
/* FIXME kFreeBSD: get_peer_pid not implemented */
return -1;
}
-
-bool ctdb_sys_check_iface_exists(const char *iface)
-{
- int s;
- struct ifreq ifr;
-
- s = socket(AF_PACKET, SOCK_RAW, 0);
- if (s == -1){
- /* We don't know if the interface exists, so assume yes */
- DEBUG(DEBUG_CRIT,(__location__ " failed to open raw socket\n"));
- return true;
- }
-
- strlcpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name));
- if (ioctl(s, SIOCGIFINDEX, &ifr) < 0 && errno == ENODEV) {
- DEBUG(DEBUG_CRIT,(__location__ " interface '%s' not found\n", iface));
- close(s);
- return false;
- }
- close(s);
-
- return true;
-}
-
int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
{
struct ucred cr;
test_cleanup remove_socket
-result_filter ()
-{
- sed -e 's|^\(\.\./common/system_linux\.c\):[0-9][0-9]*|\1:LINE|'
-}
-
uid=$(id -u)
if [ "$uid" -eq 0 ] ; then
- ok "../common/system_linux.c:LINE interface 'fake' not found"
+ ok "ctdb_sys_check_iface_exists: Interface 'fake' not found"
else
- ok "../common/system_linux.c:LINE failed to open raw socket"
+ ok "ctdb_sys_check_iface_exists: Failed to open raw socket"
fi
unit_test porting_tests --socket=${socket}