Commit graph

7774 commits

Author SHA1 Message Date
Thomas Haller
186787744c shared: move nm_utils_ascii_str_to_bool() to shared/nm-shared-utils.h 2016-04-19 13:47:41 +02:00
Lubomir Rintel
03584e420f device: check for a parent device
The device creation can be attempted if the name can be determined. It
alone is doesn't mean that there's a parent device -- the name could
just have been hardcoded in the connection.

  NetworkManager[21519]: nm_device_get_ifindex: assertion 'NM_IS_DEVICE (self)' failed

  Program received signal SIGTRAP, Trace/breakpoint trap.
  g_logv (log_domain=0x5555557fb2e5 "NetworkManager", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffd3d0) at gmessages.c:1046
  1046              g_private_set (&g_log_depth, GUINT_TO_POINTER (depth));
  (gdb) bt
  #0  0x00007ffff4ec88c3 in g_logv (log_domain=0x5555557fb2e5 "NetworkManager", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffd3d0) at gmessages.c:1046
  #1  0x00007ffff4ec8a3f in g_log (log_domain=<optimized out>, log_level=<optimized out>, format=<optimized out>) at gmessages.c:1079
  #2  0x00005555555d2090 in nm_device_get_ifindex (self=0x0) at devices/nm-device.c:562
  #3  0x00005555555ef77a in nm_device_supports_vlans (self=0x0) at devices/nm-device.c:9865
  #4  0x00005555555bf2f9 in create_and_realize (device=0x555555c549b0 [NMDeviceVlan], connection=0x555555b451e0, parent=0x0, out_plink=0x7fffffffd5f8, error=0x7fffffffd700) at devices/nm-device-vlan.c:225
  #5  0x00005555555d5757 in nm_device_create_and_realize (self=0x555555c549b0 [NMDeviceVlan], connection=0x555555b451e0, parent=0x0, error=0x7fffffffd700) at devices/nm-device.c:1783
  #6  0x0000555555688601 in system_create_virtual_device (self=0x555555af51c0 [NMManager], connection=0x555555b451e0) at nm-manager.c:1120
  #7  0x000055555568894e in connection_changed (settings=0x555555ae8220 [NMSettings], connection=0x555555b451e0, manager=0x555555af51c0 [NMManager]) at nm-manager.c:1172
  #8  0x0000555555693448 in nm_manager_start (self=0x555555af51c0 [NMManager], error=0x7fffffffda30) at nm-manager.c:4466
  #9  0x00005555555d166f in main (argc=1, argv=0x7fffffffdba8) at main.c:454
  (gdb)

Fixes: 332994f1b1
2016-04-19 13:32:28 +02:00
Lubomir Rintel
7eca706751 infiniband: check that the connection to be created is a partition first
No functional change. It will make it a bit easier to produce a good
error message in subsequent commit.
2016-04-19 13:32:28 +02:00
Lubomir Rintel
dda8e24a21 infiniband: consistently use the error code
Only report CREATION_FAILED when we did actually attempt creation.
2016-04-19 13:32:28 +02:00
Lubomir Rintel
f9a0aface3 macvlan: fix error handling 2016-04-19 13:32:28 +02:00
Thomas Haller
3f230c1ad8 merge: merge branch 'systemd' into master 2016-04-19 13:08:13 +02:00
Thomas Haller
38abb711f5 systemd: update code from upstream
This is a direct dump from systemd git on 2016-04-19, git commit
490d20e65dd85628f910299a3925bbff466b2e74.

======

SYSTEMD_DIR=../systemd
COMMIT=490d20e65dd85628f910299a3925bbff466b2e74

(
  cd "$SYSTEMD_DIR"
  git checkout "$COMMIT"
  git reset --hard
  git clean -fdx
)

git ls-files :/src/systemd/src/ | xargs -d '\n' rm -f

nm_copy_sd() {
    mkdir -p "./src/systemd/$(dirname "$1")"
    cp "$SYSTEMD_DIR/$1" "./src/systemd/$1"
}

