Commit Graph

21088 Commits

Author SHA1 Message Date
Beniamino Galvani
14ad1d0cd1 device: don't necessarily fail the connection when ipv4 DAD fails
Don't necessarily fail the entire connection if a duplicate IPv4
address is detected, but instead look at the may-fail property and at
the outcome of IPv6.

https://bugzilla.redhat.com/show_bug.cgi?id=1508001
2017-11-09 22:26:17 +01:00
Francesco Giudici
9022b14478 merge: branch 'fg/team_abstraction_rh1398925'
https://bugzilla.redhat.com/show_bug.cgi?id=1398925
2017-11-09 17:57:01 +01:00
Francesco Giudici
3e34e404b4 libnm-core: enforce team and team-port defaults
Rework a bit the way default values are check, set and aligned.
2017-11-09 17:56:15 +01:00
Francesco Giudici
81527f1a09 cli: add team-port properties 2017-11-09 17:56:15 +01:00
Francesco Giudici
ec60e01d39 libnm-core: enforce team-port config and properties alignment
Ensure .config is aligned when an explicit team-port is set and vice
versa
2017-11-09 17:56:15 +01:00
Francesco Giudici
1c99d379eb libnm-core: add explicit team properties to NMSettingTeamPort 2017-11-09 17:56:15 +01:00
Francesco Giudici
e1220c933f cli: add team properties 2017-11-09 17:56:15 +01:00
Francesco Giudici
fc3b7d61e2 libnm-core: enforce team config and properties alignment
Ensure .config is aligned when an explicit team property is set and vice versa.
2017-11-09 17:56:15 +01:00
Francesco Giudici
9715969b77 libnm-core: add explicit team properties to NMSettingTeam 2017-11-09 17:56:15 +01:00
Francesco Giudici
b4c9bcd49f libnm-core: add inline functions to update team json config
Add functions and structure to simplify json config and team property
enforcement. These will be used in both NMSettingTeam and
NMSettingTeamPort.
2017-11-09 17:56:15 +01:00
Francesco Giudici
dadf710ee3 libnm-core: add functions to align team json config to exposed properties 2017-11-09 17:56:15 +01:00
Francesco Giudici
b6c0498b04 shared: add json_boolean_value support in jansson.h
Released in jansson version 2.7, added for compatibility with older
jannson verions.
2017-11-09 17:56:15 +01:00
Thomas Haller
931910b7de all: merge branch 'th/jansson' 2017-11-09 17:40:32 +01:00
Thomas Haller
595aaf0f3e all: update compatiblity for older libjansson versions
- nm-ovsdb.c uses json_load_callback(), which is jansson v2.4.
  Hence, it cannot build the OVS plugin in our Travis-CI, which is
  still on Ubuntu Precise. Disable building the plugin in travis and
  add a compiler warning when building against an older version.

- since jansson v2.3, there is json_object_key_to_iter() to implement
  the for-each macros. Use it in json_object_foreach_safe() when
  available.
2017-11-09 17:34:39 +01:00
Thomas Haller
650a47e16c all: use nm-jansson.h 2017-11-09 17:32:22 +01:00
Thomas Haller
11b241eb1c shared: add jansson.h compatibility and utils header 2017-11-09 17:32:22 +01:00
Francesco Giudici
85cc5db7a4 shared: trivial: add space before comment close 2017-11-09 17:17:00 +01:00
Thomas Haller
b339a2742a shared: make NM_CONSTCAST() macro variadic
We need to pass more alias-types. Instead of having numbered
versions, use variadic number of macro arguments.

