Commit Graph

21088 Commits

Author SHA1 Message Date
Thomas Haller
2b43ce3a94 libnm/keyfile: use NMMetaSettingInfo for indexing keyfile vtable
We have NMMetaSettingType enum, which is an enum of all setting types.
We also have an efficient way to get the enum (and its NMMetaSettingInfo)
from an NMSetting, setting-name and GType.

No longer maintain the vtable for keyfile by "setting-name". Instead,
index it by NMMetaSettingType enum.

That way, we get efficient lookup, and don't need to duplicate the
functionality of finding the vtable entry for a setting.
2018-08-10 10:38:19 +02:00
Thomas Haller
f77f74f273 shared: use binary search in nm_meta_setting_infos_by_name()
nm_meta_setting_infos_by_name() did a naive search by name by
iterating over all 42 setting types.

Reorder nm_meta_setting_infos array, and use binary search instead.
2018-08-10 10:38:19 +02:00
Thomas Haller
9c47e2ce30 libnm: use NMMetaSettingInfo for tracking setting priority
Previously, each (non abstract) NMSetting class had to register
its name and priority via _nm_register_setting().

Note, that libnm-core.la already links against "nm-meta-setting.c",
which also redundantly keeps track of the settings name and gtype
as well.

Re-use NMMetaSettingInfo also in libnm-core.la, to track this meta
data.

The goal is to get rid of private data structures that track
meta data about NMSetting classes. In this case, "registered_settings"
hash. Instead, we should have one place where all this meta data
is tracked. This was, it is also accessible as internal API,
which can be useful (for keyfile).

Note that NMSettingClass has some overlap with NMMetaSettingInfo.
One difference is, that NMMetaSettingInfo is const, while NMSettingClass
is only initialized during the class_init() method. Appart from that,
it's mostly a matter of taste, whether we attach meta data to
NMSettingClass, to NMMetaSettingInfo, or to a static-array indexed
by NMMetaSettingType.

Note, that previously, _nm_register_setting() was private API. That
means, no user could subclass a functioning NMSetting instance. The same
is still true: NMMetaSettingInfo is internal API and users cannot access
it to create their own NMSetting subclasses. But that is almost desired.
libnm is not designed, to be extensible via subclassing, nor is it
clear why that would be a useful thing to do. One day, we should remove
the NMSetting and NMSettingClass definitions from public headers. Their
only use is subclassing the types, which however does not work.

While libnm-core was linking already against nm-meta-setting.c,
nm_meta_setting_infos was unreferenced. So, this change increases
the binary size of libnm and NetworkManager (1032 bytes). Note however
that roughly the same information was previously allocated at runtime.
2018-08-10 10:38:19 +02:00
Thomas Haller
d70dcb16da cli: fix nmc_setting_get_valid_properties() to use setting metadata
Not all properties that we want to handle in nmcli are actual GObject
properties. For the moment that was the case, but that's about to change.

This is a change in behavior with respect of the order in which
properties are reported. For example, print_setting_description()
now prints the property descriptions in a different order. However,
one might argue that this order makes more sense because:

  - it's the same order as properties are listed in
    "nm-meta-setting-desc.c". At that place, we have explict
    control over the order and set it intentionally to suite
    our needs best. The order of the GObject properties is
    much less well defined.

  - the order from "nm-meta-setting-desc.c" is used at several other
    places. So, it makes sense to use the same order everywhere.
2018-08-10 10:38:19 +02:00
Thomas Haller
23adc37377 libnm/trivial: cleanup variable names in settings' class-init functions
- Don't use @parent_class name. This local variable (and @object_class) is
  the class instance up-cast to the pointer types of the parents. The point
  here is not that it is the direct parent. The point is, that it's the
  NMSettingClass type.
  Also, it can only be used inconsistently, in face of NMSettingIP4Config,
  who's parent type is NMSettingIPConfig. Clearly, inside
  nm-setting-ip4-config.c we wouldn't want to use the "parent_class"
  name. Consistently rename @parent_class to @setting_class.

- Also rename the pointer to the own class to @klass. "setting_class" is also the
  wrong name for that, because the right name would be something like
  "setting_6lowpan_class".
  However, "klass" is preferred over the latter, because we commonly create new
  GObject implementations by copying an existing one. Generic names like "klass"
  and "self" inside a type implementation make that simpler.

