Commit graph

1285 commits

Author SHA1 Message Date
Lubomir Rintel
8ea39c3f1c modem: cancel secrets only if there's an outstanding request
Fixes an assertion failure on WWAN connection attempts that fail before
secrets are requested.

(cherry picked from commit 22c11f8ef1)
2016-04-20 18:16:35 +02:00
Thomas Haller
fa7cacd7df manager: fix wrongly removing DNS configuration on shutdown
When NetworkManager exits, it must preserve the DNS configuration of
devices that are left up.

Fixes: 9498ea507e
(cherry picked from commit 2158d6a5a8)
2016-04-20 17:54:24 +02:00
Lubomir Rintel
8de4c718af infiniband: remove the partitions on unrealizing
The infiniband drivers don't implement the rtnetlink link deletions.
Therefore we unrealize the NMDevice instance but the backing resources
stay around, preventing us from ever realizing the device again.

(cherry picked from commit a93807c288)
2016-04-20 10:49:35 +02:00
Lubomir Rintel
e3e7a25429 device: check for a parent device
The device creation can be attempted if the name can be determined. It
alone is doesn't mean that there's a parent device -- the name could
just have been hardcoded in the connection.

  NetworkManager[21519]: nm_device_get_ifindex: assertion 'NM_IS_DEVICE (self)' failed

  Program received signal SIGTRAP, Trace/breakpoint trap.
  g_logv (log_domain=0x5555557fb2e5 "NetworkManager", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffd3d0) at gmessages.c:1046
  1046              g_private_set (&g_log_depth, GUINT_TO_POINTER (depth));
  (gdb) bt
  #0  0x00007ffff4ec88c3 in g_logv (log_domain=0x5555557fb2e5 "NetworkManager", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffd3d0) at gmessages.c:1046
  #1  0x00007ffff4ec8a3f in g_log (log_domain=<optimized out>, log_level=<optimized out>, format=<optimized out>) at gmessages.c:1079
  #2  0x00005555555d2090 in nm_device_get_ifindex (self=0x0) at devices/nm-device.c:562
  #3  0x00005555555ef77a in nm_device_supports_vlans (self=0x0) at devices/nm-device.c:9865
  #4  0x00005555555bf2f9 in create_and_realize (device=0x555555c549b0 [NMDeviceVlan], connection=0x555555b451e0, parent=0x0, out_plink=0x7fffffffd5f8, error=0x7fffffffd700) at devices/nm-device-vlan.c:225
  #5  0x00005555555d5757 in nm_device_create_and_realize (self=0x555555c549b0 [NMDeviceVlan], connection=0x555555b451e0, parent=0x0, error=0x7fffffffd700) at devices/nm-device.c:1783
  #6  0x0000555555688601 in system_create_virtual_device (self=0x555555af51c0 [NMManager], connection=0x555555b451e0) at nm-manager.c:1120
  #7  0x000055555568894e in connection_changed (settings=0x555555ae8220 [NMSettings], connection=0x555555b451e0, manager=0x555555af51c0 [NMManager]) at nm-manager.c:1172
  #8  0x0000555555693448 in nm_manager_start (self=0x555555af51c0 [NMManager], error=0x7fffffffda30) at nm-manager.c:4466
  #9  0x00005555555d166f in main (argc=1, argv=0x7fffffffdba8) at main.c:454
  (gdb)

Fixes: 332994f1b1
(cherry picked from commit 03584e420f)
2016-04-19 13:33:33 +02:00
Lubomir Rintel
17e9337054 infiniband: check that the connection to be created is a partition first
No functional change. It will make it a bit easier to produce a good
error message in subsequent commit.

(cherry picked from commit 7eca706751)
2016-04-19 13:33:33 +02:00
Lubomir Rintel
6223d32e90 infiniband: consistently use the error code
Only report CREATION_FAILED when we did actually attempt creation.

