Commit Graph

15065 Commits

Author SHA1 Message Date
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
Lubomir Rintel
6d91c14b00 build: add macro to check the compiler flag support
Also, fold duplicate chunks together.
2016-05-18 20:53:51 +02:00
Lubomir Rintel
3b0dd0a55c trivial: rename compiler_warnings.m4 to compiler_options.m4
We'll use that for more compiler feature-checking macros.
2016-05-18 20:53:05 +02:00
Lubomir Rintel
84d90b71ae daemon: disable external visibility for nmdbus_* symbols
The generated code includes too much code that's not actually used.
LTO would drop it once it's not exported.
2016-05-18 20:53:05 +02:00
Lubomir Rintel
071b4fca61 build: prefer LTO-aware ar and ranlib
This actually fixes --with-lto.
2016-05-18 20:53:05 +02:00
Lubomir Rintel
5f849faa15 platform: fix the typedef-redefinition warnings
The configure script disabled the warning by accident.
2016-05-18 20:53:05 +02:00
Lubomir Rintel
85c92ff372 build: use the glib cflags when checking the compiler flags
Some of the checks include glib headers.
2016-05-18 20:52:36 +02:00
Beniamino Galvani
6280839c16 dns: merge branch 'bg/dnsmasq-interfaces-bgo765153'
https://bugzilla.gnome.org/show_bug.cgi?id=765153
2016-05-18 11:16:07 +02:00
Beniamino Galvani
b71e104d33 dns: specify egress interface for each dnsmasq upstream server
Currently we don't specify to dnsmasq which interface must be used to
contact a given nameserver and so requests can be sent through the
wrong interface.

Fix this by concatenating a @interface prefix to each server (unless
an IPv6 interface scope-id is already present).

https://bugzilla.gnome.org/show_bug.cgi?id=765153
2016-05-18 11:10:05 +02:00
Beniamino Galvani
027f4c65ac dns: assert early that @iface is not NULL
Under no circumstance should a non-global configuration with NULL or
empty iface be added to the DNS manager. Assert this early and remove
other unnecessary checks.
2016-05-18 11:10:05 +02:00
Thomas Haller
1f5c056700 man: describe logging domain "SYSTEMD" in man NetworkManager.conf 2016-05-17 19:57:55 +02:00
Thomas Haller
a2c843499c all/tests: split core part out of "nm-test-utils.h"
A large part of "nm-test-utils.h" is only relevant for tests inside "src/"
directory, as they are helpers related to NetworkManager core part.

Split this part out of "nm-test-utils.h" header.
2016-05-17 16:48:52 +02:00
Thomas Haller
65a254e03c trival: fix indention
Fixes: 5586ae80d1
2016-05-17 13:42:24 +02:00
Thomas Haller
1ad00095a1 wifi: refactor private data for NMAccessPoint
- make NMAccessPoint and NMAccessPointClass internal structs. This means,
  they cannot be subclassed anymore, but we also don't want that.

- This way, we can safely embed the private data directly in the now
  private access-point instance.

- change type of boolean fields from gboolean to bool.

- some whitespace fixes
2016-05-17 13:24:51 +02:00
Thomas Haller
5586ae80d1 wifi: refactor properties in NMAccessPoint using NM_GOBJECT_PROPERTIES_DEFINE() 2016-05-17 13:00:47 +02:00
Thomas Haller
54474993fd ifcfg-rh: merge branch 'th/ifcfg-rh-cleanup-bgo766518'
https://bugzilla.gnome.org/show_bug.cgi?id=766518
2016-05-17 12:26:35 +02:00
Thomas Haller
2d428bda35 ifcfg-rh: remove unused define ERR_GET_MSG() 2016-05-17 12:26:02 +02:00
Thomas Haller
4dcb5e5ba5 ifcfg-rh: cleanup includes
- don't include "nm-default.h" from headers. All source files
  include this header as first.

- drop G_BEGIN_DECLS/G_END_DECLS. This is not C++ nor public
  API.

- drop unnecessary includes from header files. They are either
  not required, or already provided via "nm-default.h".

- include in source files the corresponding header file as first
  after "nm-default.h". This should ensure that header files are
  self-contained (appart from "nm-default.h").
2016-05-17 12:25:55 +02:00
Thomas Haller
b503b37636 ifcfg-rh: don't print warning in svGetValueInt64()
Having a simple accessor print warnings is not nice. At that point there
is no context as to why we are trying to read the value.

Note that the function already handles and expects invalid values, it's
just not clear that printing warnings from a utility function is the right
thing to do.

Just ignore such cases silently (at this point). It's up to the caller
to print a warning or whatever.
2016-05-17 12:22:42 +02:00
Thomas Haller
f3bd778d6d ifcfg-rh: use _NMLOG() macro in writer
This gives every logging line a proper "ifcfg-rh" prefix.
But drop the "    " prefixes.
2016-05-17 12:22:42 +02:00
Thomas Haller
a519cc57b8 ifcfg-rh: use _NMLOG() macro in reader
This gives every logging line a proper "ifcfg-rh" prefix.
2016-05-17 12:22:42 +02:00
Thomas Haller
c949e1c429 ifcfg-rh: reject vlan id of value 4096
Maybe we should also reject 0 and 4095, but for now leave it.
2016-05-17 12:22:42 +02:00
Thomas Haller
a85c3db2f0 ifcfg-rh: use _nm_utils_ascii_str_to_int64() instead of strtol() 2016-05-17 12:22:42 +02:00
Thomas Haller
4b538ea8f1 ifcfg-rh: replace uses of get_int() 2016-05-17 12:22:42 +02:00