ctdb-daemon: Use ctdb_find_iface() instead of duplicating logic
authorMartin Schwenke <martin@meltin.net>
Thu, 25 Aug 2016 01:41:11 +0000 (11:41 +1000)
committerAmitay Isaacs <amitay@samba.org>
Thu, 8 Sep 2016 04:57:21 +0000 (06:57 +0200)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_takeover.c

index 6843f9b103170643ca03d63bf34a245aedd0a389..1540e367394d4310e1278aacefbdeab86ca61470 100644 (file)
@@ -103,6 +103,9 @@ static const char *ctdb_vnn_iface_string(const struct ctdb_vnn *vnn)
        return iface_string(vnn->iface);
 }
 
+static struct ctdb_interface *ctdb_find_iface(struct ctdb_context *ctdb,
+                                             const char *iface);
+
 static struct ctdb_interface *
 ctdb_add_local_iface(struct ctdb_context *ctdb, const char *iface)
 {
@@ -114,10 +117,9 @@ ctdb_add_local_iface(struct ctdb_context *ctdb, const char *iface)
        }
 
        /* Verify that we don't have an entry for this ip yet */
-       for (i=ctdb->ifaces;i;i=i->next) {
-               if (strcmp(i->name, iface) == 0) {
-                       return i;
-               }
+       i = ctdb_find_iface(ctdb, iface);
+       if (i != NULL) {
+               return i;
        }
 
        /* create a new structure for this interface */