Commit graph

8285 commits

Author SHA1 Message Date
Thomas Haller
a8d87ef87f dhcp-helper: refactor error handling
Don't exit(1) from fatal_error() because that skips destroying
local variables in main(). Just return regularly.

(cherry picked from commit bb489163db)
2016-09-08 00:26:14 +02:00
Thomas Haller
0ebdfd6cf1 dhcp-listener/trivial: rename field to track connections in NMDhcpListener
It's not "signal-handles", as it currently tracks the registration ID of
type int. Rename it, it is effectively the list of connections that we
track.

(cherry picked from commit 2dd3a5245f)
2016-09-08 00:26:14 +02:00
Thomas Haller
3920a90e4a dhcp-listener: add logging macros to nm-dhcp-listener.c
(cherry picked from commit d37cd04fe0)
2016-09-08 00:26:14 +02:00
Thomas Haller
75e13f0e15 dhcp-listener: refactor type definition and embed private data in @self
(cherry picked from commit 822f01a8fd)
2016-09-08 00:26:14 +02:00
Thomas Haller
3940d63a7e core: use _NM_GET_PRIVATE() macros
(cherry picked from commit cdf6ad4057)
2016-09-08 00:26:14 +02:00
Thomas Haller
99e30bdf70 logging: don't round subsecond part in logging timestamp
tv.tv_usec is guaranteed to have less then 6 digits, however rounding it up
we might reach 1000000 and thus the value becomes mis-aligned. To round
correctly, we would have to carry over a potential overflow to the seconds.
But that seems too much effort for little gain. Just truncate the value.

(cherry picked from commit c1b4b99a3c)
2016-09-08 00:26:14 +02:00
Thomas Haller
e9a0ce84a1 ifupdown: add curly braces to for loop
(cherry picked from commit 0ef8e98e73)
2016-09-07 13:22:16 +02:00
Scott Sweeny
1dd66ed623 plugins: ifupdown: support source-directory stanza
Enable the ifupdown settings plugin to read interface
definitions from the source directory:

/etc/network/interfaces.d/

https://mail.gnome.org/archives/networkmanager-list/2016-September/msg00014.html
(cherry picked from commit ada6b96de9)
2016-09-07 13:22:15 +02:00
Thomas Haller
db4375277c exported-object: use _NMLOG2() macro for logging property-changed signal
(cherry picked from commit ba713e8381)
2016-09-02 20:17:42 +02:00
Thomas Haller
7220d469be exported-object: use @self variable instead of @object
(cherry picked from commit b9c1868b45)
2016-09-02 20:17:42 +02:00
Thomas Haller
c29ca9b876 dbus: fix emitting D-Bus NetworkManager's old-style PropertiesChange signal
Before switching to gdbus (before 1.2.0), NetworkManager used dbus-glib.
Most objects in the D-Bus API with properties had a signal
NetworkManager-specific "PropertiesChanged" signal. Nowadays, this way of
handling of property changes is deprecated for the common "PropertiesChanged"
signal on the "org.freedesktop.DBus.Properties" interface.

There were a few pecularities in 1.0.0 and earlier:

  (1) Due to the implementation with dbus-glib, a property-changed
    signal was emitted on *all* interfaces. For example:
      - a change on a NMDeviceVeth of "NMDeviceEthernet.HwAddress" would be
        emitted both for the interfaces "fdo.NM.Device.Ethernet" and
        "fdo.NM.Device.Veth". Note that NMDeviceVeth is derived from
        NMDeviceEthernet and there is no "HwAddress" on veth device.
      - a change of "NMVpnConnection.VpnState" was emitted on both
        interfaces "fdo.NM.VPN.Connection" and "fdo.NM.Connecion.Active".
        Note that NMActiveConnection is the parent type of NMVpnConnection and
        only the latter has a property "VpnState".
  (2) NMDevice's "fdo.NM.Device" interface  doesn't have a "PropertiesChanged"
    signal. From (1) follows that all property-changes for this type were instead
    invoked with an interface like "fdo.NM.Device.Ethernet" (or multiple
    interfaces in case of NMDeviceVeth).

1.2.0 introduced gdbus, which gives us the standard "fdo.DBus.Properties"
signal. However, it made the mistake of not realizing (1), thus instead
of emitting the signal once for each interface, it would pick the first
one in the inheritance tree.

With 1.4.0, a bug from merge commit 844345e caused signals for devices
to be only emitted for the interface "fdo.NM.Device.Statistics", instead
of "fdo.NM.Device.Ethernet" or "fdo.NM.Device.Veth" (or both).

