Commit Graph

7207 Commits

Author SHA1 Message Date
Thomas Haller
76ba548959 platform: fix memleak in build_rtnl_addr() using wrong put() method
'struct nl_addr' and 'struct nl_object' have non-compatible put()
functions.
2015-05-05 04:19:00 +02:00
Thomas Haller
f614ebe6f5 platform: re-enable the platform link test
The link test was disabled in commit 67ad3fcb5b.

The previous issues are not fixed, but apparently disabling the test doesn't
help to get it fixed.

Re-enable it and if it fails we have a better reason to fix it.
Or maybe it works now (?). Didn't fail for me...
2015-05-04 18:41:15 +02:00
Thomas Haller
b22bf15c1d platform: fix root-tests after adding link detection without udev
Co-Authored-By: Lubomir Rintel <lkundrak@v3.sk>

Fixes: 388b7830f3
2015-05-04 18:41:15 +02:00
Thomas Haller
7572837375 platform: keep udev-device in udev_device_added() even if there is no netlink object
Throwing away the udev_device instance is wrong. There are two cases:

- the udev-device appears, and the netlink object will never appear
  (or is already gone). In this case, keeping the udev-device is ok
  because we will eventually get a signal from UDev to cleanup the
  device instance.

- the udev-device appears before the netlink object. In this case we
  want to keep the udev instance to have it ready.

Fixes: 388b7830f3
2015-05-04 18:41:15 +02:00
Yuri Chornoivan
f851a741a6 fix typo and do not translate an empty string
https://bugzilla.gnome.org/show_bug.cgi?id=748906
2015-05-04 18:36:54 +02:00
Thomas Haller
575d8186e4 test/trivial: use new EXIT_SKIP return value instead of 77 2015-05-04 13:51:12 +02:00
Thomas Haller
a8c158dbec dns-manager: fix missing include
dns-manager must include <gio/gio.h> itself. Otherwise
compilation only works with WITH_LIBSOUP, which includes
<gio/gio.h> via <libsoup/soup.h>.

This is an old error, but unnoticed until ad6dbc504b
which makes use of gio.h also without NETCONFIG_PATH.
2015-05-04 11:44:13 +02:00
Beniamino Galvani
e573977b80 dns: allow runtime selection of resolv.conf manager
Add a new 'rc-manager' configuration parameter that allows to select
the strategy used to write resolv.conf; currently supported values
are: none|resolvconf|netconfig, 'none' meaning that NM directly writes
the file.

The default value of the parameter is 'none'; however if a
RESOLVCONF_PATH (or NETCONFIG_PATH) is specified at build time, the
default value will be 'resolvconf' (or 'netconfig').
2015-05-04 09:42:25 +02:00
Beniamino Galvani
de0d623680 dns: don't fall back to other methods when resolvconf or netconfig fail 2015-05-04 09:42:25 +02:00
Beniamino Galvani
5f9d348c20 dns: always write a private resolv.conf to runtime directory
https://bugzilla.gnome.org/show_bug.cgi?id=747821
2015-05-04 09:42:25 +02:00
Dan Williams
624c1c52ac merge: fix continuous router solicitation loop issue with DNS expiry (rh #1207730) (bgo #748085) 2015-05-01 16:38:17 -05:00
Dan Williams
19fa547d5d rdisc: prevent solicitation loop for expiring DNS information (rh #1207730) (rh #1151665)
A solicitation loop could result for two cases:

1) a router sent DNS information, then removed that information without
sending it with lifetime=0
2) two routers exist, one sending DNS information and the other not, and
the first router which sends DNS information disappears

In these cases a solicitation would be generated when the DNS information
reached 1/2 its lifetime.  A router would then reply to the solicitation
without DNS information, which would then trigger another lifetime check,
which finds that the DNS info is still 1/2 lifetime.  Which triggers
another solicitation, etc.