- drop useless comments like

     /* virtual functions */
     /* Properties */

  It's better to logically and visually structure the code, and avoid trival
  remarks about that. They only end up being used inconsistently. If you
  even need a stronger visual separator, then an 80 char /****/ line
  should be preferred.
2018-08-10 10:38:19 +02:00
Thomas Haller
19ef103e39 libnm-core/trivial: move code 2018-08-10 10:38:19 +02:00
Thomas Haller
a67a3439b0 libnm: minor rework checking property flags in _nm_setting_to_dbus()
Properties that are backed by a GObject property are fundamentally
different.

I think it's clearer to rework the check, to first check whether
we have a param_spec, and then implement different checks.
2018-08-10 10:38:19 +02:00
Thomas Haller
332592ef4f libnm: use nm_utils_hash_table_equal() in nm-setting-user 2018-08-10 10:38:19 +02:00
Thomas Haller
a587d32467 shared: move nm_utils_ptrarray_find_binary_search() to shared utils 2018-08-10 10:38:19 +02:00
Thomas Haller
d32da2daaa shared: move nm_utils_array_find_binary_search() to shared utils 2018-08-10 10:38:19 +02:00
Thomas Haller
b5bdfdc773 shared: add nm_utils_hash_table_equal() util
Add utility function to compare the content of two
hash tables for equality.
2018-08-10 10:38:19 +02:00
Thomas Haller
64f1e78e28 cli: drop NMCTriStateValue for NMTernary 2018-08-10 10:38:19 +02:00
Thomas Haller
bcbea6fe35 ifcfg-rh: refactor parsing in parse_ethtool_option() to not call helper functions
Parsing can be complicated enough. It's simpler to just work
top-to-bottom, without calling various helper functions. This was,
you can see all the code in one place, without need to jump to
the helper function to see what it is doing.

In general, a static function that is only called once, does sometimes
not simplify but obfuscate the code.
2018-08-10 10:38:19 +02:00
Thomas Haller
64e0e241c0 ifcfg-rh: always reset ETHTOOL_WAKE_ON_LAN value
We must always set all variables, because othewise a previously set
value might be merged into the new setting.
2018-08-10 10:38:19 +02:00
Thomas Haller
cd442112c6 ifcfg-rh: split setting ETHTOOL_OPTS from write_wired_setting()
Will be used later, because we will not only have ethtool options
in conjunction with wired settings.
2018-08-10 10:38:19 +02:00
Thomas Haller
1bcf104782 ifcfg-rh: cleanup write_wired_setting()
Drop some local variables, or move them inside a nested scope,
closer to where they are used.
2018-08-10 10:38:19 +02:00
Thomas Haller
f69fb04cd0 ifcfg-rh/tests: regenerate .cexpected files with NM_TEST_REGENERATE=1
The tests already honored the environment variable $NMTST_IFCFG_RH_UPDATE_EXPECTED
to indicate that the .cexpected files should be written by the tests.

However, in the meantime, we instead use NM_TEST_REGENERATE=1 at various
places for this purpose. Honor that flag as well.
2018-08-10 10:38:19 +02:00
Thomas Haller
09031978bb keyfile: fix asserting for absolute base-dir in nm_keyfile_read() 2018-08-10 10:38:19 +02:00
Thomas Haller
b6c094e55e build/meson: fix naming of shared_nm_meta_setting_c variable 2018-08-10 10:38:19 +02:00
Thomas Haller
b7bdde6e0b platform/tests: increase wait timeout in test_cleanup_internal()
Seems this assertion still can fail. Dunno, maybe the timeout was just too
short. Increase it.
2018-08-10 10:38:19 +02:00
Beniamino Galvani
c955d91d4b cli: remove assertion in nmc_device_state_to_color()
nmcli should not fail when the state device state is > ACTIVATED.
Just return an unknown color code like we used to do, and like we do
for connections.

Fixes: 31aa2cfe29

