3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-22 04:32:37 +01:00

treewide: Parse EnableNetworkConfiguration in one place

Add netconfig_enabled() and use that in all places that want to know
whether network configuration is enabled.  Drop the enable_network_config
deprecated setting, which was only being handled in one of these 5 or so
places.
This commit is contained in:
Andrew Zaborowski 2021-10-21 10:50:30 +02:00 committed by Denis Kenzior
parent 04773eaa2c
commit 23799d0cb4
7 changed files with 23 additions and 43 deletions

View File

@ -53,6 +53,7 @@
#include "src/wscutil.h"
#include "src/eap-wsc.h"
#include "src/ip-pool.h"
#include "src/netconfig.h"
#include "src/ap.h"
#include "src/storage.h"
#include "src/diagnostic.h"
@ -132,7 +133,6 @@ struct ap_wsc_pbc_probe_record {
uint64_t timestamp;
};
static bool netconfig_enabled;
static char **global_addr4_strs;
static uint32_t netdev_watch;
static struct l_netlink *rtnl;
@ -2826,7 +2826,7 @@ static int ap_load_ipv4(struct ap_state *ap, const struct l_settings *config)
unsigned int lease_time = 0;
struct in_addr ia;
if (!l_settings_has_group(config, "IPv4") || !netconfig_enabled)
if (!l_settings_has_group(config, "IPv4") || !netconfig_enabled())
return 0;
if (l_settings_has_key(config, "IPv4", "Address")) {
@ -3829,12 +3829,7 @@ static int ap_init(void)
* Enable network configuration and DHCP only if
* [General].EnableNetworkConfiguration is true.
*/
if (!l_settings_get_bool(settings, "General",
"EnableNetworkConfiguration",
&netconfig_enabled))
netconfig_enabled = false;
if (netconfig_enabled) {
if (netconfig_enabled()) {
if (l_settings_get_value(settings, "IPv4", "APAddressPool")) {
global_addr4_strs = l_settings_get_string_list(settings,
"IPv4",

View File

@ -34,6 +34,7 @@
#include "src/iwd.h"
#include "src/module.h"
#include "src/netdev.h"
#include "src/netconfig.h"
#include "src/ip-pool.h"
struct ip_pool_addr4_record {
@ -357,15 +358,7 @@ static void ip_pool_addr4_dump_cb(int error,
static int ip_pool_init(void)
{
const struct l_settings *settings = iwd_get_config();
bool netconfig_enabled;
if (!l_settings_get_bool(settings, "General",
"EnableNetworkConfiguration",
&netconfig_enabled))
netconfig_enabled = false;
if (!netconfig_enabled)
if (!netconfig_enabled())
return 0;
rtnl = iwd_get_rtnl();

View File

@ -42,6 +42,7 @@
#include "src/rfkill.h"
#include "src/storage.h"
#include "src/anqp.h"
#include "src/netconfig.h"
#include "src/backtrace.h"
@ -217,19 +218,13 @@ static struct l_dbus_message *iwd_dbus_get_info(struct l_dbus *dbus,
struct l_dbus_message *reply;
struct l_dbus_message_builder *builder;
L_AUTO_FREE_VAR(char *, storage_dir) = storage_get_path(NULL);
bool netconfig_enabled;
if (!l_settings_get_bool(iwd_config, "General",
"EnableNetworkConfiguration",
&netconfig_enabled))
netconfig_enabled = false;
bool b = netconfig_enabled();
reply = l_dbus_message_new_method_return(message);
builder = l_dbus_message_builder_new(reply);
l_dbus_message_builder_enter_array(builder, "{sv}");
dbus_append_dict_basic(builder, "NetworkConfigurationEnabled", 'b',
&netconfig_enabled);
dbus_append_dict_basic(builder, "NetworkConfigurationEnabled", 'b', &b);
dbus_append_dict_basic(builder, "StateDirectory", 's', storage_dir);
dbus_append_dict_basic(builder, "Version", 's', VERSION);

View File

@ -1581,6 +1581,15 @@ void netconfig_destroy(struct netconfig *netconfig)
netconfig_free(netconfig);
}
bool netconfig_enabled(void)
{
bool enabled;
return l_settings_get_bool(iwd_get_config(), "General",
"EnableNetworkConfiguration",
&enabled) && enabled;
}
static int netconfig_init(void)
{
uint32_t r;

View File

@ -46,3 +46,5 @@ void netconfig_handle_fils_ip_resp(struct netconfig *netconfig,
struct netconfig *netconfig_new(uint32_t ifindex);
void netconfig_destroy(struct netconfig *netconfig);
bool netconfig_enabled(void);

View File

@ -35,6 +35,7 @@
#include "src/iwd.h"
#include "src/module.h"
#include "src/dbus.h"
#include "src/netconfig.h"
#include "src/resolve.h"
struct resolve_ops {
@ -579,18 +580,9 @@ static const struct {
static int resolve_init(void)
{
const char *method_name;
bool enabled;
uint8_t i;
if (!l_settings_get_bool(iwd_get_config(), "General",
"EnableNetworkConfiguration",
&enabled)) {
if (!l_settings_get_bool(iwd_get_config(), "General",
"enable_network_config", &enabled))
enabled = false;
}
if (!enabled)
if (!netconfig_enabled())
return 0;
method_name = l_settings_get_value(iwd_get_config(), "Network",

View File

@ -63,7 +63,6 @@ static uint32_t netdev_watch;
static uint32_t mfp_setting;
static uint32_t roam_retry_interval;
static bool anqp_disabled;
static bool netconfig_enabled;
static struct watchlist event_watches;
struct station {
@ -3872,7 +3871,7 @@ static struct station *station_create(struct netdev *netdev)
l_dbus_object_add_interface(dbus, netdev_get_path(netdev),
IWD_STATION_INTERFACE, station);
if (netconfig_enabled)
if (netconfig_enabled())
station->netconfig = netconfig_new(netdev_get_ifindex(netdev));
station->anqp_pending = l_queue_new();
@ -4455,12 +4454,7 @@ static int station_init(void)
&anqp_disabled))
anqp_disabled = true;
if (!l_settings_get_bool(iwd_get_config(), "General",
"EnableNetworkConfiguration",
&netconfig_enabled))
netconfig_enabled = false;
if (!netconfig_enabled)
if (!netconfig_enabled())
l_info("station: Network configuration is disabled.");
watchlist_init(&event_watches, NULL);