Commit Graph

21076 Commits

Author SHA1 Message Date
Thomas Haller
4186ddb58b shared: add nm_errno() and nm_utils_error_set_errno() helper 2018-09-12 10:13:11 +02:00
Thomas Haller
2a45c32e8c ppp: cleanup logging in impl_ppp_manager_set_ifindex()
It's enough that all code paths in impl_ppp_manager_set_ifindex() log exactly
one message. Also, give all messages the same prefix, so that it's clear where
they come from.
2018-09-11 22:05:45 +02:00
Thomas Haller
4a4439835d ppp: downgrade warning about repeated SetIfindex calls from ppp plugin
In src/ppp/nm-pppd-plugin.c, it seems that pppd can invoke
phasechange(PHASE_RUNNING:) multiple times. Hence, the plugin
calls SetIfindex multiple times too. In nm-ppp-manager.c, we
want to make sure that the ifindex does not change after it
was set once. However, calling SetIfindex with the same ifindex
is not something worth warning. Just log a debug message and nothing.

Maybe the plugin should remember that it already set the ifindex,
and avoid multiple D-Bus calls. But it's unclear that that is desired.
For now, just downgrade the warning.
2018-09-11 21:55:11 +02:00
Thomas Haller
4d11eba8c5 ppp: avoid strncpy() in ppp plugin nm_phasechange()
strncpy() is deemed insecure, and it raises at least an eyebrow.
While it's save in this case, just avoid it.
2018-09-11 21:53:04 +02:00
Thomas Haller
30a469e0bb ppp-manager: avoid crash with nonexisting link in impl_ppp_manager_set_ifindex()
Fixes: dd98ada33f
2018-09-11 21:30:14 +02:00
Frederic Danis
e66e4d0e71 ppp-manager: fix pppd not exiting correctly on modem hangup
When unplugging an USB 3G modem device, pppd does not exit correctly and
we have the following traces:

Sep 10 07:58:24.616465 ModemManager[1158]: <info>  (tty/ttyUSB0): released by device '/sys/devices/pci0000:00/0000:00:1c.0/0000:01:00.0/usb4/4-1'
Sep 10 07:58:24.620314 pppd[2292]: Modem hangup
Sep 10 07:58:24.621368 ModemManager[1158]: <info>  (tty/ttyUSB1): released by device '/sys/devices/pci0000:00/0000:00:1c.0/0000:01:00.0/usb4/4-1'
Sep 10 07:58:24.621835 ModemManager[1158]: <warn>  (ttyUSB1): could not re-acquire serial port lock: (5) Input/output error
Sep 10 07:58:24.621358 NetworkManager[1871]: <debug> ppp-manager: set-ifindex 4
Sep 10 07:58:24.621369 NetworkManager[1871]: <warn>  ppp-manager: can't change the ifindex from 4 to 4
Sep 10 07:58:24.623982 NetworkManager[1871]: <info>  device (ttyUSB0): state change: activated -> unmanaged (reason 'removed', sys-iface-state: 'removed')
Sep 10 07:58:24.624411 NetworkManager[1871]: <debug> kill child process 'pppd' (2292): wait for process to terminate after sending SIGTERM (15) (send SIGKILL in 1500 milliseconds)...
Sep 10 07:58:24.624440 NetworkManager[1871]: <debug> modem-broadband[ttyUSB0]: notifying ModemManager about the modem disconnection
Sep 10 07:58:24.626591 NetworkManager[1871]: <debug> modem-broadband[ttyUSB0]: notifying ModemManager about the modem disconnection
Sep 10 07:58:24.681016 NetworkManager[1871]: <warn>  modem-broadband[ttyUSB0]: failed to disconnect modem: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface 'org.freedesktop.ModemManager1.Modem.Simple' on object at path /org/freedesktop/ModemManager1/Modem/0
Sep 10 07:58:26.126817 NetworkManager[1871]: <debug> kill child process 'pppd' (2292): process not terminated after 1502368 usec. Sending SIGKILL signal
Sep 10 07:58:26.128121 NetworkManager[1871]: <info>  device (ppp0): state change: disconnected -> unmanaged (reason 'unmanaged', sys-iface-state: 'removed')
Sep 10 07:58:26.135571 NetworkManager[1871]: <debug> kill child process 'pppd' (2292): terminated by signal 9 (1511158 usec elapsed)

This is due to nm-ppp-plugin waiting on SetIfIndex call until timeout,
which is longer than termination process timeout.

Calling g_dbus_method_invocation_return_value() on error fixes this.

Fixes: dd98ada33f

