Commit graph

16418 commits

Author SHA1 Message Date
Beniamino Galvani 025235e00f ppp: split ppp manager into a plugin
Moving the PPP manager to a separate plugin that is loaded when needed
has the advantage of slightly reducing memory footprint and makes it
possible to install the PPP support only where needed.

https://bugzilla.gnome.org/show_bug.cgi?id=773482
2016-12-06 11:08:11 +01:00
Beniamino Galvani 2e21d78494 core: factor out plugin validation
The new function will be used to validate other plugins we load.
2016-12-06 11:08:11 +01:00
Beniamino Galvani 7ae6e980e4 core: move plugin path reading function to nm-core-utils.c
Even if it's called only from one place, it can be considered an
utility function.
2016-12-06 11:08:11 +01:00
Lubomir Rintel a96c819f6f contrib/travis: the test outputs are now logged more sanely
Adjust the travis script accordingly.
2016-12-05 13:54:35 +01:00
Lubomir Rintel a0aea99bd7 contrib/rpm: mark the config packages noarch 2016-12-05 13:24:51 +01:00
Beniamino Galvani 207a747064 core: merge branch 'bg/ip-order-rh1394500'
https://bugzilla.redhat.com/show_bug.cgi?id=1394500
2016-12-05 10:59:20 +01:00
Beniamino Galvani 2f68a50041 platform: fix the order of addition of primary and secondary IPv4 addresses
nm_platform_ip4_address_sync() tries to apply the new configuration
with the minimum effort and doesn't delete addresses if they are
already present on the interface. This can break the ordering, as an
existing address would be promoted by kernel to primary, even if it
was last in our configuration.

Add some logic to ensure the correct order of addresses is always
enforced. This fixes situations like:

 # nmcli connection add type ethernet ifname eth0 con-name t \
                        ipv4.method manual \
                        ipv4.addresses "1.1.1.1/24,1.1.1.2/24,1.1.1.5/24"
 # nmcli connection up t

  => addresses are applied in the right order:
     inet 1.1.1.1/24 brd 1.1.1.255 scope global eth0
     inet 1.1.1.2/24 brd 1.1.1.255 scope global secondary eth0
     inet 1.1.1.5/24 brd 1.1.1.255 scope global secondary eth0

 # nmcli connection mod t ipv4.addresses "1.1.1.5/24,1.1.1.2/24,1.1.1.1/24"
 # nmcli device reapply eth0

  => order is wrong:
     inet 1.1.1.2/24 brd 1.1.1.255 scope global eth0
     inet 1.1.1.5/24 brd 1.1.1.255 scope global secondary eth0
     inet 1.1.1.1/24 brd 1.1.1.255 scope global secondary eth0

Co-Authored-By: Thomas Haller <thaller@redhat.com>
2016-12-05 10:56:51 +01:00
Beniamino Galvani 0a0bca9c7f ip6-config: sort addresses only when reading the property value
Don't change the address order from configuration, but instead sort
addresses just before returning them to clients.
2016-12-05 10:56:51 +01:00
Beniamino Galvani 803a79f778 ip6-config: add nm_ip6_config_set_privacy() 2016-12-05 10:56:51 +01:00
Beniamino Galvani ed4d5889c7 ip6-config: cache addresses variants 2016-12-05 10:56:51 +01:00
Beniamino Galvani 9609d4da1d ip4-config: sort addresses only when reading the property value
Don't change the address order from configuration, but instead sort
addresses just before returning them to clients.
2016-12-05 10:56:51 +01:00
Beniamino Galvani 5ce81e23b7 ip4-config: cache addresses variants 2016-12-05 10:56:51 +01:00
Beniamino Galvani e02752c2ed ip4-config: don't change order of addresses in the same subnet
When multiple address are assigned to an interface and the kernel must
decide which one should be used to communicate with a given IP, it
chooses the most specific one in the same subnet as the
destination. In case there are multiple addresses in the same subnet,
the primary address is choosen, which is basically the first one that
was added.