nm_copy_sd "src/basic/alloc-util.c"
nm_copy_sd "src/basic/alloc-util.h"
nm_copy_sd "src/basic/async.h"
nm_copy_sd "src/basic/escape.c"
nm_copy_sd "src/basic/escape.h"
nm_copy_sd "src/basic/ether-addr-util.c"
nm_copy_sd "src/basic/ether-addr-util.h"
nm_copy_sd "src/basic/fileio.c"
nm_copy_sd "src/basic/fileio.h"
nm_copy_sd "src/basic/fd-util.c"
nm_copy_sd "src/basic/fd-util.h"
nm_copy_sd "src/basic/fs-util.c"
nm_copy_sd "src/basic/fs-util.h"
nm_copy_sd "src/basic/hash-funcs.c"
nm_copy_sd "src/basic/hash-funcs.h"
nm_copy_sd "src/basic/hashmap.c"
nm_copy_sd "src/basic/hashmap.h"
nm_copy_sd "src/basic/hexdecoct.c"
nm_copy_sd "src/basic/hexdecoct.h"
nm_copy_sd "src/basic/hostname-util.c"
nm_copy_sd "src/basic/hostname-util.h"
nm_copy_sd "src/basic/in-addr-util.c"
nm_copy_sd "src/basic/in-addr-util.h"
nm_copy_sd "src/basic/io-util.c"
nm_copy_sd "src/basic/io-util.h"
nm_copy_sd "src/basic/list.h"
nm_copy_sd "src/basic/log.h"
nm_copy_sd "src/basic/macro.h"
nm_copy_sd "src/basic/mempool.h"
nm_copy_sd "src/basic/mempool.c"
nm_copy_sd "src/basic/parse-util.c"
nm_copy_sd "src/basic/parse-util.h"
nm_copy_sd "src/basic/path-util.c"
nm_copy_sd "src/basic/path-util.h"
nm_copy_sd "src/basic/prioq.h"
nm_copy_sd "src/basic/prioq.c"
nm_copy_sd "src/basic/random-util.c"
nm_copy_sd "src/basic/random-util.h"
nm_copy_sd "src/basic/refcnt.h"
nm_copy_sd "src/basic/set.h"
nm_copy_sd "src/basic/signal-util.h"
nm_copy_sd "src/basic/siphash24.c"
nm_copy_sd "src/basic/siphash24.h"
nm_copy_sd "src/basic/socket-util.c"
nm_copy_sd "src/basic/socket-util.h"
nm_copy_sd "src/basic/sparse-endian.h"
nm_copy_sd "src/basic/stdio-util.h"
nm_copy_sd "src/basic/string-table.c"
nm_copy_sd "src/basic/string-table.h"
nm_copy_sd "src/basic/string-util.c"
nm_copy_sd "src/basic/string-util.h"
nm_copy_sd "src/basic/strv.c"
nm_copy_sd "src/basic/strv.h"
nm_copy_sd "src/basic/time-util.c"
nm_copy_sd "src/basic/time-util.h"
nm_copy_sd "src/basic/umask-util.h"
nm_copy_sd "src/basic/unaligned.h"
nm_copy_sd "src/basic/utf8.c"
nm_copy_sd "src/basic/utf8.h"
nm_copy_sd "src/basic/util.c"
nm_copy_sd "src/basic/util.h"
nm_copy_sd "src/libsystemd-network/arp-util.c"
nm_copy_sd "src/libsystemd-network/arp-util.h"
nm_copy_sd "src/libsystemd-network/dhcp6-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp6-lease-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp6-network.c"
nm_copy_sd "src/libsystemd-network/dhcp6-option.c"
nm_copy_sd "src/libsystemd-network/dhcp6-protocol.h"
nm_copy_sd "src/libsystemd-network/dhcp-identifier.c"
nm_copy_sd "src/libsystemd-network/dhcp-identifier.h"
nm_copy_sd "src/libsystemd-network/dhcp-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp-lease-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp-network.c"
nm_copy_sd "src/libsystemd-network/dhcp-option.c"
nm_copy_sd "src/libsystemd-network/dhcp-packet.c"
nm_copy_sd "src/libsystemd-network/dhcp-protocol.h"
nm_copy_sd "src/libsystemd-network/lldp-internal.h"
nm_copy_sd "src/libsystemd-network/lldp-neighbor.c"
nm_copy_sd "src/libsystemd-network/lldp-neighbor.h"
nm_copy_sd "src/libsystemd-network/lldp-network.c"
nm_copy_sd "src/libsystemd-network/lldp-network.h"
nm_copy_sd "src/libsystemd-network/network-internal.c"
nm_copy_sd "src/libsystemd-network/network-internal.h"
nm_copy_sd "src/libsystemd-network/sd-dhcp6-client.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp6-lease.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp-client.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp-lease.c"
nm_copy_sd "src/libsystemd-network/sd-ipv4ll.c"
nm_copy_sd "src/libsystemd-network/sd-ipv4acd.c"
nm_copy_sd "src/libsystemd-network/sd-lldp.c"
nm_copy_sd "src/libsystemd/sd-event/sd-event.c"
nm_copy_sd "src/libsystemd/sd-id128/sd-id128.c"
nm_copy_sd "src/shared/dns-domain.c"
nm_copy_sd "src/shared/dns-domain.h"
nm_copy_sd "src/systemd/_sd-common.h"
nm_copy_sd "src/systemd/sd-dhcp6-client.h"
nm_copy_sd "src/systemd/sd-dhcp6-lease.h"
nm_copy_sd "src/systemd/sd-dhcp-client.h"
nm_copy_sd "src/systemd/sd-dhcp-lease.h"
nm_copy_sd "src/systemd/sd-event.h"
nm_copy_sd "src/systemd/sd-ndisc.h"
nm_copy_sd "src/systemd/sd-id128.h"
nm_copy_sd "src/systemd/sd-ipv4acd.h"
nm_copy_sd "src/systemd/sd-ipv4ll.h"
nm_copy_sd "src/systemd/sd-lldp.h"
2016-04-19 13:01:08 +02:00
Beniamino Galvani
28274495d6 device/team: always try to connect to teamd in update_connection()
update_connection() may be called during startup when the bus watch
hasn't notified yet the presence (or absence) of the teamd service on
the bus. Try to obtain a connection to the service in order to
retrieve the current configuration.
2016-04-18 21:50:36 +02:00
Lubomir Rintel
332994f1b1 device-factory: always prefer manually set interface name to a generated one
If the connection specifies an interface name, it should never attach to
a device of a different name even if the factory thinks the connection
is compatible with the device.

