Commit graph

7710 commits

Author SHA1 Message Date
Thomas Haller
fbfe2ef216 core/utils: add NM_UTILS_LOOKUP_ITEM_IGNORE_OTHER() switch case
NM_UTILS_LOOKUP_DEFAULT_NM_ASSERT() is useful because unless
compiled with NM_MORE_ASSERTS, there is no assertion.
An assertion includes the function name, and can make the
function ineligible for inlining.
2016-04-11 11:22:50 +02:00
Thomas Haller
c328cf52f2 dnsmasq: fix using '%' delimiter to scope link local with zone-id
Since long, dnsmasq supports scoping the IPv6 address
with '@<interface-name>'. Since 2.58, it also supports
'%' as delimiter, which is the standard way to specify
the zone-id (rfc6874).

Since 2.73, specifying the scope with '@' as "server"
address is no longer working properly, thus breaking
NetworkManager with dnsmasq >= 2.73.

To work around that, use '%' delimiter. That breaks pre-2.58
users that have a DNS server on a link local address, but that
seems acceptable as that version was released in January 2012.

https://bugzilla.gnome.org/show_bug.cgi?id=764839
2016-04-11 11:13:17 +02:00
Beniamino Galvani
9b7f9af077 device: take care of default route of DHCP generated-assumed connections
In general we don't touch the externally set default route on devices
that use a generated-assumed connection. When the IP method is AUTO
(or DHCP), this means that we are not able to restore the default
route after a temporary expiration of the lease which removes
addresses/routes from the device.

Change this, and let NM update the default route for generated-assumed
devices using dynamic addressing.

https://bugzilla.redhat.com/show_bug.cgi?id=1265239
2016-04-08 21:28:57 +02:00
Beniamino Galvani
c84fd50287 device: don't update applied connection for generated assumed devices
The applied connection must describe the configuration that was
initially activated on the device. Even if the IP configuration
changes, we shouldn't reset the applied connection for devices using a
generated-assumed connection, otherwise we would lose information on
the IP method we're trying on the device.
2016-04-08 21:28:57 +02:00
Thomas Haller
2e34d34cf0 device: let managed by user-udev overwrite external-down
An externally configured software device is considered external-down until
it is IF_UP and has IP configuration.

When the user explicitly manages the device via UDEV rule, that decision
should overrule external-down.
2016-04-08 11:37:38 +02:00
Thomas Haller
4a8a294fe1 ppp-manager: refactor create temporary ppp setting in nm_ppp_manager_start() 2016-04-08 11:16:53 +02:00
Beniamino Galvani
76309ebe79 ppp-manager: don't modify the applied connection
The applied connection must not be modified during the activation. If
the PPP setting needs to be changed when activating a PPPoE
connection, make a copy to prevent the following error:

 could not get secrets:
 GDBus.Error:org.freedesktop.NetworkManager.Settings.Failed:
 The connection was modified since activation

https://bugzilla.redhat.com/show_bug.cgi?id=1324895
2016-04-08 11:08:54 +02:00
Thomas Haller
8f8bf0d315 config/tests: avoid test failure for valgrind due to g_file_copy()
Valgrind doesn't like it, so don't use g_file_copy().

  ==10410== Syscall param ioctl(generic) points to unaddressable byte(s)
  ==10410==    at 0x82E1707: ioctl (syscall-template.S:84)
  ==10410==    by 0x7712E71: btrfs_reflink_with_progress (gfile.c:3012)
  ==10410==    by 0x7712E71: file_copy_fallback (gfile.c:3186)
  ==10410==    by 0x7712E71: g_file_copy (gfile.c:3394)
  ==10410==    by 0x1350CA: test_config_state_file (test-config.c:948)
  ==10410==    by 0x7D0845A: test_case_run (gtestutils.c:2158)
  ==10410==    by 0x7D0845A: g_test_run_suite_internal (gtestutils.c:2241)
  ==10410==    by 0x7D08622: g_test_run_suite_internal (gtestutils.c:2253)
  ==10410==    by 0x7D0882D: g_test_run_suite (gtestutils.c:2328)
  ==10410==    by 0x7D08850: g_test_run (gtestutils.c:1596)
  ==10410==    by 0x12EFA4: main (test-config.c:1032)
  ==10410==  Address 0x9 is not stack'd, malloc'd or (recently) free'd
  ==10410==

