Commit graph

15651 commits

Author SHA1 Message Date
Thomas Haller
e678bd29a4 dhcp: call synchronous Notify D-Bus method from nm-dhcp-helper
A D-Bus signal is asynchronous and it can happen that nm-dhcp-helper
emits the "Event" signal before the server is able to register a handler:

   NM_DHCP_HELPER=/usr/libexec/nm-dhcp-helper
   nmcli general logging level TRACE
   for i in `seq 1 500`; do $NM_DHCP_HELPER & done
   journalctl -u NetworkManager --since '1 min ago' | grep "didn't have associated interface" | wc -l
    499

Avoid that, by calling the synchronous D-Bus method "Notify".

Interestingly, this race seem to exist since 2007.

Actually, we called g_dbus_connection_signal_subscribe() from inside
GDBusServer:new-connection signal. So it is not clear how such a race
could exist. I was not able to reproduce it by putting a sleep
before g_dbus_connection_signal_subscribe(). On the other hand, there
is bug rh#1372854 and above reproducer which strongly indicates that
events can be lost under certain circumstances.
Now we instead g_dbus_connection_register_object() from the
new-connection signal. According to my tests there was no more race
as also backed by glib's documentation. Still, keep a simple retry-loop
in nm-dhcp-helper just to be sure.

https://bugzilla.redhat.com/show_bug.cgi?id=1372854
https://bugzilla.redhat.com/show_bug.cgi?id=1373276
(cherry picked from commit 2856a658b3)
2016-09-08 00:26:14 +02:00
Thomas Haller
3ac3125aff dhcp: add new header "nm-dhcp-helper-api.h"
(cherry picked from commit 7684b68c49)
2016-09-08 00:26:14 +02:00
Thomas Haller
9d44dafc3c dhcp-helper: refactor logging to use logging macros
(cherry picked from commit cc89996c9e)
2016-09-08 00:26:14 +02:00
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
5bac57496c shared: add _NM_GET_PRIVATE() macro
(cherry picked from commit 2cae9ba348)
2016-09-08 00:26:14 +02:00
Thomas Haller
811aaead4c shared: add NM_MIN()/NM_MAX() macros to replace glib's MIN()/MAX()
(cherry picked from commit b2016fd2a5)
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
fe0e507617 libnm: merge branch 'th/empty-cloned-mac-address-rh1372799'
https://bugzilla.redhat.com/show_bug.cgi?id=1372799

(cherry picked from commit ad3c8a0d4e)
2016-09-06 16:17:45 +02:00
Thomas Haller
742bf5671f libnm: fix regression serializing empty "cloned-mac-address"
For "cloned-mac-address", the empty string "" is an invalid
value that is rejected by verify().

Commit 8eed671 changed how the property is serialized to D-Bus.
Before, it was serialized using _nm_utils_hwaddr_to_dbus().
For invalid or empty addresses, this would not serialize the
value on D-Bus (or before commit 76aa6f8e0, it would create
a bogus value with no array elements).

With commit 8eed671, the cloned-mac-address gets also serialized
as "assigned-mac-address" via _nm_utils_hwaddr_cloned_data_synth(),
which would pass on invalid strings that the server would then reject.

That breaks for example nmtui. Try editing a connection with
"cloned-mac-address" set to NULL. Note, as long as you don't edit
the cloned MAC address in nmtui, you can save the modification.
Once you start modifying the entry, you can no longer set an empty
MAC address as the server now receives the invalid empty string.
Thus, the "OK" button fails with
   Unable to save connection:
   802-3-ethernet.cloned-mac-address:
   is not a valid MAC address
It also means, nmtui cannot modify the "cloned-mac-address" field to
become empty.

Fix that problem at various places by coercing "" to NULL.

Fixes: 8eed67122c

