Use proper address family when adding multiple addresses to SQL pool
authorTobias Brunner <tobias@strongswan.org>
Mon, 18 Mar 2013 18:11:10 +0000 (19:11 +0100)
committerTobias Brunner <tobias@strongswan.org>
Tue, 19 Mar 2013 15:33:07 +0000 (16:33 +0100)
src/libhydra/plugins/attr_sql/pool.c

index f355e96..880af61 100644 (file)
@@ -495,6 +495,21 @@ static void add_addresses(char *pool, char *path, int timeout)
                fclose(file);
        }
 
+       if (family == AF_INET6)
+       {       /* update address family if necessary */
+               addr = host_create_from_string("%any6", 0);
+               if (db->execute(db, NULL,
+                                       "UPDATE pools SET start = ?, end = ? WHERE id = ?",
+                                       DB_BLOB, addr->get_address(addr),
+                                       DB_BLOB, addr->get_address(addr), DB_UINT, pool_id) <= 0)
+               {
+                       addr->destroy(addr);
+                       fprintf(stderr, "updating pool address family failed.\n");
+                       exit(EXIT_FAILURE);
+               }
+               addr->destroy(addr);
+       }
+
        commit_transaction();
 
        printf("%d addresses done.\n", count);