(cherry picked from commit dda8e24a21)
2016-04-19 13:33:32 +02:00
Lubomir Rintel
af7321ae3f macvlan: fix error handling
(cherry picked from commit f9a0aface3)
2016-04-19 13:33:32 +02:00
Lubomir Rintel
4abb943e84 device-factory: always prefer manually set interface name to a generated one
If the connection specifies an interface name, it should never attach to
a device of a different name even if the factory thinks the connection
is compatible with the device.

This fixes an issue that caused the inifniband connections to attach to
different devices or partitions.

(cherry picked from commit 332994f1b1)
2016-04-18 19:01:56 +02:00
Thomas Haller
58c501eda5 device: fix preserving the default-route during _cleanup_generic_post()
When we want to preserve the default-route on cleanup, we must first
set it to assumed, before clearing it. Otherwise, NMDefaultRouteManager's
update() will delete the default route.

This is the oposite of the deconfigure case, where we first set it to
!has && !assumed, to force the route-manager to delete the route.

(cherry picked from commit 4697376f99)
2016-04-15 21:06:44 +02:00
Thomas Haller
b6973827cf device: refactor clearing default-route in NMDevice
Add a function _update_default_route() to set the default_route
flags and call update() in one step.

Also, if there are no changes, skip the call to NMDefaultRouteManager's
update().

(cherry picked from commit b2f794fe1e)
2016-04-15 21:06:43 +02:00
Thomas Haller
9c9dc9727a device: fix wrongly deleting default-route on exit
We must preserve the default-route on shutdown.

Thus it must first be announced as "assumed", and only removed
in a second step.

Fixes: 9498ea507e
(cherry picked from commit 2079f8361c)
2016-04-15 21:06:41 +02:00
Beniamino Galvani
8e405e99f0 device/vlan: update hw address also during prepare phase
The hardware address of a VLAN must be kept aligned with the one of
its parent device, and we already used a signal in NMDeviceVlan to
catch changes in parent address and update the VLAN device
accordingly.

But this didn't work in all cases because the change might happen
after the VLAN gets created but before we register the signal, so it
is necessary to add further checks to enforce the alignment during the
device activation.

https://bugzilla.redhat.com/show_bug.cgi?id=1325752
(cherry picked from commit a032ce72ea)
2016-04-14 14:05:44 +02:00
Thomas Haller
a79a94fcfd platform/tests: add @platform argument to nmtstp functions
This allows tests to use these functions on a different platform instance
then on the singleton. The change makes the argument list longer, which is
unfortunate. On the other hand, it makes those functions more useful
in general.

You can't have it all.

Also, they now follow the pattern of most functions in NM where the type
is a singleton: you always pass the singleton to the function, although
in the usual case there is only one singleton instance. This allows to
use the function also on the non-singleton instance.

(cherry picked from commit c4151ebb5b)
2016-04-12 11:14:01 +02:00
Thomas Haller
7d6b286e1f platform/tests/trivial: rename init_tests() and setup_tests() function
Make it clear that they are nmtstp functions, i.e. they are found
in the header "test-common.h".

(cherry picked from commit 25d826ec49)
2016-04-12 11:14:01 +02:00
Thomas Haller
4873850fd4 platform: change @plen field of NMPlatformIPxAddress to type guint8
On netlink layer, this field is uint8_t/uchar.

A larger (signed) plen makes no sense. Adjust the signatures
to have only guint8.

(cherry picked from commit 44768f0311)
2016-04-12 11:14:01 +02:00
Thomas Haller
08cce6c0ef platform: change @plen field of NMPlatformIPxRoute to type guint8
On netlink layer, this field is uint8_t/uchar.

A larger (signed) plen makes no sense. Adjust the signatures
to have only guint8.

