kernel: Restore enumeration of all addresses when searching for address in TS
authorTobias Brunner <tobias@strongswan.org>
Wed, 21 Aug 2013 14:52:19 +0000 (16:52 +0200)
committerTobias Brunner <tobias@strongswan.org>
Wed, 21 Aug 2013 15:01:03 +0000 (17:01 +0200)
Since f52cf07532 addresses on ignored, down or loopback interfaces were
not considered as valid addresses anymore when searching for an address
contained in the local traffic selector.  This meant that route
installation failed, for instance, if charon.install_virtual_ip_on was
set to 'lo', or, on gateways, if internal interfaces were ignored with
the charon.interfaces_* options.

src/libhydra/kernel/kernel_interface.c

index 90637fa..68a8c3e 100644 (file)
@@ -447,7 +447,9 @@ METHOD(kernel_interface_t, get_address_by_ts, status_t,
        }
        host->destroy(host);
 
-       addrs = create_address_enumerator(this, ADDR_TYPE_VIRTUAL);
+       /* try virtual IPs only first (on all interfaces) */
+       addrs = create_address_enumerator(this,
+                                                                         ADDR_TYPE_ALL ^ ADDR_TYPE_REGULAR);
        while (addrs->enumerate(addrs, (void**)&host))
        {
                if (ts->includes(ts, host))
@@ -464,8 +466,9 @@ METHOD(kernel_interface_t, get_address_by_ts, status_t,
        addrs->destroy(addrs);
 
        if (!found)
-       {
-               addrs = create_address_enumerator(this, ADDR_TYPE_REGULAR);
+       {       /* then try the regular addresses (on all interfaces) */
+               addrs = create_address_enumerator(this,
+                                                                                 ADDR_TYPE_ALL ^ ADDR_TYPE_VIRTUAL);
                while (addrs->enumerate(addrs, (void**)&host))
                {
                        if (ts->includes(ts, host))