Fixes: e3a30665d7
2016-04-08 10:46:33 +02:00
Thomas Haller
d0836be0eb core: rename nm_config_run_state* to nm_config_state*
After all, this state is stored persistently to /var/lib/NetworkManager,
and not to volatile storage in /var/run. Hence the name is better.
It's also shorter, so rename it.

The commit is mostly trivial, including update of code comments
and logging messages.

Fixes: 1b43c880ba
2016-04-07 18:52:12 +02:00
Beniamino Galvani
e3a30665d7 config: test reading and writing of state file 2016-04-07 17:57:25 +02:00
Beniamino Galvani
69955694a7 core: add code coverage support for files in src/ 2016-04-07 17:57:25 +02:00
Thomas Haller
1b43c880ba config: let NMConfig handle "NetworkManager.state" file (bgo#764474)
Move reading and writing of the state file to NMConfig
("/var/lib/NetworkManager/NetworkManager.state" file).

Originally, I intended to persist more state, thus it made
sense to cleanup handling of the state file and move it all
at one place. Now, it's not clear that will happen anytime soon.

Still, the change is a worthy cleanup, so do it anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=764474
2016-04-07 10:15:01 +02:00
Thomas Haller
9152dec99f build: disable deprecation checks for internal compilation
For internal compilation we want to be able to use deprecated
API without warnings.

Define the version min/max macros to effectively disable deprecation
warnings.

However, don't do it via CFLAGS option in the makefiles, instead hack it
to "nm-default.h". After all, *every* source file that is for internal
compilation needs to include this header as first.
2016-04-05 22:22:58 +02:00
Lubomir Rintel
a8e8e76641 dbus: fix up the XML formatting
The conversion script didn't do a very good job. It got fired.
2016-04-05 14:37:51 +02:00
Lubomir Rintel
6e2b188361 dbus: convert the annotations to gtk-doc blocks 2016-04-05 14:37:51 +02:00
Beniamino Galvani
5e78322088 core: fix message format for failed creation of secret key 2016-04-05 14:32:00 +02:00
Thomas Haller
e4c1699a83 build: reorder files for building platform
Build the sources in order so that files that depend on other
files are build after the files they depend on.
2016-04-05 13:38:32 +02:00
Thomas Haller
30302d7157 auth: downgrade g_assert() to nm_assert()
We know that this isn't going to fail. No need to check every time.
2016-04-05 10:39:20 +02:00
Lubomir Rintel
9498ea507e manager: ensure IP config of device is cleared before removal
If the manager removes the device, the IP config objects must
be cleared. The reason is that NMPolicy registers to the IP config
changed signal and passes these object on to NMDnsManager.

If the INTERNAL_DEVICE_REMOVED signal is emited with IP configuration
object pending, those objects will be leaked.

This partly redoes commit f72816bf10,
which was reverted.

Co-Authored-By: Thomas Haller <thaller@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=764483
2016-04-04 23:10:20 +02:00
Thomas Haller
c5d827057e device: ensure @error always set by nm_device_factory_create_device()
https://bugzilla.gnome.org/show_bug.cgi?id=764606
2016-04-04 21:27:05 +02:00
Thomas Haller
fe6940b692 manager: refactor error variable in platform_link_added()
Free the error via gs_free_error and create separate instances.
2016-04-04 21:26:51 +02:00
Thomas Haller
f7729751da core: use defines for signal names in NMDnsManager and NMFirewallManager 2016-04-04 16:48:10 +02:00
Thomas Haller
1ddc2c59b8 policy: pass private pointer as signal user-data for settings handlers 2016-04-04 16:48:10 +02:00
Thomas Haller
9e886147c9 policy: pass private pointer as signal user-data for manager handlers 2016-04-04 16:48:10 +02:00
Thomas Haller
9a9250e53a policy: pass private pointer as signal user-data for device handlers
We want to unregister the signals at cleanup time via
g_signal_handlers_disconnect_by_data(). This saves us from
storing the signal handler id or by naming the function
explicitly via g_signal_handlers_disconnect_by_func().

However, the registered user-data @self is a public pointer. That
is ugly, because potentially another component could register a
signal with passing the public @self pointer as user-data.
Although that doesn't currently happen, it is more correct to register
with a private pointer to avoid this case altogether.
2016-04-04 16:46:48 +02:00
Thomas Haller
b298d3e279 policy: removed unused signal subscription to "NMManager::state-changed" 2016-04-04 16:45:48 +02:00
Thomas Haller
1dd0693055 policy: refactor tracking registered signals to NMManager's instance 2016-04-04 16:45:48 +02:00
Thomas Haller
ccda474a02 manager: remove unused signal "user-permissions-changed" 2016-04-04 16:45:48 +02:00
Thomas Haller
9cc00d9e26 manager: use defines for signal names 2016-04-04 16:45:48 +02:00
Thomas Haller
aabb63e8b7 policy: refactor tracking registered signals to NMSettings's instance 2016-04-04 15:47:22 +02:00
Thomas Haller
6a08085d27 policy: embed pointer to private data into NMPolicy
Instead of a G_TYPE_INSTANCE_GET_PRIVATE() call every time,
fetching the private data becomes a pointer dereference.

As only one instance of NMPolicy exists, this costs us only
one additional pointer of memory.
2016-04-04 15:47:22 +02:00
Thomas Haller
7e3d090acb policy: refactor tracking of registered devices
No need to track the signal id of the device. We unsubscribe
all devices together, hence we can just use
g_signal_handlers_disconnect_by_data().
2016-04-04 15:47:21 +02:00
Thomas Haller
47c6b6db07 device: remove ignored dummy variable 2016-04-04 15:47:21 +02:00
Thomas Haller
e42fe89242 device/trivial: fix indention with tabs vs. spaces and align "nm-device.h" 2016-04-04 15:47:21 +02:00
Beniamino Galvani
35059ed48e device: allow NM-owned device to be assumed
Software devices created by NM should be kept up when quitting so that
they can be assumed upon restart. But now we consider devices created
by NM (those with the @is_nm_owned flag) not capable of assuming
connections and therefore we tear them down and deconfigure when
quitting.

Change this and ignore @is_nm_owned when deciding if a device can be
re-assumed.
2016-04-04 15:33:17 +02:00
Thomas Haller
e1edcda317 device: consider external devices as unmanaged until they have an IP address 2016-04-04 15:33:16 +02:00
Thomas Haller
207c0f5f81 platform: add nm_platform_link_can_assume() 2016-04-04 15:33:16 +02:00
Lubomir Rintel
a6fb37bae2 Revert "manager: don't remove the device before policy learns of ip config change"
This doesn't unexport the connection on disconnect (as opposed to device
removal).

