Commit Graph

15047 Commits

Author SHA1 Message Date
Thomas Haller
18019d55a1 active-connection: update D-Bus properties of active-connection when settings-connection changes
$ nmcli connection up my-connection
  Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/42)

  $ nmcli connection modify my-connection connection.id other-name

  $ nmcli -f connection.id connection show other-name
  connection.id: other-name

  $ nmcli -f GENERAL.CONNECTION device show enp0s25
  GENERAL.CONNECTION: my-connection

  $ nmcli connection down other-name
  Error: 'other-name' is not an active connection.
  Error: no active connection provided.

  $ nmcli connection down my-connection
  Connection 'my-connection' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/13)

When modifying a connection, NMActiveConnection must update the D-Bus
properties that belong to the settings-connection.
2016-04-14 12:25:41 +02:00
Thomas Haller
3164c026a2 settings: merge "connection-updated" and "connection-updated-by-user" signals
This is mostly interesting of NMPolicy, which no longer needs to
subscribe to two almost identical signals (where the by-user signal
was always invoked together with the plain "updated" signal).
2016-04-14 12:25:41 +02:00
Thomas Haller
65c55e2a78 settings: combine "updated" and "updated-by-user" signal in NMSettingsConnection
Instead of connecting to two similar signals, combine them into one
and pass "by_user" argument.

We still need to keep the original NM_SETTINGS_CONNECTION_UPDATED signal,
because it is exposed on D-Bus.
2016-04-14 12:25:40 +02:00
Thomas Haller
a4f1a1794f settings: emit NM_SETTINGS_CONNECTION_UPDATED right away and not on an idle handler
I want to combine NM_SETTINGS_CONNECTION_UPDATED and NM_SETTINGS_CONNECTION_UPDATED_BY_USER
into one signal. Thus, they must have same behavior with respect as to whether they are
scheduled on idle.

Emit NM_SETTINGS_CONNECTION_UPDATED right away.

The "Updated" signal is exposed via D-Bus on the settings object.
Removing the idle handling has no bad consequences there.

Apart from that, the signal has only the listener NMSettings::connection_updated().
connection_updated() first emits NM_SETTINGS_SIGNAL_CONNECTION_UPDATED, which only
has listener: NMPolicy::connection_updated(), which already delegates to
an idle handler.

Second, NMSettings::connection_updated() emits
NM_CP_SIGNAL_CONNECTION_UPDATED which has the following listeners:

  - NMBluezDevice::cp_connection_updated(), which can cause the
    connection to be tracked/untracked. Any further changes are
    already delayed on an idle handler (check_emit_usable_schedule()).

  - NMDevice::cp_connection_added_or_updated(), which causes the
    connection to be tracked by the device. It also emits
    "notify::available-connections", which however is only relevant
    for the D-Bus bindings.
    At last, it does available_connections_check_delete_unrealized()
    which also is on an idle handler already.
2016-04-14 12:24:38 +02:00
Thomas Haller
640ef67cd7 device/bluez: delay check_emit_usable() for NM_CP_SIGNAL_CONNECTION_UPDATED
Currently, NM_CP_SIGNAL_CONNECTION_UPDATED signal will be invoked on an
idle handler. I want to change that, so to be save, delay actions that
matter on an idle handler.
2016-04-14 12:17:36 +02:00
Thomas Haller
3325cd3d90 device/bluez: refactor registering to connections
No (intentional) change in behavior.
2016-04-14 12:17:36 +02:00
Thomas Haller
920054d8aa policy: handle schedule_activate_all() in an idle handler
schedule_activate_all() needs to iterate over all devices and is thus
relatively costly (and scales O(n^2)).

By scheduling the action on an idle handler we delay and combine
multiple redundant requests.

