Commit Graph

4279 Commits

Author SHA1 Message Date
Dan Williams
20031e1846 ifcfg-rh: save bridge STP disabled setting (bgo #694841)
STP defaults to yes in NetworkManager (and the initscripts), so a missing
STP value in an ifcfg file means yes/on.  Calling svSetValue(STP, NULL)
clears that line from the ifcfg, and thus STP gets interpreted as yes.
Explicitly set stp to "no" so that the value actually gets saved.
2013-03-08 15:43:45 -06:00
Dan Williams
4cdb841881 wifi: optimize AvailableConnections updating on device disable
Call recheck_available_connections() once after removing all APs,
not every time we remove an AP.
2013-03-08 09:27:51 -06:00
Dan Williams
ec781ff9d5 core: fix leak of StateReason struct
==23089== 38,232 (4,248 direct, 33,984 indirect) bytes in 177 blocks are definitely lost in loss record 5,122 of 5,123
==23089==    at 0x4A0881C: malloc (vg_replace_malloc.c:270)
==23089==    by 0x39B905488E: g_malloc (gmem.c:159)
==23089==    by 0x39B9068CA1: g_slice_alloc (gslice.c:1003)
==23089==    by 0x39B98371B1: g_value_array_new (gvaluearray.c:140)
==23089==    by 0x31FB81B67D: valuearray_constructor (dbus-gvalue-utils.c:771)
==23089==    by 0x42DD8F: get_property (nm-device.c:4675)
==23089==    by 0x39B9819C64: g_object_get_property (gobject.c:1289)
==23089==    by 0x31FB80DA49: object_registration_message (dbus-gobject.c:1322)
==23089==    by 0x363961DA44: _dbus_object_tree_dispatch_and_unlock (dbus-object-tree.c:858)
==23089==    by 0x363960FA82: dbus_connection_dispatch (dbus-connection.c:4685)
==23089==    by 0x31FB80AC44: message_queue_dispatch (dbus-gmain.c:90)
==23089==    by 0x39B904EC54: g_main_context_dispatch (gmain.c:2539)
2013-03-08 09:27:51 -06:00
Dan Williams
b711256a5c core: fix use-after-free
'device' is freed by nm_ip6_manager_cancel_addrconf().  Plus if
addrconf fails, the DHCP options should be ignored anyway.

==23089== Thread 1:
==23089== Invalid read of size 4
==23089==    at 0x4861E0: finish_addrconf (nm-ip6-manager.c:444)
==23089==    by 0x39B904F7EA: g_timeout_dispatch (gmain.c:3882)
==23089==    by 0x39B904EC54: g_main_context_dispatch (gmain.c:2539)
==23089==    by 0x39B904EF87: g_main_context_iterate.isra.23 (gmain.c:3146)
==23089==    by 0x39B904F381: g_main_loop_run (gmain.c:3340)
==23089==    by 0x426188: main (main.c:614)
==23089==  Address 0xcdb791c is 60 bytes inside a block of size 152 free'd
==23089==    at 0x4A07786: free (vg_replace_malloc.c:446)
==23089==    by 0x39B905499E: g_free (gmem.c:252)
==23089==    by 0x39B90692FE: g_slice_free1 (gslice.c:1111)
==23089==    by 0x39B903EC49: g_hash_table_remove_internal (ghash.c:1274)
==23089==    by 0x4861DC: finish_addrconf (nm-ip6-manager.c:443)
==23089==    by 0x39B904F7EA: g_timeout_dispatch (gmain.c:3882)
==23089==    by 0x39B904EC54: g_main_context_dispatch (gmain.c:2539)
==23089==    by 0x39B904EF87: g_main_context_iterate.isra.23 (gmain.c:3146)
==23089==    by 0x39B904F381: g_main_loop_run (gmain.c:3340)
==23089==    by 0x426188: main (main.c:614)
2013-03-08 09:27:51 -06:00
Dan Williams
7badb7ae43 trivial: remove unused define 2013-03-07 16:29:03 -06:00
Colin Walters
dc6f5f5dd7 keyfile: handle NetworkManager.conf not existing
Since in gnome-ostree we're trying to move towards an empty /etc.
We'll create it on demand if necessary.
2013-03-07 15:49:28 -06:00
Colin Walters
21ba714f78 keyfile: Use "goto out" style error handling
Just code cleanup: This is much less error-prone than manual nesting,
and will mesh very well with future changes to use the libgsystem
cleanup macros.
2013-03-07 15:46:15 -06:00
Dan Winship
6f44b7f3c6 all: remove redundant return-if-fail checks
NM_IS_FOO(x) returns FALSE if x is NULL, so we don't need a separate
(x != NULL) check before it.
2013-03-07 07:32:27 -05:00
Pavel Šimerda
bf32605287 cleanup: remove unnecessary headers from nm-netlink-monitor.h
Accomodate nm-netlink-monitor.c to the change by moving around utility
functions and making them static (removing if not used). Unsubscription
of rtnl groups is not necessary and the whole process will be eventually
moved to nm-platform.
2013-03-06 11:59:07 +01:00
Pavel Šimerda
8f758b0af9 cleanup: remove nm-netlink-compat 2013-03-05 23:02:50 +01:00
Pavel Šimerda
47a3e24d32 netlink: replace libnl 1.x functions
Confusingly, nm-platform-compat's rtnl_link_set_oif adds a new nexthop
with ifindex set, while rtnl_link_set_gateway sets gateway for an
existing nexthop. Keeping the behavior to avoid potential problems.
2013-03-05 23:02:42 +01:00
Pavel Šimerda
92481c6a6a ip6: replace libnl 1.x functions 2013-03-05 20:22:47 +01:00
Pavel Šimerda
487afb779c ip6: use delayed execution to avoid duplicate events
device_sync_from_netlink() and nm_netlink_request_ip6_info() are now
delayed, so that they are called only once for a series of events. This
makes the IPv6 processing and especially debug messages more sane.
2013-03-05 02:34:21 +01:00
Pavel Šimerda
896af74097 ip6: replace timed polling with event-based call
Request IPv6 flags from kernel on RTM_NEWROUTE/RTM_DELROUTE instead
of requesting periodically.
2013-03-05 02:32:42 +01:00
Pavel Šimerda
a93fb28d1a ip6: don't subscribe for RTM_PREFIX messages 2013-03-05 02:29:50 +01:00
Pavel Šimerda
195a09d7c0 ip6: fix rtnl_route_alloc_cache() call
NL_AUTO_PROVIDE is not a valid flag for this call and it's coincidental
with ROUTE_CACHE_CONTENT, which is certainly not what we want.

NETLINK_ROUTE is a netlink family, not an address family. It is
coincidental with AF_UNSPEC which is what we actually want.
2013-03-05 02:29:43 +01:00
Pavel Šimerda
fc41ae3ac6 ip6: use assert for fatal errors during initialization 2013-03-05 01:49:18 +01:00
Pavel Šimerda
54746d5ed4 ip6: clean up and improve debugging
Stop logging the whole list of addresses as we already have new and lost
addresses logged. Stop putting 'state' and 'ra_flags' in almost every
message since changes of those are already logged. Log target state
change.
2013-03-05 01:49:13 +01:00
Pavel Šimerda
9dddb51af2 ip6: rename got-ra to got-router-advertisement 2013-03-05 01:02:37 +01:00
Pavel Šimerda
649c21bbc9 trivial: add missing standard includes
This will help later cleanups of nm-system.
2013-03-04 22:11:54 +01:00
Dan Williams
a096ef8f87 core: fix more GValueArray deprecation fallout 2013-02-27 18:09:52 +01:00
Dan Williams
97990135f1 dhcp: ensure any dhclient script from dhclient.conf is ignored
The config file can specify a dhclient script, which gets used instead
of what NM passes on the command-line.  Make sure that script gets
ignored in the final dhclient config, because the script NM passes
is the script that needs to be used to pass data back to NM.  People
may have old dhclient.conf files lying around that get picked up and
we don't want any script specified there to interfere.
2013-02-27 17:17:11 +01:00
Dan Williams
db7ba1c161 trivial: rename 'link' to avoid shadowing a global variable/function
nm-system.c: In function "nm_system_bond_enslave":
nm-system.c:1689:21: error: declaration of "link" shadows a global declaration [-Werror=shadow]
2013-02-27 15:41:07 +01:00
Dan Winship
be89197214 core: remove remaining pre-2.32 GLib compat / deprecated usage 2013-02-26 13:07:33 +01:00
Dan Winship
a2cdf63204 core: use GResolver for reverse resolution
Remove the HostnameThread stuff from nm-policy-hostname and just use
GResolver instead. Move the one remaining nm-policy-hostname function
into nm-policy.
2013-02-26 13:07:33 +01:00
Dan Winship
f936400c38 tests: clean up gtester usage
Use g_test_add_func() and g_test_add_data_func() to simplify the test
cases, getting rid of the GLIB_CHECK_VERSION calls in the process.
2013-02-26 13:07:33 +01:00
Dan Winship
ed9e2d8377 build: avoid GValueArray deprecation warnings
Avoid warnings about GValueArray being deprecated by adding macros
that wrap G_GNUC_BEGIN_IGNORE_DEPRECATIONS /
G_GNUC_END_IGNORE_DEPRECATIONS around the GValueArray calls.
2013-02-26 13:07:33 +01:00
Dan Williams
47d8db57b5 trivial: plug some memory leaks
(review+ danw)
2013-02-25 16:07:03 +01:00
Dan Williams
39e48f730d modem: preserve data_iface over PPP connections
data_iface is the serial port over which PPP should be run, so
we need to preserve that and not overwrite it with the PPP interface
name.  When reconnecting, pppd wants the TTY to run PPP over (eg the
ModemManager data_port like ttyUSB0) but if we overwrote that with
ppp0 on the last connection, that's extremely unhelpful and pppd will
fail to start.
2013-02-20 14:01:39 -06:00
Dan Williams
e8df700cdd bluetooth: fix handling of ModemManager restarts
When built with MM1 support, the restart handling code here would
fail for both old MM and new MM.  The code should ignore the
name owner change even if the incoming bus name is *neither*
old MM nor new MM.  It wasn't doing that.
2013-02-20 14:01:34 -06:00
Dan Williams
ddbb13bcc6 core: fix setting IPv6 default route
Seems that NLM_F_CREATE isn't enough, we need to replace anything
that's already there.  Oddly, this is even though we already cleaned
out anything that was already there.
2013-02-20 14:01:30 -06:00
Mihai Dontu
f96a42b0e2 core: allow '2' when reading startup accept_ra value (bgo #691213)
Otherwise, priv->accept_ra_path would be NULL, which isn't very
useful and  makes nm_utils_do_sysctl() angry.  No reason we shouldn't
always create priv->accept_ra_path in the future though.

https://bugzilla.gnome.org/show_bug.cgi?id=691213
2013-02-20 14:01:24 -06:00
Pavel Šimerda
f0277c19aa settings: add support for code coverage to the settings plugins
Use:

  ./autogen.sh --enable-code-coverage
  make
  make -C src/settings check-code-coverage
2013-02-19 13:05:52 +01:00
Jiří Klimeš
bc867ff6fe core: fix uninitialized priv in set_carrier() 2013-02-18 10:02:52 +01:00
Dan Winship
feeafb8cf1 core: Update device activation for :carrier-detect
Add a "need_carrier" argument to nm_device_is_available(), to allow
distinguishing between "device is not available", "device is fully
available", and "device is available except for not having carrier".

Adjust various parts of NMDevice and NMManager to allow for the
possibility of activating a connection with :carrier-detect = "no" on
a device with no carrier, and to avoid auto-disconnecting devices with
:carrier-detect = "on-activate".

https://bugzilla.gnome.org/show_bug.cgi?id=688284
2013-02-15 13:40:39 -05:00
Dan Winship
5266e25e2b libnm-utils: add :carrier-detect properties
For settings corresponding to devices that have a :carrier property
(ie bond, bridge, infiniband, vlan, and wired), add a :carrier-detect
property specifying how that affects the connection:

  yes: The connection can only be activated when the device
      has carrier, and will be deactivated if the device loses
      carrier (for more than 4 seconds).
  no: The connection ignores carrier on the device; it can be
      activated when there is no carrier, and stays activated
      when carrier is lost.
  on-activate: The connection can only be activated when the
      device has carrier, but it will not be deactivated if the
      device loses carrier.

https://bugzilla.gnome.org/show_bug.cgi?id=688284
2013-02-15 13:40:38 -05:00
Dan Winship
fe307dbd3e core: move carrier-detect NMDeviceState handling into NMDevice
Move some duplicated carrier-handling code into NMDevice (which can
introspect itself to see if it's a subclass that has carrier).

The "mostly ignore carrier" special handling for bridges and bonds is
now also handled as part of the NMDevice-level carrier handling.

https://bugzilla.gnome.org/show_bug.cgi?id=688284
2013-02-15 13:40:38 -05:00
Dan Williams
cc7e5cc591 dhcp: debug log generated DUID 2013-02-14 16:19:10 -06:00
Dan Williams
1b1b4bd91c dhcp: write DUID out to lease file if not already present
Ensure that dhclient uses the administrator-specified or machine-id
generated DUID.
2013-02-14 16:19:05 -06:00
Gene Czarcinski
c0efef8c92 dhcp: add special machine-id parse function
The original used uuid_parse() but that function did not
work properly since the format of the machine-id is
not compatable with a real uuid.  This patch adds a new
machine_id_parse() routine to correctly convert the
character string of hex digits to a 16 byte binary string.
2013-02-14 16:18:59 -06:00
Dan Winship
b54a4e601d core: fix a bug in NMSettingsConnection
nm_settings_connection_init() was calling nm_connection_set_path(),
but this was pointless since that would end up getting cleared by the
property's default value shortly after init() returned (and
claim_connection() depended on this). So remove that code.

https://bugzilla.gnome.org/show_bug.cgi?id=693829
2013-02-14 13:59:53 -05:00
Dan Winship
08f04466e8 all: remove more pointless NULL checks
GObject creation cannot normally fail, except for types that implement
GInitable and take a GError in their _new() method. Some NM types
override constructor() and return NULL in some cases, but these
generally only happen in the case of programmer error (eg, failing to
set a mandatory property), and so crashing is reasonable (and most
likely inevitable anyway).

So, remove all NULL checks after calls to g_object_new() and its
myriad wrappers.

https://bugzilla.gnome.org/show_bug.cgi?id=693678
2013-02-13 13:38:36 -05:00
Dan Winship
d04f286327 all: remove pointless NULL checks
g_malloc(), etc, never return NULL, by API contract. Likewise, by
extension, no other glib function ever returns NULL due to lack of
memory. So remove lots of unnecessary checks (the vast majority of
which would have immediately crashed had they ever run anyway, since
g_set_error(), g_warning(), and nm_log_*() all need to allocate
memory).

https://bugzilla.gnome.org/show_bug.cgi?id=693678
2013-02-13 13:38:13 -05:00
Pavel Šimerda
018c387e2c workaround to build against libnl
This reverts commit ff15a5e and adds netlink.h header file so that
we build on all systems. We haven't propery analyzed which systems
are affected and which are not.
2013-02-13 13:34:45 +01:00
Dan Williams
3a2e6de0d3 wifi: ensure new supplicant is noticed if previous one quit quickly
If the Wifi device hadn't yet had a chance to transition away from
UNAVAILALBLE before the supplicant quit, the NMSupplicantInterface
would not be re-acquired becuase that was only happening from
the device state change handler when entering the UNAVAILALBE state,
and clearly setting the same state is NOP.

Since the old supplicant interface was torn down, and the wifi device
hadn't created a new supplicant interface (because it hadn't changed
state) nothing was listening for the supplicant to appear.

Fix that by ensuring that the wifi device reacquires a supplicant
interface whenever an old one is torn down and the device is enabled.

NetworkManager[3062]: <info> (wlan0): supplicant interface state: scanning -> down
NetworkManager[3062]: <info> (wlan0): device state change: config -> unavailable (reason 'supplicant-failed') [50 20 10]
NetworkManager[3062]: <info> (wlan0): deactivating device (reason 'supplicant-failed') [10]
NetworkManager[3062]: <info> wpa_supplicant started
NetworkManager[3062]: <info> wpa_supplicant stopped
NetworkManager[3062]: <info> (wlan0): supplicant interface state: starting -> down
<start new supplicant, nothing happens>
2013-02-12 16:13:00 -06:00
Dan Williams
4973da78e4 core: remove unused SIGUSR1 handling 2013-02-12 15:41:52 -06:00
Dan Winship
414af39c3c keyfile: fix some test error message cut+paste errors 2013-02-12 15:50:20 -05:00
Jiří Klimeš
2c69caf2d5 policy: use private 'dns_manager' member to simplify code a bit 2013-02-12 15:47:13 +01:00
Jiří Klimeš
07c5651a36 policy,dns: fix a race in looking up hostname and updating DNS (rh #877084)
"config-changed" signal is added to dns-manager and emited when resolv.conf is
changed. Policy listens for the signal and restarts reverse-lookup in order to
get correct results.
2013-02-12 15:40:08 +01:00
Dan Williams
e5f8b426bf settings: load keyfile plugin even if no plugins are given
If no config file was specified, and if no other plugins were given
on the command-line, the keyfile plugin would not be loaded.  This
meant no connections would be read, and no connections could be
created either.

Always load the keyfile plugin.
2013-02-11 15:45:48 -06:00