https://mail.gnome.org/archives/networkmanager-list/2018-September/msg00010.html
2018-09-11 21:22:37 +02:00
Andrew Zaborowski
32506c8788 wifi/iwd: handle new GetOrderedNetworks() return type
The Station.GetOrderedNetworks dbus method's return type has changed in
IWD commit 0a42f63d42be903a46c595693884772c1c84d39f as the last incompatible
API change before IWD 0.8 (docs change was made earlier in
0453308134a3aadb6a2ec6a78ea642e19427704c) so that network names and
types are no longer included in the reply.  Expect this new reply
signature although still handle the old signature if we're using the
Device interface for IWD <= 0.7 compatibility.

It may be good idea to eventually pass the object manager instance from
nm-iwd-manager.c to nm-device-iwd.c to avoid using g_dbus_proxy_new_sync
and g_dbus_proxy_new_for_bus_sync in act_stage2_config, which possibly
generates a lot of DBus property queries.

https://github.com/NetworkManager/NetworkManager/pull/197
2018-09-11 14:10:30 +02:00
Thomas Haller
c87faf07a1 dhcp: fix leak in dhclient's dhclient_start()
Fixes: 5d6d5cd136
2018-09-10 14:32:14 +02:00
Thomas Haller
e3bd482329 device: mark wireguard devices as unmanaged
Later we want to fully support wireguard devices. Also,
possibly activating a generic profile in a wireguard device
would make sense.

Anyway, for the moment, just prevent that from happening
by explicitly marking the device as unmanaged.
2018-09-10 11:12:39 +02:00
Thomas Haller
045a36b33b device: rename NM_UNMANAGED_LOOPBACK to NM_UNMANAGED_BY_TYPE
It is generally useful, not only for loopback. Rename.
2018-09-10 11:11:40 +02:00
Thomas Haller
3635f462b0 device: detect loopback device explicitly
Don't use NM_UNMANAGED_LOOPBACK for that.
2018-09-10 11:11:40 +02:00
Thomas Haller
baa0008313 device: make device incompatible with profiles by default
Currently, NMDeviceWireguard does neither set connection_type_check_compatible
nor implement check_connection_compatible. That means, it appears to be compatible
with every connection profile, which is obviously wrong.

Allow devices not to implement check_connection_compatible() and avoid the issue
by rejecting profiles by default.
2018-09-10 11:11:40 +02:00
Thomas Haller
57cfc6f19d release: bump version to 1.15.0 (development) 2018-09-08 10:24:20 +02:00
Thomas Haller
16ad82f967 release: bump version to 1.13.90 (1.14-rc1) 2018-09-08 10:24:16 +02:00
Thomas Haller
9d50d981c3 wifi/iwd: merge branch 'balrog-kun/iwd-fixes' (part 2)
https://github.com/NetworkManager/NetworkManager/pull/194
2018-09-08 10:10:44 +02:00
Andrew Zaborowski
7308ba2cb8 wifi/iwd: use the new 'Station' DBus interface
The following commit between IWD 0.7 and 0.8 splits the previous Device
interface into two interfaces with no functional changes:
https://git.kernel.org/pub/scm/network/wireless/iwd.git/commit/doc?id=0453308134a3aadb6a2ec6a78ea642e19427704c

Try using this new API but fall back to the old one if the State
property is found still on the Device interface.
2018-09-08 02:31:57 +02:00
Thomas Haller
c3808550eb shared: change nm_utils_strbuf_seek_end() handling truncated strings
Ok, I changed my mind.

The new behavior seems to make more sense to me. Not that it matters,
because we always use nm_utils_strbuf*() API with buffers that we expect
to be large enough to contain the result. And when truncation occurs,
we usually don't care much about it. That is, there is no code that
uses nm_utils_strbuf*() API and handles string truncation in particular.
2018-09-07 18:13:10 +02:00
Thomas Haller
d45e0b6558 wifi/iwd: merge branch 'balrog-kun/iwd-fixes' (partial)
https://github.com/NetworkManager/NetworkManager/pull/194
2018-09-07 15:19:52 +02:00
Andrew Zaborowski
618568366d wifi/iwd: add new DBus interface name defines
New IWD DBus interfaces added before 0.4 and before 0.8
2018-09-07 15:18:56 +02:00
Andrew Zaborowski
436c2a1c8b wifi/iwd: use NM_IN_STRSET for strings
NM_IN_SET will only compare string pointers and isn't useful for
checking if nm_setting_wireless_get_mode (s_wifi) is infrastructure.

