Don't check interface of inbound message if interfaces are not filtered
authorTobias Brunner <tobias@strongswan.org>
Sun, 23 Sep 2012 07:14:26 +0000 (09:14 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 24 Sep 2012 15:12:18 +0000 (17:12 +0200)
We don't have a proper kernel-net interface on Android yet, so the check
for a usable interface does not work there.

src/libcharon/network/receiver.c
src/libhydra/kernel/kernel_interface.c
src/libhydra/kernel/kernel_interface.h

index 143d46f..2f87a5e 100644 (file)
@@ -447,8 +447,9 @@ static job_requeue_t receive_packets(private_receiver_t *this)
 
        dst = packet->get_destination(packet);
        src = packet->get_source(packet);
-       if (!hydra->kernel_interface->get_interface(hydra->kernel_interface,
-                                                                                               dst, NULL))
+       if (!hydra->kernel_interface->all_interfaces_usable(hydra->kernel_interface)
+               && !hydra->kernel_interface->get_interface(hydra->kernel_interface,
+                                                                                                  dst, NULL))
        {
                DBG3(DBG_NET, "received packet from %#H to %#H on ignored interface",
                         src, dst);
index 7bfda24..5320ee2 100644 (file)
@@ -389,6 +389,12 @@ METHOD(kernel_interface_t, is_interface_usable, bool,
                                                                                   NULL, iface) == expected;
 }
 
+METHOD(kernel_interface_t, all_interfaces_usable, bool,
+       private_kernel_interface_t *this)
+{
+       return this->ifaces_filter == NULL;
+}
+
 METHOD(kernel_interface_t, get_address_by_ts, status_t,
        private_kernel_interface_t *this, traffic_selector_t *ts, host_t **ip)
 {
@@ -698,6 +704,7 @@ kernel_interface_t *kernel_interface_create()
                        .enable_udp_decap = _enable_udp_decap,
 
                        .is_interface_usable = _is_interface_usable,
+                       .all_interfaces_usable = _all_interfaces_usable,
                        .get_address_by_ts = _get_address_by_ts,
                        .add_ipsec_interface = _add_ipsec_interface,
                        .remove_ipsec_interface = _remove_ipsec_interface,
@@ -725,12 +732,9 @@ kernel_interface_t *kernel_interface_create()
                                        "%s.interfaces_use", NULL, hydra->daemon);
        if (!ifaces)
        {
+               this->ifaces_exclude = TRUE;
                ifaces = lib->settings->get_str(lib->settings,
                                        "%s.interfaces_ignore", NULL, hydra->daemon);
-               if (ifaces)
-               {
-                       this->ifaces_exclude = TRUE;
-               }
        }
        if (ifaces)
        {
index c09f07b..88d4a5b 100644 (file)
@@ -312,7 +312,7 @@ struct kernel_interface_t {
         * @param name                  allocated interface name (optional)
         * @return                              TRUE if interface found and usable
         */
-       bool (*get_interface) (kernel_interface_t *this, host_t *host, char **name);
+       bool (*get_interface)(kernel_interface_t *this, host_t *host, char **name);
 
        /**
         * Creates an enumerator over all local addresses.
@@ -416,6 +416,13 @@ struct kernel_interface_t {
        bool (*is_interface_usable)(kernel_interface_t *this, const char *iface);
 
        /**
+        * Check if interfaces are excluded by config.
+        *
+        * @return                              TRUE if no interfaces are exclued by config
+        */
+       bool (*all_interfaces_usable)(kernel_interface_t *this);
+
+       /**
         * Tries to find an IP address of a local interface that is included in the
         * supplied traffic selector.
         *