Commit graph

8110 commits

Author SHA1 Message Date
Thomas Haller
3704197d87 device: re-read the current MAC address when the link changes
The current MAC address is part of NMPlatformLink in the platform cache.
When it changes, we must update the device's current value.

Also, the MAC address of NMDeviceEthernet is exposed on D-Bus. That
property should show the currently configured MAC address, not a state
that was read some time in the past.

Also, nm_device_hw_addr_set() compares the current MAC address before
resetting it. If that field is out-of-date, nm_device_hw_addr_set() will
behave wrongly.

NMDeviceEthernet had some special handling in link_changed() that would
re-read the MAC addresses and possibly bring up the interface. Move that
code to the parent device.
2016-06-30 08:29:55 +02:00
Thomas Haller
4bb1e2a536 device: cleanup logging for setting MAC address
Give all related messages a "set-hw-addr"/"hw-addr" prefix.
2016-06-30 08:29:55 +02:00
Thomas Haller
89d6dfdb96 device: split nm_device_update_permanent_hw_address() out of nm_device_update_initial_hw_address()
Either, the function is called different to reflect that it does
not only update the initial_hw_addres, or it is split.

Split it.
2016-06-30 08:29:55 +02:00
Thomas Haller
6947aedb6e device: initialize NMDevice's hw_addr at end of object construction
hw-addr is a constuct-only property. We should not do complex stuff in the property
setter before the object is sufficiently initialized. For example, the logging
macros access nm_device_get_iface(), which might be unset at that early
point.

Instead, initialize hw_addr and hw_addr_len later, at the end of the constructor()
function.

Also, ensure that @hw_addr_len is zero iff @hw_addr is unset.

Also, ensure that we always log a message when changing/setting the
hardware address -- except when clearing it during unrealize. It's
implicit that unrealize clears the hardware address.

Also, give all related logging messages a "hw-addr:" prefix.
2016-06-30 08:29:55 +02:00
Thomas Haller
e92b743ce9 device: don't use g_warning for differing hw-addr-len after reading permanent address
Accessing the platform cache might anytime yield unexpected results.
E.g. the link could be gone, or the ifindex could even be replaced
by a different interface (yes, that can happen when moving links
between network namespaces).

It's not clear how to handle such a case at runtime. It seems wrong to
me to just error out. Still, such case might happen under normal
conditions, so it's wrong to just warn and proceed.
2016-06-30 08:29:55 +02:00
Thomas Haller
fa5230e255 device: refactor setting HW address via nm_device_set_hw_addr()
This brings no real change in behavior, except getting rid of the
logging domain argument.
2016-06-30 08:29:55 +02:00
Thomas Haller
224937f5dd device: always set "cloned-mac-address" even with missing NMSettingWired
When the entire NMSettingWired setting is missing, it should be treated
exactly the same as each property having the default/unset value.

Otherwise, adding a NMSettingWired setting only to set (say) MTU,
would result in different behavior. Although effectively the
"cloned-mac-address" shall be in both cases the same.
2016-06-30 08:29:54 +02:00
Thomas Haller
e5637dc089 device: clear initial_hw_addr in nm_device_update_initial_hw_address()
There was no leak here, because we would only call
nm_device_update_initial_hw_address() when @initial_hw_addr is unset.
However, still clear it to make it more robust against later changes.
2016-06-30 08:29:54 +02:00
Thomas Haller
89970b5ca6 device: refactor nm_device_get_applied_setting() 2016-06-30 08:29:54 +02:00
Thomas Haller
83d231776b core: use nm_utils_read_urandom() in nm_utils_secret_key_read()
nm_utils_read_urandom() repeats on EINTR and repeats for partial reads.
2016-06-30 08:29:54 +02:00
Thomas Haller
dcc8de16b2 core: add utils for file handling
Copied and adjusted from systemd code.
2016-06-30 08:29:54 +02:00
Thomas Haller
dab657043c ifcfg-rh: explicitly clear HWADDR setting and others in write_wired_for_virtual()
When modifying an existing ifcfg-rh file, we always want to enforce
the absense of a certain setting. That is done, by calling svSetValue()
with a value of NULL.

Same for writing MTU value.
2016-06-30 08:29:54 +02:00
Thomas Haller
c7b7305b59 core/utils: convert MAC address in nm_match_spec_hwaddr() from string once 2016-06-30 08:29:54 +02:00
Thomas Haller
05ecb28436 core: make global variable _nm_utils_testing static 2016-06-30 08:29:54 +02:00
Thomas Haller
c9ab22f41d wifi: move static lookup-array for is_manf_default_ssid() 2016-06-30 08:29:54 +02:00
Thomas Haller
0a5af391e0 core: prefer connection.stable-id to generate IPv6 stable privacy addresses
The Network_ID for generating RFC 7217 stable privacy IPv6 addresses
is by default the UUID of the connection.

