Commit Graph

36 Commits

Author SHA1 Message Date
Beniamino Galvani
0c2576e4bf core: allow setting SR-IOV num_vfs
(cherry picked from commit 32975b6aa5)
2017-04-19 08:49:37 +02:00
Thomas Haller
e68cc17f43 build: fix -Wignored-qualifiers warnings
./src/nm-config-data.h:163:1: error: 'const' type qualifier on return type has no effect [-Werror,-Wignored-qualifiers]
    const guint nm_config_data_get_connectivity_interval (const NMConfigData *config_data);
    ^~~~~~
2017-02-06 19:27:21 +01:00
Thomas Haller
6689d0bf71 config: optionally let nm_config_get_plugins() return compile time default
Instead of having the caller do the fallback to the compile time default
plugins, let it be handled by nm_config_get_plugins().

The knowledge of fallback to a compile time default (and how to do that
properly) should be inside NMConfig/NMConfigData alone.

Also, as this function is only called once, let NMConfig not cache
the string list but create it once as needed.
2016-11-25 15:26:30 +01:00
Thomas Haller
4d37f7a1e9 core: refactor private data in "src"
- use _NM_GET_PRIVATE() and _NM_GET_PRIVATE_PTR() everywhere.

- reorder statements, to have GObject related functions (init, dispose,
  constructed) at the bottom of each file and in a consistent order w.r.t.
  each other.

- unify whitespaces in signal and properties declarations.

- use NM_GOBJECT_PROPERTIES_DEFINE() and _notify()

- drop unused signal slots in class structures

- drop unused header files for device factories
2016-10-04 09:50:56 +02:00
Thomas Haller
3cda2df12b config: add support for per-device configuration to NetworkManager.conf
Add a new [device*] section to NetworkManager.conf. This works similar
like the default connection settings in [connection*].

This will allow us to express per-device configuration in NetworkManager.conf
in our familar style.

Later, via NMConfig's write API it will be possible to make settings
accessible via D-Bus and persist them in NetworkManager-intern.conf.
This way, the user can both edit configuration snippets and modify
them via D-Bus, and also support installing default configuration
from the package.

In a way, a [device*] setting is similar to networkd's link files.
The match options is all encoded in the match-device specs.
One difference is, that the resulting setting can be merged together
by multiple section by partially overwriting them. This makes it
more flexible and allows for example to drop a configuration snippet
that only sets one property, while the rest can be merged from different
snippets.
2016-06-30 08:07:35 +02:00
Thomas Haller
2c411e9070 config: cleanup includes 2016-06-01 19:06:35 +02:00
Thomas Haller
0acee97220 config,dns: support Reload flags to specify that only parts should be reloaded
Support 3 new flags for Reload:

  - 0x01 (CONF): reload the configuration from disk
  - 0x02 (DNS_RC): write DNS configuration to resolv.conf
  - 0x04 (DNS_FULL): restart DNS plugin

Omitting all flags is the same as reloading everything, thus SIGHUP.
2016-06-01 19:06:34 +02:00
Thomas Haller
eb6140a772 config: refactor change-flags to be a cause/reason which triggered the change
For the most part, this patch just renames some change-flags, but
doesn't change much about them. The new name should better express
what they are.

A config-change signal can be emitted for different reasons:
when we receive a signal (SIGHUP, SIGUSR1, SIGUSR2) or for internal
reasons like resetting of no-auto-default or setting internal
values.

Depending on the reason, we want to perform different actions.
For example:
 - we reload the configuration from disk on SIGHUP, but not for
   SIGUSR1.
 - For SIGUSR1 and SIGHUP, we want to update-dns, but not for SIGUSR2.

Another part of the change-flags encodes which part of the configuration
actually changed. Often, these parts can only change when re-reading
from disk (e.g. a SIGUSR1 will not change any configuration inside
NMConfig).

