Commit Graph

16627 Commits

Author SHA1 Message Date
Thomas Haller
2b51d39671 device: merge branch 'th/device-mtu-bgo777251'
https://bugzilla.gnome.org/show_bug.cgi?id=777251
2017-01-16 17:34:14 +01:00
Thomas Haller
665e398022 device: enforce a link MTU of at least 1280 for connections with IPv6 2017-01-16 17:30:12 +01:00
Thomas Haller
22e8af6242 device: set a per-device default MTU on activation
In absence of an explicit MTU (either via user configuration, PPP or
DHCP), set a default MTU on activation that depends on the device type.

We only want to do that on the very first call to _commit_mtu(). Later
calls (for example in response to new DHCP leases) skip over this step.

This means, on activation the MTU will always be reset to a sensible
value instead of preserving whatever was left from a previous
configuration.

This does not cover setting the MTU from the VPN plugin :(
2017-01-16 17:30:12 +01:00
Thomas Haller
1e67c7ac0b device: reset previous MTU when device disconnects
When you have a connection with "ethernet.mtu=0 (auto)", the MTU is not set
during activation. That means, the effective MTU depends on the previous
MTU configuration of the device. Which in turn, depends on the
previously active connection, as we don't reset the MTU on deactivation.

Restore the previous MTU on deactivation iff NetworkManager changed
the MTU during device activation.
2017-01-16 17:29:44 +01:00
Thomas Haller
b5fcbdf594 device: refactor configuring MTU by dropping mtu_desired
Don't have this mtu_desired variable. All the data is readily available
without redundancy. E.g. the applied-connection contains everything
we need to know. Just get it as needed.

Also drop apply_mtu_from_config(). It didn't take into account
the MTU settings beside NMSettingWired.

Also, no longer merge the NM_IP_CONFIG_SOURCE_USER MTU value into
priv->ip4_config. NMIP4Config now only tracks the MTU from the various
non-user-config sources, but the user config is no longer merged back
into the composite.
2017-01-16 17:29:44 +01:00
Thomas Haller
b3a89dc153 ip4-config: cleanup MTU handling
It is wrong that nm_ip4_config_set_mtu() tries to ~merge~ the new MTU
with the existing. All callers of nm_ip4_config_set_mtu() want that the
new value prevails.
That is also already the case because the DHCP clients and PPP manager set
the MTU on a newly created NMIP4Config instance, thus their value is taken.
Similarly, the final merge with NM_IP_CONFIG_SOURCE_USER also prevails as the
source has the highest priority.

The setter should just set. The only place where we want the merge behavior
is in nm_ip4_config_merge(), where it is now implemented in-place.

For example, nm_ip4_config_replace() very much wants that the new value
wins, regardless of the previous setting. Using nm_ip4_config_set_mtu()
with the merge behavior was wrong because it means that the MTU of NMDevice's
composite can never be raised again (for example with a new DHCP event).
2017-01-16 17:29:44 +01:00
Thomas Haller
797ad260e6 device/bridge: support setting bridge MTU via wired setting
The problem is that the bridge's MTU cannot be larger then the slaves'.
Configuring such a setting results in an error being logged and the
activation proceeds (without applying the desired MTU).

Unclear how to fix that best.
2017-01-16 17:29:44 +01:00
Thomas Haller
6e52efe950 device: refactor setting user-configured MTU during config commit
Instead of overwriting ip4_config_pre_commit(), add a new function
get_mtu().

This also adds a default value in case there is no user-configuration.
This will allow us later to reset a default MTU based on the device
type.
2017-01-16 17:29:06 +01:00
Thomas Haller
0210754f18 device: refactor handling of MTU in device
The field priv->mtu should contain what is actually configured
on the device, as that field is also exposed on D-Bus as NM_DEVICE_MTU
property.

That shall be handled distinct from what we want to configure as
MTU on the device.

Refactor the handling of MTU with a new functoin _set_mtu() which looks
at the desired paramters and compares it with what is configured (in
platform and sysctl). Then it makes a decision what to configure.
2017-01-16 17:24:36 +01:00
Thomas Haller
be4442bd0d device: cleanup setting of mtu in NMDevice
Mark priv->mtu/priv->ip_mtu/ priv->ip6_mtu as const to highlight the
places that explicitly set their mutable aliases priv->mtu_/
priv->ip_mtu_/priv->ip6_mtu_.

Also, NM_DEVICE_MTU property is read-only. It cannot be set
via g_object_set().

Also, clear priv->mtu in nm_device_unrealize().
2017-01-16 17:24:36 +01:00
Thomas Haller
5051a04d81 device: drop unused virtual function NMDevice:ip6_config_pre_commit 2017-01-16 17:24:36 +01:00
Thomas Haller
c69ad50b07 device: fix indention and assertion in apply_mtu_from_config()
For the assertion use nm_streq0(). If we bother checking for invalid
values (that are supposed to never happen), avoid a possible crash too.
2017-01-16 17:24:36 +01:00
Thomas Haller
f0cd2403d4 device: fix sysctl getter for MTU using guint32 type
The only caller wants to read the MTU, which is more
type guint32 then gint32.
2017-01-16 17:24:36 +01:00
Thomas Haller
2802e823fc ip[46]-config: reorder fields in private struct and use bool bitfield
bool:1 bitfields allow for tighter packing and are guaranteed to be
strictly 0 or 1 (contrary to gboolean's typedef for int). Not that it
matters too much, but it's favorable.

Especially, because each device has several of these ip-config instances,
we might save a few bytes for no(?) downsides.
2017-01-16 17:24:36 +01:00
Thomas Haller
0bb1e9a116 ip[46]-config/trivial: move code around
Move the GObject related functions to the end of the source file.
Similar to how it's done for most other implementations.
2017-01-16 17:24:36 +01:00
Thomas Haller
175ef8f611 ppp: use defines for signal names 2017-01-16 17:24:36 +01:00
Thomas Haller
f8227029fe platform: avoid one memset() in nmp_cache_id_init()
We end up calling nmp_cache_id_init_*() a lot to initialize stack-allocated
cache-ids to lookup the NMMultiIndex. There is no need to memset() it to
zero, because all relevant fields are supposed to be set explicitly.
2017-01-16 17:20:35 +01:00
Thomas Haller
953afd681a core: use nm_offsetofend() macro 2017-01-16 17:20:35 +01:00
Thomas Haller
61da320d62 shared: add nm_offsetofend() macro 2017-01-16 17:20:35 +01:00
Thomas Haller
9cf3cbfc3e core: use _nm_packed attribute instead of __attribute__((packed)) 2017-01-16 17:20:35 +01:00
Thomas Haller
803467fe93 libnm: fix leak in nm_setting_802_1x_set_phase2_ca_cert()
Fixes: 2b09cee6fa
2017-01-16 17:20:35 +01:00
Thomas Haller
85c38d18a0 device: cleanup converting mtu to string for sysctl_set()
Use %u for unsigned type and cast the guint32 to (unsigned).
While at it, increase the stack-allocated buffer to 64 bytes
(it doesn't hurt) and use nm_sprintf_buf().
2017-01-13 11:14:12 +01:00
Beniamino Galvani
334a8a54be libnm-core: fix documentation warnings
libnm-core/nm-setting-8021x.c:658: Warning: NM: nm_setting_802_1x_set_ca_cert: unknown parameter 'value' in documentation comment, should be 'cert_path'
libnm-core/nm-setting-8021x.c:1023: Warning: NM: nm_setting_802_1x_set_client_cert: unknown parameter 'value' in documentation comment, should be 'cert_path'
libnm-core/nm-setting-8021x.c:1331: Warning: NM: nm_setting_802_1x_set_phase2_ca_cert: unknown parameter 'value' in documentation comment, should be 'cert_path'
libnm-core/nm-setting-8021x.c:1702: Warning: NM: nm_setting_802_1x_set_phase2_client_cert: unknown parameter 'value' in documentation comment, should be 'cert_path'
libnm-core/nm-setting-8021x.c:2027: Warning: NM: nm_setting_802_1x_set_private_key: unknown parameter 'value' in documentation comment, should be 'key_path'
libnm-core/nm-setting-8021x.c:2374: Warning: NM: nm_setting_802_1x_set_phase2_private_key: unknown parameter 'value' in documentation comment, should be 'key_path'

Fixes: 2b09cee6fa
2017-01-12 14:38:26 +01:00
Thomas Haller
950991d781 supplicant: fix passing FALSE to hidden argument for nm_supplicant_config_add_option()
Fixes: 34b4a0e561
2017-01-12 13:57:02 +01:00
Dan Williams
8de7b8ed31 device/wwan: indicate whether IP iface/ifindex changed and simplify WwAN code
Replace some code in the WWAN device class that checks for a changed
interface name with code that uses the new return value from
nm_device_set_ip_iface(), which now checks whether the ip_ifindex
changed too.

https://mail.gnome.org/archives/networkmanager-list/2017-January/msg00010.html
2017-01-12 13:34:22 +01:00
Thomas Haller
bf3b3d444c device: avoid changing immutable properties during reapply
We allow to reapply a connection with different id, uuid, stable-id, autoconnect value.
This is allowed for convenience, so that a user can reapply a connection that differs
in these fields. But actually, these fields cannot be reapplied. That
is, their new values are not considered and the old values are continued
to be used.

Thus, mangle the reapplied connection to use the original, actually used
values.
2017-01-12 13:02:25 +01:00
Thomas Haller
304e2f56af device: allow reapplying a connection with differing stable-id
The stable-id for one activation cannot actually change. This is also, because we cache it
as priv->current_stable_id. Still, allow reapply with a differing stable-id for convenience.
2017-01-12 12:59:07 +01:00
Lubomir Rintel
9b9a180597 ifcfg-rh: unknown scheme means no certificate at all
Fixes: 30db08d38e
2017-01-11 15:12:29 +01:00
Lubomir Rintel
30db08d38e ifcfg-rh: don't ignore certificates with unknown scheme 2017-01-10 23:30:18 +01:00
Lubomir Rintel
33c3ed8991 libnm-core/8021x: don't prefix PKCS#11 URIs with "pkcs11:"
They already include the scheme prefix.
2017-01-10 23:30:18 +01:00
Lubomir Rintel
13b2ac2214 sparse: avoid clash with __bitwise and __force from 4.10 linux/types.h
It also used __bitwise and __force. It seems easier to rename
our versions since they are local to this one single header.

Also, undefine them afteerwards, so that we don't pollute the
preprocessor macro namespace.

https://github.com/systemd/systemd/pull/5061
2017-01-10 20:21:34 +01:00
Beniamino Galvani
1dbd9d7948 platform: don't update IPv6 temporary addresses
The kernel already takes care of adding and updating temporary
addresses when an address with IFA_F_MANAGETEMPADDR flag is added or
updated; doing it also in nm_platform_ip6_address_sync() can overwrite
the changes done by kernel, especially because since commit
0a0bca9c7f ("ip6-config: sort addresses only when reading the
property value") there is no guarantee that temporary addresses are
before the public ones in the IPv6 configuration.

Still delete temporary addresses, but don't add or update them.
2017-01-10 15:39:15 +01:00
Thomas Haller
6eb2d60fbe iface-helper: don't cache nm_platform_check_support_kernel_extended_ifa_flags() flag
nm_platform_check_support_kernel_extended_ifa_flags() is already cached in a static
variable. Just look it up anew every time.
2017-01-10 14:29:46 +01:00
Beniamino Galvani
a9384452ed settings: fix assertion when changing connection managed state
When a ifcfg-rh connection becomes unamanaged it is removed from the
connection list in NMSettings and marked as removed; it is however
kept alive in the plugin and can become managed again later. To avoid
failed assertions, the @removed flag of the NMSettingsConnection must
be cleared if the connection is not being disposed.
2017-01-10 14:26:32 +01:00
Thomas Haller
be1f04038d device: fix invalid assertion
Fixes: f0d40525df
2017-01-09 20:24:23 +01:00
Francesco Giudici
71e172e080 man: minor fix to nmcli.xml 2017-01-09 18:40:21 +01:00
Thomas Haller
4b9176eb7d core: merge branch 'th/stable-id-bgo776904'
https://bugzilla.gnome.org/show_bug.cgi?id=776904
2017-01-09 17:29:53 +01:00
Thomas Haller
6fa069fad1 example: add example configuration snippet '30-anon.conf' 2017-01-09 14:50:33 +01:00
Thomas Haller
f0d40525df device: support dynamic "connection.stable-id" in form of text-substitution
Usecase: when connecting to a public Wi-Fi with MAC address randomization
("wifi.cloned-mac-address=random") you get on every re-connect a new
IP address due to the changing MAC address.
"wifi.cloned-mac-address=stable" is the solution for that. But that
means, every time when reconnecting to this network, the same ID will
be reused. We want an ID that is stable for a while, but at a later
point a new ID should e generated when revisiting the Wi-Fi network.

Extend the stable-id to become dynamic and support templates/substitutions.
Currently supported is "${CONNECTION}", "${BOOT}" and "${RANDOM}".
Any unrecognized pattern is treated verbaim/untranslated.

"$$" is treated special to allow escaping the '$' character. This allows
the user to still embed verbatim '$' characters with the guarantee that
future versions of NetworkManager will still generate the same ID.
Of course, a user could just avoid '$' in the stable-id unless using
it for dynamic substitutions.

Later we might want to add more recognized substitutions. For example, it
could be useful to generate new IDs based on the current time. The ${} syntax
is extendable to support arguments like "${PERIODIC:weekly}".

Also allow "connection.stable-id" to be set as global default value.
Previously that made no sense because the stable-id was static
and is anyway strongly tied to the identity of the connection profile.
Now, with dynamic stable-ids it gets much more useful to specify
a global default.

Note that pre-existing stable-ids don't change and still generate
the same addresses -- unless they contain one of the new ${} patterns.
2017-01-09 14:50:33 +01:00
Thomas Haller
21ae09c1cc core: add assertions for network_id/stable_type
We require a network-id. Assert that it is set.

Also, we encode the stable-id as uint8. Thus, add
an assertion that we don't use more then 254 IDs.

If we ever make use of stable-type 255, we must extend
the encoding to allow for more values. The assertion
is there to catch that.
2017-01-09 14:50:33 +01:00
Thomas Haller
46d53e1101 keyfile: fix interpreting missing wifi.mac-address-randomization as permanent address
With commit 4f6c91d696, we aimed to
enable mac-address-randomization by default for Wi-Fi. That however
is not possible by default because it breaks various scenarios.
Also, later wifi.mac-address-randomization was deprecated in favor
of wifi.cloned-mac-address setting.

Both wifi.mac-address-randomization and wifi.cloned-mac-address support
global default values, so it is wrong to read a missing
mac-address-randomization as "NEVER" -- which due to
normalization also results in cloned-mac-address=permanent.
2017-01-09 14:50:33 +01:00
Thomas Haller
dea3c49ce2 utils: add nm_utils_get_boot_id() util to read "/proc/sys/kernel/random/boot_id" 2017-01-09 14:50:33 +01:00
Thomas Haller
142009c6a5 shared: add nm_str_realloc() 2017-01-09 14:50:33 +01:00
Beniamino Galvani
ae5adc9e21 vpn: add device route to VPN gateway if parent has no gateway
We set a dedicated route to reach the VPN gateway only if the parent
device has a gateway. If the parent device doesn't have a gateway (for
example in case of GSM connections) and the VPN gets the default
route, the VPN gateway will be contacted through the VPN itself, which
obviously doesn't work.

Set up a device route if the parent device doesn't provide a gateway.

https://bugzilla.redhat.com/show_bug.cgi?id=1403660
2017-01-07 15:05:03 +01:00
Lubomir Rintel
2b09cee6fa libnm-core/8021x: fix up scheme handling in setters
Fixes: 690e33bdf2
2017-01-06 16:14:13 +01:00
Lubomir Rintel
8386cb6ca6 merge: branch 'lr/pkcs11'
https://bugzilla.gnome.org/show_bug.cgi?id=776268
2017-01-06 15:57:57 +01:00
Lubomir Rintel
234a72cb91 supplicant: allow accessing certs and keys in PKCS#11 tokens 2017-01-06 15:56:11 +01:00
Lubomir Rintel
34b4a0e561 supplicant: allow specifying a replacement string for hidden items
Makes it possible to hide only a part of a value (such as inline PIN),
but still log useful info.
2017-01-06 15:56:11 +01:00
Lubomir Rintel
b4a31174ea cli: add support for pkcs11: URI scheme on relevant properties 2017-01-06 15:56:11 +01:00
Lubomir Rintel
d5a1a09567 cli: support printing the pkcs11: URI scheme 2017-01-06 15:56:11 +01:00