Commit graph

7756 commits

Author SHA1 Message Date
Thomas Haller
4f06ae603e auth: allow failures to read process start_time from /proc/$PID/stat with hidepid
When mounting /proc with hidepid, we might fail to read the
start-time of the process from /proc/$PID/stat. In this case,
we should just accept a start-time of zero.

On the other side of authentication, polkit should accept a zero
start-time too.

nm_utils_get_start_time_for_pid() has other uses in NetworkManager,
mostly when killing a process from a PIDFILE or during
nm_utils_kill_process_sync(). In both these cases, this will only
succeed if we try to kill a process that also runs a root.

For processes started by the current instance, we don't care about the
PIDFILE and use nm_utils_kill_child_?sync() -- so there is no problem
with hidepid there.

https://bugzilla.gnome.org/show_bug.cgi?id=764502
(cherry picked from commit 3d505b3f87)
2016-04-22 14:42:51 +02:00
Thomas Haller
3341365e29 dns: avoid using global "/etc/dnsmasq.conf" config for dnsmasq
Pass an empty configuration file otherwise dnsmasq loads
"/etc/dnsmasq.conf".

We already allow for a config.d/ directory "/etc/NetworkManager/dnsmasq.d"
to allow the user to overwrite configuration. We don't want to consider
the global config file.

Fixes: 497a8aa5c6
(cherry picked from commit 3d3f71acec)
2016-04-22 13:40:17 +02:00
Thomas Haller
99168f6009 dns: various cleanup for new dnsmasq's D-Bus support
(cherry picked from commit baaec81aea)
2016-04-22 13:39:23 +02:00
Mathieu Trudel-Lapierre
08673a623f dns: use DBus to make dnsmasq nameserver changes
Use DBus to make nameserver updates rather than restarting the dnsmasq binary
again and again.

Signed-off-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>

https://mail.gnome.org/archives/networkmanager-list/2016-March/msg00144.html
(cherry picked from commit 18282df0aa)
2016-04-22 13:39:23 +02:00
Thomas Haller
9f3c8f3e01 dns: add and use _NMLOG() logging macro in nm-dns-plugin.c
(cherry picked from commit 44a61eda77)
2016-04-22 13:39:23 +02:00
Thomas Haller
4fa0f205b6 dns: cleanup managing child process for NMDnsPlugin
The 4 private fields pid, watch_id, progname and pidfile strictly
belong together. When spawning a child, we set all 4 of them and
when killing the child all get cleared. Cleanup to code to always
set those 4 fields together.

(cherry picked from commit 4d5ca7f9de)
2016-04-22 13:39:23 +02:00
Thomas Haller
3571356d9d dns: remove unnecessary finalize() implementation from NMDnsPlugin
dispose() already calls nm_dns_plugin_child_kill(), which clears
both pidfile and progname.

(cherry picked from commit 252258eb2a)
2016-04-22 13:39:23 +02:00
Thomas Haller
853b815266 dns: minor code cleanup in NMDnsPlugin
(cherry picked from commit de9ad6bd8c)
2016-04-22 13:39:23 +02:00
Lubomir Rintel
8ea39c3f1c modem: cancel secrets only if there's an outstanding request
Fixes an assertion failure on WWAN connection attempts that fail before
secrets are requested.

(cherry picked from commit 22c11f8ef1)
2016-04-20 18:16:35 +02:00
Thomas Haller
fa7cacd7df manager: fix wrongly removing DNS configuration on shutdown
When NetworkManager exits, it must preserve the DNS configuration of
devices that are left up.

Fixes: 9498ea507e
(cherry picked from commit 2158d6a5a8)
2016-04-20 17:54:24 +02:00
Lubomir Rintel
8de4c718af infiniband: remove the partitions on unrealizing
The infiniband drivers don't implement the rtnetlink link deletions.
Therefore we unrealize the NMDevice instance but the backing resources
stay around, preventing us from ever realizing the device again.

(cherry picked from commit a93807c288)
2016-04-20 10:49:35 +02:00
Lubomir Rintel
bb5a51aab3 platform: add functionality to remove infiniband partitions
(cherry picked from commit 940a423de4)
2016-04-20 10:49:34 +02:00
Dan Williams
866a5389e1 Revert "core: don't leak ActiveConnection object on AddAndActivate failure"
This reverts commit 8b6a1ac62f.

Original patch was in error; 'active' is already gs_unref_object.

(cherry picked from commit 2b0e5cd6e6)
2016-04-19 15:24:51 -05:00
Thomas Haller
7e41c15ace shared: move nm_utils_ascii_str_to_bool() to shared/nm-shared-utils.h
(cherry picked from commit 186787744c)
2016-04-19 15:14:17 +02:00
Lubomir Rintel
e3e7a25429 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
(cherry picked from commit 03584e420f)
2016-04-19 13:33:33 +02:00
Lubomir Rintel
17e9337054 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.

(cherry picked from commit 7eca706751)
2016-04-19 13:33:33 +02:00
Lubomir Rintel
6223d32e90 infiniband: consistently use the error code
Only report CREATION_FAILED when we did actually attempt creation.