Fix this by ensuring that a solicitation is never sent less than
rtr_solicitation_interval seconds after the last one.
2015-05-01 16:35:47 -05:00
Dan Williams
b324b970bc rdisc: fix double-addition of gateways & routes if priority increases
If a route or gateway's priority increased, the item would be added
to the array again without removing the older entry.  At the same time
don't bother adding an item with a zero lifetime, since it will just
be removed again by the clean_* functions.
2015-05-01 16:35:47 -05:00
Dan Williams
32058d1928 rdisc: split fake & linux test code; add testcases 2015-05-01 16:35:45 -05:00
Dan Williams
527eeb6d68 rdisc: fix leak of DNS domains 2015-05-01 16:30:33 -05:00
Dan Williams
8d9ee6d8e8 rdisc: move most RA processing logic into base class
Instead of having it all in the Linux implementation, move all the
timeout logic and most of the processing logic into the NMRDisc
base class so that it can be used by NMFakeRDisc as well. This
will help increase testability since now we can test the timeout
and expiry logic from the fake plugin too.
2015-05-01 16:30:32 -05:00
Dan Williams
67033ddab1 rdisc: add missing chain up to parent finalize/dispose 2015-05-01 16:27:24 -05:00
Thomas Haller
f53fda9fd6 Revert "core: treat ECHILD as child already terminated"
This reverts commit 268da271cc.

This breaks the test, but it is not clear that this is the
right fix. Revert for now, needs still investigation.
2015-05-01 23:14:38 +02:00
Thomas Haller
3171b543dc platform: intern driver string for NMPlatformLink
Always intern string from udev_get_driver().

We use the result of udev_get_driver() for setting NMPlatformLink.driver.
In all other cases, we already set that value to an interned string,
which simplifies memory handling.

As it was, the lifetime of that string was tied to the lifetime of the
GUdevDevice.

This is not a stelar solution, but we assume that the overall numbers
of different drivers is limited so we don't leak large amounts of
memory.
2015-05-01 14:26:40 -05:00
Thomas Haller
e2c742c77b platform: refactor extraction of type-name for link
link_extract_type() would return the NMLinkType and a
@type_name string. If the type was unknown, this string
was rtnl_link_get_type() (IFLA_INFO_KIND).

Split up this behavior and treat those values independently.
link_extract_type() now only detects the NMLinkType. Most users
don't care about unknown types and can just use nm_link_type_to_string()
to get a string represenation.

Only nm_platform_link_get_type_name() (and NMDeviceGeneric:type_description)
cared about a more descriptive type. For that, modify link_get_type_name()
to return nm_link_type_to_string() if NMLinkType could be detected.
As fallback, return rtnl_link_get_type().

Also, rename the field NMPlatformLink:link_type to "kind". For now this
field is mostly unused. It will be used later when refactoring platform
caching.
2015-05-01 14:26:39 -05:00
Thomas Haller
b538adf123 platform: expose nm_link_type_to_string() function
Given the name nm_link_type_to_string(), we would not expect
to find it in nm-linux-platform.c. It either should be named
nm_platform_link_type_to_string() and be put in a new
nm-platform-utils.c file, or it should be named
nm_utils_link_type_to_string() and be put in NetworkManagerUtils.h.

For now, just leave it here.
2015-05-01 14:25:59 -05:00
Dan Williams
268da271cc core: treat ECHILD as child already terminated
prevents:

NetworkManager[2775]: <error> [1429889302.113450] [NetworkManagerUtils.c:576]
   nm_utils_kill_child_async(): kill child process 'teamd' (3025): failed due
   to unexpected return value -1 by waitpid (No child processes, 10) after
   sending SIGTERM (15)
2015-05-01 14:25:59 -05:00
Thomas Haller
18d611d5d2 platform: detect TUN/TAP device in link_extract_type() independently of platform cache
link_extract_type() would call tun_get_properties() to determine whether
the link if a TAP or TUN device. The previous implementation would
receive the ifindex, and resolve the ifname via lookup in the platform
cache.
This means, the call on link_extract_type() will only succeed to detect
the TUN/TAP properties, if the libnl object is already in the cache.
Currently that is always the case and there is no problem.

