Commit Graph

21088 Commits

Author SHA1 Message Date
Thomas Haller
18501d7b68 vpn-connection: add @fallback_device argument to nm_vpn_connection_get_ip_iface()
and nm_vpn_connection_get_ip_ifindex(). For VPN types that have no own
IP interface, we often want instead lookup the IP interface from the
parent device.
2016-05-27 12:54:55 +02:00
Thomas Haller
5357b1874e vpn-connection: ensure ip_iface and ip_ifindex are set together
ip_iface and ip_ifindex come as a pair. They must be either set both, or not
at all. Ensure that whenever setting one, the other is set too (or cleared).
2016-05-27 12:27:59 +02:00
Beniamino Galvani
0c80e38f64 dns/dnsmasq: use servers without split DNS if no domain was received
When a VPN server doesn't push any DNS domain, we want to use the
received servers for all queries.

https://bugzilla.gnome.org/show_bug.cgi?id=766769
2016-05-26 09:47:43 +02:00
Beniamino Galvani
3c649e6429 team: expose current device configuration through D-Bus and nmcli
Add a new "Config" property to the D-Bus interface for team devices
and show its value through "nmcli device show". The property contains
the full JSON configuration from teamd for the device.

https://bugzilla.redhat.com/show_bug.cgi?id=1310435
2016-05-26 09:16:46 +02:00
Cosimo Cecchi
3df3e46d64 nm-device-wifi: add TURBONETT to no-roaming WiFi networks
TURBONETT is the default network name of a very popular internet
provider in Guatemala, so roaming should be disabled.

https://bugzilla.gnome.org/show_bug.cgi?id=766845
2016-05-25 22:42:54 +02:00
Beniamino Galvani
52819b7c94 device: fix NM_DEVICE_GET_PRIVATE() macro
Fixes: adbba0fb39
2016-05-25 17:29:18 +02:00
Thomas Haller
791cbd0817 platform: handle missing netlink attribute IFLA_ADDRESS by cache-lookup
Sometimes the netlink event lacks the IFLA_ADDRESS attribute with
the MAC address of the link. In this case, take the value from
the cached link instance. A missing netlink attribute should have the
meaning of reusing the previous value, not clearing the address.
2016-05-25 15:11:47 +02:00
Thomas Haller
9cf1dbcaef logging,vpn: merge branch 'th/vpn-plugin-debug-bgo766816'
https://bugzilla.gnome.org/show_bug.cgi?id=766816
2016-05-24 22:43:30 +02:00
Thomas Haller
acbdc30f90 logging: print debug messages with syslog level LOG_DEBUG 2016-05-24 21:53:27 +02:00
Thomas Haller
dacf496a2b vpn: set environment for VPN plugin to configure logging
Introduce two environment variables to configure logging
for the VPN plugins:

-  NM_VPN_LOG_LEVEL: when set, a syslog logging level (0-7).

-  NM_VPN_LOG_SYSLOG: either 0 or 1, whether the plugin should
      log to stdout or syslog. Basically, if NetworkManager itself
      runs in the forground, we also want that the plugin logs
      to stdout.
2016-05-24 21:53:27 +02:00
Thomas Haller
7f3ea16533 logging: add new logging domain LOGD_VPN_PLUGIN
This logging domain will be used to enable debugging of the VPN plugins.

However, the plugins might expose sensitive data in this mode, so exclude
the new domain from "LOGD_ALL".
2016-05-24 19:39:30 +02:00
Thomas Haller
a0130e4128 logging: add nm_logging_syslog_enabled() function
We want to know, whether running in debug-mode (logging to stdout)
or whether we log to syslog.
2016-05-24 19:39:30 +02:00
Thomas Haller
13101f8444 logging: add nm_logging_get_level() function 2016-05-24 19:39:25 +02:00
Thomas Haller
4c7fbcc941 device: replace static zero_hwaddr by nm_ip_addr_zero.addr_eth
Instead of defining multiple all-zero-ethernet-address variables, use
nm_ip_addr_zero.addr_eth.
2016-05-24 16:01:59 +02:00
Thomas Haller
82f2fbf78d platform: reuse nm_ip_addr_zero for a all-zero ethernet MAC address 2016-05-24 16:01:59 +02:00
Thomas Haller
a4a75b638f platform: refactor comparing for all-zero,all-ones MAC address in nmp_utils_ethtool_get_permanent_address()
Don't like the static fields.