Later, we will have more causes, and accordingly more fine-grained
effects of what should be done on reload.
2016-06-01 19:06:34 +02:00
Thomas Haller
e1ea4b725e main: add argument --print-config to NetworkManager 2015-11-22 13:40:32 +01:00
Beniamino Galvani
c83ac1ed41 manager: export DNS global configuration D-Bus property 2015-10-01 09:05:08 +02:00
Beniamino Galvani
ae9e82354a dns: add support for global configuration in DNS manager
Modify the DNS manager to use the static global DNS configuration when
available. In addition, change DNS plugins interface to accept a new
argument for global configuration and add support for this new
parameter to the dnsmasq plugin.
2015-10-01 09:05:08 +02:00
Beniamino Galvani
55c204b9a3 core: add support for reading global DNS configuration from keyfile
Add to the NMConfigData object information about global DNS
configuration, which is loaded from user or internal keyfile upon
object construction.
2015-10-01 09:05:08 +02:00
Thomas Haller
19c3ea948a all: make use of new header file "nm-default.h" 2015-08-05 15:32:40 +02:00
Dan Winship
3452ee2a0e all: rename nm-glib-compat.h to nm-glib.h, use everywhere
Rather than randomly including one or more of <glib.h>,
<glib-object.h>, and <gio/gio.h> everywhere (and forgetting to include
"nm-glib-compat.h" most of the time), rename nm-glib-compat.h to
nm-glib.h, include <gio/gio.h> from there, and then change all .c
files in NM to include "nm-glib.h" rather than including the glib
headers directly.

(Public headers files still have to include the real glib headers,
since nm-glib.h isn't installed...)

Also, remove glib includes from header files that are already
including a base object header file (which must itself already include
the glib headers).
2015-07-24 13:25:47 -04:00
Thomas Haller
aa54d5a36e config: add nm_config_data_get_value_cached() function
nm_config_data_get_value() returns an allocated string. This is inconvenient
for the caller. Add a utility function nm_config_data_get_value_cached() that
caches the returned value. Of course, use with care as the returned string
will be invalidated by each call to nm_config_data_get_value_cached().
2015-07-14 15:52:50 +02:00
Thomas Haller
40c57fa7f1 config: add write support to atomic-sections
We already support setting configuration values, either:
 (1) set any internal section, i.e. groups starting with [.intern*].
     Those values don't ever interfere with that the user can
     configure.
 (2) set individual properties that overwrite user configuration.
     When doing that, we record the value from user configuration
     and on load, we reject our internal overwrite if the user
     configuration changed in the meantime.
     This is done by storing the values with ".set." and ".was." prefixes.

Now add support for "atomic sections". In this case, certain groups
can be marked as "atomic". When writing to such sections, we overwrite
the entire user-provided setting.
We also record the values from user configuration, and reject our
internal value if we notice modifications. This basically extends
(2) from individual properties to the entire section.
2015-07-02 16:01:20 +02:00
Thomas Haller
947fc9a278 config: add write support for NMConfig
Internal configuration is written as keyfile to
NMSTATEDIR"/NetworkManager-intern.conf"

Basically, the content of this file is merged with user
configuration from "NetworkManager.conf" files. After loading
the configuration, NMConfig exposes a merged view of user-provided
settings and internal overwrites.

All sections/groups named [.intern*] are reserved for internal
configuration values. They can be written by API, but are ignored
when the user sets them via "NetworkManager.conf". For these
internal sections, no conflicts can arise.

We can also overwrite individual properties from user configuration.
In this case, we store the value we want to set, but also remember
the value that the user configuration had, at the time of setting.
If on a later reload the user configuration changed, we ignore our
internal value -- as we assume that the user modified the value
afterwards.
We can also hide/delete value from user configuration.
This works on a per-setting basis.
2015-07-02 16:01:20 +02:00
Thomas Haller
d3e2193783 config: add NMConfigGetValueFlags argument to nm_config_data_get_value()
In some cases we want the returned value to be stripped. In some cases,
we want to read the raw value instead of the string parsed by GKeyFile.
Add an flags argument to nm_config_data_get_value(). It is up to the caller
to determine the exact meaning (and whether to strip).

By adding the flags argument, the caller can get the desired behavior easier
without having to workaround it afterwards. But more importantly, it becomes
apparent that there are different ways to retrieve the value and the caller
should decide on the details.
2015-07-02 15:50:04 +02:00
Thomas Haller
11c0e107b9 config: add config utility accessors 2015-07-02 15:50:04 +02:00
Thomas Haller
b506c29fe1 config: log configuration at startup and on reload 2015-07-02 15:50:04 +02:00
Thomas Haller
a0e92799af config: add nm_config_data_get_value_boolean() 2015-07-02 15:50:04 +02:00
Thomas Haller
a5f7abb842 config: get rid of @error argument to nm_config_data_get_value()
We don't use this argument. A failure to retrieve a key is (for
every practical purpose) the same as no such key.
2015-07-02 15:50:03 +02:00
Thomas Haller
3e4458659b config: fix evaluation of no-auto-default setting
We used to merge the spec list for no-auto-default from keyfile with the
content of the state file. Since the addition of the "except:" spec this
is wrong.
For example, if the user configured:

  no-auto-default=except:mac:11:11:11:11:11