This fixes an issue that caused the inifniband connections to attach to
different devices or partitions.
2016-04-18 19:00:54 +02:00
Lubomir Rintel
178c972fac libnm-core/vpn-connection: get the service for bus path from plugin
...not from the connection. Otherwise the o.fdo.NM.openswan connection
would try to use a name they're not allowed to use.
2016-04-18 19:00:46 +02:00
Thomas Haller
201d91115c linux-platform: fix crash in _new_from_nl_link() when sharing lnk data
We want to reuse an existing (equal) lnk-data from the cache.

  NetworkManager[20977]: <debug> [1460993609.1427] platform: signal: link   added: 11: qib_ib0.8002@4 <UP,LOWER_UP;broadcast,multicast,up,running,lowerup> mtu 65520 arp 32 infiniband? not-init addrgenmode eui64 addr 80:00:00:11:FE:80:00:00:00:00:00:00:00:11:75:00:00:6F:33:DE driver ib_ipoib
  ...
  NetworkManager[20977]: <debug> [1460993609.1467] platform-linux: do-request-link: 11
  NetworkManager[20977]: nmp_object_ref: assertion 'NMP_OBJECT_IS_VALID (obj)' failed

  Program received signal SIGTRAP, Trace/breakpoint trap.
  g_logv (log_domain=0x55555583dcce "NetworkManager", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffc8e0) at gmessages.c:1046
  1046              g_private_set (&g_log_depth, GUINT_TO_POINTER (depth));
  (gdb) bt
  #0  0x00002aaaad94b8c3 in g_logv (log_domain=0x55555583dcce "NetworkManager", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffc8e0) at gmessages.c:1046
  #1  0x00002aaaad94ba3f in g_log (log_domain=<optimized out>, log_level=<optimized out>, format=<optimized out>) at gmessages.c:1079
  #2  0x00005555557863be in nmp_object_ref (obj=0x0) at platform/nmp-object.c:210
  #3  0x0000555555624c0e in event_handler_recvmsgs (id_only=<optimized out>, nlh=<optimized out>, cache=<optimized out>, platform=<optimized out>) at platform/nm-linux-platform.c:1568
  #4  0x0000555555624c0e in event_handler_recvmsgs (id_only=<optimized out>, msg=0x555555b0ebf0, cache=<optimized out>, platform=<optimized out>) at platform/nm-linux-platform.c:1923
  #5  0x0000555555624c0e in event_handler_recvmsgs (handle_events=<optimized out>, msg=0x555555b0ebf0, platform=<optimized out>) at platform/nm-linux-platform.c:3656
  #6  0x0000555555624c0e in event_handler_recvmsgs (platform=platform@entry=0x555555b00980 [NMLinuxPlatform], handle_events=handle_events@entry=1) at platform/nm-linux-platform.c:5886
  #7  0x0000555555626857 in event_handler_read_netlink (platform=platform@entry=0x555555b00980 [NMLinuxPlatform], wait_for_acks=wait_for_acks@entry=0) at platform/nm-linux-platform.c:5942
  #8  0x0000555555627093 in do_request_link_no_delayed_actions (platform=platform@entry=0x555555b00980 [NMLinuxPlatform], ifindex=ifindex@entry=11, name=name@entry=0x0) at platform/nm-linux-platform.c:3480
  #9  0x00005555556273d6 in delayed_action_handle_all (ifindex=11, platform=0x555555b00980 [NMLinuxPlatform]) at platform/nm-linux-platform.c:2918
  #10 0x00005555556273d6 in delayed_action_handle_all (platform=0x555555b00980 [NMLinuxPlatform]) at platform/nm-linux-platform.c:3003
  #11 0x00005555556273d6 in delayed_action_handle_all (platform=0x555555b00980 [NMLinuxPlatform], read_netlink=<optimized out>) at platform/nm-linux-platform.c:3029
  #12 0x000055555562a33f in constructed (_object=<optimized out>) at platform/nm-linux-platform.c:6241
  #13 0x00002aaaad6c0292 in g_object_new_internal (class=class@entry=0x555555b12ef0, params=params@entry=0x7fffffffd660, n_params=2) at gobject.c:1814
  #14 0x00002aaaad6c21d4 in g_object_new_valist (object_type=object_type@entry=93824998249472, first_property_name=first_property_name@entry=0x55555580629e "register-singleton", var_args=var_args@entry=0x7fffffffd7b0) at gobject.c:2034
  #15 0x00002aaaad6c25d1 in g_object_new (object_type=93824998249472, first_property_name=0x55555580629e "register-singleton") at gobject.c:1617
  #16 0x00005555555d1798 in main (argc=1, argv=0x7fffffffda58) at main.c:446