This reverts commit f72816bf10.
2016-04-04 12:52:56 +02:00
Lubomir Rintel
f72816bf10 manager: don't remove the device before policy learns of ip config change
First let the device know it's being removed soon so that it has a
chance to clean up the IP configuration early.

If the manager removes the device fist, the policy never learns of
config removal and doesn't unhook it from the DNS manager resulting in a
IPConfig leak and possible wrong DNS configuration in effect.

Also adjust the route manager to skip over devices without IP
configuration when determining the best connection; it is perhaps
just due to being removed.

https://bugzilla.gnome.org/show_bug.cgi?id=764483
2016-04-04 12:40:40 +02:00
Thomas Haller
c06289459f rdisc: reject invalid prefix lengths from router advertisements
Later in NMDevice's rdisc_config_changed(), we already reject
routes with plen==0. Just do it earlier.

We would however not reject bogus routes with a prefix larger then 128.
That would later lead to an error when trying to add such a route to the
kernel.
2016-04-04 12:21:35 +02:00
Thomas Haller
c84d659b9b rdisc: refactor receive_ra() to set data in initializer
Don't use memset() and set the fields afterwards. Instead use
designated initializers.

Also, move the temporary variables closer to where they are used.
2016-04-04 11:48:55 +02:00
Thomas Haller
2b394d0092 dns-manager: use NM_IN_SET() in condition 2016-04-03 14:54:37 +02:00
Thomas Haller
fd496fd887 dns-manager: fix compute_hash() to skip over duplicate other configs
Fixes: f76aa4f77c
2016-04-03 14:54:34 +02:00
Thomas Haller
a6af426271 manager: fix memleak in error-path of _internal_enable() 2016-04-01 18:55:15 +02:00
Thomas Haller
7871a8fb06 manager: refactor handling GObject properties
Use NM_GOBJECT_PROPERTIES_DEFINE() and _notify() function.
2016-04-01 17:47:45 +02:00
Thomas Haller
5617cd4e61 merge: merge branch 'systemd' into master
After merging https://github.com/systemd/systemd/pull/2898,
use the LLDP defines now from public systemd API.
2016-04-01 15:15:43 +02:00
Lubomir Rintel
ec542df4df manager: don't the already activated devices shouldn't be considered added
The NMSettings shouldn't generate a new default wired connection for
devices that are being deactivated.
2016-04-01 14:35:38 +02:00
Thomas Haller
2fcd9f8bc7 systemd: update code from upstream
This is a direct dump from systemd git on 2016-03-31, git commit
1db30aeab10ca716aae877b298289fe1765f14fb.