https://bugzilla.redhat.com/show_bug.cgi?id=1372799
(cherry picked from commit 814784aa46)
2016-09-06 16:16:19 +02:00
Thomas Haller
1fdf026e2d libnm-core: replace local helper with nm_stdup_not_empty()
(cherry picked from commit f4d7db964e)
2016-09-06 16:16:19 +02:00
Thomas Haller
4aad70a61d shared: add helper macros nm_str_not_empty() and nm_strdup_not_empty()
(cherry picked from commit 3227b9017b)
2016-09-06 16:16:19 +02:00
Lubomir Rintel
bcc9a7eacf po: add translations from Red Hat
https://bugzilla.redhat.com/show_bug.cgi?id=887771
(cherry picked from commit 2724ec53b7)
2016-09-06 15:43:00 +02:00
Thomas Haller
c87b89bf8f core: merge branch 'th/dbus-property-changed-source-iface-bgo770629-v2'
https://bugzilla.gnome.org/show_bug.cgi?id=770629
https://bugzilla.redhat.com/show_bug.cgi?id=1371920

(cherry picked from commit 673282ece6)
2016-09-02 20:28:40 +02:00
Thomas Haller
e0eca5cec9 NEWS: update file with changes to PropertiesChanged signal
(cherry picked from commit 56bd86fd0c)
2016-09-02 20:28:21 +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
98773bff54 dbus: deprecated NM specific PropertiesChanged signals
Nowadays, users should use the standard "PropertiesChanged" signal
on "org.freedesktop.DBus.Properties" interface.

(cherry picked from commit 6fb917178a)
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
Thomas Haller
268ae4a359 man: fix wording in NetworkManager.conf for "rc-manager"
(cherry picked from commit e284651f4c)
2016-09-02 17:05:17 +02:00
Thomas Haller
c66cbe9375 doc: add comment to systemd's NetworkManager.service about ibft requiring CAP_SYS_ADMIN
We don't want to enable this upstream, but make the requirement
more discoverable by documenting it and put a comment to
NetworkManager.service.

https://bugzilla.redhat.com/show_bug.cgi?id=1371201
(cherry picked from commit 9aee7b493e)
2016-09-02 15:39:42 +02:00
Thomas Haller
4f125532fe doc: fix mistake in documenting Reload D-Bus call
(cherry picked from commit e54b6c2bd5)
2016-09-01 16:56:43 +02:00
Beniamino Galvani
228799a78b team: merge branch 'bg/team-config-validation'
Restore the validation on team and team port configuration.

(cherry picked from commit ee6a4039c8)
2016-08-31 17:44:46 +02:00
Beniamino Galvani
bf422e972a libnm: restore verify() comments in team/team-port settings
Restore the comments removed in commit
a524091966afb884cdb8db48067d5599a685a8eb.

(cherry picked from commit d06279f3db)
2016-08-31 17:44:16 +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
4f5059306b Revert "libnm-core/team: normalize invalid config to NULL"
It's better to fail the validation of any invalid configuration
instead of silently ignoring it.

This reverts commit 476810c290.

(cherry picked from commit 39ad134b0c)
2016-08-31 17:44:13 +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
923eaa6a47 core: merge branch 'th/dbus-property-changed-source-iface-bgo770629'
https://bugzilla.gnome.org/show_bug.cgi?id=770629

(cherry picked from commit d2550cef44)
2016-08-31 14:23:43 +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
3a2e3aa70b device: merge branch 'th/platform-set-address-enfile-bgo770456-v2'
https://bugzilla.gnome.org/show_bug.cgi?id=770456

(cherry picked from commit e109f87067)
2016-08-30 11:22: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
a3fd48545c platform: merge branch 'th/platform-set-address-enfile-bgo770456'
https://bugzilla.gnome.org/show_bug.cgi?id=770456

(cherry picked from commit 091620e765)
2016-08-29 11:41:56 +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
9f4ce4e283 ifcfg-rh: merge branch 'th/ifcfg-rh-read-team-rh1367180'
https://bugzilla.redhat.com/show_bug.cgi?id=1367180

(cherry picked from commit cbbc8620a1)
2016-08-26 12:57:14 +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