Alternatively, prefer "connection.stable-id" as Network_ID to generate
the stable addresses. This allows to configure a set of connections that
all use the same Network_ID for generating stable addresses.

Note that the stable-id and the UUID do no overlap, that is two
connections
    [connection]
    uuid=uuid1
    stable-id=
and
    [connection]
    uuid=uuid2
    stable-id=uuid1
generate distinct addresses.
2016-06-30 08:29:54 +02:00
Thomas Haller
0df5e9b736 rdisc/trivial: rename @uuid field to @network_id
Next we will optionally use a stable-id instead of the UUID. Rename it.
Also, RFC 7217 calls this argument Network_ID.
2016-06-30 08:29:54 +02:00
Thomas Haller
3f3ea1df21 libnm: add NMSettingConnection:stable-id property
This new property be used as token to generate stable-ids instead
of the connection's UUID.

Later, this will be used by ipv6.addr-gen-mode=stable-privacy,
ethernet.cloned-mac-address=stable, and wifi.cloned-mac-address=stable
setting. Those generate stable addresses based on the connection's
UUID, but allow to use the stable-id instead.

This allows multiple connections to generate the same addresses
-- on the same machine, because in the above cases a machine
dependant key is also hashed.
2016-06-30 08:29:54 +02:00
Thomas Haller
c7cee12189 config: make "ignore-carrier" a per-device configuration option
NetworkManager.conf already contains several per-device settings,
that is, settings that have a device-spec as argument.

   main.ignore-carrier
   main.no-auto-default
   main.assume-ipv6ll-only
   keyfile.unmanged-devices

Optimally, these settings should be moved to the new [device*]
section.

For now, only move main.ignore-carrier there. For the others
it may not make sense to do so:

- main.no-auto-default: is already merged with internal state
  from /var/lib/NetworkManager/no-auto-default.state. While
  NMConfig's write API would be fine to also persist and merge
  the no-auto-default setting, we'd still have to read the old
  file too. Thus, deprecating this setting gets quite cumbersome
  to still handle the old state file.
  Also, it seems a less useful setting to configure in the
  global configuration aside setting main.no-auto-default=*.

- main.assume-ipv6ll-only: one day, I hope that we no longer
  assume connections at all, and this setting becomes entirely
  obsolete.

- keyfile.unmanged-devices: this sets NM_UNMANAGED_USER_SETTINGS,
  which cannot be overruled via D-Bus. For a future device.managed
  setting we want it it to be overwritable via D-Bus by an explicit
  user action. Thus, a device.managed property should have a different
  semantic, this should be more like a device.unmanaged-force setting,
  which could be done.
2016-06-30 08:27:17 +02:00
Thomas Haller
3cda2df12b config: add support for per-device configuration to NetworkManager.conf
Add a new [device*] section to NetworkManager.conf. This works similar
like the default connection settings in [connection*].

This will allow us to express per-device configuration in NetworkManager.conf
in our familar style.

Later, via NMConfig's write API it will be possible to make settings
accessible via D-Bus and persist them in NetworkManager-intern.conf.
This way, the user can both edit configuration snippets and modify
them via D-Bus, and also support installing default configuration
from the package.

In a way, a [device*] setting is similar to networkd's link files.
The match options is all encoded in the match-device specs.
One difference is, that the resulting setting can be merged together
by multiple section by partially overwriting them. This makes it
more flexible and allows for example to drop a configuration snippet
that only sets one property, while the rest can be merged from different
snippets.
2016-06-30 08:07:35 +02:00
Beniamino Galvani
2b958dce91 wwan/ofono: fix indentation 2016-06-28 17:34:42 +02:00
Dan Williams
7d89b862f4 wwan/ofono: remove unused code 2016-06-28 17:34:42 +02:00
Dan Williams
0c9527d9b8 wwan/ofono: fix comment about IP4Config refcounting 2016-06-28 17:34:42 +02:00
Dan Williams
602c3f6ed3 wwan/ofono: clean up and standardize logging 2016-06-28 17:34:42 +02:00
Dan Williams
938b27a8d2 wwan/ofono: simplify capabilities function and add FIXME about LTE 2016-06-28 17:34:42 +02:00
Dan Williams
b898b0882b wwan/ofono: whitespace fixup 2016-06-28 17:34:42 +02:00
Dan Williams
3c054e21ba wwan/ofono: remove some unused types 2016-06-28 17:34:42 +02:00
Dan Williams
87aa671e6b wwan: no need for NM_MODEM_BROADBAND_MODEM to be public 2016-06-28 17:34:42 +02:00
Dan Williams
219904920f wwan/ofono: clean up g_clear_object() usage 2016-06-28 17:34:42 +02:00
Dan Williams
58ab8c9316 wwan/ofono: use g_dbus_proxy_new_for_bus() 2016-06-28 17:34:42 +02:00
Dan Williams
f0af7a0d05 wwan: rework ModemManager/ofono initialization
Avoids the following error when ofono isn't running:

NetworkManager[25133]: <info>  [1466186144.1392] ofono is now available
NetworkManager[25133]: <warn>  [1466186144.1637] failed to enumerate oFono devices: Cannot invoke method; proxy is for a well-known name without an owner and proxy was constructed with the G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START flag

because the code assumes that if the GDBusProxy is created, that
oFono is available.  That's not the case with DO_NOT_AUTO_START
because it creates the proxy anyway, and lets the caller listen
for name-owner-changed signals instead.  The GDBusProxy also
doesn't need to be cleared, since it will follow name-owner
changes and emit g-name-owner changes when oFono starts/stops.

This also fixes the oFono name-owner-changed watch.  It was presumably
using the signal name copied from the ModemManager 'notify::name-owner'
code, but that's a GDBusObjectManagerClient.  The oFono code is using
a GDBusProxy for which the signal is 'notify::g-name-owner'.

Finally, the oFono code shouldn't really be piggy-backing on the
ModemManager autolaunch code, it's just cleaner to keep the two
code paths separate and initialize oFono in parallel.
2016-06-28 17:34:42 +02:00
Dan Williams
019b34af62 wwan/ofono: whitespace fixup 2016-06-28 17:34:42 +02:00
Dan Williams
8a827b1b4f wwan/ofono: fix a few more memory leaks 2016-06-28 17:34:42 +02:00
Dan Williams
425ae4fbd2 wwan: remove some dbus-glib left-overs 2016-06-28 17:34:42 +02:00
Dan Williams
d99171d700 wwan: use modem basename as NM device name
NM_MODEM_UID is used as the modem device name, and the device name
cannot contain path-like characters.

Ofono has a bluez plugin that detects paired DUN/PAN capable
Bluetooth devices, and these devices are created with a multi-component
object path like "/hfp/org/bluez/hci0/dev_00_26_E2_AB_68_66".
The NM ofono plugin cannot use these paths as NM device names.

Instead, strip off any path components and use the last part
of the object path as the NM device name.
2016-06-28 17:34:42 +02:00
Thomas Haller
e06e1d4691 wwan: cleanup clearing ofono proxy instance 2016-06-28 17:34:42 +02:00
Thomas Haller
521133d456 core: revert asserts to NM_ASSERT_VALID_PATH_COMPONENT() and _get_property_path()
If ofono violates these asserts, then the bug must be fixed somewhere
else, not by silently doing something wrong.
2016-06-28 17:34:42 +02:00
Thomas Haller
5a740d323e wwan: fix memleaks
And use gs_free in ofono_check_name_owner()
2016-06-28 17:34:42 +02:00
Thomas Haller
5cdb2b1520 wwan: cleanup includes 2016-06-28 17:34:42 +02:00
Thomas Haller
3ef0641674 wwan: some minor refactorings 2016-06-28 17:34:42 +02:00
Thomas Haller
4e00e7a15f wwan: remove unused code 2016-06-28 17:34:42 +02:00
Thomas Haller
735bb933f6 wwan: fix building for !WITH_OFONO 2016-06-28 17:34:42 +02:00
Thomas Haller
acac97f818 wwan: fix compilation error about wrong field name 2016-06-28 17:34:42 +02:00
Thomas Haller
9e63ada7e2 wwna: fix compiler error about wrong prototype 2016-06-28 17:34:42 +02:00
Thomas Haller
8621b0aba9 wwan: fix using wrong enum type for flags for g_dbus_proxy_new() 2016-06-28 17:34:42 +02:00
Thomas Haller
1b570723b4 trivial: style issues and indention 2016-06-28 17:34:42 +02:00
Mathieu Trudel-Lapierre
a6e81af87f wwan: add support for using oFono as a modem manager
This patch adds core wwan support for ofono, as used by Ubuntu Touch.

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

https://mail.gnome.org/archives/networkmanager-list/2016-June/msg00089.html
2016-06-28 17:34:42 +02:00
Thomas Haller
13b2253df6 wwan: cleanup clearing modem-manager instance 2016-06-28 17:34:42 +02:00
Beniamino Galvani
df48628a48 vpn: don't merge DNS properties into parent device's configuration
DNS properties should not be copied to parent device's configuration
otherwise they will be applied twice, possibly with two different DNS
priorities.
2016-06-28 16:24:28 +02:00
Beniamino Galvani
a5d1db08f8 dns: log DNS servers at TRACE level
Be more verbose at TRACE level and log the DNS servers associated to
configurations. This will help to debug issues like [0].

[0] https://bugzilla.redhat.com/show_bug.cgi?id=1348887
2016-06-28 16:24:28 +02:00