Another reason is that NM_SETTINGS_CONNECTION_UPDATED is currently
executed on an idle handler which first leads to
NM_SETTINGS_SIGNAL_CONNECTION_UPDATED signal and eventually calls
schedule_activate_all().
I want to change that to emit the connection update signal immediately,
thus to preserve the delay, we delay handling in NMPolicy.
2016-04-14 12:17:35 +02:00
Thomas Haller
d571933505 settings: drop signal slots from NMSettings
NMSettings has no derived classes and obviously nobody is using
those slots. Just drop them.
2016-04-14 12:17:35 +02:00
Thomas Haller
f7e7df772d settings: refactor connection_changed()
Again, no functional change.
2016-04-14 12:17:35 +02:00
Thomas Haller
866df17e97 settings: refactor connection-changed handler
No change in behavior, just not pass on this GUINT_TO_POINTER (TRUE).
2016-04-14 12:17:35 +02:00
Thomas Haller
30b8842a48 settings: use NM_GOBJECT_PROPERTIES_DEFINE in NMSettings/NMSettingsConnection/NMActiveConnection 2016-04-14 12:17:35 +02:00
Thomas Haller
8c86648313 device: drop available_connections_notify() and call _notify() directly 2016-04-14 12:17:35 +02:00
Thomas Haller
c57e5a6b66 manager: fix implementation of NMManager's "startup-complete
Due to a bug, NMManager would connect to "notify::connections"
and might miss an important notification when NMSettings declares
startup-complete.

