Commit graph

9944 commits

Author SHA1 Message Date
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
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
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
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
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
146fbfab33 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.
2017-11-08 11:45:34 +01:00
Thomas Haller
3c2b9485a7 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.
2017-11-08 11:45:34 +01:00
Thomas Haller
5279ab5be6 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.
2017-11-08 11:45:34 +01:00
Thomas Haller
6fff832fe3 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.
2017-11-08 11:45:34 +01:00
Thomas Haller
a7ef46eaaa policy: refactor auto_activate_device() to return early 2017-11-08 11:45:34 +01:00
Thomas Haller
bfe66fb8f4 policy: optimize nm_device_can_auto_connect() to not check nm_device_autoconnect_allowed() 2017-11-08 11:45:33 +01:00
Thomas Haller
45da11f370 device: minor refactoring of condition in nm_device_autoconnect_allowed()
Makes it clearer what is happening (to me).
2017-11-08 11:45:33 +01:00
Thomas Haller
7074b88a6a 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().
2017-11-08 11:33:32 +01:00
Thomas Haller
715aebe08a 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.
2017-11-08 11:33:32 +01:00
Thomas Haller
990af413ac 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.
2017-11-08 11:33:32 +01:00
Thomas Haller
fc18ff30cf device: move nm_device_get_enabled() from schedule_activate_check() to nm_device_autoconnect_allowed() 2017-11-08 11:33:32 +01:00
Thomas Haller
9a7e668dbb device: drop stub implementation of get_autoconnect_allowed() in NMDevice 2017-11-08 11:33:32 +01:00
Beniamino Galvani
29a576496e ifcfg-rh: persist the connection type for TeamPort connections
Currently the ifcfg-rh plugin doesn't explicitly store the connection
type for team slaves and is only able to read back ethernet and vlan
connections.

Leave this unchanged for ethernet and vlan slaves, but store the TYPE
variable for other connection types (Wi-Fi and Infiniband) so that we
can properly determine their type when the connection is read.
2017-11-06 16:40:57 +01:00
Thomas Haller
cc993aa020 logging: configure dnsmasq's logging in shared mode via nm-logging 2017-11-06 12:00:28 +01:00
Beniamino Galvani
db41380c15 ndisc: fix ordering of gateways
Insert the new gateway at the end when it has the least preference.

Fixes the following runtime error:
 src/ndisc/nm-ndisc.c:204:_ASSERT_data_gateways: assertion failed:
 (_preference_to_priority (item_prev->preference) >=
 _preference_to_priority (item->preference))
2017-11-03 10:44:48 +01:00
Thomas Haller
72756994d4 wifi: use connection.auth-retries to handle authentication in NMDeviceWifi 2017-11-02 11:41:01 +01:00
Thomas Haller
32acaccf2a device: move tracking auth_retry to NMDevice
It will be also used by NMDeviceWifi. It might waste a 4 bytes for device types
that don't require authentication. But it deduplicates code.
2017-11-02 11:41:01 +01:00
Thomas Haller
6705c71263 ifcfg-rh: use svSetValueInt64_cond() in write_connection_setting() 2017-11-02 11:41:01 +01:00
Thomas Haller
2730dc60de all: move setting 802-1x.auth-retries to connection.auth-retries
The number of authentication retires is useful also for passwords aside
802-1x settings. For example, src/devices/wifi/nm-device-wifi.c also has
a retry counter and uses a hard-coded value of 3.

Move the setting, so that it can be used in general. Although it is still
not implemented for other settings.

This is an API and ABI break.
2017-11-02 11:41:01 +01:00
Thomas Haller
53dea38834 ifcfg-rh: refactor write_object() to avoid coverity warning
Coverity detects that the "if (blob)" condition must always be true.
Reorder the code, to avoid the warning. It's a bit clearer this way
anyway.
2017-10-31 20:15:04 +01:00
Thomas Haller
76b913a210 ovs: add backward compatibility wrapper for json_object_foreach() macro 2017-10-31 20:02:48 +01:00
Thomas Haller
cb2aa6bd4c policy: move blocking autoconnect from NMDeviceModem to NMPolicy
Only NMPolicy should be concerned with handling autoconnect, and
blocking it.

