Commit Graph

21088 Commits

Author SHA1 Message Date
Thomas Haller
ed299cc860 device/wwan: use nm_auto_close instead of gs_fd_close 2016-12-13 11:26:58 +01:00
Thomas Haller
312cea870d shared: add nm_auto_close and nm_auto_fclose
We already have gs_fd_close, which however doesn't preserve
errno and only checks for fd != -1. Add our own define.

Downside is, we have to include stdio.h and errno.h,
which effectively ends up to be included *everywhere*.
2016-12-13 11:26:58 +01:00
Thomas Haller
7744fdd00f platform: rename _assert_netns_current() to a ASSERT_NETNS_CURRENT()
This assert, although being a regular function has more the character
of a macro as it only contains asserts itself.
2016-12-13 11:26:58 +01:00
Beniamino Galvani
597f327b20 dns: merge branch 'bg/dns-dbus-bgo603321'
https://bugzilla.gnome.org/show_bug.cgi?id=603321
2016-12-12 22:27:39 +01:00
Thomas Haller
3206b72964 dns: split collecting resolv-conf data out of update_dns()
update_dns() is rather complicated. The part where we collect
resolv-conf data can be moved out. That is nice, because
_collect_resolv_conf_data() has no side-effects (except logging)
and it's only purpose is to return the out-arguments.
2016-12-12 22:06:24 +01:00
Thomas Haller
916a0e7cad dns: use cleanup attributes for update_dns()'s strv arrays 2016-12-12 22:06:24 +01:00
Beniamino Galvani
8af465d579 examples: add DNS example with python and GObject introspection 2016-12-12 22:06:24 +01:00
Beniamino Galvani
20bf5ce359 cli: add DNS information to overview output
Example:

   $ nmcli
   [...]
   DNS configuration:
   	servers: 10.0.0.1
   	domains: foobar.com
   	interface: tun0
   	type: vpn

   	servers: 192.168.10.1
   	domains: home
   	interface: ens3

   	servers: fd01🔡:21
   	interface: ens3
2016-12-12 22:06:24 +01:00
Beniamino Galvani
a8d6005256 libnm: implement support for DNS manager properties 2016-12-12 22:06:24 +01:00
Beniamino Galvani
e3c67177ac dns: export current configuration through D-Bus
It is useful to let clients retrieve the current DNS configuration,
which can be displayed to users or used (together with dns=none) to
implement custom DNS configuration logic through external tools.
2016-12-12 22:06:23 +01:00
Beniamino Galvani
14105ece56 dns: export DNS manager D-Bus object
Extend the D-Bus API and introduce a new NMDnsManager interface that
contains all the information related to DNS configuration.

At the moment the new DnsManager object only contains basic properties
describing the current DNS mode and resolv.conf manager.
2016-12-12 21:49:15 +01:00
Beniamino Galvani
5307e07e3b dns: don't print empty configurations
Previously we printed the DNS configuration for all devices including
unmanaged and unconfigured ones:

  dns-mgr: config:      100 best    v4 ens3             : 192.168.10.1
  dns-mgr: config:      100 default v6 ens3             : fd01🔡:3681:c4ff:fec0:fe94
  dns-mgr: config:      100 default v4 lo               :
  dns-mgr: config:      100 default v6 lo               :
  dns-mgr: config:      100 default v4 ens9             :
  dns-mgr: config:      100 default v6 ens9             :

Instead, print only devices that have name servers set.
2016-12-12 21:41:23 +01:00
Beniamino Galvani
8c4e824997 exported-object: don't assert the presence of PropertiesChanged signal
For new interfaces we don't define a PropertiesChanged signal as we
rely on GDBus to generate one on the standard
org.freedesktop.DBus.Properties interface.
2016-12-12 21:41:23 +01:00
Thomas Haller
a2402acfed build: fix dependency of NetworkManager.ver for libnm-ppp-plugin
Fixes: 025235e00f
2016-12-12 21:38:26 +01:00
Beniamino Galvani
a3b61303f8 cli: implement 'networking' subcommand using nmc_do_cmd()
It simplifies the code and doesn't require that NM is running to
display the help.
2016-12-09 17:57:49 +01:00
Francesco Giudici
c5fe886a36 trivial: fix indentation 2016-12-09 07:26:04 +01:00
Thomas Haller
994f1ca96e device: fix activation_source_schedule() for rescheduling the same function
Fixes: 78ca961c0f
2016-12-08 13:26:04 +01:00
Thomas Haller
92ea1bdb06 proxy: stricter validate the proxy pac script in NMSettingProxy 2016-12-06 22:01:41 +01:00
Beniamino Galvani
d7c4807737 ppp: merge branch 'bg/ppp-manager-split-bgo773482-squashed'
https://bugzilla.gnome.org/show_bug.cgi?id=773482
2016-12-06 14:51:14 +01:00
Beniamino Galvani
bdc61c4e95 contrib/rpm: split PPP support into a separate package
This allows to remove from the main package the PPP dependency.
2016-12-06 11:08:11 +01:00
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