Commit Graph

18368 Commits

Author SHA1 Message Date
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
Lubomir Rintel
faed200b2b keyfile: add support for pkcs11: URI scheme 2017-01-06 15:56:11 +01:00
Lubomir Rintel
690e33bdf2 libnm-core/8021x: make cert/key setters handle pkcs11 URI scheme 2017-01-06 15:56:11 +01:00
Lubomir Rintel
84c57c34bc libnm-core/8021x: add pkcs11: scheme for certificates and keys
The getters just return the whole URI as-is, without any mangling.
2017-01-06 15:56:11 +01:00
Lubomir Rintel
afd2811028 cli: do not require a password when setting a PK
It results in a rather confusing behavior:

  # nmcli c modify wifi \
     802-1x.private-key /etc/pki/themostsecret.key \
     802-1x.private-key-password verystrong
  Error: failed to modify 802-1x.private-key: private key
  password not provided.

Moreover, the user might have a good reason for not specifying it on a command
liue and it's not strictly required anyway -- we'll do fine if we don't verify
a private key at addition time.
2017-01-06 15:14:46 +01:00
Lubomir Rintel
5209c034f2 merge: branch 'lr/ifname-validation' 2017-01-06 15:13:28 +01:00
Lubomir Rintel
f9be6540b0 libnm-core: deprecate nm_utils_iface_valid_name()
We don't use it internally and a better version exists. Not like we
could drop it or anything.
2017-01-06 15:11:56 +01:00
Lubomir Rintel
260563a7d9 all: use nm_utils_is_valid_iface_name() 2017-01-06 15:11:56 +01:00
Lubomir Rintel
ac0563d784 libnm-core: add nm_utils_is_valid_iface_name()
Version of nm_utils_iface_valid_name() with error reporting.
2017-01-06 15:11:56 +01:00
Thomas Haller
aef473f005 keyfile: merge branch 'th/keyfile-parsing-bgo776484'
https://bugzilla.gnome.org/show_bug.cgi?id=776484
2017-01-05 12:30:12 +01:00