From b4abda09c79e4ce372a3771300abf568c85c7ff5 Mon Sep 17 00:00:00 2001 From: Fabrice Bellet Date: Thu, 21 Apr 2016 18:18:59 +0200 Subject: [PATCH] interfaces: ignore predefined network interfaces Some interfaces, like the one managed by libvirtd to provide a network bridge to locally hosted virtual machines, can be completely ignored when gathering ICE candidates. The motivation for adding this possibility is that, ignoring them doesn't remove capabilities, and improves the overall speed of the connection check method, by reducing the number of pairs to be tested. This patch adds the possibility to define such interfaces in the configuration script. Differential Revision: https://phabricator.freedesktop.org/D948 --- agent/interfaces.c | 6 ++++++ configure.ac | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/agent/interfaces.c b/agent/interfaces.c index 0fa2fd7..a81888e 100644 --- a/agent/interfaces.c +++ b/agent/interfaces.c @@ -276,6 +276,12 @@ nice_interfaces_get_local_ips (gboolean include_loopback) nice_debug ("Ignoring loopback interface"); g_free (addr_string); } +#ifdef IGNORED_IFACE_PREFIX + } else if (g_str_has_prefix (ifa->ifa_name, IGNORED_IFACE_PREFIX)) { + nice_debug ("Ignoring interface %s as it matches prefix %s", + ifa->ifa_name, IGNORED_IFACE_PREFIX); + g_free (addr_string); +#endif } else { if (nice_interfaces_is_private_ip (ifa->ifa_addr)) ips = add_ip_to_list (ips, addr_string, TRUE); diff --git a/configure.ac b/configure.ac index b39bfe3..98bbc08 100644 --- a/configure.ac +++ b/configure.ac @@ -354,6 +354,20 @@ AM_CONDITIONAL([ENABLE_GTK_DOC], false) # GObject introspection GOBJECT_INTROSPECTION_CHECK([1.30.0]) +dnl Ignore a specific network interface name prefix from the connection check +AC_MSG_CHECKING([whether to ignore a specific network interface name prefix]) +AC_ARG_WITH([ignored-network-interface-prefix], + [AS_HELP_STRING([--with-ignored-network-interface-prefix=string], + [Ignore network interfaces whose name starts with "string" from the ICE connection + check algorithm. For example, interfaces "virbr" in the case of the virtual bridge + handled by libvirtd, do not help in finding connectivity.])], + [interface_prefix="$withval"]) +AS_IF([test -n "$interface_prefix"], + [AC_DEFINE_UNQUOTED([IGNORED_IFACE_PREFIX],["$interface_prefix"], + [Ignore this network interface prefix from the connection check]) + AC_MSG_RESULT([yes, $interface_prefix])], + [AC_MSG_RESULT([no])]) + AC_CONFIG_MACRO_DIR(m4) AC_OUTPUT -- 2.7.4