Also, fix build failure with old compiler:

  In file included from src/nm-ip6-config.c:24:
  ./src/nm-ip6-config.h:44:29: error: controlling expression type 'typeof (ipconf_iter->current->obj)' (aka 'const void *const') not compatible with any generic association type
                  *out_address = has_next ? NMP_OBJECT_CAST_IP6_ADDRESS (ipconf_iter->current->obj) : NULL;
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fixes: b1810d7a68
2017-11-09 14:15:34 +01:00
Thomas Haller
b1810d7a68 shared: rework _NM_GET_PRIVATE() to use _Generic()
_NM_GET_PRIVATE() used typeof() to propagate constness of the @self
pointer. However, that means, it could only be used with a self pointer
of the exact type. That means, you explicitly had to cast from (GObject *)
or from (void *).
The requirement is cumbersome, and often led us to either create @self
pointer we didn't need:

    NMDeviceVlan *self = NM_DEVICE_VLAN (device);
    NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (self);

or casting:

    NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE ((NMDevice *) device);

In both cases we forcefully cast the source variable, loosing help from
the compiler to detect a bug.

For "nm-linux-platform.c", instead we commonly have a pointer of type
NMPlatform. Hence, we always forcefully cast the type via _NM_GET_PRIVATE_VOID().

Rework the macro to use _Generic(). If compiler supports _Generic(), then we
will get all compile time checks as desired. If the compiler doesn't support
_Generic(), it will still work. You don't get the compile-time checking of course,
but you'd notice that something is wrong once you build with a suitable
compiler.
2017-11-09 10:57:13 +01:00
Beniamino Galvani
e25d6ad0d3 checkpoint: don't include unrealized devices
Don't include unrealized devices in checkpoint because, as the name
says, they are not real.

While at it, remove nm_manager_get_device_paths() as it is no longer
used.

(cherry picked from commit 974f21eca3)
2017-11-09 10:33:26 +01:00
Beniamino Galvani
de5de2d4ee checkpoint: specify path of already existing checkpoint on error
(cherry picked from commit 66d048023c)
2017-11-09 10:33:20 +01:00
Beniamino Galvani
cba9614298 libnm: don't invert order in array properties
The order of elements in array properties was inverted when
reconstructing the array. Keep the original order from D-Bus.

(cherry picked from commit c90118ff60)
2017-11-09 10:33:18 +01:00
Beniamino Galvani
f02df2c2ca checkpoint: add libnm support
Add support for checkpoint/rollback functionality to libnm.

https://bugzilla.redhat.com/show_bug.cgi?id=1496739
2017-11-09 10:14:21 +01:00
Beniamino Galvani
77d3b1555e examples: add checkpoint example using python gobject-introspection 2017-11-09 10:12:30 +01:00
Beniamino Galvani
c3efedf54b libnm: add checkpoint support 2017-11-09 10:12:30 +01:00
Beniamino Galvani
dece9f9dda core: export checkpoint list over D-Bus 2017-11-09 10:12:15 +01:00
Beniamino Galvani
a034a917e6 checkpoint: track checkpoints in a list
Checkpoints will be exported over D-Bus and they must be presented in
a predictable order. Keep them in a list ordered by creation time.
2017-11-09 10:12:15 +01:00
Beniamino Galvani
974f21eca3 checkpoint: don't include unrealized devices
Don't include unrealized devices in checkpoint because, as the name
says, they are not real.

While at it, remove nm_manager_get_device_paths() as it is no longer
used.
2017-11-09 10:12:15 +01:00
Beniamino Galvani
66d048023c checkpoint: specify path of already existing checkpoint on error 2017-11-09 10:12:15 +01:00
Beniamino Galvani
c90118ff60 libnm: don't invert order in array properties
The order of elements in array properties was inverted when
reconstructing the array. Keep the original order from D-Bus.
2017-11-09 10:12:15 +01:00
Thomas Haller
a5b4850682 core: merge branch 'th/dns-ip-config-unify' 2017-11-09 10:06:05 +01:00
Thomas Haller
54bcbb85d3 core: merge IPv4 and IPv6 implementations in NMDnsManager 2017-11-09 09:29:39 +01:00
Thomas Haller
9e25538ff5 core: add NMIPConfig helpers
For now, hack some generic accessors to the NMIP4Config/NMIP6Config
type. Eventually, NMIP4Config and NMIP6Config should get merged in
one class.
2017-11-09 09:28:49 +01:00
Thomas Haller
ffcab3f653 libnm: add internal helper function nm_utils_inet_ntop() 2017-11-09 09:27:31 +01:00
Beniamino Galvani
b227198e92 build: fix make distcheck
Fixes the following errors in 'make distcheck':