With commit 7197425137 ("device: expose NMIP4Config:addresses in
stable/defined sort order") we sorted all the addresses before
committing the configuration, with the side effect that the order no
longer respected the one in the user configuration.

Instead, change the sort function to keep the subnet order unchanged.
2016-12-05 10:56:51 +01:00
Beniamino Galvani 593cfc73c1 cli: the 'networking' command needs a client and NM running
Fixes: 01a20015e0
2016-12-05 10:52:59 +01:00
Thomas Haller ed82b6bcb3 platform: increase initial buffer size of libnl's nl_recvmsg() to 32K
Since commit 9fafb382db, we would
explicitly set libnl's socket buffer size to 4*getpagesize().
That is also the default of libnl itself. Additionally, we would
workaround too small buffers by increasing the buffer size up to 512K.

A too small buffer causes messages to be lost. Usually, that only
results in a cache-resync, which isn't too bad. Lost messages are however
a problem if the lost message was an ACK that we were waiting for.
However, it is rather unlikely to happen, because it's expected that
the buffer size gets adjusted already when the cache is filled initially,
before any other requests are pending.

Still, let's increase the default buffer size to 32K, hoping that this
initial value is already large enough to avoid the problem altogether.

Note that iproute2 also uses a buffer size of 32K [1] [2].

Alternatively, we could use MSG_PEEK like systemd does [3]. However,
that requires two syscalls per message.

[1] https://patchwork.ozlabs.org/patch/592178/
[2] https://git.kernel.org/cgit/linux/kernel/git/shemminger/iproute2.git/tree/lib/libnetlink.c?id=f5f760b81250630da23a4021c30e802695be79d2#n274
[3] cd66af2274/src/libsystemd/sd-netlink/netlink-socket.c (L323)
2016-12-02 15:23:11 +01:00
Thomas Haller d29839c430 device: allow device reapply of a connection with differing connection.autoconnect
Autoconnect property doesn't really matter for the applied
connection. Whitelist it from the properties and allow changing
it during reapply.
2016-12-01 23:09:00 +01:00
Thomas Haller ce2d1f062b platform: don't use static temporary cache_id
This only saves some typing at a few places. In general, avoid
static variables, so drop it in favor of a stack-allocated
cache_id.
2016-12-01 10:57:35 +01:00
poma fde46d7e65 libnm-core/man: add a warning on static link negotiation parameters
When disabling link autonegotiation and setting speed and duplex manually,
the user is alone: no check is performed against supplied values.
So, the user is supposed to check that the device supports those values.
Explicit this in nm-settings man page.

[fgiudici@redhat.com: added the commit message]
2016-12-01 10:41:06 +01:00
Thomas Haller 9fafb382db platform: workaround NLE_MSG_TRUNC failure of nl_recv() with too small buffer size
We don't want to enable MSG_PEEK due to the overhead. But when we detect
that we just lost a message due to MSG_TRUNC, increase the buffer size and
retry.

See-also: 55ea6e6b6c
2016-11-30 17:01:35 +01:00
Beniamino Galvani 12e6314a19 dns: merge branch 'bg/dnsmasq-clear-cache-option'
https://mail.gnome.org/archives/networkmanager-list/2016-November/msg00095.html
2016-11-30 10:32:15 +01:00
Beniamino Galvani 6546b70c98 Revert "dns: clear dnsmasq cache after an update"
We now pass the --clear-on-reload option to dnsmasq, so the manual
clear is no longer needed.

This reverts commit 4feb58b50b.
2016-11-29 23:12:23 +01:00
Christian Hesse c966fd54bf dns: tell dnsmasq to clear cache on servers reload
A new DNS may have different data for us. So tell dnsmasq to
automatically clear the cache when servers change.

Signed-off-by: Christian Hesse <mail@eworm.de>
2016-11-29 22:56:39 +01:00
mirh 48402cd526 build: fix compilation with Python3
has_key() has long been dropped
https://docs.python.org/3.1/whatsnew/3.0.html#builtins

Should still work with anything from 2.3 onwards

https://github.com/NetworkManager/NetworkManager/pull/11
2016-11-29 22:03:01 +01:00
Beniamino Galvani 5f1e36e026 manager: fix state transition on resuming from sleep
When going to sleep, we unmanage devices setting the unmanaged flags
immediately but delaying the state transition (because we do it from
another state transition). The signal handler can be executed after
the wake and, especially, after we have already re-managed the device,
making the device unmanaged again.

Detect such situation and force the state to UNMANAGED (which will
also clear any pending state change), so that later we manage the
device again and it will try to activate any available connection.

Fixes: 81ea812362

https://bugzilla.redhat.com/show_bug.cgi?id=1382526
2016-11-29 18:10:31 +01:00
Thomas Haller d8dd4e8bc2 build: merge branch 'th/build-without-gtk-doc'
https://bugzilla.gnome.org/show_bug.cgi?id=775003
2016-11-28 12:44:20 +01:00
Thomas Haller a80ba4ea09 build: fix gtk-doc/introspection handling for build
- `make dist` requires --enable-gtk-doc --enable-introspection --with-libnm-glib
- --enable-gtk-doc requires --enable-introspection
- --with-nmcli requires either --enable-introspection or pregenerated
   settings-docs.c files from the dist tarball. It does not require
   --enable-gtk-doc.

There is a bit of a problem in that --enable-introspection requires
now xsltproc. However, gobject-introspection does itself not depend
on xsltproc. So, more correct might be a special --enable-doc argument,
that combines --enable-introspection --with-xsltproc. Anyway, that
seems to make it more complicated then it already is so just implicitly
(and surprisingly?) require xsltproc with --enable-introspection.

https://bugzilla.gnome.org/show_bug.cgi?id=775003
2016-11-28 12:43:51 +01:00
Emmanuele Bassi 41ed42d5ba build: do not require GTK-Doc to build nmcli
We can simply check for xsltproc and depend on pygobject and
introspection.

https://bugzilla.gnome.org/show_bug.cgi?id=775003
2016-11-28 12:43:47 +01:00
Piotr Drąg b08dd30b09 po: update Polish (pl) translation (bgo #775181)
https://bugzilla.gnome.org/show_bug.cgi?id=775181
2016-11-28 11:16:11 +01:00
Thomas Haller 55fb25f59d libnm: force unsigned integer comparisong in nm_utils_bin2hexstr()
Not really a big issue, without the case the intergers
would be compared as ssize_t, which is large enough for
final_len, but possibly not for buflen.
2016-11-28 10:21:24 +01:00
Thomas Haller 99decefc95 libnm: merge branch 'th/str2bin-cleanup'
Merge the different bin2str/str2bin implementations.
2016-11-28 10:10:34 +01:00
Thomas Haller 3aa41c6e17 libnm: merge hwaddr_aton() and nm_utils_hexstr2bin()
Have nm_utils_hexstr2bin() take over the allocated buffer
via g_bytes_new_take().
2016-11-28 10:06:27 +01:00
Thomas Haller d7e535aee5 libnm/trivial: rename internal function _bin2str() 2016-11-28 08:50:35 +01:00
Thomas Haller 4cc2f8906c libnm: drop _bin2str() util
It was only used by two places, inline it.
2016-11-27 13:57:13 +01:00
Thomas Haller 542d1c257d libnm: implement nm_utils_bin2hexstr() via _bin2str_buf() 2016-11-27 13:54:23 +01:00
Thomas Haller 5ea2fc776c libnm/trivial: move code 2016-11-27 13:54:23 +01:00
Thomas Haller 8aead609b3 main: fix compiler warning about uninitialized auto variable in _init_nm_debug()
Fixes: c7d2e1f3bc
2016-11-25 20:17:58 +01:00
Francesco Giudici 0af0f167dd libnm-core: make normalizable ethernet_link properties _VERIFY_NORMALIZABLE
declassify bad combinations of auto-negotiate, duplex and speed
properties values from _VERIFY_NORMALIZABLE_ERRORS to
_VERIFY_NORMALIZABLE. This would preserve compatibility with legacy
nm-connection-editors.
2016-11-25 18:42:11 +01:00
Thomas Haller 9fce5ae0eb config: merge branch 'th/config-rh1397938'
https://bugzilla.redhat.com/show_bug.cgi?id=1397938
2016-11-25 18:04:35 +01:00
Thomas Haller c7d2e1f3bc config: drop nm_config_get_debug() and access config directly 2016-11-25 18:02:38 +01:00
Thomas Haller 61c6ccaad4 config: drop nm_config_get_dhcp_client() and access config directly
Also, ifnet plugin would read the configuration value, which is just wrong
because:

  - the configuration might not be set and ifnet would fail to fallback
    to the compile time default.
  - the configuration only is in effect if the plugin is also available.
    Otherwise, we fallback to the next plugin.

Only the dhcp-manager knows which DHCP plugin is in use.
2016-11-25 18:02:38 +01:00
Thomas Haller ff4cb2a1fc config: drop nm_config_get_auth_polkit() and access value directly 2016-11-25 18:02:38 +01:00
Thomas Haller afcfa7be2b config/trivial: unify name of compile time config defaults 2016-11-25 18:02:38 +01:00
Thomas Haller 03f35e96de config: fix config merging default value for main.plugins
Since commit fb2ca0ce3d we would no longer pre-set the main.plugins
value in NMConfig's keyfile to recognize unset default settings.

This breaks with

  [main]
  plugins+=foo

which now results in

  main.plgin=foo

while previously it would have extended the compile time default.

https://bugzilla.redhat.com/show_bug.cgi?id=1397938

Fixes: fb2ca0ce3d
2016-11-25 18:02:38 +01:00
Thomas Haller 6689d0bf71 config: optionally let nm_config_get_plugins() return compile time default
Instead of having the caller do the fallback to the compile time default
plugins, let it be handled by nm_config_get_plugins().

The knowledge of fallback to a compile time default (and how to do that
properly) should be inside NMConfig/NMConfigData alone.

Also, as this function is only called once, let NMConfig not cache
the string list but create it once as needed.
2016-11-25 15:26:30 +01:00
Jiří Klimeš 544f7d3683 agent: don't clear "error", g_simple_async_result_take_error() overtakes it
From valgrind:
==21921== Invalid free() / delete / delete[] / realloc()
==21921==    at 0x4C2CD5A: free (vg_replace_malloc.c:530)
==21921==    by 0x81C4F2D: g_free (gmem.c:189)
==21921==    by 0x81AB021: g_error_free (gerror.c:491)
==21921==    by 0x81AB325: g_clear_error (gerror.c:674)
==21921==    by 0x767B555: reg_request_cb (nm-secret-agent-old.c:616)
==21921==    by 0x7A211F2: g_task_return_now (gtask.c:1107)
==21921==    by 0x7A21228: complete_in_idle_cb (gtask.c:1121)
==21921==    by 0x81BF6B9: g_main_dispatch (gmain.c:3154)
==21921==    by 0x81BF6B9: g_main_context_dispatch (gmain.c:3769)
==21921==    by 0x81BFA6F: g_main_context_iterate.isra.29 (gmain.c:3840)
==21921==    by 0x81BFB1B: g_main_context_iteration (gmain.c:3901)
==21921==    by 0x7A4748C: g_application_run (gapplication.c:2381)
==21921==    by 0x118AEF: main (main.c:81)

It caused memory corruption and may result in strange nm-applet crashes.
2016-11-25 14:31:47 +01:00
Francesco Giudici 5da352c5e8 ifupdown/trivial: whitespace fixup 2016-11-24 18:31:02 +01:00
Francesco Giudici b029e92569 libnm-core: normalize ethernet_link properties when auto-negotiate is off
If auto-negotiate is switched off, enforce that both speed and duplex
are set or unset (which would mean "ignore"): if only one is set, reset
both silently and ignore link configuration.
2016-11-24 17:51:52 +01:00
Thomas Haller d61c2264d4 build: merge branch 'th/build-cleanup' 2016-11-24 16:56:36 +01:00
Thomas Haller a4224b9882 build: combine targets for nm-settings*.xml via pattern rule in Makefile.am 2016-11-24 16:55:17 +01:00
Thomas Haller 7864435c3c build: fix out-of-tree build to find common.ent for documentation
Need to pass --path to xsltproc to find common.ent in the
build-directory.

  $ git clean -fdx && NMTST_MAKE='V=1 -d' ./tools/test-build.sh man/nm-settings-ifcfg-rh.xml
2016-11-24 16:55:17 +01:00