https://bugzilla.gnome.org/show_bug.cgi?id=796834
2018-08-10 10:10:51 +02:00
Thomas Haller
cf02b9c5df checkpatch.pl: complain about space in elvis operator ?: 2018-08-09 17:07:23 +02:00
Thomas Haller
852abf3d3d all/style: write elvis operator ?: without space
By far most of the time, we write "?:" and not "? :". Adjust
the few places that don't.
2018-08-09 17:06:18 +02:00
Beniamino Galvani
8d1c256290 merge: branch 'th/connection-multi-connect-rh1555012'
https://bugzilla.redhat.com/show_bug.cgi?id=1555012
https://github.com/NetworkManager/NetworkManager/pull/177
2018-08-08 11:36:29 +02:00
Beniamino Galvani
ffb4e36fee manager: fix assuming multi-connect connections
When assuming existing connections, allow the same connection to be
activated on a different device if the connection is multi-connect
capable. Otherwise, when a connection is active on multiple devices
and NM is restarted, we assume only the first instance, and create
in-memory connections for others.
2018-08-08 11:34:02 +02:00
Thomas Haller
16389f1037 core: implement connection.multi-connect to activate profiles multiple times
Make use of the new property, and implement it.

See previous commits for the reasons why.

https://bugzilla.redhat.com/show_bug.cgi?id=1555012
2018-08-08 11:24:29 +02:00
Thomas Haller
07a421913b core: extend nm_manager_get_activatable_connections() for autoconnect and multi-connect
In general, a activatable connection is one that is currently not
active, or supports to be activatable multiple times according to
multi-connect setting. In addition, during autoconnect, a profile
which is marked as multi-connect=manual-multiple will not be avalable.
Hence, add an argument "for_auto_activation".

The code is mostly unused but will be used next (except for connections,
which set connection.multi-connect=multiple).
2018-08-08 11:24:29 +02:00
Thomas Haller
55ae69233d all: add connection.multi-connect property for wildcard profiles
Add a new option that allows to activate a profile multiple times
(at the same time). Previoulsy, all profiles were implicitly
NM_SETTING_CONNECTION_MULTI_CONNECT_SINGLE, meaning, that activating
a profile that is already active will deactivate it first.

This will make more sense, as we also add more match-options how
profiles can be restricted to particular devices. We already have
connection.type, connection.interface-name, and (ethernet|wifi).mac-address
to restrict a profile to particular devices. For example, it is however
not possible to specify a wildcard like "eth*" to match a profile to
a set of devices by interface-name. That is another missing feature,
and once we extend the matching capabilities, it makes more sense to
activate a profile multiple times.

See also https://bugzilla.redhat.com/show_bug.cgi?id=997998, which
previously changed that a connection is restricted to a single activation
at a time. This work relaxes that again.

This only adds the new property, it is not used nor implemented yet.

https://bugzilla.redhat.com/show_bug.cgi?id=1555012
2018-08-08 11:24:29 +02:00
Beniamino Galvani
2ead94d5f9 merge: branch 'bg/route-metric-reapply-rh1528071'
https://bugzilla.redhat.com/show_bug.cgi?id=1528071
https://github.com/NetworkManager/NetworkManager/pull/180
2018-08-08 09:57:41 +02:00
Beniamino Galvani
b9e6433a02 core: handle route metric when reapplying dynamic IP methods
For dynamic IP methods (DHCP, IPv4LL, WWAN) the route metric is set at
activation/renewal time using the value from static configuration. To
support runtime change we need to update the dynamic configuration in
place and tell the DHCP client the new value to use for future
renewals.

https://bugzilla.redhat.com/show_bug.cgi?id=1528071
2018-08-08 09:50:35 +02:00
Beniamino Galvani
9ca56089eb dhcp: allowing changing route metric and route table 2018-08-08 09:48:57 +02:00
Lubomir Rintel
e2071e92f0 build: set -Wall when probing extra warning options
Some warnings depends on others: -Wformat-security won't work without
-Wformat. With -Wall we're confident enough that we have important
warnings enabled and in any case we're going to enable it anyway.

https://github.com/NetworkManager/NetworkManager/pull/175
2018-08-07 16:58:36 +02:00
Lubomir Rintel
99b92fd992 build: check whether g-ir-scanner actually works
g-ir-scanner uses distutils that have an unfortunate misfeature of
inheriting the compiler flags it itself was built with.

This includes the hardening flags that don't work with without
redhat-rpm-build and break with clang every full moon.

A configure check makes it clear about what went wrong in case
introspection is desired, otherwise turns it off.