1)
  GEN      libnm/fake-typelib/NMClient.typelib
 failed to open 'libnm/fake-typelib/NMClient.typelib.tmp': No such file or directory
 make[2]: *** [libnm/fake-typelib/NMClient.typelib] Error 1

2)
  GEN      libnm/fake-typelib/typelibs.c
 ../../libnm/fake-typelib/typelibs.gresource.xml: Failed to locate “NetworkManager.typelib” in any source directory.
 make[1]: *** [Makefile:17790: libnm/fake-typelib/typelibs.c] Error 1

3)
 ERROR: files left in build directory after distclean:
 ./libnm/fake-typelib/typelibs.c
 ./libnm/fake-typelib/NMClient.typelib
 ./libnm/fake-typelib/NetworkManager.typelib

Fixes: 4d1f090aed
2017-11-08 18:49:49 +01:00
Thomas Haller
6246364747 core: replace nm_dns_ip_config_data_get_dns_priority()
Add instead nm_ip_config_get_dns_priority(). If we want to treat NMIP4Config/NMIP6Config
generically, then the accessor should be right there.
2017-11-08 14:46:31 +01:00
Thomas Haller
10d38a950d core: add generic opaque NMIPConfig type
One day, I hope to merge NMIP4Config and NMIP6Config implementations.
A small step, and a typesafe cast-macro.
2017-11-08 14:46:31 +01:00
Thomas Haller
157932f7dd policy: merge IPv4 and IPv6 implementation of update_ip_dns() 2017-11-08 14:03:26 +01:00
Thomas Haller
0a0b417882 core: merge branch 'th/autoconnect-rh1401515-3'
https://bugzilla.redhat.com/show_bug.cgi?id=1401515

(cherry picked from commit 0e4405e924)
2017-11-08 12:35:38 +01:00
Thomas Haller
8f131e4e18 policy: don't block autoconnect for connections when disconnecting software devices
This was added by commit 979b8920b4
(core: move virtual device autoconnect tracking bits out of NMManager)
to avoid autoconnecting software devices repeatedly. That was done,
because disconnecting a software device would delete the NMDevice
instance, and there is no property on a device to prevent autoconnect.

In the meantime, we only unrealize software devices and don't delete
them entirely. Also, the autoconnect-blocked flags of the device are
preserved when the device unrealized.

It was anyway odd, that deactivating one software-device would block
autoconnection for all matching connections.

(cherry picked from commit 146fbfab33)
2017-11-08 12:35:10 +01:00
Thomas Haller
186d9de66a device: improve tracking autoconnect-blocked flags of NMDevice
- split NM_DEVICE_AUTOCONNECT_BLOCKED_INTERN in two parts:
  "wrong-pin" and "manual-disconnect". Setting/unsetting them
  should be tracked differently, as their reason differs.

- no longer initialize/clear the autoconnect-blocked reasons
  during realize/unrealize of the device. Instead, initialize
  it once when the object gets created (nm_device_init()), and
  keep the settings beyond unrealize/realize cycles. This only
  matters for software devices, as regular devices get deleted
  after unrealizing once. But for software devices it is essential,
  because we don't want to forget the autoconnect settings of
  the device instance.

- drop verbose logging about blocking autoconnect due to failed
  pin. We already log changes to autoconnect-blocked flags with
  TRACE level. An additional message about this particular issue
  seems not necessary at INFO level.

- in NMManager's do_sleep_wake(), no longer block autoconnect
  for devices during sleep. We already unmanage the device, which
  is a far more effective measure to prevent activation. We should
  not also block autoconnect.