The latter is what bgo#770629 is about and what commit 82e9439 tried to fix.
However, the fix was wrong because it tried to do the theoretically correct
thing of emitting the property-changed signal exactly once for the
interface that actually ontains the property. In addition, it missed that
NMDevice doesn't have a PropertiesChanged signal, which caused signals for
"fdo.NM.Device" to get lost *sigh*.

Now, restore the (broken) behavior of 1.0.0. These old-style property changed
signals are anyway considered deprecated and exist solely to satisfy old clients
and preserve the old API.

Fixes: 63fbfad3705db5901e6a2a6a2fc332da0f0ae4be

https://bugzilla.gnome.org/show_bug.cgi?id=770629
https://bugzilla.redhat.com/show_bug.cgi?id=1371920
(cherry picked from commit bef26a2e69)
2016-09-02 20:17:42 +02:00
Beniamino Galvani
67f064f11b team: normalize invalid configuration during load
Now that we validate the JSON syntax of a team/team-port
configuration, any existing connection with invalid JSON configuration
would fail to load and disappear upon upgrade. Instead, modify the
setting plugins to emit a warning but still load the connection with
empty configuration.

(cherry picked from commit d6ec009afd)
2016-08-31 17:44:14 +02:00
Beniamino Galvani
9740a59035 device: manage firewall zone for assumed persistent connections
After the fix in [1], if the connection is assumed we don't update its
firewall zone. The goal of that change was to prevent NM from
interfering with the configuration done externally on devices not
created by NM.

However if there is an assumed persistent connection active on the
device NM touches the configuration in other ways, for example it
configures DHCP and manages the default route. So it seems correct to
also update the firewall zone.

OTOH, if the connection is assumed-generated there is no persistent
connection specifying a firewall zone and updating it makes no sense.

Bug [1] was about not interfering with devices unknown to NM (for
which there is no persistent connection) and so this change should not
conflict with the previous fix.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1098281

https://bugzilla.redhat.com/show_bug.cgi?id=1366288
(cherry picked from commit c39e03edbf)
2016-08-31 14:48:40 +02:00
Thomas Haller
4f452eedab exported-object: cleanup logging about properties-changed
(cherry picked from commit 46f285e3d3)
2016-08-31 14:23:25 +02:00
Thomas Haller
8d9ea18b3d exported-object: fix source interface for PropertiesChanged D-Bus signal
nm_exported_object_notify() hooks GObject's property-change signal
and searches for the D-Bus interface to which to send the
PropertiesChanged signal.
Then it would enqueue the value encoded as GVariant in pending_notifications.
However, thereby the association between the property that changed and the
interface was lost. So later in idle_emit_properties_changed() it would
just pick the first interface with a properties-changed-id.

That is wrong. pending_notifications must be associated with the D-Bus
interface that we are going to notify. That is, each InterfaceData must
have its own separate list.

This is broken since introducing NMExportedObject and moving to gdbus.
Only now it was discovered as NMDevice itself has two D-Bus interfaces:
"Device" and "Device.Statistics".

Note that the order of the PropertiesChanged in our D-Bus API is not defined
so that later signals can reach the receiver before earlier signals.
Also, multiple change signals for one property may be combined.
That is not changed by this patch and is not considered a bug, but something
that our D-Bus API wrt. PropertiesChanged does not guarantee.

https://bugzilla.gnome.org/show_bug.cgi?id=770629
(cherry picked from commit 82e94390de)
2016-08-31 14:23:24 +02:00
Lubomir Rintel
7e96eb5e66 device: don't let external changes cause a release of the slave
At this point we don't know if the slave has been using an assumed
connection that just vanished -- the best bet is to let the device be.

If it's meant to be unenslaved, it won't be due to an external event.

https://bugzilla.redhat.com/show_bug.cgi?id=1357738
(cherry picked from commit 3127fb0d17)
2016-08-31 12:08:21 +02:00
Thomas Haller
0d23ffdb6b device: forget unmanaged-flag "user-explicit" for unrealized devices
When a software device unrealizes, we want to forget about the "user-explict"
unmanaged state. It means, that after a software device is deleted, the
"user-explict" managed flag will be cleared for that device.

It might be nice to preserve the managed-state after deletion of the device.
However, the unrealized-device only exists as long as we have a connection
for the device. That means, before this patch whether the unmanaged flag
was forgotten depends on whether the user had some connections that keep
the device alive as unrealized. That behavior was complicated, just don't
do that.