(cherry picked from commit dda8e24a21)
2016-04-19 13:33:32 +02:00
Lubomir Rintel
af7321ae3f macvlan: fix error handling
(cherry picked from commit f9a0aface3)
2016-04-19 13:33:32 +02:00
Lubomir Rintel
4abb943e84 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.

(cherry picked from commit 332994f1b1)
2016-04-18 19:01:56 +02:00
Lubomir Rintel
60226446b3 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.

(cherry picked from commit 178c972fac)
2016-04-18 19:01:55 +02:00
Thomas Haller
401fd3adf9 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
(cherry picked from commit 201d91115c)
2016-04-18 18:00:58 +02:00
Thomas Haller
58c501eda5 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.

(cherry picked from commit 4697376f99)
2016-04-15 21:06:44 +02:00
Thomas Haller
b6973827cf 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().

(cherry picked from commit b2f794fe1e)
2016-04-15 21:06:43 +02:00
Thomas Haller
9c9dc9727a 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
(cherry picked from commit 2079f8361c)
2016-04-15 21:06:41 +02:00
Beniamino Galvani
8e405e99f0 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
(cherry picked from commit a032ce72ea)
2016-04-14 14:05:44 +02:00
Lubomir Rintel
d40539acaf 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
(cherry picked from commit dd0e070844)
2016-04-14 12:40:35 +02:00
Thomas Haller
b78e4de648 ifcfg-rh: support zero prefix length for IP addresses in reader
(cherry picked from commit a170320c35)
2016-04-12 11:16:12 +02:00
Thomas Haller
7b280fa162 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.

(cherry picked from commit 420bd611fd)
2016-04-12 11:16:12 +02:00
Thomas Haller
0a97605d2e 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.

(cherry picked from commit 4bb76fb4c3)
2016-04-12 11:14:02 +02:00
Thomas Haller
ec35bb8236 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.

(cherry picked from commit f8b2cadfc1)
2016-04-12 11:14:02 +02:00
Thomas Haller
bb654d8c25 platform: use _NM_UTILS_LOOKUP_DEFINE()
(cherry picked from commit 20618901dd)
2016-04-12 11:14:02 +02:00
Thomas Haller
6beb383bd7 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().

(cherry picked from commit ff8c82e7e1)
2016-04-12 11:14:01 +02:00
Thomas Haller
d6478fa764 platform: refactor calling event_seq_check()
This makes more sense with the next commit.

(cherry picked from commit 8bf635af0e)
2016-04-12 11:14:01 +02:00
Thomas Haller
c0e0e5e92c platform: refactor delayed_action_wait_for_nl_response_complete()
(cherry picked from commit 90550a276b)
2016-04-12 11:14:01 +02:00
Thomas Haller
a20e11d268 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.

(cherry picked from commit c59687c6b2)
2016-04-12 11:14:01 +02:00
Thomas Haller
53823384b5 platform: add macro FOR_EACH_DELAYED_ACTION()
(cherry picked from commit 15e357c30a)
2016-04-12 11:14:01 +02:00
Thomas Haller
c7f62fcd81 platform: expose nmp_utils_ip_config_source_to/from_rtprot()
Will be used also from the tests.

(cherry picked from commit 198baca830)
2016-04-12 11:14:01 +02:00
Thomas Haller
86e4975c60 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.

(cherry picked from commit af55476bf1)
2016-04-12 11:14:01 +02:00
Thomas Haller
a79a94fcfd 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.

(cherry picked from commit c4151ebb5b)
2016-04-12 11:14:01 +02:00
Thomas Haller
df74df710e platform/tests: change build order to first build test-common.c and platform core
(cherry picked from commit 468501d0b0)
2016-04-12 11:14:01 +02:00
Thomas Haller
bd76c1e2d0 platform/tests/trivial: rename ip4_route_exists() functions to have nmtstp prefix
(cherry picked from commit f8f8c516e0)
2016-04-12 11:14:01 +02:00
Thomas Haller
7d6b286e1f 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".

(cherry picked from commit 25d826ec49)
2016-04-12 11:14:01 +02:00
Thomas Haller
a314272d46 platform/tests: cleanup includes
(cherry picked from commit 93c81a809d)
2016-04-12 11:14:01 +02:00
Thomas Haller
bbec8844e2 platform/tests/trivial: move code around
(cherry picked from commit 56753ee41f)
2016-04-12 11:14:01 +02:00
Thomas Haller
04890bc709 platform/tests: use nm_linux_platform_new()
(cherry picked from commit 35e7703bdc)
2016-04-12 11:14:01 +02:00
Thomas Haller
d306ac633a platform: add NM_PLATFORM_NETNS_SUPPORT_DEFAULT
(cherry picked from commit d6b3081f7b)
2016-04-12 11:14:01 +02:00
Thomas Haller
b5bd562614 platform: add nm_linux_platform_new() constructor
(cherry picked from commit 45a9a6b30b)
2016-04-12 11:14:01 +02:00
Thomas Haller
4873850fd4 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.

(cherry picked from commit 44768f0311)
2016-04-12 11:14:01 +02:00
Thomas Haller
08cce6c0ef 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.

(cherry picked from commit 14ee5dd2f8)
2016-04-12 11:14:01 +02:00
Thomas Haller
395a09cfc7 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.

(cherry picked from commit b1e3deaf2f)
2016-04-12 11:14:01 +02:00