Also, don't assert against return values from the ethtool call.
And check that the length is positive.
2016-05-24 16:01:59 +02:00
Thomas Haller
d7b4733d3e ifcfg-rh: avoid creating temporary string prefix for svGetValueFull() 2016-05-24 16:01:59 +02:00
Thomas Haller
487dcf7e55 core: merge branch 'th/drop-connection-provider-bgo766560'
https://bugzilla.gnome.org/show_bug.cgi?id=766560
2016-05-24 12:42:21 +02:00
Thomas Haller
5337003c4c core: drop NMConnectionProvider and use NMSettings directly
This is not C# but glib. Using interfaces is so cumbersome, that they
don't simplify code but make it more complicated.

E.g. following signals and its subscribers is complicated enough. It gets
more complicated by having NM_SETTINGS_SIGNAL_CONNECTION_ADDED and
NM_CP_SIGNAL_CONNECTION_ADDED. Of course, your favorite IDE has no idea
about glib interfaces, so figuring out who calls who gets more
complicated.

This undoes commit 4fe48b1273. Originally,
NMConnectionProvider had only one function get_best_connection(). But it
kept growing and more functions were added.

If we want to ~hide~ certain part of the NMSettings API, we should move them
to a separate header which gives internal access.
2016-05-24 12:35:58 +02:00
Thomas Haller
f20341a1fd core: drop interface function nm_connection_provider_get_best_connections()
... in favor of nm_settings_get_best_connections().
2016-05-24 12:35:58 +02:00
Thomas Haller
8e1443457d device: use NMSettings directly instead of NMConnectionProvider in subclasses
Instead of accessing the singleton getter nm_settings_get(), obtain
the settings instance from the device instance itself via
nm_device_get_settings().
2016-05-24 12:35:58 +02:00
Thomas Haller
b9fc9cd389 device: use NMSettings directly instead of NMConnectionProvider 2016-05-24 12:35:58 +02:00
Thomas Haller
b9b18c8a86 bluez: use NMSettings directly instead of NMConnectionProvider 2016-05-24 12:35:58 +02:00
Thomas Haller
6e54057bf7 settings: add nm_settings_get_connections()
This will replace nm_connection_provider_get_connections(), but has
a different API.

Instead of returning a (const) GSList list, it returns a (cached) NULL
terminated array. The reason for this change is simply that I find
arrays more convenient to use (in this case) and it doesn't have the
overhead of a GSList instance per entry.

Like with nm_connection_provider_get_connections(), cache the result
internally. This for one is more convenient for the caller, which
doesn't need to free the result. On the other hand, the list of
connections is fairly static, this allows us to reuse the same list.
2016-05-24 12:35:58 +02:00
Thomas Haller
b4e8ce876d core: add nm_settings_get() singleton getter for NMSettings 2016-05-24 12:35:57 +02:00
Thomas Haller
c35164a6a3 settings/trivial: rename nm_settings_get_connections() to nm_settings_get_connections_sorted()
nm_settings_get_connections() returns a sorted list. We have many users
of nm_connection_provider_get_connection(), which returns the same result,
but undefined order.

Next NMConnectionProvider will be dropped. Thus, we don't want to
seamlessly replace nm_connection_provider_get_connection() by a sorted
version nm_settings_get_connections().

Rename nm_settings_get_connections() to make clear it is sorted.
2016-05-24 12:35:57 +02:00
Thomas Haller
adbba0fb39 device: assertion object in NM_DEVICE_GET_PRIVATE() 2016-05-24 12:35:57 +02:00
Thomas Haller
51791c4772 dns: add configure option "--with-config-dns-rc-manager-default" for default of main.rc-manager
Downstream might want to choose a different default value for
main.rc-manager setting (and it can does so, by compiling with
explicit resolvconf or netconfig support).

Make the default configurable at build-time and also embed it into
the manual page of "NetworkManager.conf".