(cherry picked from commit 34880d62d0)
2016-08-30 18:07:35 +02:00
Thomas Haller
89d68b1a96 platform: fix return value for error case in do_change_link_request()
There is a "goto retry" in do_change_link_request(), at that point,
seq_result has the value -EOPNOTSUPP, instead of
WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN.

Fixes: 02fb3eff48
(cherry picked from commit 145d199589)
2016-08-30 18:07:34 +02:00
Lubomir Rintel
4cf61eeafd platform: fix build
Fixes: 471521ca84
(cherry picked from commit 02fb3eff48)
2016-08-30 15:06:34 +02:00
Thomas Haller
3b51959f48 device: add hack to wait after changing MAC address
It seems some drivers return success for nm_platform_link_set_address(),
but at that point the address did not yet actually change *sigh*.
It changes a bit later, possibly after setting the device up.

Add a workaround to retry reading the MAC address when platform indicates
success but the address still differs at first.

https://bugzilla.gnome.org/show_bug.cgi?id=770456
(cherry picked from commit 67b6852358)
2016-08-30 11:22:15 +02:00
Thomas Haller
b1f5d3d798 device: fix spelling in logging
(cherry picked from commit d51f2c2a4e)
2016-08-30 11:22:14 +02:00
Thomas Haller
06d1679aa9 platform: workaround kernel wrongly returning ENFILE when changing MAC address
https://bugzilla.gnome.org/show_bug.cgi?id=770456
(cherry picked from commit 2bef71611b)
2016-08-29 11:41:40 +02:00
Thomas Haller
471521ca84 platform: split processing result from do_change_link()
(cherry picked from commit 3dc0944677)
2016-08-29 11:41:39 +02:00
Thomas Haller
5696a99eec platform/tests: avoid test failure setting bridge forward_delay
Seems odd numbers may be coerced to the next-smaller even number.
Avoid that by using an even number for the test, as the number
has no particular meaning.

https://bugzilla.gnome.org/show_bug.cgi?id=765835
(cherry picked from commit 895c61a742)
2016-08-28 18:06:36 +02:00
Michael Biebl
1a486a277e build: export _IO_stdin_used symbol in NetworkManager.ver
This symbol is required to decide which version of certain IO functions
to use on various architectures. So we can't strip away the symbol from
the NetworkManager binary as this will lead to segfaults on those
architectures.

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=835550
https://bugzilla.gnome.org/show_bug.cgi?id=770515
(cherry picked from commit 2f8ab8cd9f)
2016-08-28 16:56:25 +02:00
Thomas Haller
a82b7c8d5e ifcfg-rh: accept TEAM connections also without DEVICETYPE setting
Allow omitting DEVICETYPE=Team or DEVICETYPE=TeamPort and accept
team connections based on the presence of TEAM_CONFIG/TEAM_MASTER
alone.

Also, check first for a team slave before checking for bond
slave. That is what initscripts do and matters if somebody wrongly
sets MASTER and TEAM_MASTER.

libteam:     20d45a1e02
initscripts: https://git.fedorahosted.org/cgit/initscripts.git/commit/?id=3235be4a3da91bc91c698b318935240dbdf81aac

https://bugzilla.redhat.com/show_bug.cgi?id=1367180
(cherry picked from commit 114eb5b963)
2016-08-26 12:56:56 +02:00
Thomas Haller
6de181247f ifcfg-rh: make out_unhandled argument non-optional
Depending on the connection we are about to read,
we would assert that the user provided a @out_unhandled
argument.

That means, the user must always provide a valid @out_unhandled
pointer, because he cannot know beforehand how the reading
of the ifcfg file goes.

(cherry picked from commit 50d7ac4af3)
2016-08-26 12:56:55 +02:00
Thomas Haller
1d909f4229 ifcfg-rh: clear IP settings for slave connections
Clear some IP related entries from the ifcfg-rh file if
the connection is a slave connection.

Also, drop utils_ignore_ip_config(). It is guaranteed, that
writer only handles connections that verify(). Such connections
have an IPv4/IPv6 setting if (and only if) they are not slave
types.

