aboutsummaryrefslogtreecommitdiffstats
path: root/extcap.c
diff options
context:
space:
mode:
authorJohn Thacker <johnthacker@gmail.com>2024-02-14 20:22:00 -0500
committerAndersBroman <a.broman58@gmail.com>2024-02-18 20:23:39 +0000
commit4fb2ef8af871682905b29cc1f3dbbfaba41c9e38 (patch)
treee1ff6528baa15cf9d406c7ed1668786e87eb1503 /extcap.c
parent48bb12831bac88c338011b99ff9e5518c3da23fa (diff)
extcap: Really don't load extcap interfaces if disabled
If the capture.no_extcap preference is set, really don't load the extcap interfaces. Previously, the extcap interfaces were loaded before the preference was read, because otherwise the extcap preferences wouldn't be registered and properly read out of the configuration file. Wait until after that preference is read to register the extcap preferences and then re-read just the extcap module preferences from the configuration files. Make sure to check other times when the preference may be changed, such as switching profiles. Write extcap prefs to a separate file so that they don't get lost if the extcap interfaces aren't loaded and the prefs are then written out. Continue writing them to the main file for backwards compability. Related to #15295. Cuts ~100 ms off the loading time of Wireshark in a normal situation if the capture.no_extcap preference is set, more if an extcap has some kind of issue that makes it take a long time to load.
Diffstat (limited to 'extcap.c')
-rw-r--r--extcap.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/extcap.c b/extcap.c
index 72a09c586d..de9a859559 100644
--- a/extcap.c
+++ b/extcap.c
@@ -31,6 +31,7 @@
#include <glib.h>
#include <epan/prefs.h>
+#include <epan/prefs-int.h>
#include "ui/iface_toolbar.h"
@@ -740,6 +741,12 @@ append_extcap_interface_list(GList *list)
void extcap_register_preferences(void)
{
+ /* Unconditionally register the extcap configuration file, so that
+ * it is copied if we copy the profile even if we're not going to
+ * read it because extcaps are disabled.
+ */
+ profile_register_persconffile("extcap");
+
if (prefs.capture_no_extcap)
return;
@@ -862,6 +869,7 @@ extcap_pref_for_argument(const gchar *ifname, struct _extcap_arg *arg)
static gboolean cb_preference(extcap_callback_info_t cb_info)
{
+ gboolean new_pref = false;
GList *arguments = NULL;
GList **il = (GList **) cb_info.data;
module_t *dev_module = NULL;
@@ -894,7 +902,7 @@ static gboolean cb_preference(extcap_callback_info_t cb_info)
{
char *pref_name_for_prefs;
char *pref_title = wmem_strdup(wmem_epan_scope(), arg->display);
-
+ new_pref = TRUE;
arg->pref_valptr = extcap_prefs_dynamic_valptr(pref_ifname, &pref_name_for_prefs);
/* Set an initial value if any (the string will be copied at registration) */
if (arg->default_complex)
@@ -945,7 +953,7 @@ static gboolean cb_preference(extcap_callback_info_t cb_info)
extcap_free_arg_list(arguments);
}
- return TRUE;
+ return new_pref;
}
GList *
@@ -2154,6 +2162,7 @@ extcap_list_interfaces_cb(thread_pool_t *pool, void *data, char *output)
static void
extcap_load_interface_list(void)
{
+ bool prefs_registered = false;
if (prefs.capture_no_extcap)
return;
@@ -2219,12 +2228,17 @@ extcap_load_interface_list(void)
.output = iface_info->output,
.data = NULL,
};
- cb_preference(cb_info);
+ prefs_registered = cb_preference(cb_info);
}
}
extcap_free_extcaps_info_array(infos, count);
g_free(arg_version);
}
+
+ if (prefs_registered)
+ {
+ prefs_read_module("extcap");
+ }
}
/*