Commit Graph

16639 Commits

Author SHA1 Message Date
Lubomir Rintel
5b51a5f260 platform/tun: don't passing around the ifname guess
nm_platform_sysctl_open_netdir() doesn't take it anyways, gets it from
the cache.

CID 160209 (#1 of 1): Unused value (UNUSED_VALUE)
2017-01-16 22:14:47 +01:00
Lubomir Rintel
cb8e70546b ifupdown: remove redundant error check
The presence of a parameter is checked above.

CID 59899 (#1 of 1): Logically dead code (DEADCODE)
2017-01-16 22:14:47 +01:00
Beniamino Galvani
1a24f528c8 merge: branch 'bg/macsec-bgo762114'
https://bugzilla.gnome.org/show_bug.cgi?id=762114
2017-01-16 17:50:42 +01:00
Beniamino Galvani
c46627e1dc contrib: add macsec test script 2017-01-16 17:47:10 +01:00
Beniamino Galvani
d197c0626a cli: macsec support 2017-01-16 17:47:10 +01:00
Beniamino Galvani
808b1a0f61 core: support macsec connections
Add code to nm-device-macsec.c to support the creation of macsec
connection. Most of the code for controlling wpa_supplicant is copied
from nm-device-ethernet.c and probably could be consolidated in some
ways.
2017-01-16 17:47:09 +01:00
Beniamino Galvani
0150b644ed supplicant: add an enum to specify the driver
With macsec we now have 3 drivers and a boolean is no longer enough.
2017-01-16 17:37:14 +01:00
Beniamino Galvani
17da42704a supplicant: add support for macsec options
Add new configuration options for wpa_supplicant to support MACsec.
2017-01-16 17:37:14 +01:00
Beniamino Galvani
d252a99fa2 libnm-core: add NMSettingMacsec
The new NMSettingMacsec contains information necessary to establish a
MACsec connection. At the moment we support two different MACsec
modes, both using wpa_supplicant: PSK and EAP.

PSK mode is based on a static CAK key for the MACsec key agreement
protocol, while EAP mode derives keys from a 802.1x authentication and
thus requires the presence of a NMSetting8021x in the connection.
2017-01-16 17:37:14 +01:00
Beniamino Galvani
67adbda83e core,libnm: introduce NMDeviceMacsec
At the moment the device only exposes the current link status, but
cannot create new links.
2017-01-16 17:37:14 +01:00
Beniamino Galvani
85103656e9 platform: add support for macsec links
Add support for a new macsec link type and its netlink attributes to
the platform code.
2017-01-16 17:37:14 +01:00
Beniamino Galvani
00463a6e09 ethernet: simplify supplicant error path
Replace the custom supplicant_iface_connection_error_cb_handler() with
nm_device_queue_state().
2017-01-16 17:37:14 +01:00
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