It is desireable, that we can resolve the link type of an object without
consulting the platform cache first.
2015-05-01 14:25:59 -05:00
Thomas Haller
63bb33b534 core: remove G_GNUC_WARN_UNUSED_RESULT from ASSERT_VALID_PATH_COMPONENT()
ASSERT_VALID_PATH_COMPONENT() always returns the input argument --
unless it fails an assertion and terminates the program. No need
to require the user to use the return value.
2015-05-01 14:25:58 -05:00
Dan Williams
8a5910c25c core: change activation failure messages to debug level
Otherwise any user with network control privileges can spam the logs.
2015-05-01 14:25:58 -05:00
Dan Williams
2d527b30ff platform: rework link type detection for better fallback (bgo #743209)
See "Revert "wireless: Support of IFLA_INFO_KIND rtnl attribute""
http://www.spinics.net/lists/linux-wireless/msg132219.html

The reverted kernel patch caused rtnl_link_get_type() to return "wlan"
for WiFi devices.  Since NM depends on this function returning
NULL for WiFi devices so that it goes on to check the sysfs DEVTYPE
attribute, the kernel patch caused WiFi devices to show up as Generic
ones instead.  That's wrong, and NM should be able to more easily
handle changes in the kernel drivers from NULL to a more descriptive
rtnl_link_get_type() return, since that's the kernel trend.

What NM should be doing here is to fall back to other detection
schemes if the type is NULL or unrecognized. Make that happen and
clean things up to use a table instead of a giant if(strcmp()) block.

https://bugzilla.gnome.org/show_bug.cgi?id=743209
2015-05-01 14:25:58 -05:00
Dan Williams
b484b03acf platform: refactor link-type to string conversion 2015-05-01 14:25:58 -05:00
Dan Williams
388b7830f3 platform: don't wait for udev before announcing links 2015-05-01 14:25:55 -05:00
Dan Williams
3006df940c core: add generic NMDevice function to recheck availability
And use it everywhere.
2015-05-01 14:18:29 -05:00
Dan Williams
2599dadc28 platform: don't use udev for link type determination
This allows us to always announce links when the kernel advertises
them, instead of waiting for udev.
2015-05-01 14:18:28 -05:00
Thomas Haller
bdaaf9849b platform: don't accept lowering IPv6 hop-limit from RA (CVE-2015-2924)
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=6fd99094de2b83d1d4c8457f2c83483b2828e75a
http://seclists.org/oss-sec/2015/q2/46
https://bugzilla.redhat.com/show_bug.cgi?id=1209902
https://bugzilla.redhat.com/show_bug.cgi?id=1209903
2015-04-29 14:14:20 +02:00
Jiří Klimeš
02c6a93343 platform: use driver name to detect IBM z-System CTC devices (rh #1212118)
We used to detect CTC devices according to the interface name. But that does
not work anymore due to systemd renaming the devices.
Let's use driver name for the detection instead. The driver is called 'ctcm'.

http://www-01.ibm.com/support/knowledgecenter/linuxonibm/com.ibm.linux.z.lgdd/lgdd_r_mpc_setup.html

https://bugzilla.redhat.com/show_bug.cgi?id=1212118
2015-04-29 13:19:22 +02:00
Mathieu Trudel-Lapierre
f3b8285be5 wifi: expose the last_seen property for a NMAccessPoint
https://mail.gnome.org/archives/networkmanager-list/2015-April/msg00053.html
2015-04-29 07:49:23 +02:00
Thomas Haller
967376b840 core: add nm_utils_monotonic_timestamp_as_boottime() function 2015-04-29 07:32:42 +02:00
Thomas Haller
af2c0ef771 platform: ignore routes with non-zero TOS
The identifying properties of a route are (in libnl)

    .o_id_attrs = (ROUTE_ATTR_FAMILY | ROUTE_ATTR_TOS |
                   ROUTE_ATTR_TABLE | ROUTE_ATTR_DST |
                   ROUTE_ATTR_PRIO),

NM ignores routes other then in table RT_TABLE_MAIN and considers
only the tuple 'family,network/plen,metric' as identifying for a route.

We must also ignore routes with TOS non-zero as we cannot
handle those, i.e. we cannot distinguish between them.
2015-04-28 17:11:28 +02:00
David Ward
db4d83d5a4 nm-iface-helper: set last_config properly
Update last_config outside of the conditional; otherwise it will
always remain set to NULL.

Signed-off-by: David Ward <david.ward@ll.mit.edu>
Acked-By: Thomas Haller <thaller@redhat.com>
2015-04-27 19:18:21 +02:00
Dan Williams
bbcf5444fd settings: remove 'do_export' argument from claim_connection()
It was always TRUE, and unused anyway.
2015-04-27 11:33:59 +02:00
Dan Williams
fe96dbc0ee settings/dbus: harden connection removal and object unexport
None of these functions was checking if the same operation had already
been performed, or if the object being removed/unexported was known.
2015-04-27 11:33:59 +02:00
Lubomir Rintel
74ed416d84 manager: don't try to delete generated connection if it's already gone
Move the cleanup of the generated assumed connection to active connection
dispose. If the connection vanishes earlier (explicit deletion from client),
tear down the reference so that we don't try to remove it redundantly.

  NetworkManager[9221]: <info>  (eth2): device state change: deactivating -> disconnected (reason 'connection-removed') [110 30 38]
  NetworkManager[9221]: <info>  (eth2): deactivating device (reason 'connection-removed') [38]

  (NetworkManager:9221): GLib-GObject-WARNING **: g_object_weak_unref: couldn't find weak ref 0x496610(0x7c2ba0)

  Program received signal SIGTRAP, Trace/breakpoint trap.
  g_logv (log_domain=0x7ffff4d4f1a4 "GLib-GObject", log_level=G_LOG_LEVEL_WARNING, format=<optimized out>, args=args@entry=0x7fffffffd860) at gmessages.c:1046
  1046              g_private_set (&g_log_depth, GUINT_TO_POINTER (depth));
  (gdb) bt
  #0  0x00007ffff4a2cc60 in g_logv (log_domain=0x7ffff4d4f1a4 "GLib-GObject", log_level=G_LOG_LEVEL_WARNING, format=<optimized out>, args=args@entry=0x7fffffffd860) at gmessages.c:1046
  #1  0x00007ffff4a2ce9f in g_log (log_domain=<optimized out>, log_level=<optimized out>, format=<optimized out>) at gmessages.c:1079
  #2  0x000000000049780b in nm_dbus_manager_unregister_object (self=0x7c2ba0 [NMDBusManager], object=0x80f3e0) at nm-dbus-manager.c:921
  #3  0x000000000047cc83 in nm_settings_connection_signal_remove (self=self@entry=0x80f3e0 [NMIfcfgConnection]) at settings/nm-settings-connection.c:1752
  #4  0x000000000047cd22 in do_delete (connection=0x80f3e0 [NMIfcfgConnection], callback=0x479d60 <ignore_cb>, user_data=0x0) at settings/nm-settings-connection.c:687
  #5  0x00000000004b1eb6 in active_connection_remove (self=self@entry=0x8701c0 [NMManager], active=active@entry=0x8b02f0) at nm-manager.c:292
  #6  0x00000000004b2174 in _active_connection_cleanup (user_data=<optimized out>) at nm-manager.c:316
  #7  0x00007ffff4a25aeb in g_main_context_dispatch (context=0x7be3a0) at gmain.c:3111
  #8  0x00007ffff4a25aeb in g_main_context_dispatch (context=context@entry=0x7be3a0) at gmain.c:3710
  #9  0x00007ffff4a25e88 in g_main_context_iterate (context=0x7be3a0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3781
  #10 0x00007ffff4a261b2 in g_main_loop_run (loop=0x7be460) at gmain.c:3975
  #11 0x0000000000432f55 in main (argc=1, argv=0x7fffffffded8) at main.c:460
  (gdb)

https://bugzilla.gnome.org/show_bug.cgi?id=744812
2015-04-27 11:33:58 +02:00
Lubomir Rintel
8a00bb36ec nm-settings: add nm_settings_has_connection()
Useful for checking if a connection is already deleted.

https://bugzilla.gnome.org/show_bug.cgi?id=744812
https://bugzilla.redhat.com/show_bug.cgi?id=1174164
2015-04-27 11:33:58 +02:00
Lubomir Rintel
cd2cef9cab utils: match a cloned mac address with a connection that does not specify it
We do the same for the original MAC address.

A device enslaved to a bond it inherits the bond's MAC address. When
NetworkManager tries to assume a connection the generated cloned-mac property
causes a mismatch with the connection that originally brought up the device,
causing the generated connection to be used instead:

  NetworkManager[14190]: <debug> [1424355817.112154] [NetworkManagerUtils.c:1641]
         nm_utils_match_connection(): Connection 'eth2' differs from candidate
         'bond-slave-eth2' in 802-3-ethernet.cloned-mac-address

https://bugzilla.gnome.org/show_bug.cgi?id=744812
2015-04-27 11:33:58 +02:00
Thomas Haller
cb6bafb9af logging: define _LOGT() macro to check valid arguments
With NM_MORE_LOGGING disabled, we still want the compiler to evaluate
the argument list. By wrapping it in "if(FALSE)", we get compile time
checks, but the logging statement will be optimized out.
2015-04-24 13:51:43 +02:00
Dan Williams
9b07ea77b8 dbus-manager: harden registering/unregistering object
Saw some g_warning() about g_object_weak_unref() trying to unref a non
registed reference. While this does not fix it, let's assert that
situation a step earlier to ease debugging.

Also, move g_object_weak_ref() closer to adding the object into the
@exported hash.

[thaller@redhat.com: rewrote commit message, change to register_object()]
2015-04-23 19:49:34 +02:00
Lubomir Rintel
72f264ad9b ifcfg-rh: don't try to read DEVTIMEOUT from file for in-memory connections
#0  0x00007ffff4a2c970 in g_logv (log_domain=0x7fffe9201115 "NetworkManager-ifcfg-rh", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffd710) at gmessages.c:1046
  #1  0x00007ffff4a2cbaf in g_log (log_domain=log_domain@entry=0x7fffe9201115 "NetworkManager-ifcfg-rh", log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0x7ffff4a9bc1d "%s: assertion '%s' failed") at gmessages.c:1079
  #2  0x00007ffff4a2cbe9 in g_return_if_fail_warning (log_domain=log_domain@entry=0x7fffe9201115 "NetworkManager-ifcfg-rh", pretty_function=pretty_function@entry=0x7fffe9204b70 <__FUNCTION__.30626> "devtimeout_from_file", expression=expression@entry=0x7fffe9202d97 "filename != NULL") at gmessages.c:1088
  #3  0x00007fffe91fbfa2 in devtimeout_from_file (filename=<optimized out>) at reader.c:4884
  #4  0x00007fffe91ef845 in nm_ifcfg_connection_new (self=0x8d2200 [NMIfcfgConnection]) at nm-ifcfg-connection.c:159
  #5  0x00007fffe91ef845 in nm_ifcfg_connection_new (source=source@entry=0x83ba40, full_path=full_path@entry=0x0, error=error@entry=0x7fffffffd980) at nm-ifcfg-connection.c:240
  #6  0x00007fffe91ec7e6 in update_connection (self=self@entry=0x80c2a0 [SCPluginIfcfg], source=source@entry=0x83ba40, full_path=0x0, connection=connection@entry=0x0, protect_existing_connection=protect_existing_connection@entry=0, protected_connections=protected_connections@entry=0x0, error=0x7fffffffd980) at plugin.c:225
  #7  0x00007fffe91eddf2 in add_connection (config=<optimized out>, connection=0x83ba40, save_to_disk=<optimized out>, error=0x7fffffffd980) at plugin.c:715
  #8  0x000000000048fc1d in nm_settings_add_connection (self=<optimized out>, connection=0x83ba40, save_to_disk=0, error=<optimized out>) at settings/nm-settings.c:1045
  #9  0x0000000000490858 in pk_add_cb (chain=0x8b1fc0, chain_error=<optimized out>, context=<optimized out>, user_data=<optimized out>) at settings/nm-settings.c:1151
  #10 0x00000000004ca98c in auth_chain_finish (user_data=0x8b1fc0) at nm-auth-utils.c:82
  #11 0x00007ffff4a257fb in g_main_context_dispatch (context=0x7cd3e0) at gmain.c:3111
  #12 0x00007ffff4a257fb in g_main_context_dispatch (context=context@entry=0x7cd3e0) at gmain.c:3710
  #13 0x00007ffff4a25b98 in g_main_context_iterate (context=0x7cd3e0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3781
  #14 0x00007ffff4a25ec2 in g_main_loop_run (loop=0x7cd4a0) at gmain.c:3975
  #15 0x0000000000444c81 in main (argc=<optimized out>, argv=<optimized out>) at main.c:486
2015-04-23 17:14:03 +02:00
Thomas Haller
842ec6163d core: refactor nm_ethernet_address_is_valid() and reject invalid addresses
nm_ethernet_address_is_valid() did not check whether @addr was a valid
address in the first place. It only checked whether the address was not
equal to a few notorious MAC addresses.

At the same time, be more forgiving and accept %NULL as argument.
This fixes an assertion nm_ap_match_in_hash().
2015-04-23 16:38:51 +02:00
Thomas Haller
dbb3b44ca6 core/test: add test for nm_ethernet_address_is_valid() 2015-04-23 16:38:51 +02:00
Thomas Haller
7f8149bdb7 wifi: avoid assertion in request_wireless_scan() passing NULL to nm_utils_ssid_to_utf8() 2015-04-23 16:38:51 +02:00
Thomas Haller
8f080747c6 platform: remove wrong assertion
This is a well known issue that we cannot convert some libnl
objects to NMPlatformObject. The to-string function for libnl
objects is only used for debug logging. No need to assert.
2015-04-23 16:38:51 +02:00
Thomas Haller
245720819e build/trivial: reorder and break lines in Makefile.am 2015-04-22 22:30:46 +02:00
Thomas Haller
ea5865cf45 platform: add NM_PLATFORM_SIGNAL_NONE enum value 2015-04-22 16:54:23 +02:00