diff options
author | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2011-09-06 17:29:30 +1000 |
---|---|---|
committer | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2011-09-06 17:29:30 +1000 |
commit | b0fdfd8ec9a035c4c66e6a146b43f9a0a27da707 (patch) | |
tree | 0b80f624c9a79e26b54974c4656603dc131d3735 /ctdb/common/system_linux.c | |
parent | 2e5b0f1eb27fddfb5cdd0a705ad0057eb5f29292 (diff) | |
parent | 783ceca07b1283e5818d407ff212900be9547379 (diff) | |
download | samba-b0fdfd8ec9a035c4c66e6a146b43f9a0a27da707.tar.gz samba-b0fdfd8ec9a035c4c66e6a146b43f9a0a27da707.tar.xz samba-b0fdfd8ec9a035c4c66e6a146b43f9a0a27da707.zip |
Merge branch 'master' of 10.1.1.27:/shared/ctdb/ctdb-master
(This used to be ctdb commit a3e8784bb107f7acd2a95913c1e6def52ce96105)
Diffstat (limited to 'ctdb/common/system_linux.c')
-rw-r--r-- | ctdb/common/system_linux.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/ctdb/common/system_linux.c b/ctdb/common/system_linux.c index a498ab2d68..2dcdffb3ec 100644 --- a/ctdb/common/system_linux.c +++ b/ctdb/common/system_linux.c @@ -537,3 +537,25 @@ int ctdb_sys_read_tcp_packet(int s, void *private_data, } +bool ctdb_sys_check_iface_exists(const char *iface) +{ + int s; + struct ifreq ifr; + + s = socket(PF_PACKET, SOCK_RAW, 0); + if (s == -1){ + /* We dont know if the interface exists, so assume yes */ + DEBUG(DEBUG_CRIT,(__location__ " failed to open raw socket\n")); + return true; + } + + strncpy(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; +} |