(cherry picked from commit 3c2b9485a7)
2017-11-08 12:35:10 +01:00
Thomas Haller
f0731dc716 device: refactor autoconnect blocking by introducing NMDeviceAutoconnectBlockedFlags enum
The flags allow for more then two reasons. Currently the only reasons
for allowing or disallowing autoconnect are "user" and "intern".

It's a bit odd, that NMDeviceAutoconnectBlockedFlags has a negative
meaning. So
  nm_device_set_autoconnect_intern (device, FALSE);
gets replaced by
  nm_device_set_autoconnect_blocked_set (device, NM_DEVICE_AUTOCONNECT_BLOCKED_INTERN);
and so on.

However, it's chosen this way, because autoconnect shall be allowed,
unless any blocked-reason is set. That is, to check whether autoconnect
is allowed, we do
  if (!nm_device_get_autoconnect_blocked (device, NM_DEVICE_AUTOCONNECT_BLOCKED_ALL))
The alternative check would be
  if (nm_device_get_autoconnect_allowed (device, NM_DEVICE_AUTOCONNECT_ALLOWED_ALL) == NM_DEVICE_AUTOCONNECT_ALLOWED_ALL)
which seems odd too.

So, add the inverse flags to block autoconnect.

Beside refactoring and inverting the meaning of the autoconnect
settings, there is no change in behavior.

(cherry picked from commit 5279ab5be6)
2017-11-08 12:35:10 +01:00
Thomas Haller
f7e72d9d70 policy: don't check autoconnect flag of connection in nm_device_can_auto_connect()
nm_device_can_auto_connect() only has one caller, auto_activate_device()
in NMPolicy.

That caller already checks whether the connection has autoconnect
enabled, so drop the duplicate check.

This saves some duplication, but it also makes some sense:
NMSettingsConnection has a complex blocking of autoconnect,
so just looking at connection.autoconnect is not enough in
any case to determine whether the connection should autoconnect.
We move thus more handling of autoconnect to NMPolicy, where
it belongs.

(cherry picked from commit 6fff832fe3)
2017-11-08 12:35:10 +01:00
Thomas Haller
bb0536fc00 policy: refactor auto_activate_device() to return early
(cherry picked from commit a7ef46eaaa)
2017-11-08 12:35:10 +01:00
Thomas Haller
baa0d95c95 policy: optimize nm_device_can_auto_connect() to not check nm_device_autoconnect_allowed()
(cherry picked from commit bfe66fb8f4)
2017-11-08 12:35:10 +01:00
Thomas Haller
f77b48a59a device: minor refactoring of condition in nm_device_autoconnect_allowed()
Makes it clearer what is happening (to me).

(cherry picked from commit 45da11f370)
2017-11-08 12:35:10 +01:00
Thomas Haller
816adbe89c device/olpc-mesh: reject autoconnect requests early via get_autoconnect_allowed()
OLPC devices cannot autoconnect, according to can_auto_connect().
We should instead reject any attempt to autoconnect earlier, via
get_autoconnect_allowed().

(cherry picked from commit 7074b88a6a)
2017-11-08 12:35:10 +01:00
Thomas Haller
1433682c28 device: inline NMDevice's implementation of can_auto_connect()
Derived classes should not modify or overwrite this essential behavior
of can_auto_connect(). It doesn't belong to the virtual function.

(cherry picked from commit 715aebe08a)
2017-11-08 12:35:10 +01:00
Thomas Haller
d8bb62c909 policy: remove redundant check in device_autoconnect_changed()
schedule_activate_check() also checks for nm_device_autoconnect_allowed()
and aborts if there is nothing to do.

(cherry picked from commit 990af413ac)
2017-11-08 12:35:10 +01:00
Thomas Haller
d0f82352ea device: move nm_device_get_enabled() from schedule_activate_check() to nm_device_autoconnect_allowed()
(cherry picked from commit fc18ff30cf)
2017-11-08 12:35:09 +01:00