Fixes: 570e1fa75b
2018-09-07 15:18:56 +02:00
Andrew Zaborowski
910dc39cd3 wifi/iwd: fix leaking agent DBus objects
Make sure we free our IWD agent objects whenever we're freeing the
IWD Object Manager.  We're registering those objects on the same DBus
connection as the Object Manager so that they're visible to IWD, and
our only reference to that connection is through priv->object_manager
so even though the connection isn't changing when we free the object
manager and create a new one, we still need to free the agent object.
We could maybe keep a reference to the connection, but I'm not sure
there's any warranty that it doesn't get closed.  We could also use
nm_dbus_manager_get_connection (nm_dbus_manager_get ()) and only
register and free the agent once, since it happens to be the same
connection but it'd perhaps be a hack to rely on this.
2018-09-07 15:17:12 +02:00
Thomas Haller
1df7ed0cbe release: update NEWS 2018-09-07 14:50:12 +02:00
Thomas Haller
e90e1536c9 libnm/docs: clarify which interface to share with ipvx.method=shared 2018-09-07 12:45:38 +02:00
Thomas Haller
ec17242f2e platform: merge branch 'th/platform-wireguard'
Various cleanups. Also fixes a crash.

https://github.com/NetworkManager/NetworkManager/pull/193
2018-09-07 11:26:23 +02:00
Thomas Haller
62d14e1884 platform/wireguard: rework parsing wireguard links in platform
- previously, parsing wireguard genl data resulted in memory corruption:

  - _wireguard_update_from_allowedips_nla() takes pointers to

      allowedip = &g_array_index (buf->allowedips, NMWireGuardAllowedIP, buf->allowedips->len - 1);

    but resizing the GArray will invalidate this pointer. This happens
    when there are multiple allowed-ips to parse.

  - there was some confusion who owned the allowedips pointers.
    _wireguard_peers_cpy() and _vt_cmd_obj_dispose_lnk_wireguard()
    assumed each peer owned their own chunk, but _wireguard_get_link_properties()
    would not duplicate the memory properly.

- rework memory handling for allowed_ips. Now, the NMPObjectLnkWireGuard
  keeps a pointer _allowed_ips_buf. This buffer contains the instances for
  all peers.
  The parsing of the netlink message is the complicated part, because
  we don't know upfront how many peers/allowed-ips we receive. During
  construction, the tracking of peers/allowed-ips is complicated,
  via a CList/GArray. At the end of that, we prettify the data
  representation and put everything into two buffers. That is more
  efficient and simpler for user afterwards. This moves complexity
  to the way how the object is created, vs. how it is used later.

- ensure that we nm_explicit_bzero() private-key and preshared-key. However,
  that only works to a certain point, because our netlink library does not
  ensure that no data is leaked.

- don't use a "struct sockaddr" union for the peer's endpoint. Instead,
  use a combintation of endpoint_family, endpoint_port, and
  endpoint_addr.

- a lot of refactoring.
2018-09-07 11:24:17 +02:00
Thomas Haller
cb23779e0a platform/trivial: rename local variables for nla_policy/nlattr
We have such variables with similar purpose at various places.
Name them all the same.
2018-09-07 11:24:17 +02:00
Thomas Haller
f18fb7745a platform: fix resusing ext-data from cache in _new_from_nl_link() 2018-09-07 11:24:17 +02:00
Thomas Haller
989bdaec63 platform/trivial: move code in nm-linux-platform.c around
Move NMLinuxPlatformPrivate earlier.

In the past, I moved the declaration of NMLinuxPlatformPrivate
after utility functions which are independent from platform
instance.

However, parsing netlink messages actually requires
NMLinuxPlatformPrivate, because we want to access the "genl"
socket.

So, move the types to the beginning of the file, like we do
for most other source files.
2018-09-07 11:24:17 +02:00
Thomas Haller
f99ee135d1 platform: let _lookup_cached_link() also return cached links that are not in netlink
The _lookup_cached_link() function, should not skip over links which are
currently in the cache, but not in netlink. Instead, let the callers
skip them, as they see fit.

No change in behavior, because the few callers now explicitly check
for this.
2018-09-07 11:24:17 +02:00
Thomas Haller
7042cd5e19 platform: cleanup error paths
- drop "goto error_label" in favor of returning right away.
  At most places, there was no need to do any cleanup or
  the cleanup is handled via nm_auto().

- adjust the return types of wireguard functions to return
  a boolean success/failure, instead of some error code which
  we didn't use.

- the change to _wireguard_get_link_properties() is intentional.
  This was wrong previously, because in _wireguard_get_link_properties()
  obj is always a newly created instance, and never has a genl
  family ID set. This will be improved later.