(cherry picked from commit 14ee5dd2f8)
2016-04-12 11:14: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
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
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
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
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
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
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
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
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
Lubomir Rintel
ce745e098a device: delay the activation if the backing device is not yet there 2016-03-26 11:29:41 +01:00
Lubomir Rintel
2a45d30cc5 device: only clear the activate request when the device disconnects
If it's traversing from unavailable to disconnected (e.g. realizing
of the device was delayed because it was awaiting the parent connection),
then we just want to progress the activation.
2016-03-26 11:29:41 +01:00
Lubomir Rintel
6219759490 device: _get_available_connections() with _get_best_connection()
We'll need to share the best conneciton logic and it's the only caller
of nm_device_get_available_connections(). Let's just move it all to
NMDevice and provide the best connection from there instead.
2016-03-26 11:29:41 +01:00
Thomas Haller
60cc501a66 device: optimize hashtable usage for shared_ips
No point ins storing "TRUE" as value in the @shared_ips hash
table. That forces glib to allocate a separate storage for the
value. Just use g_hash_table_add() instead.
2016-03-20 10:59:46 +01:00
Thomas Haller
3363d8fd4e lldp: refactor keeping tlv data and order entries in neighbor GVariant
The fields in the neighbor variant should have a defined order.

Instead of sorting the hash table entries while constructing the
variant in lldp_neighbor_to_variant(), refactor the management of
the TLV attributes.
As we only support known attributes, we can
store them in an array at a known index instead of putting them
in a hash table.
An alternative would be to have explict fields for every known
attribute. That would be even more efficient, but requires more
work when adding new attributes.
2016-03-17 15:04:37 +01:00
Thomas Haller
191e5ae8a7 lldp: ensure stable order of variants in LLDP neighbor list 2016-03-17 15:00:49 +01:00
Thomas Haller
121e790bda lldp: drop process_lldp_neighbors()
We register the callback early on, so we get notified about
every single neighbor as they show up. No need to iterate over
them explicitly -- and probably, at that early state, there are
no neighbors yet.
2016-03-17 15:00:49 +01:00
Thomas Haller
4cd6ac3a7b lldp: process one neighbor at a time
The systemd event tells which neighbor changed. Make use
of this information and don't rebuild all the neighbors
all the time.

That means, we must also change our rate limiting. Instead of
rate limiting the processing of all neighbors, we process neighbors
right away but limit the notification that gobject property changed.
2016-03-17 15:00:49 +01:00
Thomas Haller
e1f1e07a3d lldp: implement properties via NM_GOBJECT_PROPERTIES_DEFINE() 2016-03-17 15:00:48 +01:00
Thomas Haller
c68dd4a202 lldp: improve logging 2016-03-17 15:00:48 +01:00
Thomas Haller
9c5265621c lldp: let lldp_neighbor_new() also create invalid objects
When we receive an update for a certain neighbor, the update
might be invalid and we want to reject it. However, we still
must create an invalid object to compare whether the update
causes a remove of a previously valid neighbor.

Let lldp_neighbor_new() create an instance as long as the
id fields are present.
2016-03-17 15:00:48 +01:00
Thomas Haller
1497b7eaf8 lldp: cache the GVariant in LldpNeighbor 2016-03-17 15:00:48 +01:00
Thomas Haller
2cf562f58e lldp: factor out lldp_neighbor_to_variant() 2016-03-17 15:00:48 +01:00
Thomas Haller
a16da9c6a8 lldp: refactor processing all lldp-neighbors
Instead of replacing the whole hash with a new one (and all new by a new one,
LldpNeighbor instances), update the existing hash.

One point of this is that our process-all function requires less
comparisons and avoids duplicate work right earlier. E.g. if a neighbor
didn't change, we don't have to put it into a hash to compare later for
equality.

But more importantly, we preserve our LldpNeighbor instance instead
of recreating them all the time. Later, the LldpNeighbor will cache
the GVariant.
2016-03-17 15:00:48 +01:00
Thomas Haller
e66c581c11 lldp: split out creation of LldpNeighbor instance 2016-03-17 15:00:48 +01:00