Commit Graph

7207 Commits

Author SHA1 Message Date
Thomas Haller
a609dd12d3 ifcfg-rh/trivial: rename connection_new_or_changed() and variable
The ifcfg-rh implementation should be similar to the one from keyfile.
Rename the variables and function that have the same meaning.
Do this trivial commit first, before starting refactoring.
2015-01-13 16:41:30 +01:00
Thomas Haller
bbaa243e31 ifcfg-rh: add logging macros _LOGX() to plugin.c 2015-01-13 16:41:30 +01:00
Thomas Haller
7b807b11cc settings: avoid duplicate UUID in settings
When adding a connection to NMSettings we did not check for
duplicate connection UUIDs (which could for example happen
if two different plugins report a conflicting UUID).
Also, we would not check that an already added connection
changes it's UUID.

Both could lead to have duplicate connections (by UUID).

Avoid that two ways:
- when adding a connection to NMSettings, ensure that we don't add
  a conflicting UUID. Otherwise just bail out and do nothing.
- when modifying a connection that is already added to NMSettings,
  enforce that the UUID cannot change. Otherwise fail with error.

For ifcfg-rh plugin this situation still can happen during reload.
In this case error out and refuse to update the connection. After
all, the user configured invalid UUIDs.

https://bugzilla.redhat.com/show_bug.cgi?id=1171751
2015-01-13 16:41:30 +01:00
Thomas Haller
8ba8a55cfa keyfile: ignore GFileMonitor change flags in dir_changed()
When writing a file (for example with `sed -i`) a temporary file
might be created and removed quickly. This causes spurious events
in dir_changed().
2015-01-13 16:41:30 +01:00
Thomas Haller
db5c4ce64f keyfile: reuse duplicate check from update_connection() in add_connection()
Also during add_connection() we must take special care of not "adding" a
connection with a conflicting UUID. In that case we want to fallback to
"update".

update_connection() already does all the checks, so call
update_connection() from add_connection().
2015-01-13 16:41:30 +01:00
Thomas Haller
5c2fa92099 keyfile: cleanup logging
Log lines with a "keyfile:" prefix and show more information about
the loaded connection. Especially printing the UUID is interesting.
2015-01-13 16:41:30 +01:00
Thomas Haller
8a4e64c6aa keyfile: read_connections() must skip duplicate connections
If there are keyfiles with duplicate UUIDs, read_connections()
would iterate over the files, loading them as they appear and
overwriting duplicate connections that were just loaded.

For example, have keyfiles 'A' and 'B' with the same UUID.
On start, NM might first load 'A', then 'B'. 'B' would replace the
content of 'A' which was just loaded.
On reload, NM would first overwrite 'B' with 'A', and then again
overwriting 'A' with 'B'.

Fix that by accept the first found connection and don't overwrite
it during the same read_connections() run.

Also sort the files by file modification timestamp so that we
get a reproducible and sensible behavior.
2015-01-13 16:41:30 +01:00
Thomas Haller
c2fcb680f8 keyfile: merge update_connection() and new_connection()
new_connection() and update_connection() are very similar as both
must anticipate collisions of UUIDs.

When reloading a connection (update_connection(), previously), the loaded
connection for a certain path might actually replace another existing
connection. In this case, the old connection must be removed, and
the existing one updated instead.
If reloading a connection changes the UUID to a new value, the old
connection must be removed likewise and a new connection added.

Merge both functions into update_connection().
2015-01-13 12:14:37 +01:00
Thomas Haller
f41586f00c keyfile/trival: move code 2015-01-13 11:46:06 +01:00
Thomas Haller
fbd30c7dd2 keyfile: simplify g_return() checks for _internal_write_connection() 2015-01-13 11:44:05 +01:00
Thomas Haller
e14ea6818a settings: log connection diffs in replace_settings only where appropriate
Only log connection diffs when we update a connection that we actually
care about.

Note that most plugin specific connections use
nm_settings_connection_replace_settings() in their constructor
to initialize themselves. These occurrences are not interesting
and spam the logfile.
2015-01-13 11:44:05 +01:00
Thomas Haller
750f01dfcb settings: no need to check nm_connection_compare() before nm_settings_connection_replace_settings()
nm_settings_connection_replace_settings() does nothing, if there are no changes.
2015-01-13 11:23:22 +01:00
Thomas Haller
c2dc5d3b0f settings: fix wrong assertions for calling nm_settings_connection_replace_settings() 2015-01-13 11:23:22 +01:00
Thomas Haller
73703c4d19 core: log object type in nm_utils_log_connection_diff() 2015-01-13 11:23:22 +01:00
Thomas Haller
45094c71d8 core: log ignored property notification with level TRACE
Avoids for example:
  notify(): ignoring notification for prop visible on type NMKeyfileConnection
