check that the actual interface exist, print error and fail startup if the interface does not exist.
}
+bool ctdb_sys_check_iface_exists(const char *iface)
+{
+ return true;
+}
close(s);
return ret == 0;
}
+
+
}
+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;
+}
uint32_t uint16_checksum(uint16_t *data, size_t n);
int ctdb_sys_send_arp(const ctdb_sock_addr *addr, const char *iface);
bool ctdb_sys_have_ip(ctdb_sock_addr *addr);
+bool ctdb_sys_check_iface_exists(const char *iface);
int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
const ctdb_sock_addr *src,
uint32_t seq, uint32_t ack, int rst);
int i;
int ret;
+ tmp = talloc_strdup(vnn, ifaces);
+ for (iface = strtok(tmp, ","); iface; iface = strtok(NULL, ",")) {
+ if (!ctdb_sys_check_iface_exists(iface)) {
+ DEBUG(DEBUG_CRIT,("Interface %s does not exist. Can not add public-address : %s\n", iface, ctdb_addr_to_str(addr)));
+ talloc_free(tmp);
+ return -1;
+ }
+ }
+ talloc_free(tmp);
+
/* Verify that we dont have an entry for this ip yet */
for (vnn=ctdb->vnn;vnn;vnn=vnn->next) {
if (ctdb_same_sockaddr(addr, &vnn->public_address)) {