https://bugzilla.redhat.com/show_bug.cgi?id=1368761
(cherry picked from commit cf7b8866ce)
2016-08-26 11:40:32 +02:00
Beniamino Galvani
2a56c07092 dhcp/systemd: honor timeout for DHCPv6
https://bugzilla.gnome.org/show_bug.cgi?id=770329
(cherry picked from commit bdaa3acfc3)
2016-08-24 18:01:18 +02:00
Thomas Haller
9382fb0213 device/team: fix assuming non-NULL team-config in NMDeviceTeam::act_stage1_prepare()
(cherry picked from commit 4f6fd1bf0e)
2016-08-24 10:59:39 +02:00
Lubomir Rintel
aa0ebcc324 tests: try to resolve the .so file symbols
At some point, linker on ppc64le would throw away useful symbols along with the
garbage: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1c9177d9a5c3e06d3344347c8068acfb7d8ecc8b

Add a post-build check so that the distributors running broken binutils
would catch this early and fix their toolchain (or disable the garbage
collecting at the expense of larger and slower binaries).

(cherry picked from commit 680b3d1037)
2016-08-23 14:32:43 +02:00
Thomas Haller
633344bf27 core: use #define for "rfkill-changed" signal name
(cherry picked from commit 640fbec855)
2016-08-23 11:46:28 +02:00
Beniamino Galvani
772a9cb05d core: check valid uid for D-Bus load_connection(s)/set_logging calls
Commit 4c7fa8dfdc ("core: drop root requirement for
load_connection(s)/set_logging D-Bus calls") removed the enforcing of
permission in the daemon for such methods since the D-Bus daemon
configuration already does that. That change also allows clients to
send a request and not wait for a response, since we don't have to
check the caller credentials in the daemon.

In the future we might switch to polkit for these methods, breaking
clients that don't wait for a reponse, so it seems better to prevent
from beginning such behavior.

Fixes: 4c7fa8dfdc
(cherry picked from commit dd27b79c4e)
2016-08-23 11:24:19 +02:00
Thomas Haller
0852401b0e vpn: ignore unexpected default-route for nm_vpn_connection_ip6_config_get()
The VPN data comes from an external source, it may be bogus.
Default-routes are not allowed on this point and would trigger
an assertion afterwards. Skip over them.

(cherry picked from commit 071103b172)
2016-08-23 11:12:10 +02:00
Thomas Haller
6757dd3713 vpn: fix nm_vpn_connection_ip6_config_get() for VPNs without own interface
We need an ifindex for the NMIP4Config/NMIP6Config instance.
For interface-less VPN types, we need to lookup the parent
device, as already done for IPv4.

Fix IPv6 case too.

https://bugzilla.redhat.com/show_bug.cgi?id=1368354
(cherry picked from commit 2da35ddfe8)
2016-08-23 11:12:10 +02:00
Thomas Haller
bf1713a701 vpn: refactor property implementation in NMVpnConnection
(cherry picked from commit 9d6f613df4)
2016-08-23 11:12:10 +02:00
Thomas Haller
907b5a597e vpn: embed private data in NMVpnConnection structure
(cherry picked from commit d52195475b)
2016-08-23 11:12:10 +02:00
Thomas Haller
02980bed49 core: downgrade assertion in nm-ip[46]-config.c to g_critical
(cherry picked from commit c5682d601b)
2016-08-23 11:12:10 +02:00
Thomas Haller
417039fbd6 device: silence logging about "link disconnected"
<info> logging is just too verbose for something that happens
frequently.

(cherry picked from commit ed7f832c40)
2016-08-23 10:50:49 +02:00
Thomas Haller
f392da2c78 device: fix queued activation failure due to link disconnected
When activating a connection, it may fail with nmcli reporting:
  $ nmcli connection up id "Wired Connection 1"
  Error: Connection activation failed: Active connection removed before it was initialized

This should be easily reproducible by having a connection "Wired Connection 1" with
cloned-mac-address set to random. When the connection is already active on a device,
re-activating with
  $ nmcli connection up id "Wired Connection 1"
fails.

We first create a queued-activation and tear down the existing
connection:
   device (enp0s25): state change: deactivating -> disconnected (reason 'new-activation')
Shortly after we see:
   device[0x557d02cdb0c0] (enp0s25): set-hw-addr: setting MAC address to 'AA:BB:CC:DD:EE:FF' (reset, deactivate)...
   device[0x557d02cdb0c0] (enp0s25): taking down device
later, we get:
   device (enp0s25): link disconnected
   device[0x557d02cdb0c0] (enp0s25): queued state change to unavailable due to carrier-changed (id 17290)
in the meantime, the queued activation request starts:
   device (enp0s25): Activation: starting connection 'my-wired' (ca058ec5-8a47-4e1e-b38e-962b71c4699e)
but the device already transitions to unavailable
   device[0x557d02cdb0c0] (enp0s25): running queued state change to unavailable (id 17290)
   device (enp0s25): state change: disconnected -> unavailable (reason 'carrier-changed') [30 20 40]
which kills the new activation request:
   active-connection[0x557d02c10e40]: set state deactivated (was unknown)

Just delay a carrier-lost handling if we have any queued activation
requests.

(cherry picked from commit d4e9b30320)
2016-08-23 10:50:48 +02:00
Thomas Haller
6c4447520d platform: disable debug logging for NMPObject ref-couting
These logging lines are already disabled by default as _LOGt()
is a NOP unless configured --with-more-logging.

However, the logging is still very verbose also for debug-builds
and currently there are no known issues there. Disable the logging
statements (but leave them in so they can easily be enabled).

(cherry picked from commit 4cb845558e)
2016-08-22 18:37:04 +02:00
Thomas Haller
f1beb01050 core: use define for signal name in nm_active_connection_set_device()
(cherry picked from commit 598bea3481)
2016-08-22 16:25:33 +02:00
Thomas Haller
0e1c7ede12 device: emit NM_DEVICE_STATE_CHANGED signal by id
This saves a lookup of the ID by name. We already have the signal-id,
use it.

(cherry picked from commit 534b0360c1)
2016-08-22 16:25:32 +02:00
Beniamino Galvani
a77ed0de97 core: drop root requirement for load_connection(s)/set_logging D-Bus calls
The D-Bus configuration already ensures that only root can do that;
enforcing the permission at policy level seems better than doing it in
the daemon itself because it allows users to change the policy and
also because callers can exit immediately after issuing the request.

(cherry picked from commit 4c7fa8dfdc)
2016-08-20 10:45:53 +02:00
Beniamino Galvani
0944a86182 ifcfg-rh: ensure master is cleared when updating a connection
If the connection is not a slave we must clear any existing variable
indicating the connection's master.

https://bugzilla.redhat.com/show_bug.cgi?id=1355656
(cherry picked from commit 2750714802)
2016-08-19 18:56:59 +02:00
Beniamino Galvani
9364585eeb device: don't flush addresses when unmanaging assumed devices
When a assumed software device is brought down externally, it becomes
UNMANAGED_EXTERNAL_DOWN and its state goes from ACTIVATED directly to
UNMANAGED. In such case, we shouldn't flush the IP configuration
(addresses and routes) present on the device.

To fix this, clean up the device with CLEANUP_TYPE_KEEP and modify
nm_device_cleanup() not to flush addresses and devices with such flag.

https://bugzilla.redhat.com/show_bug.cgi?id=1363995
(cherry picked from commit 45cd3302dc)
2016-08-19 18:19:13 +02:00
Thomas Haller
eff2dc63b4 vpn: fix out-of-range access reading route.plen in nm_vpn_connection_ip4_config_get()
Also, skip over routes with plen zero.

Fixes: 44768f0311

https://bugzilla.redhat.com/show_bug.cgi?id=1368355
(cherry picked from commit 87fcbb491d)
2016-08-19 13:42:06 +02:00
Thomas Haller
4023659ee1 logging: remove unused formatting options
Previously, we logged also the location (file:line func). nm-logging.c
supported format flags to control the timestamp, the location, and alignment
of the timestamp.

We want that all our logging backends log the same messages. That is,
both syslog and journal should have our ~default~ logging format, that
is with timestamp but without location.

Drop the unused code.

(cherry picked from commit cc828431b8)
2016-08-19 12:32:30 +02:00
Beniamino Galvani
db14c1b167 policy: always try to update kernel hostname
Even if we know that the new hostname being set is equal to the cached
old one, the user may have manually changed the kernel hostname in the
meanwhile. For example:

 # hostname
 host123

 # hostname localhost
 # nmcli connection up eth1
                    # (now NM receives 'host123' from DHCP, but
                    # believes it's already set and doesn't update it)
 # hostname
 localhost

Let's always try to update the kernel (transient) hostname, unless it
is really already set (as returned by gethostname()).

https://bugzilla.redhat.com/show_bug.cgi?id=1356015
(cherry picked from commit 51b2cef04f)
2016-08-19 10:02:41 +02:00
Thomas Haller
ed20625309 platform/tests: relax condition for test
Got a test failure for /link/software/bond

(cherry picked from commit bdd0f722b8)
2016-08-18 15:26:57 +02:00