======

SYSTEMD_DIR=../systemd
COMMIT=1db30aeab10ca716aae877b298289fe1765f14fb

(
  cd "$SYSTEMD_DIR"
  git checkout "$COMMIT"
  git reset --hard
  git clean -fdx
)

git ls-files :/src/systemd/src/ | xargs -d '\n' rm -f

nm_copy_sd() {
    mkdir -p "./src/systemd/$(dirname "$1")"
    cp "$SYSTEMD_DIR/$1" "./src/systemd/$1"
}

nm_copy_sd "src/basic/alloc-util.c"
nm_copy_sd "src/basic/alloc-util.h"
nm_copy_sd "src/basic/async.h"
nm_copy_sd "src/basic/escape.c"
nm_copy_sd "src/basic/escape.h"
nm_copy_sd "src/basic/ether-addr-util.c"
nm_copy_sd "src/basic/ether-addr-util.h"
nm_copy_sd "src/basic/fileio.c"
nm_copy_sd "src/basic/fileio.h"
nm_copy_sd "src/basic/fd-util.c"
nm_copy_sd "src/basic/fd-util.h"
nm_copy_sd "src/basic/fs-util.c"
nm_copy_sd "src/basic/fs-util.h"
nm_copy_sd "src/basic/hash-funcs.c"
nm_copy_sd "src/basic/hash-funcs.h"
nm_copy_sd "src/basic/hashmap.c"
nm_copy_sd "src/basic/hashmap.h"
nm_copy_sd "src/basic/hexdecoct.c"
nm_copy_sd "src/basic/hexdecoct.h"
nm_copy_sd "src/basic/hostname-util.c"
nm_copy_sd "src/basic/hostname-util.h"
nm_copy_sd "src/basic/in-addr-util.c"
nm_copy_sd "src/basic/in-addr-util.h"
nm_copy_sd "src/basic/io-util.c"
nm_copy_sd "src/basic/io-util.h"
nm_copy_sd "src/basic/list.h"
nm_copy_sd "src/basic/log.h"
nm_copy_sd "src/basic/macro.h"
nm_copy_sd "src/basic/mempool.h"
nm_copy_sd "src/basic/mempool.c"
nm_copy_sd "src/basic/parse-util.c"
nm_copy_sd "src/basic/parse-util.h"
nm_copy_sd "src/basic/path-util.c"
nm_copy_sd "src/basic/path-util.h"
nm_copy_sd "src/basic/prioq.h"
nm_copy_sd "src/basic/prioq.c"
nm_copy_sd "src/basic/random-util.c"
nm_copy_sd "src/basic/random-util.h"
nm_copy_sd "src/basic/refcnt.h"
nm_copy_sd "src/basic/set.h"
nm_copy_sd "src/basic/siphash24.c"
nm_copy_sd "src/basic/siphash24.h"
nm_copy_sd "src/basic/socket-util.c"
nm_copy_sd "src/basic/socket-util.h"
nm_copy_sd "src/basic/sparse-endian.h"
nm_copy_sd "src/basic/stdio-util.h"
nm_copy_sd "src/basic/string-table.c"
nm_copy_sd "src/basic/string-table.h"
nm_copy_sd "src/basic/string-util.c"
nm_copy_sd "src/basic/string-util.h"
nm_copy_sd "src/basic/strv.c"
nm_copy_sd "src/basic/strv.h"
nm_copy_sd "src/basic/time-util.c"
nm_copy_sd "src/basic/time-util.h"
nm_copy_sd "src/basic/umask-util.h"
nm_copy_sd "src/basic/unaligned.h"
nm_copy_sd "src/basic/utf8.c"
nm_copy_sd "src/basic/utf8.h"
nm_copy_sd "src/basic/util.c"
nm_copy_sd "src/basic/util.h"
nm_copy_sd "src/libsystemd-network/arp-util.c"
nm_copy_sd "src/libsystemd-network/arp-util.h"
nm_copy_sd "src/libsystemd-network/dhcp6-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp6-lease-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp6-network.c"
nm_copy_sd "src/libsystemd-network/dhcp6-option.c"
nm_copy_sd "src/libsystemd-network/dhcp6-protocol.h"
nm_copy_sd "src/libsystemd-network/dhcp-identifier.c"
nm_copy_sd "src/libsystemd-network/dhcp-identifier.h"
nm_copy_sd "src/libsystemd-network/dhcp-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp-lease-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp-network.c"
nm_copy_sd "src/libsystemd-network/dhcp-option.c"
nm_copy_sd "src/libsystemd-network/dhcp-packet.c"
nm_copy_sd "src/libsystemd-network/dhcp-protocol.h"
nm_copy_sd "src/libsystemd-network/lldp.h"
nm_copy_sd "src/libsystemd-network/lldp-internal.h"
nm_copy_sd "src/libsystemd-network/lldp-neighbor.c"
nm_copy_sd "src/libsystemd-network/lldp-neighbor.h"
nm_copy_sd "src/libsystemd-network/lldp-network.c"
nm_copy_sd "src/libsystemd-network/lldp-network.h"
nm_copy_sd "src/libsystemd-network/network-internal.c"
nm_copy_sd "src/libsystemd-network/network-internal.h"
nm_copy_sd "src/libsystemd-network/sd-dhcp6-client.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp6-lease.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp-client.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp-lease.c"
nm_copy_sd "src/libsystemd-network/sd-ipv4ll.c"
nm_copy_sd "src/libsystemd-network/sd-ipv4acd.c"
nm_copy_sd "src/libsystemd-network/sd-lldp.c"
nm_copy_sd "src/libsystemd/sd-event/sd-event.c"
nm_copy_sd "src/libsystemd/sd-id128/sd-id128.c"
nm_copy_sd "src/shared/dns-domain.c"
nm_copy_sd "src/shared/dns-domain.h"
nm_copy_sd "src/systemd/_sd-common.h"
nm_copy_sd "src/systemd/sd-dhcp6-client.h"
nm_copy_sd "src/systemd/sd-dhcp6-lease.h"
nm_copy_sd "src/systemd/sd-dhcp-client.h"
nm_copy_sd "src/systemd/sd-dhcp-lease.h"
nm_copy_sd "src/systemd/sd-event.h"
nm_copy_sd "src/systemd/sd-ndisc.h"
nm_copy_sd "src/systemd/sd-id128.h"
nm_copy_sd "src/systemd/sd-ipv4acd.h"
nm_copy_sd "src/systemd/sd-ipv4ll.h"
nm_copy_sd "src/systemd/sd-lldp.h"
2016-04-01 13:31:10 +02:00
Thomas Haller
603e6dc006 exported-object: reorder includes 2016-04-01 08:58:19 +02:00
Thomas Haller
8fd3a2b893 exported-object/trivial: move code 2016-04-01 08:58:19 +02:00