Fixes: b067ca7034
2016-04-14 12:17:35 +02:00
Thomas Haller
d0ed5f83ce libnm: use <> to include in public header
In a public header file ("nm-vpn-editor.h"), other public headers
from NetworkManager must be included with <nm-vpn-editor-plugin.h>
and not quotes.
2016-04-13 19:20:52 +02:00
Anders Jonsson
be34518dc1 po: update Swedish (sv) translation (bgo #764750)
https://bugzilla.gnome.org/show_bug.cgi?id=764750
2016-04-13 11:13:05 +02:00
Piotr Drąg
ed9a25773a po: update Polish (pl) translation (bgo #764955)
https://bugzilla.gnome.org/show_bug.cgi?id=764955
2016-04-13 00:21:40 +02:00
Thomas Haller
d6915100a5 po: translation fixes (bgo#764956)
https://bugzilla.gnome.org/show_bug.cgi?id=764956
2016-04-12 18:46:37 +02:00
Piotr Drąg
2cec85ed92 po: fix syntax error in Telugu (te) translation 2016-04-12 18:42:07 +02:00
Piotr Drąg
4eedbb067a po: fix syntax error in French (fr) translation 2016-04-12 18:41:39 +02:00
Francesco Giudici
7796c489fd device: minor logging change in platform_link_added()
Show ignored devices in debug level.
2016-04-12 11:24:19 +02:00
Thomas Haller
defc7fc89a libnm-core,core: merge branch 'th/nm-ip-address-zero-prefix' 2016-04-11 14:15:01 +02:00
Thomas Haller
a170320c35 ifcfg-rh: support zero prefix length for IP addresses in reader 2016-04-11 13:01:42 +02:00
Thomas Haller
420bd611fd core: expose NMIPAddress instances with prefix zero on D-Bus
Since commit 44768f0311, we skip
exposing NMIPAddress instances with prefix zero. Now, that is
supported and we can remove the check.
2016-04-11 12:49:48 +02:00
Thomas Haller
6b8729a599 libnm-core: drup unused @allow_zero_prefix argument from valid_prefix() 2016-04-11 12:40:35 +02:00
Thomas Haller
57860c329e libnm-core: allow zero prefix length in NMIPAddress
Adding addresses with a prefix of zero is valid. Don't
reject them.

Note that this is an actual bug. If you configure an
address with prefix length zero, nmcli will report:

  $nmcli connection
  (process:1040): libnm-WARNING **: Ignoring invalid IP4 address: Invalid IPv4 address prefix '0'
2016-04-11 12:33:07 +02:00
Thomas Haller
d68ccb84f1 libnm-core/trivial: add code comment 2016-04-11 12:29:33 +02:00
Thomas Haller
514245b1d7 platform: merge branch 'th/platform-route-resync'
Lots of cleanup and refactoring. Most notably, make the
prefix-length property guint8.

Also fix keeping the route cache in sync when "modifying"
an existing route via `ip route change` or `ip route replace`.
2016-04-11 12:18:28 +02:00
Thomas Haller
4bb76fb4c3 platform: set NLM_F_EXCL when adding links
When adding a link, set both NLM_F_CREATE and NLM_F_EXCL
flags.

`ip route add` and systemd-networkd sets NLM_F_EXCL too.
2016-04-11 11:33:08 +02:00
Thomas Haller
f8b2cadfc1 platform: ensure cache consistency for routes by workaround missing kernel event
Consider:

  unshare -n
  ip link add d0 type dummy
  ip link add d1 type dummy
  ip link set d0 up
  ip link set d1 up
  ip addr add 192.168.100.5/24 dev d0
  ip addr add 192.168.101.5/24 dev d1

  ip route add 192.168.200.0/24 via 192.168.100.1
  ip monitor &
  ip route change 192.168.200.0/24 via 192.168.101.1
  #prints 192.168.200.0/24 via 192.168.101.1 dev d1
  ip route show
  #192.168.100.0/24 dev d0  proto kernel  scope link  src 192.168.100.5
  #192.168.101.0/24 dev d1  proto kernel  scope link  src 192.168.101.5
  #192.168.200.0/24 via 192.168.101.1 dev d1

Note that `ip route change` replaced the exising route. "Replaced" in this
case means: the previous route on device "d0" got removed and a new route
on "d1" was added. However, kernel only sent one RTM_NEWROUTE event, no
RTM_DELROUTE that notifies about this change.

We need to workaround that by re-synching the routes when we receive a
RTM_NEWROUTE notification.
2016-04-11 11:32:48 +02:00
Thomas Haller
20618901dd platform: use _NM_UTILS_LOOKUP_DEFINE() 2016-04-11 11:30:56 +02:00
Thomas Haller
ff8c82e7e1 platform: track refresh-all actions that are in progress
We aim to keep the platform cache up-to-date only via the netlink
events. However, due to kernel shortcomings we often have to resync
by re-requesting the data, which especially for routes and addresses
means a full dump (as you cannot request only specific route/address
information).

Thus it makes sense to avoid expensive dumps whenever we can.

We schedule dumps via "delayed-actions" and that is already smart
so that muliple schedulings are combined. However, before requesting
a new dump, we clear the flag that indicates that a dump is scheduled.
Thus, while processing the result of of a dump, we would re-schedule
anew which can be necessary in some cases.

In certain cases, we don't require a full resync, when we are in the
middle of processing a dump, because that one dump will provide us
with the full picture. Thus, we can avoid scheduling a new dump if
  - we already scheduled a delayed action
  - we are in the middle or processing a dump.
This can now be checked via delayed_action_refresh_all_in_progress().
2016-04-11 11:30:56 +02:00
Thomas Haller
8bf635af0e platform: refactor calling event_seq_check()
This makes more sense with the next commit.
2016-04-11 11:30:56 +02:00
Thomas Haller
90550a276b platform: refactor delayed_action_wait_for_nl_response_complete() 2016-04-11 11:30:56 +02:00
Thomas Haller
c59687c6b2 platform: #ifdef out nlh_seq_last_handled if it's unused
This is not for performance. It's to separate the relavant
parts from a part that is only for logging/asserts.
2016-04-11 11:26:37 +02:00
Thomas Haller
15e357c30a platform: add macro FOR_EACH_DELAYED_ACTION() 2016-04-11 11:26:37 +02:00
Thomas Haller
198baca830 platform: expose nmp_utils_ip_config_source_to/from_rtprot()
Will be used also from the tests.
2016-04-11 11:26:37 +02:00
Thomas Haller
af55476bf1 platform/tests: improve nmtstp_wait_for_signal() to return number of signals
Instead of returning only TRUE/FALSE, return the number of signals
that were received while waiting. This make the API cleared, because
previously I always had to check anew whether wait-for-signal returns
TRUE or FALSE on timeout.

Also, add nmtstp_assert_wait_for_signal() and nmtstp_assert_wait_for_signal_until()
macros.
2016-04-11 11:26:37 +02:00
Thomas Haller
c4151ebb5b platform/tests: add @platform argument to nmtstp functions
This allows tests to use these functions on a different platform instance
then on the singleton. The change makes the argument list longer, which is
unfortunate. On the other hand, it makes those functions more useful
in general.

You can't have it all.

Also, they now follow the pattern of most functions in NM where the type
is a singleton: you always pass the singleton to the function, although
in the usual case there is only one singleton instance. This allows to
use the function also on the non-singleton instance.
2016-04-11 11:26:37 +02:00
Thomas Haller
468501d0b0 platform/tests: change build order to first build test-common.c and platform core 2016-04-11 11:26:37 +02:00
Thomas Haller
f8f8c516e0 platform/tests/trivial: rename ip4_route_exists() functions to have nmtstp prefix 2016-04-11 11:26:37 +02:00
Thomas Haller
25d826ec49 platform/tests/trivial: rename init_tests() and setup_tests() function
Make it clear that they are nmtstp functions, i.e. they are found
in the header "test-common.h".
2016-04-11 11:26:37 +02:00
Thomas Haller
93c81a809d platform/tests: cleanup includes 2016-04-11 11:26:37 +02:00
Thomas Haller
56753ee41f platform/tests/trivial: move code around 2016-04-11 11:26:37 +02:00
Thomas Haller
35e7703bdc platform/tests: use nm_linux_platform_new() 2016-04-11 11:26:37 +02:00
Thomas Haller
d6b3081f7b platform: add NM_PLATFORM_NETNS_SUPPORT_DEFAULT 2016-04-11 11:26:37 +02:00
Thomas Haller
45a9a6b30b platform: add nm_linux_platform_new() constructor 2016-04-11 11:26:37 +02:00
Thomas Haller
44768f0311 platform: change @plen field of NMPlatformIPxAddress to type guint8
On netlink layer, this field is uint8_t/uchar.

A larger (signed) plen makes no sense. Adjust the signatures
to have only guint8.
2016-04-11 11:26:36 +02:00
Thomas Haller
14ee5dd2f8 platform: change @plen field of NMPlatformIPxRoute to type guint8
On netlink layer, this field is uint8_t/uchar.

A larger (signed) plen makes no sense. Adjust the signatures
to have only guint8.
2016-04-11 11:26:36 +02:00
Thomas Haller
b1e3deaf2f nmp-object: refactor handling of NMPCacheId to consider only relevant part of union
NMPCacheId is a union with fields for all known NMPCacheIdTypes.
Up to now, we always cloned the entire union, computed the hash
over all (possibly unset) fields and used memcmp() unanimously.

That was ok, because NMPCacheId was 16 bytes in total and cache-id
types that consumed less bytes didn't have a large overhead.

Next, we will add a new cache id type which increases the size of
NMPCacheId to 24 bytes. So, while possibly only a fraction of the
instances is that large, they would all have to pay that price.

Change that to consider and clone only those parts of the id
that are actually used.
2016-04-11 11:26:36 +02:00
Thomas Haller
fe78ae0b6a nmp-object: refactor initializing NMPCacheId
As we get more NMPCacheIdType values, it's better to have for
each type a pre-declared list of supported types, instead of
iterating over all types and letting _nmp_object_init_cache_id()
figure out that the cache-id-type is unsupported on that object.
2016-04-11 11:26:36 +02:00