Fixes: db5d00d396
2016-04-18 17:55:02 +02:00
Beniamino Galvani
f439f05237 dns-manager: properly handle multiple VPN configurations
Now that we support multiple VPNs active at the same time, the DNS
manager must be able to keep a list of all the VPN configurations and
give them a higher priority than other configurations.

Before this commit all the VPN configuration except one were
considered as normal configurations.

https://bugzilla.gnome.org/show_bug.cgi?id=764689
2016-04-18 11:29:25 +02:00
Beniamino Galvani
89306ebb2e dns-manager: add 'priv' pointer to object structure 2016-04-18 11:29:09 +02:00
Beniamino Galvani
317f70997b dns: fix debug message
Fixes: 5f9d348c20
2016-04-15 22:01:56 +02:00
Thomas Haller
4697376f99 device: fix preserving the default-route during _cleanup_generic_post()
When we want to preserve the default-route on cleanup, we must first
set it to assumed, before clearing it. Otherwise, NMDefaultRouteManager's
update() will delete the default route.

This is the oposite of the deconfigure case, where we first set it to
!has && !assumed, to force the route-manager to delete the route.
2016-04-15 18:09:48 +02:00
Thomas Haller
b2f794fe1e device: refactor clearing default-route in NMDevice
Add a function _update_default_route() to set the default_route
flags and call update() in one step.

Also, if there are no changes, skip the call to NMDefaultRouteManager's
update().
2016-04-15 18:07:01 +02:00
Thomas Haller
2079f8361c device: fix wrongly deleting default-route on exit
We must preserve the default-route on shutdown.

Thus it must first be announced as "assumed", and only removed
in a second step.

Fixes: 9498ea507e
2016-04-15 17:39:09 +02:00
Beniamino Galvani
b88ce6d044 dns: update caching plugins on configuration change signal
A HUP or USR1 signal forces the rewrite of DNS configuration, however
caching plugins are ignored when using dns=dnsmasq and so the real
servers are written to resolv.conf:

 $ cat /etc/resolv.conf
 nameserver 127.0.0.1

 # killall -USR1 NetworkManager

 $ cat /etc/resolv.conf
 nameserver 192.168.1.1

Set @no_caching to FALSE when calling update_dns() after a signal to
take caching plugins into account.
2016-04-15 11:56:29 +02:00
Beniamino Galvani
53dfaddda2 device: apply MTU setting also to devices without IPv4 configuration
Usually the MTU in the ethernet.mtu property is applied to the device
during the commit of IPv4 configuration.  For devices with
ipv4.method=disabled or slave devices that phase is skipped and so the
setting does not have effect.  Apply the MTU explicitly in such cases.

https://bugzilla.redhat.com/show_bug.cgi?id=1303968
https://bugzilla.redhat.com/show_bug.cgi?id=1303731
2016-04-14 15:19:11 +02:00
Beniamino Galvani
a032ce72ea device/vlan: update hw address also during prepare phase
The hardware address of a VLAN must be kept aligned with the one of
its parent device, and we already used a signal in NMDeviceVlan to
catch changes in parent address and update the VLAN device
accordingly.

But this didn't work in all cases because the change might happen
after the VLAN gets created but before we register the signal, so it
is necessary to add further checks to enforce the alignment during the
device activation.

https://bugzilla.redhat.com/show_bug.cgi?id=1325752
2016-04-14 14:01:17 +02:00
Lubomir Rintel
dd0e070844 vpn-connection: don't fail the connection if there's no VPN gateway
The stongswan charon_nm plugin doesn't send a gateway.
The logic was accidentally broken with GDBus port.

Fixes: 231b0390a5
2016-04-14 12:39:56 +02:00
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
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
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
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