https://bugzilla.redhat.com/show_bug.cgi?id=1337222
2016-05-23 21:49:42 +02:00
Thomas Haller
f664c04973 libnm/keyfile: sort entries for writing hash-of-strings
This sorts the entries of the [vpn] section alphabetically.

The sorting order doesn't really matter, but having a defined,
stable way to export a connection is preferred. Also, it looks
better when looking at the keyfile with an editor.
2016-05-23 10:15:17 +02:00
Thomas Haller
7eb9731fac man: fix minor style issue in man NetworkManager.conf
Previously, it would read:

  "This implies rc-managerunmanaged"
2016-05-23 08:50:14 +02:00
Thomas Haller
d71ba919af device: use NM_PLATFORM_GET instead of "nm_platform_get ()"
We use basically everywhere else the NM_PLATFORM_GET macro.
2016-05-22 14:20:05 +02:00
Beniamino Galvani
7dbabe9bdc device: wait for termination of IPv6 DAD before proceeding to IP_CHECK
Currently NM proceeds with the activation of a device just after the
IPv6 configuration is applied. Server applications will bind to IPv6
addresses as soon as NM signals the presence of network connectivity,
but since the addresses are still tentative the bind will fail. There
are a couple of solutions to this.

Linux kernel supports "optimistic DAD", which is a modification of
Neighbor Discovery and SLAAC processes that allows addresses to be
used (under certain contraints) while kernel is performing DAD on
them. However it is not feasible to let NM enable optimistic DAD for
the devices it controls for the following reasons:

 - it is not guaranteed to be always available since it can be turned
   off at compile time
 - RFC 4429 states that it should not be used for manually entered
   addresses
 - it works only with autoconf addresses generated by kernel

Therefore, use a different approach and handle this in NM by waiting
that the kernel completes DAD before continuing activation. We build a
list of addresses that are tentative just after the new configuration
is applied and then we asynchronously wait a platform address-change
event where all NM-configured addresses become non-tentative.

A similar solution has been adopted also by other network managing
tools:
  https://anonscm.debian.org/cgit/collab-maint/ifupdown.git/commit/?id=ec357a5d6cb5fa8b0004c727d7cc48253c59eb0f
  8012cd3919

https://bugzilla.redhat.com/show_bug.cgi?id=1243958
2016-05-22 14:20:05 +02:00
Thomas Haller
f8cc73150f logging: add check for logging level in nm_logging_enabled()
With this check, the function is safe to use even with invalid
logging levels. But it can still be inlined as for most cases
@level is a (enum) constant and the check can be evaluated at
compile time.

Oddly enough, on a default build with
  ./autogen.sh && make && strip ./src/NetworkManager
this patch decreases the size of the binary by 8k.
2016-05-22 11:25:48 +02:00
Thomas Haller
0209e01eff logging: merge branch 'th/logging-inline-enabled' 2016-05-20 12:52:34 +02:00
Thomas Haller
4ed1784ce4 logging: make nm_logging_enabled() inline function
Basically every logging statement is wrapped by a nm_logging_enabled()
to evaluate the function call of the logging lazy.

Make the function a candidate for inlining, it safes some space. On
a default build it goes for me from 2580584 to 2560104 bytes (20k).

   $ ./autogen.sh && make && strip ./src/NetworkManager
2016-05-20 12:50:52 +02:00
Thomas Haller
a9ef2f9c50 logging: move static variable with logging state to file-scope 2016-05-20 12:50:52 +02:00
Thomas Haller
1a070f6a44 logging: remove assertion in nm_logging_enabled() from production builds
We really expect this assertion not to be violated.

As we want for nm_logging_enabled() to become smaller and inline,
remove the runtime assertion from regular builds.

Live fast and dangerous.
2016-05-20 12:50:36 +02:00
Thomas Haller
553b04148a logging: drop explicit initialization of nm-logging
Instead of calling _ensure_initialized() at various places
to ensure that we setup logging before any logging commands
are executed, initialize the logging fields in the global variable.

This removes code from nm_logging_enabled(), which we want to
become a static inline function.
2016-05-20 12:41:47 +02:00
Beniamino Galvani
57c001200d config: add file name to error messages for parsing failures
When one of the configuration snippet is malformed, NM doesn't tell
which file caused the error:

$ NetworkManager --print-config
Failed to read configuration: Key file does not start with a group

Fix this.

$ NetworkManager --print-config
Failed to read configuration: /usr/lib/NetworkManager/conf.d/test.conf: Key file does not start with a group
2016-05-19 18:12:06 +02:00
Thomas Haller
77e7a9c075 cli: re-merge branch 'th/cli-vpn-import-fixes-rh1337300'
(fix wrong merge. I already cherry-picked 3d25b2e to nm-1-2)

https://bugzilla.redhat.com/show_bug.cgi?id=1337300
2016-05-19 17:21:44 +02:00
Beniamino Galvani
73221a809d cli: remove wrong assertion in check_valid_name()
As explained in the function comment, a NULL value for @val is
acceptable. Otherwise:

$ nmcli connection edit
 (process:2276): nmcli-CRITICAL **: check_valid_name: assertion 'val' failed

Fixes: fb8fe1d8cb
2016-05-19 17:09:06 +02:00
Thomas Haller
3d25b2e1a1 cli: merge branch 'th/cli-vpn-import-fixes-rh1337300'
https://bugzilla.redhat.com/show_bug.cgi?id=1337300
2016-05-19 12:56:47 +02:00
Thomas Haller
d0f01aa2c2 clients,cli: show better error message when failing to load VPN plugin
VPN plugins are often not installed or they might be legacy-only.
In both cases we should show a better error message about the
failure reason.
2016-05-19 12:52:59 +02:00
Thomas Haller
41976e3069 clients,cli: for connection-add consider VPNs as loaded from the plugin
Instead of using (only) a hard-coded list of VPN types,
prefer lookup the VPN settings from the .name files.

Still, fallback to a hard-coded list if the plugin cannot
be found, because for connection-add we currently don't
actually need the plugin installed.
2016-05-19 12:52:59 +02:00
Thomas Haller
2b4b9d34e4 clients: don't assert against existance of plugin in nm_vpn_supports_ipv6()
Obviously, loading a plugin can fail easily.
2016-05-19 12:52:59 +02:00
Thomas Haller
0225c4567b clients: lookup VPN plugins either by "name" or "service"
... not constructing a "service" by prepending a D-Bus prefix to "name" (urgh).
2016-05-19 12:52:59 +02:00
Thomas Haller
09a015b23b nmcli-completion: complete filename for VPN import and passwd-file
Also hard-code the VPN types strongswan and fortisslvpn.

https://bugzilla.redhat.com/show_bug.cgi?id=1337300
2016-05-19 12:52:59 +02:00
Thomas Haller
e0e1c59160 NEWS: fix mistake in NEWS file about wifi.mac-address-randomization 2016-05-19 12:11:38 +02:00
Lubomir Rintel
71fa3cb810 merge: branch 'lr/ld-gc'
Make NetworkManager small again!
2016-05-19 11:30:57 +02:00
Lubomir Rintel
c8f65e95fd build: garbage collect unused symbols by default
GCC can place each symbols into separate sections making it possible for
ld to discard unneeded sections (and thus symbols afterwards). This achieves
almost the same size benefits as LTO without the huge performance
penalty (and the undefined behavior with -g).

The cost of more section headers in .o files seems to be negligible.

Before:

  359.73user 71.94system 1:29.67elapsed 481%CPU (0avgtext+0avgdata 137948maxresident)k

     text        data     bss     dec     hex filename
  2772228       74848    9272 2856348  2b959c src/NetworkManager

With LTO:

  740.37user 94.89system 4:13.83elapsed 329%CPU (0avgtext+0avgdata 118316maxresident)k

     text        data     bss     dec     hex filename
  2435437       74224    8704 2518365  266d5d src/NetworkManager

With --gc-sections:

  365.63user 72.34system 1:30.12elapsed 485%CPU (0avgtext+0avgdata 138016maxresident)k

     text        data     bss     dec     hex filename
  2498498       74040    8408 2580946  2761d2 src/NetworkManager
2016-05-19 11:06:55 +02:00