Commit graph

21212 commits

Author SHA1 Message Date
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
Beniamino Galvani 53d9050b36 core: add nm_config_data_get_connection_default_int64() 2018-09-06 09:07:41 +02:00
Thomas Haller ffea27a581 settings: merge branch 'th/settings-cleanup'
https://github.com/NetworkManager/NetworkManager/pull/190
2018-09-06 07:41:33 +02:00
Thomas Haller 3091ffa50a settings/ifupdown: use _NMLOG() macros for logging
Does not address the issues that the existing logging is much too verbose
and does not provide necessary context for what it's complaining. The
logging messages should be improved.

At least, the logging macro gives all messages a "ifupdown: " prefix.
2018-09-06 07:41:22 +02:00
Thomas Haller 7064b81bbc settings/ifupdown: various cleanup in nms-ifupdown-parser.c 2018-09-06 07:41:22 +02:00
Thomas Haller bb273c0881 settings/ifupdown: optimize allocating parser data 2018-09-06 07:41:22 +02:00
Thomas Haller fe018a7e81 settings/ifupdown: use c-list for data structure of ifupdown parser
We already have a linked-list implementation. Use it.
2018-09-06 07:41:22 +02:00
Thomas Haller 70350bb621 settings/ifupdown: don't use global variables for /e/n/i parser 2018-09-06 07:41:22 +02:00
Thomas Haller 6f14228cb3 settings/ifupdown: hide internal functions in "nms-ifupdown-interface-parser.h" 2018-09-06 07:41:22 +02:00
Thomas Haller b8da0855fa settings/ifupdown: refactor string prefix matching in parser 2018-09-06 07:41:22 +02:00
Thomas Haller de2e75e327 settings/ifupdown: use nm_streq() in parser 2018-09-06 07:41:22 +02:00
Thomas Haller 03be91f038 settings/ifupdown: adjust coding style for "nms-ifupdown-interface-parser" 2018-09-06 07:41:22 +02:00
Thomas Haller 518c7be77b settings/ifupdown: in plugin drop listening to udev for devices
Don't listen to udev to find out about devices. First of all, using udev
for this is already very wrong, because we have the platform cache.

Anyway, all that the device information is used, is pointless as well.
Drop it.

It's pointless because:

The entires in eni_ifaces are already indexed by the interface name.
Likewise, all NMIfupdownConnection set "connection.interface-name" to
restict the profile by name.
/e/n/i matches devices is by name, that's it. We don't need udev to
look up the MAC address (by name!!) to later ignore/match devices
by MAC address. Especially, because NetworkMaanger can already
restrict profiles to devices based on the interface name.
Likewise, NetworkMaanger can use the interface name for the
unmanaged-specs.
It's wrong to extend the on-disk configuration from /e/n/i with runtime
information from udev, especially, because other NetworkMaanger layers
are perfectly content using the interface name for this purpose.

Also, bind_device_to_connection() was fundamentally wrong. It's wrong
to modify the settings connection at random moments (on udev event).
If at all, that should only happen during connection load/reload.

This may have been necessary a long time ago, when unmanaged devices were
not expressed by device-match-specs, but by the HAL UDI. That was since
improved, for example by commit c9067d8fed.
2018-09-06 07:41:22 +02:00
Thomas Haller 6aa66426a4 settings/ifupdown: merge eni_ifaces and connections hashes in plugin
The "connections" hash contains a mapping of block->name (iface) to the
NMSettingsConnection. The "eni_ifaces" hash contains the name of all
blocks which are mentioned, but for which no connection was created.

Merge the two hashes. We don't need to keep track of whether a
connections was successfully created ("connections"), but the
same name also has a non-connection block. This information is
unnecessary, so one hash is enough.
2018-09-06 07:41:22 +02:00
Thomas Haller dfadaaf7f8 settings/ifupdown: change plugin's field @unmanage_well_known to @ifupdown_managed
@unmanage_well_known directly depends on the "ifupdown.managed" setting from
NetworkManager.conf. Rename it (and invert the meaning) so that this
relation ship becomes clearer.

Also, the double negation of "if (!unmanaged_well_known)" hurts the
brain.
2018-09-06 07:41:22 +02:00