Don't check interface of inbound message if interfaces are not filtered

We don't have a proper kernel-net interface on Android yet, so the check
for a usable interface does not work there.
This commit is contained in:
Tobias Brunner
2012-09-24 17:12:18 +02:00
parent 64595464b2
commit 2e2feffb67
3 changed files with 19 additions and 7 deletions
+3 -2
View File
@@ -447,8 +447,9 @@ static job_requeue_t receive_packets(private_receiver_t *this)
dst = packet->get_destination(packet); dst = packet->get_destination(packet);
src = packet->get_source(packet); src = packet->get_source(packet);
if (!hydra->kernel_interface->get_interface(hydra->kernel_interface, if (!hydra->kernel_interface->all_interfaces_usable(hydra->kernel_interface)
dst, NULL)) && !hydra->kernel_interface->get_interface(hydra->kernel_interface,
dst, NULL))
{ {
DBG3(DBG_NET, "received packet from %#H to %#H on ignored interface", DBG3(DBG_NET, "received packet from %#H to %#H on ignored interface",
src, dst); src, dst);
+8 -4
View File
@@ -389,6 +389,12 @@ METHOD(kernel_interface_t, is_interface_usable, bool,
NULL, iface) == expected; 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, METHOD(kernel_interface_t, get_address_by_ts, status_t,
private_kernel_interface_t *this, traffic_selector_t *ts, host_t **ip) 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, .enable_udp_decap = _enable_udp_decap,
.is_interface_usable = _is_interface_usable, .is_interface_usable = _is_interface_usable,
.all_interfaces_usable = _all_interfaces_usable,
.get_address_by_ts = _get_address_by_ts, .get_address_by_ts = _get_address_by_ts,
.add_ipsec_interface = _add_ipsec_interface, .add_ipsec_interface = _add_ipsec_interface,
.remove_ipsec_interface = _remove_ipsec_interface, .remove_ipsec_interface = _remove_ipsec_interface,
@@ -725,12 +732,9 @@ kernel_interface_t *kernel_interface_create()
"%s.interfaces_use", NULL, hydra->daemon); "%s.interfaces_use", NULL, hydra->daemon);
if (!ifaces) if (!ifaces)
{ {
this->ifaces_exclude = TRUE;
ifaces = lib->settings->get_str(lib->settings, ifaces = lib->settings->get_str(lib->settings,
"%s.interfaces_ignore", NULL, hydra->daemon); "%s.interfaces_ignore", NULL, hydra->daemon);
if (ifaces)
{
this->ifaces_exclude = TRUE;
}
} }
if (ifaces) if (ifaces)
{ {
+8 -1
View File
@@ -312,7 +312,7 @@ struct kernel_interface_t {
* @param name allocated interface name (optional) * @param name allocated interface name (optional)
* @return TRUE if interface found and usable * @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. * Creates an enumerator over all local addresses.
@@ -415,6 +415,13 @@ struct kernel_interface_t {
*/ */
bool (*is_interface_usable)(kernel_interface_t *this, const char *iface); 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 * Tries to find an IP address of a local interface that is included in the
* supplied traffic selector. * supplied traffic selector.