Commit graph

7673 commits

Author SHA1 Message Date
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
Thomas Haller
61f3c9890f exported-object: static variable prefix_counters from global scope to _create_export_path() 2016-04-01 08:58:19 +02:00
Thomas Haller
d4d72e2bda exported-object: inline find_dbus_property_type() in nm_exported_object_notify()
nm_exported_object_notify() is not that large of a function. Having it
all at one place makes it clearer what it does.
2016-04-01 08:58:19 +02:00
Thomas Haller
429cc30607 exported-object: allocate temporary buffer in nm_exported_object_signal_hook() using alloca
The size of GValue is about 24 bytes. The number of arguments
for a signal is also small. No problem allocating the temporary buffer
on the stack.
2016-04-01 08:58:19 +02:00
Thomas Haller
05d4faf334 exported-object: cache signal-id for "property-changed" in InterfaceData
Instead of looking up the signal-id every time, cache it.
g_signal_lookup() requires a g_quark_try_string() and a
lock a lock on a global mutex.

Downside is that the InterfaceData structure grows.
2016-04-01 08:58:19 +02:00
Thomas Haller
6a42e18d53 exported-object: refactor list of interfaces from GSList to an array
NMExportedObject is the center of every D-Bus exported object in
NetworkManager's core. It makes sense to optimize it.

Transform the GSList of interfaces to be a array. The array is still
allocated via the slice allocator (as we expect that there are only few
types in the list). This saves the overhead to allocate a GSList item
for each entry.

Another advantage is that the interfaces list is now strongly typed
instead of an opaque data pointer.
2016-04-01 08:58:18 +02:00
Thomas Haller
efae518e3c exported-object: sort fields in emitted "property-changed" data variant
The fields of the variant should have a consistent sort order.
2016-04-01 08:58:18 +02:00
Thomas Haller
2b9462f172 exported-object: reorder fields in NMExportedObjectPrivate struct
For now, this doesn't change the overall size of the struct.
But with the next commits this ordering allows tighter packing.
2016-04-01 08:58:18 +02:00
Nikolay Martynov
28e9ec499a device: renew dhcp leases on awake for software devices
This makes sure that devices like bond get their dhcp renewed

[thaller@redhat.com: original patch modified to rename
 now-public function update_dynamic_ip_setup()]

https://bugzilla.gnome.org/show_bug.cgi?id=764398
2016-03-31 16:31:34 +02:00
Thomas Haller
3c8ffa766c device: refactor by adding set_unmanaged_external_down() function
No functional change.
2016-03-31 10:38:39 +02:00
Thomas Haller
f7523ae6e2 device: refactor setting unmanaged flag EXTERNAL_DOWN
This should not actually change how we handle EXTERNAL_DOWN
unmanaged devices.
2016-03-31 10:38:38 +02:00
Thomas Haller
2d472657bd device: add nm_device_get_unmanaged_mask() 2016-03-31 10:38:38 +02:00
Thomas Haller
c1f58e9bb6 device: trival refactoring in can_unmanaged_external_down()
Swap order of operands so that the "cheaper" is evaluated first.
2016-03-30 18:50:52 +02:00
Beniamino Galvani
1422ce0a6a ifcfg-rh: don't chain up after failure of replace_and_commit()
If replace_and_commit() found existing route files (and the callback
has potentially already been invoked), it is wrong to chain up to
parent class and continue the update.

Fixes: f79d62692e
2016-03-30 18:12:32 +02:00
Lubomir Rintel
05e454a98d platform: don't assume that netlink message is as big as at compile time
The link_stats structure grew between 4.5 and 4.6 and this would cause
the messages to me ignored when compiling with 4.6 headers and running
on 4.5.

https://bugzilla.gnome.org/show_bug.cgi?id=764332
2016-03-30 13:25:49 +02:00
Lubomir Rintel
6b62536ce6 manager: make some error reporting a bit more specific
Make sure there's always the device and connection as well as the reason
when a slave activation fails. The slave connection could in fact be
chosen automatically on "nmcli d connect" and the user might not be
aware activation of which connection was attempted:

  $ nmcli d connect enp0s25
  Error: Device activation failed: Master connection not found or invalid
2016-03-30 13:24:49 +02:00
Dan Williams
415e9441ab core: fix duplicate values in NM-specific PropertiesChanged signals
GVariantBuilder doesn't care if you give it multiple dict entries with
the same key.  But that causes duplicate dict entries in the legacy
D-Bus PropertiesChanged signals that NM emits.  So instead go back to
a hash table to ensure that any previous value is dropped in favor of
the new one.
2016-03-29 15:52:23 -05:00
Dan Williams
8b6a1ac62f core: don't leak ActiveConnection object on AddAndActivate failure 2016-03-29 15:52:23 -05:00
Dan Williams
f2182fbf9b core: don't emit double PropertiesChanged signal for new active connections
When porting to GDBus property change notifications were converted from a
hash table to a GVariantBuilder.  GVariantBuilder doesn't care about
duplicated properties in the dict so each g_object_notify() will add
an additional item with possibly different values:

signal time=1458571005.592811 sender=:1.10 -> destination=(null destination) serial=64451 path=/org/freedesktop/NetworkManager; interface=org.freedesktop.NetworkManager; member=PropertiesChanged
   array [
      dict entry(
         string "ActiveConnections"
         variant             array [
               object path "/org/freedesktop/NetworkManager/ActiveConnection/19"
               object path "/org/freedesktop/NetworkManager/ActiveConnection/18"
               object path "/org/freedesktop/NetworkManager/ActiveConnection/15"
               object path "/org/freedesktop/NetworkManager/ActiveConnection/0"
            ]
      )
      dict entry(
         string "ActiveConnections"
         variant             array [
               object path "/org/freedesktop/NetworkManager/ActiveConnection/24"
               object path "/org/freedesktop/NetworkManager/ActiveConnection/19"
               object path "/org/freedesktop/NetworkManager/ActiveConnection/18"
               object path "/org/freedesktop/NetworkManager/ActiveConnection/15"
               object path "/org/freedesktop/NetworkManager/ActiveConnection/0"
            ]
      )
   ]

Fix that by not emitting notify events for the manager's ActiveConnections
property until the property has actually been updated in active_connection_add().
The unexport also isn't required for VPN connections since it will get
unexported when it's disposed after _internal_activation_failed() gets called.
2016-03-29 15:52:23 -05:00
Robby Workman
c0a506648f settings: add persistent hostname support for Slackware 2016-03-29 15:51:34 -05:00
Beniamino Galvani
260fcc52a8 bond: add some missing options
https://bugzilla.redhat.com/show_bug.cgi?id=1299103
2016-03-29 18:10:05 +02:00
Beniamino Galvani
2324410a75 bond: fix re-assuming of connections
When a value of a TYPE_BOTH option is read back from kernel it
contains both string and numeric values ("balance-rr 0"), so we must
chop off the number before adding the option to the setting. Also
change the default values of options to the string form so that the
option matching logic works.
2016-03-29 18:10:05 +02:00
Thomas Haller
ff06754fe8 core: downgrade warning logging message when creating virtual device
This can regularly happen when a virtual device depends on a parent/master
that is not yet created. We will retry later when the parent is ready, so
logging a warning about it is wrong and confusing.
2016-03-29 15:46:17 +02:00
Lubomir Rintel
2c2662f772 device: drop external changes on Reapply
https://bugzilla.gnome.org/show_bug.cgi?id=762322
2016-03-29 14:20:09 +02:00
Thomas Haller
573f3a9f59 policy: use slice allocator for ActivateData 2016-03-29 12:18:15 +02:00
Thomas Haller
03d5479320 policy: use slice allocator for PendingSecondaryData 2016-03-29 12:18:15 +02:00
Thomas Haller
0ea3880238 policy/trival: rename "policy" argument to "self"
We call the "self" pointer in our source files not after the
type. It's just "self".
2016-03-29 12:18:15 +02:00
Thomas Haller
6a7ba9b5e1 policy: remove initialized guard from nm_policy_new()
If we want to ensure that we create only one single instance of
NMPolicy, just don't create multiple instances. The nm_policy_new()
method should not be restriced and behave like other *new() functions
and create a new object as requested.
2016-03-29 12:18:15 +02:00
Thomas Haller
caebe764a5 policy: initialize object during GObject construction 2016-03-29 12:18:15 +02:00
Thomas Haller
bff0b02d9a policy: refactor object properties to notify by property enum 2016-03-29 12:18:15 +02:00
Thomas Haller
446d5c3a9e policy/trivial: move code 2016-03-29 12:18:15 +02:00
Thomas Haller
7991298c51 core: be strict about connection argument in D-Bus methods
There is no excuse for clients to send connections to NetworkManager
that have invalid/unknown fields. Just reject them.

This is a dangerous change, because we might now reject connections
that we were accepting previously. Who know what clients were sending
and it used to work.
2016-03-29 11:56:26 +02:00
Thomas Haller
0c5b98b464 core: be strict when parsing connection in AddAndActivateConnection
AddAndActivateConnection is allowed to provide an incomplete connection
that will be completed by NetworkManager. That is, a connection that
does not verify.

But we still want to catch invalid properties or unknown setting types.
Thus, we want to reject invalid partial connections.

This possibly rejects invalid requests from clients that were accepted
before. Thus this change has the potential to break misbehaving clients.
2016-03-29 11:55:24 +02:00
Thomas Haller
d4c201272e core: be strict about connection argument for Reapply() D-Bus method
There is no excuse for clients to send connections to NetworkManager
that have invalid/unknown fields. Just reject them.

As Reapply() is new API in nm-1-1, there is no problem with backward
compatibility.
2016-03-26 12:10:54 +01:00
Thomas Haller
3d8776108c libnm-core: add _nm_simple_connection_new_from_dbus() function
Contary to nm_simple_connection_new_from_dbus(), this internal
function allows to specify parse-flags.
2016-03-26 12:10:54 +01:00
Thomas Haller
72216f7359 shared: move NM_UTILS_ERROR to shared-utils
NM_UTILS_ERROR is our way to say, that we don't care about
the GError domain and code. nmcli sometimes passes domain "1"
and code "0" to g_set_error(), which could be considered
a bug.

We usually don't care about the error but only about the error
message, so let's have a universally available error quark around.
2016-03-26 12:10:53 +01:00
Lubomir Rintel
b26159b149 manager: allow delaying the device activation when the parent is not real
Don't try to realize our device when the parent device is not real.
Instead, enqueue the activation and wait until it is active before
realizing our device and progressing the device to DISCONNECTED so that
it can get connected.
2016-03-26 11:31:21 +01:00
Lubomir Rintel
da226ae137 manager: separate the traversal to disconected to a separate routine
Will be useful when we'll be able to defer the realization of the
device.
2016-03-26 11:31:20 +01:00