Move the code. Note that there is a slight possible change in
behavior, as the order of when the connection is blocked changes,
based on the different times when the device changed signal gets
executed. But that shouldn't be a problem.
2017-10-31 19:35:33 +01:00
Thomas Haller
3828ba3b0e policy: inline can_autoconnect check in auto_activate_device() 2017-10-31 19:35:33 +01:00
Thomas Haller
1a9d4869ed policy: move nm_settings_connection_can_autoconnect() to policy
Step by step, we move all tracking of autoconnect to NMPolicy.
2017-10-31 19:35:33 +01:00
Thomas Haller
e62e52dfe1 device: handle authentication retries using 802-1x.auth-retries setting
Since commit 4a6fd0e83e (device: honor the
connection.autoconnect-retries for 802.1X) and the related bug bgo#723084,
we reuse the autoconnect-retries setting to control the retry count
for requesting passwords.

I think that is wrong. These are two different settings, we should not
reuse the autoconnect retry counter while the device is still active.

For example, the user might wish to set autoconnect-retries to infinity
(zero). In that case, we would retry indefinitly to request a password.
That could be problematic, if there is a different issue with the
connection, that makes it appear tha the password is wrong.
A full re-activation might succeed, but we would never stop retrying
to authenticate. Instead, we should have two different settings for
retrying to authenticate and to autoconnect.

This is a change in behavior compared to 1.8.
2017-10-31 19:35:33 +01:00
Thomas Haller
89e518db5a libnm,cli,ifcfg-rh: add NMSetting8021x:auth-retries property 2017-10-31 19:35:33 +01:00
Thomas Haller
18f2d272ba settings: add and use nm_settings_connection_autoconnect_retries_try_next() 2017-10-31 19:35:33 +01:00
Thomas Haller
361a199a06 device: move resetting autoconnect retries from subtype to NMDevice 2017-10-31 19:35:28 +01:00
Thomas Haller
447dc874ce config: remove nm_config_data_get_value_cached()
It has almost no callers, and it is a bit of a strange API. Let's
not cache the last accessed value inside NMConfigData. Instead, free
it right after use. It was not reused anyway, it only hangs around
as convenience for the caller.
2017-10-31 19:14:07 +01:00
Thomas Haller
262159be00 config: add nm_config_data_get_value_int64() util 2017-10-31 19:14:07 +01:00
Thomas Haller
ec9bff293b settings/trivial: rename settings-connection's autoconnect functions
Names like
  - nm_settings_connection_get_autoconnect_retries
  - nm_settings_connection_set_autoconnect_retries
  - nm_settings_connection_reset_autoconnect_retries
are about the same thing, but they are cumbersome to grep
because they share not a common prefix.

Rename them from SUBJECT_VERB_OBJECT to SUBJECT_OBJECT_VERB,
which sounds odd in English, but seems preferred to me.
Now you can grep for "nm_settings_connection_autoconnect_retries_" to
get all accessors of the retry count, or "nm_settings_connection_autoconnect_"
to get all accessors related to autoconnect in general.
2017-10-31 19:14:07 +01:00
Lubomir Rintel
f0a23bf999 Revert "device: log device type too"
I didn't really mean to include it as it doesn't make any sense at this
point and makes the logs a bit more messy.

This reverts commit 340e35c09d.
2017-10-31 18:48:41 +01:00
Lubomir Rintel
bc83bec253 device: avoid touching sysctls for devices without platform link
Since 32b3eb1181 [core: merge IPv4 and IPv6 implementation of
nm_utils_ip4_property_path()], nm_utils_sysctl_ip_conf_path() introduced
in cd271d5cb1 [core: add nm_utils_sysctl_ip_conf_is_path() util] is used to
cunstruct sysctl paths and it is way less tolerant towards using something
that is not an interface name in the path.

It's always been incorrect to assume the ifname is a linux link name and
it resulted it ugly, if benign, sysctl access attempts such as
"/sys/class/net/28:B2:BD:5D:23:AB/phys_port_id" etc.

Now it triggers an assertion failure. Let's guard all such accesses.

Fixes: 32b3eb1181
Fixes: cd271d5cb1
2017-10-31 18:46:17 +01:00
Beniamino Galvani
5f97430e21 ifcfg-rh: remove password-raw keys file after test
Fixes: a83ab252ee
2017-10-31 14:44:39 +01:00
Lubomir Rintel
47ebb98630 devices/ovs/ovsdb: fix 32bit builds
So that we work well on VAXen.
2017-10-31 10:57:05 +01:00
Beniamino Galvani
a83ab252ee ifcfg-rh: add support for 802-1x.password-raw property
When the ifcfg-rh plugin writes a 802-1x setting it currently ignores
the password-raw property and so the password disappears when the
connection is saved. Add support for the property.
2017-10-31 10:19:49 +01:00
Lubomir Rintel
eee1553288 devices/ovs/ovsdb: fix build with old Jansson 2017-10-31 09:21:30 +01:00