(Taken from network-manager commit 678890ed0347849990787e8893122a39f95cb708)
2018-08-07 10:06:44 +02:00
Lubomir Rintel
667a81e593 agent-manager: upgrade a logging level of new agent notice
On default log level we don't log anything when a new agent registers.
Let's raise the log level here, it doesn't add too much noise.

https://github.com/NetworkManager/NetworkManager/pull/174
2018-08-06 19:24:06 +02:00
Lubomir Rintel
d4b39a42ef agent-manager: order newer agents befor the old one
This is a mere debugging convenience thing: e.g. if you run, but want to
check whether nm-applet or nmcli agent works fine, it's convenient that
the agent you run later gets a chance to deal with the secrets requests
first.

Is seems to do the job and is simpler that adding some more complicated
policy (e.g. introducing priorities or something).

https://github.com/NetworkManager/NetworkManager/pull/174
2018-08-06 19:23:58 +02:00
Lubomir Rintel
57d4286d54 man/openvswitch: advise to use "master" instead of "conn.master"
It does some extra magic -- normalizes the value and initializes
slave-type.

https://bugzilla.redhat.com/show_bug.cgi?id=1519176
2018-08-06 18:59:01 +02:00
Thomas Haller
3c66495a09 libnm/wireguard: merge branch 'jbeta/wireguard-device-basic'
https://github.com/NetworkManager/NetworkManager/pull/162
2018-08-06 08:34:33 +02:00
Thomas Haller
93ce88a2fa libnm: fix leak for NMDeviceWireGuard's public_key 2018-08-06 08:34:27 +02:00
Javier Arteaga
1427719116 libnm: introduce NMDeviceWireGuard 2018-08-06 08:34:27 +02:00
Javier Arteaga
54df43ed52 core: introduce NMDeviceWireGuard
For now, the device only exposes partial link status (not including
peers). It cannot create new links.
2018-08-06 08:34:27 +02:00
Javier Arteaga
edd5cf1a3c platform: rename instances of Wireguard to WireGuard
Respect WireGuard canonical capitalization on identifiers.
As per discussion on:
https://github.com/NetworkManager/NetworkManager/pull/162
2018-08-06 08:34:27 +02:00
Thomas Haller
aca73150ad libnm/docs: fix examples for NMSetting:name values 2018-08-03 14:24:28 +02:00
Thomas Haller
86841df368 libnm/docs: don't document NM_SETTING_NAME property
NM_SETTING_NAME is a special property that only has relevance
to libnm. It is inherited by all NMSetting instances. It is
read-only, and it has no corresponding value on D-Bus or nmcli.

Skip it during generate-setting-docs.py.

This also drops it from `man nm-settings`, where it doesn't belong.
2018-08-03 14:24:28 +02:00
Thomas Haller
c8f2384210 contrib/rpm: enable connectivity_redhat only from rhel-8 onwards
There is no consensus, that this should be enabled on rhel-7 (yet).
2018-08-03 11:30:32 +02:00
Thomas Haller
e028a53612 contrib/rpm: use %autosetup to simplify patch application
This allows us to omit the %patch1 macros.

See-also: http://rpm.org/user_doc/autosetup.html
2018-08-03 11:08:47 +02:00
Beniamino Galvani
2d6864efe1 core: merge branch 'bg/update-dev-state-file-rh1593282'
https://github.com/NetworkManager/NetworkManager/pull/178
https://bugzilla.redhat.com/show_bug.cgi?id=1593282
2018-08-02 16:42:48 +02:00
Beniamino Galvani
614f4733e2 manager: use NM_IN_SET()
No functional change.
2018-08-02 16:39:44 +02:00
Beniamino Galvani
8bbe61206f manager: update the device state file upon (dis)connection
Update the device state file every time the device is connected,
disconnected, or becomes unmanaged.  In this way, NM becomes more
robust against crashes or forced terminations because it can resume
the previous device state seamlessly.
2018-08-02 16:39:44 +02:00
Beniamino Galvani
060f2138ee manager: rename nm_manager_write_device_state()
Rename nm_manager_write_device_state() to
nm_manager_write_device_state_all(), and split out the code to write a
single device state to a new function.
2018-08-02 16:39:44 +02:00
Beniamino Galvani
bdebb8e2cf main: drop unused define 2018-08-02 16:39:44 +02:00