2015-01-13 11:23:22 +01:00
Jiří Klimeš
91fd36e166 ifnet: fix a crash in ifnet settings plugin (bgo #737645)
conn_name can be NULL now as the connections are tracked by UUID
(see commit 689dadaffb)

Sep 29 21:20:34 Jdeapad NetworkManager[1339]: <info> getting unmanaged specs...
Sep 29 21:20:34 Jdeapad NetworkManager[1339]: <info> Checking unmanaged: (null)
Sep 29 21:20:38 Jdeapad kernel: NetworkManager[1339]: segfault at 0 ip
00007f1bfffbedd0 sp 00007fff98daa628 error 4 in
libglib-2.0.so.0.4002.0[7f1bfff86000+130000]

https://bugzilla.gnome.org/show_bug.cgi?id=737645
2015-01-13 10:27:52 +01:00
Jiří Klimeš
c743670251 ifcfg-rh: add a testcase for numeric bonding mode values in BONDING_OPTS 2015-01-13 09:35:49 +01:00
Thomas Haller
96c099de09 platform: suppress change event when deleting IPv4 route with metric 0
refresh_object() raised a spurious change event for the route we
are about to delete. Suppress that by adding an internal reason flag.

Fixes: 41e6c4fac1
2015-01-12 20:02:06 +01:00
Thomas Haller
4f390e7e4d platform/tests: add test for deleting IPv4 route with metric 0 2015-01-12 20:02:06 +01:00
Thomas Haller
a6cd0e7a29 platform/tests: use assert_ip4_route_exists() function 2015-01-12 20:02:06 +01:00
Thomas Haller
b421af3730 platform/tests: add ip4_route_exists() test function 2015-01-12 20:02:06 +01:00
Thomas Haller
0f1fca29db platform/tests: fix errors in fake platform handling route metrics 2015-01-12 20:02:06 +01:00
Lubomir Rintel
529591d8de platform: fix draining of the event queue with old libnl (rh #1180773)
It fails doesn't propagate EAGAIN properly. Fixed in 3.2.22's 375a629.

https://bugzilla.redhat.com/show_bug.cgi?id=1180773
2015-01-12 17:07:00 +01:00
Dan Williams
a687d1f9e0 core: ensure manager state is updated on resume with connectivity checking enabled (rh #1162636) (bgo #742675)
On resume configured interfaces are unmanaged to clear their pre-resume
state and then re-managed.  Eventually the interface should end up moving
to the DISCONNECTED state, which should trigger an auto-activate check in
the Policy.  If connectivity checking was enabled, that auto-activate check
would fail because the Manager's state was still NM_STATE_ASLEEP.

This caused bridge slaves not to auto-activate on resume, which left bridges
without connectivity.

The manager never left NM_STATE_ASLEEP when connectivity checking was
enabled due to nm_manager_update_state() returning early when kicking
off a connectivity check.  Instead, the manager's state should always
be updated to accurately reflect the current state.

https://bugzilla.redhat.com/show_bug.cgi?id=1162636
https://bugzilla.gnome.org/show_bug.cgi?id=742675
2015-01-12 09:57:13 -06:00
Lubomir Rintel
c9002c041d settings: fix up bad merge
Fixes: 24a464a7da
2015-01-12 16:44:17 +01:00
Dan Winship
f79d62692e ifcfg-rh: allow handling complex routing rules via dispatcher (rh #1160013)
If a connection has an associated "rule-NAME" or "rule6-NAME" file,
don't try to read in the routes, since NetworkManager won't be able to
parse them correctly. Instead, log a warning that they will need to be
applied via a dispatcher script, and provide a script that would do
that in examples/dispatcher/.
2015-01-12 09:53:24 -05:00
Dan Winship
5a229741cc settings: make nm_settings_connection_replace_and_commit() virtual 2015-01-12 09:53:23 -05:00
Dan Winship
bd2deace70 dispatcher: pass CONNECTION_FILENAME to dispatcher scripts 2015-01-12 09:53:21 -05:00
Dan Winship
24a464a7da settings: add NMSettingsConnection:filename
Add a "filename" property to NMSettingsConnection, and set it from
keyfile and ifcfg-rh (replacing the existing priv->path variables in
those connection types). (The other plugins either don't use files, or
don't use per-connection files.)
2015-01-12 09:44:20 -05:00
Thomas Haller
3b1c5ee0fd keyfile: retry harder finding a suitable filename in writer()
Try harder to find a suitable filename by appending a counter
to the name.

https://bugzilla.gnome.org/show_bug.cgi?id=740738
2015-01-12 12:21:46 +01:00
Thomas Haller
1208c0dd13 dbus: destroy singleton instance of NMDBusManager on exit
Don't have the singleton instance of NMDBusManager owned by
the main function. Instead use NM_DEFINE_SINGLETON_DESTRUCTOR()
which also logs what's happening.
2015-01-12 12:10:03 +01:00
Thomas Haller
e5a82e5698 auth: destroy singleton instance of NMAuthManager on exit 2015-01-12 12:10:03 +01:00
Thomas Haller
eecc440351 core: use NM_DEFINE_SINGLETON_GETTER() macro 2015-01-12 12:10:03 +01:00
Thomas Haller
3af40acf31 core: declare nm_agent_manager_get() using NM_DEFINE_SINGLETON_GETTER()
Also move the initilization of the instance into the constructed()
method.

NMAgentManager now owns a reference to the DBUS manager and Auth
manager and the dispose() function properly unregisters itself from
both.
2015-01-12 12:10:03 +01:00
Thomas Haller
d45c1b84f4 core: declare nm_supplicant_manager_get() using NM_DEFINE_SINGLETON_GETTER() 2015-01-12 12:10:03 +01:00
Thomas Haller
d8887019ce core: declare nm_session_monitor_get() using NM_DEFINE_SINGLETON_GETTER() 2015-01-12 12:10:03 +01:00
Thomas Haller
22409e0481 core: declare nm_firewall_manager_get() using NM_DEFINE_SINGLETON_GETTER() 2015-01-12 12:10:03 +01:00
Thomas Haller
f4bf50bf4a core: declare nm_inotify_helper_get() using NM_DEFINE_SINGLETON_GETTER()
Refactor NMInotifyHelper to implement the singleton getter using
NM_DEFINE_SINGLETON_GETTER().

For one this means that the getter no longer increments the reference
count. This was anyway wrong, because no caller of nm_inotify_helper_get()
unrefered the returned reference, hence leaking the singleton.

Also, the getter can no longer fail to create the singleton instance.
Note that none of the callers actually coped with a failure to get
the singleton.
Instead return an instance that does nothing.
One downside (upside?) of this is that we only try once to initialize
the inotify handle.
2015-01-12 12:10:03 +01:00
Thomas Haller
e2739cfc1b core: declare nm_vpn_manager_get() using NM_DEFINE_SINGLETON_GETTER() 2015-01-12 12:10:03 +01:00
Thomas Haller
fc575d6783 core: declare nm_dhcp_manager_get() using NM_DEFINE_SINGLETON_GETTER() 2015-01-12 12:10:03 +01:00
Thomas Haller
e439637ada core: declare nm_dns_manager_get() using NM_DEFINE_SINGLETON_GETTER() 2015-01-12 12:10:02 +01:00
Thomas Haller
a8ebd1aa1a core: declare nm_sleep_monitor_get() using NM_DEFINE_SINGLETON_GETTER()
Also no longer increment the reference count in the getter and
properly disconnect the signals in NMManager:dispose().

Also use the defines for the signal names instead of plain strings.
2015-01-12 12:10:02 +01:00
Thomas Haller
822cb293ef core/trivial: rename singleton variables according to default name 2015-01-12 12:10:02 +01:00
Thomas Haller
41e6c4fac1 platform: workaround deletion of IPv4 route with metric 0
Deleting routes with metric 0 might end up deleting other
routes with a different metric.

Workaround this in platform to only delete a route with
metric 0 if such a route can be found prior to deletion.

Don't only look into the cache (which might be out of date).
Instead refetch the route we are about to delete to be sure.

There is still a race that we might end up deleting the wrong
route.

https://bugzilla.gnome.org/show_bug.cgi?id=741871
https://bugzilla.redhat.com/show_bug.cgi?id=1172780
2015-01-11 13:08:34 +01:00
Thomas Haller
2cb3c7e8a0 platform: route_search_cache() should not treat a metric 0 as "any" route
This match-any behavior ignoring metric is nowhere used. And even if we
would need such a behavior, using 0 is wrong because IPv4 routes can
have a metric of zero.
2015-01-11 13:08:34 +01:00
Thomas Haller
06e4eee0ce platform: fix IPv6 route methods for metric 0
Handling a route with metric 0 effectively means
a metric of 1024 (user default). Adjust the add(),
delete() and exist() functions to consider routes
with metric 0 as 1024.
2015-01-11 13:08:34 +01:00
Thomas Haller
4ba8df425f platform: fix data type for metric argument of refresh_route() 2015-01-11 13:08:34 +01:00
Thomas Haller
3e33a5a6c5 ifcfg-rh: support ipvx.route-metric property as IPVX_ROUTE_METRIC
Write ipv4.route-metric and ipv6.route-metric property of
NMSettingConnection as IPV4_ROUTE_METRIC and IPV6_ROUTE_METRIC,
respectively.
2015-01-10 21:10:52 +01:00
Thomas Haller
207ab013a1 ifcfg-rh: fix invalid g_return_val_if_fail() argument in devtimeout_from_file()
Fixes: 62d870e1a6
2015-01-10 14:21:25 +01:00
Dan Williams
3bcd1c7495 dbus: fix NMRUNDIR permissions on create
This is really a no-op because the directory will be created by
nm_main_utils_check_pidfile() anyway, but make sure the permissions
are synchronized.  Now that resolv.conf is symlink into NMRUNDIR,
if normal users don't have permissions to read NMRUNDIR then
DNS won't work.
2015-01-09 13:56:40 -06:00