2018-09-07 11:24:17 +02:00
Thomas Haller
9740d3a68c platform/netlink: assert that callbacks don't return positive error code 2018-09-07 11:24:17 +02:00
Thomas Haller
a30dd1eff0 platform/netlink: drop ref-counting for "struct nl_msg"
It was unused.
2018-09-07 11:24:17 +02:00
Thomas Haller
e9cf8b196d platform/trivial: reorder code 2018-09-07 11:24:17 +02:00
Thomas Haller
5fd4ca8a5b platform/netlink: drop nlmsg_alloc_inherit() function
It's only used internally, and it seems not very useful to have.
As it is confusing to have multiple functions for doing something
similar, drop it -- since it's not really used. I also cannot imagine
a good use-case for it.
2018-09-07 11:24:17 +02:00
Thomas Haller
09aaeb83b7 platform: fix printing all-info about NMPObjectLink instances
When we print info about the link, we also want to print
info about the referenced lnk instance, which commonly contains
link-specific data.

For NMP_OBJECT_TO_STRING_PUBLIC this was done correctly, by
calling to-string of public fields on the lnk object.

For NMP_OBJECT_TO_STRING_ALL, we wrongly just delegated to the
public to-string function, this means, for the lnk object we
would not print all fields.

Fix that.
2018-09-07 11:24:17 +02:00
Thomas Haller
0a8248af10 shared: add nm_utils_strbuf_seek_end() helper 2018-09-07 11:24:17 +02:00
Thomas Haller
0feeeaac63 shared: add nm_utils_mem_all_zero() 2018-09-07 11:24:17 +02:00
Thomas Haller
085a369446 all: avoid g_memdup()
By using nm_memdup().

Except in shared/nm-utils/nm-compat.c, which may not include
"shared/nm-utils/nm-shared-utils.h".
2018-09-07 11:24:17 +02:00
Thomas Haller
1fb8fbbc99 shared: add nm_memdup() as replacement for g_memdup()
I think g_memdup() is dangerous for integer overflow. There
is no need for accepting this danger, just use our own nm_memdup()
which does not have this flaw.
2018-09-07 11:24:17 +02:00
Thomas Haller
98f28ddf2e platform/netlink: fix nl_errno() to get absolute error number value 2018-09-07 11:24:17 +02:00
Beniamino Galvani
c882633d48 core: fix wireless bitrate property name on D-Bus
In commit 297d4985ab ("core/dbus: rework D-Bus implementation to use
lower layer GDBusConnection API") the Device.Wireless 'Bitrate'
property on D-Bus was accidentally changed to 'BitRate'. Revert the
old name.

Reported-by: Joseph Conley <joseph.j.conley@gmail.com>
Fixes: 297d4985ab

https://mail.gnome.org/archives/networkmanager-list/2018-September/msg00004.html
2018-09-07 09:40:09 +02:00
Thomas Haller
f3f5d5c900 platform/trivial: add FIXME comment to use new ethtool API to set link settings 2018-09-06 10:30:51 +02:00
Beniamino Galvani
b23403559e merge: branch 'bg/llmnr'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/13
https://github.com/NetworkManager/NetworkManager/pull/192
2018-09-06 09:23:55 +02:00
Beniamino Galvani
0cfbca53e4 device: allow the reapply of mdns and llmnr properties 2018-09-06 09:19:41 +02:00
Beniamino Galvani
6169cd570f core: nm-ip4-config: consider dns-related differences as relevant
The DNS manager reacts to NM_DEVICE_IP4_CONFIG_CHANGED events, which
are generated when there is a relevant change to an IP4 configuration.

Until now, changes to the mdns,llmnr properties were not
considered relevant (and neither minor, this is already a bug).

Promote them to relevant so that the DNS manager is notified and will
rewrite the DNS configuration when one of this properties changes.

Note that the DNS priority should be considered relevant and added
into the checksum as well, but is a problem right now because in the
DNS manager we rely on the fact that an empty configuration (i.e. just
created) has a zero checksum. This is needed to avoid rewriting
resolv.conf when there is no change. The DNS priority initial value
depends on the connection type (VPN or not), so it's a bit difficult
to add it to checksum maintaining the assumption of checksum(empty)=0.
This should be improved in the future.
2018-09-06 09:19:41 +02:00
Beniamino Galvani
44d77a7476 ifcfg-rh: add support for connection.llmnr 2018-09-06 09:07:41 +02:00
Beniamino Galvani
481fce62bf cli: add support for connection.llmnr 2018-09-06 09:07:41 +02:00
Beniamino Galvani
bc7efc750a core: add support for connection.llmnr 2018-09-06 09:07:41 +02:00
Beniamino Galvani
e83c31bbe0 libnm-core: add connection.llmnr property 2018-09-06 09:07:41 +02:00
Beniamino Galvani
8e6ad2853c libnm-core: fix documentation for connection.mdns
After an update of the connection.mdns property, a reactivation is
needed to apply the new value.

Also, the ifcfg-rh variable name was wrong.

Fixes: 2e2ff6f27a
2018-09-06 09:07:41 +02:00