and statefile contained "11:11:11:11:11" and "22:22:22:22:22", we would
wrongly not match "11:11:11:11:11". The two lists must be kept separate,
so that devices that are blocked by internal decision always match.

This separation is also clearer. Now the spec list is devided into a
part that comes from user configuration, and a part that comes from
internal decision.
2015-07-02 15:50:03 +02:00
Thomas Haller
caed15e082 config: pass signals to nm_config_reload()
Also react on SIGUSR1 and SIGUSR2, beside SIGHUP.
Only for SIGHUP actually reload the configuration from
disc. For the other signals only emit a config-changed
signal.
2015-06-25 22:02:18 +02:00
Thomas Haller
dc0193ac02 config: support a [connection] section to NetworkManager.conf to specify connection defaults
Add support for a new section [connection] in NetworkManager.conf.
If the connection leaves an option at "unknown"/"default", we can
support overwriting the value from global configuration.

We also support other sections that are named with "connection"
as a prefix, such as [connection2], [connection-wifi]. This is
to support multiple default values that can be applied depending
on the used device.

I think this has great potential. Only downside is that when
the user looks at a connection value, it will see that it is
unspecified. But the actually used value depends on the device
type and might not be obvious.

https://bugzilla.gnome.org/show_bug.cgi?id=695383
https://bugzilla.redhat.com/show_bug.cgi?id=1164677
2015-06-05 12:38:29 +02:00
Beniamino Galvani
3bc097b084 device: don't assume by default IPv6LL-only connections
Add the new configuration option 'assume-ipv6ll-only' which specifies
the devices for which NM will try to assume an existing IPv6LL-only
configuration.

The new default behavior is to ignore such configurations since IPv6LL
addresses are automatically assigned by the kernel when the device is
brought up and thus the presence of an IPv6LL address doesn't mean
that the device was configured by the administrator.

The previous behavior was to always assume IPv6LL-only configurations
but this often had the unwanted effect of preventing other on-disk
configurations to be activated. To preserve the old behavior the
option must be set to '*'.

https://bugzilla.redhat.com/show_bug.cgi?id=1138426
2015-06-02 14:04:54 +02:00
Thomas Haller
2d333a1769 config: make ignore-carrier option reloadable
Only move the ignore-carrier option from NMConfig to
NMConfigData. The ignore-carrier option is still
immutable after startup.

https://bugzilla.gnome.org/show_bug.cgi?id=748050
2015-05-05 16:51:19 +02:00
Beniamino Galvani
e573977b80 dns: allow runtime selection of resolv.conf manager
Add a new 'rc-manager' configuration parameter that allows to select
the strategy used to write resolv.conf; currently supported values
are: none|resolvconf|netconfig, 'none' meaning that NM directly writes
the file.

The default value of the parameter is 'none'; however if a
RESOLVCONF_PATH (or NETCONFIG_PATH) is specified at build time, the
default value will be 'resolvconf' (or 'netconfig').
2015-05-04 09:42:25 +02:00
Lubomir Rintel
aa672b2dc2 config: move dns mode configuration to NMConfigData
This will make is possible for the NMDnsManager to watch for
configuration changes.
2015-02-25 18:25:04 +01:00
Thomas Haller
5b47462f32 config: use flags argument in config-changed signal instead of a hash table 2015-02-03 13:01:54 +01:00
Thomas Haller
13c7f6a56d config: move no-auto-default to NMConfigData
With this change, NMConfig is really immutable and all
modifyable parts migrated to NMConfigData.

Another advantage is that components can now subscribe to
NMConfig changes to pickup changes to no-auto-default.
2015-02-03 13:01:53 +01:00
Thomas Haller
ba74f9d242 config: move keyfile values to NMConfigData 2015-02-03 13:01:53 +01:00
Thomas Haller
045a576a7a config: add new function nm_config_data_diff() 2015-02-03 13:01:53 +01:00
Thomas Haller
56f5fba723 config: move main_file and description to NMConfigData
Every reload might change the main_file and description.
Move those properties to NMConfigData.
2015-02-03 13:01:53 +01:00
Thomas Haller
699b12ddc9 config: refactor reloading not to create a second NMConfig instance 2015-02-03 13:01:53 +01:00
Thomas Haller
076478505d config: add new NMConfigData class
The NMConfig class should be immutable and its properties should
not change, with one exception: the NMConfigData property.

Later, when changing/reloading a configuration, NMConfig will only swap
the NMConfigData instance.

The NMConfigData instance itself is also immutable.
2015-02-03 13:01:53 +01:00