Commit Graph

7207 Commits

Author SHA1 Message Date
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
Dan Williams
6cba496a4f wifi: don't warn on unknown nl80211 ciphers 2013-02-11 15:38:04 -06:00
Dan Williams
aa5013cf2d core: fix duplicating (not removing) active connections
This is a regression introduced by reworked active connections tracking:
7258dd270f core: add the NM_ACTIVE_CONNECTION_STATE_DEACTIVATED state
59420add04 core: track active connections directly in the manager

Because nm-manager.c:active_connection_state_changed() postpones active
connection removal to an idle handler (to be able to receive last property
change notifications), we also need to ensure that NM_ACTIVE_CONNECTION_STATE_DEACTIVATED
state is not changed again in the meantime in nm-activation-request.c:device_state_changed().
After the NMActRequest was deactivated (which is a terminal state) it was still
listening to state changes of its child NMDevice which could be starting a
new activation request.  Thus the new activation's NMDevice state would cause
the old activation request's state to change from DEACTIVATED.  To fix this
stop listening to the child NMDevice when DEACTIVATED becuase there's no point
to doing so anyway.

Reproducer:
Just activate already active connection by clicking it in nm-applet or
run 'nmcli con up id <connnection name>' several times, and then check
active connections with 'nmcli c s'.
2013-02-11 11:48:11 -06:00
Dan Williams
527cbf1924 Revert "core: fix duplicating (not removing) active connections"
This reverts commit df796527a4.

We found the real problem.
2013-02-11 11:48:11 -06:00
Dan Winship
fc700e9213 core: add NM_WIFI_DEVICE_CAP_ADHOC
Some wireless devices don't support Ad-Hoc mode. Expose this fact in
the wireless capabilities so that clients can disable the hot-spot
option if neither CAP_ADHOC nor CAP_AP is available.

https://bugzilla.gnome.org/show_bug.cgi?id=692869
2013-02-11 12:39:28 -05:00
Jiří Klimeš
df796527a4 core: fix duplicating (not removing) active connections
This is a regression introduced by reworked active connections tracking:
7258dd270f core: add the NM_ACTIVE_CONNECTION_STATE_DEACTIVATED state
59420add04 core: track active connections directly in the manager

Because nm-manager.c:active_connection_state_changed() postpones active
connection removal to an idle handler (to be able to receive last property
change notifications), we also need to ensure that NM_ACTIVE_CONNECTION_STATE_DEACTIVATED
state is not changed again in the meantime in nm-activation-request.c:device_state_changed().

Reproducer:
Just activate already active connection by clicking it in nm-applet or
run 'nmcli con up id <connnection name>' several times, and then check
active connections with 'nmcli c s'.
2013-02-11 14:03:17 +01:00
Dan Williams
6431df02d4 trivial: remove unused gdb-cmd
No longer used after the removal of the internal crash dumper.
2013-02-08 23:54:16 -06:00
Aleksander Morgado
fb8ebc2a97 modem-manager: workaround issue in 'GDBusObjectManagerClient'
The 'GDBusObjectManagerClient' won't signal added or removed objects when it
was created but no name owner was available in the bus. We can still use it for
name-owner changes, but in order to have added/removed object signals, we'll
need to re-create the whole 'MMManager' when we know the service came alive in
the bus.

See GLib/GIO/GDBus bug:
   https://bugzilla.gnome.org/show_bug.cgi?id=693285
2013-02-08 18:03:42 -06:00
Aleksander Morgado
03c1e40e66 modem-manager: keep track of the signals added to the 'GDBusObjectManagerClient'
Make sure we cleanup all the signals when we remove our internal reference to
the 'MMManager' object.
2013-02-08 18:03:39 -06:00
Dan Williams
778d1cf2e8 core: track which interface an IP config came from
Various bits of code want the network interface which an IP config
came from, for example when distinguishing which interface to
send DNS requests to when the DNS servers are link-local.  DNS
plugins may also want this data for various reasons.

So it makes sense to attach the interface name to the IP config
object when the DNS manager gets it, so that later DNS updates
that don't have any interface information (hostname changes, etc)
can still generate correct DNS information.

This also eliminates the "last_iface" hack, which was often
inaccurate.

It also now sends "NetworkManager" to SUSE netconfig as the
interface name, because the DNS information being sent is already
merged/prioritized and not specific to a network interface, so
it's time to stop lying about where it came from.
2013-02-07 15:31:00 -06:00
Dan Williams
f2b33e31da trivial: fix spacing in AP mode message 2013-02-07 15:25:13 -06:00
Dan Williams
140ebbbf89 dhcp: generate DUID-UUID from /etc/machine-id (bgo #691885)
DHCPv6 RFCs require the DUID to be constant over time and to
be used as a permanent identifiers of the machine.  This precludes
using a network interface MAC address since the MAC address may
change, and there may be more than one network interface installed.

Storing the DUID causes problems when an OS image is cloned between
virtual or physical machines because then the saved DUID is no longer
unique.

To fix all these issues, generate the DUID from the machine's hashed
machine-id, which is already a unique identifier of the machine and
will always be present because dbus requires it, and NM requires
dbus.  It is assumed administrators will change the machine-id when
cloning an OS image; thus they only have to update one file, not
two (machine-id and the stored DUID).

Administrators may still override the machine-id-derived DUID by
setting a DUID in the default dhclient config file or the
interface-specific dhclient config files.

dhclient no longer saves a generated DUID to the config files,
because the default DUID will always be regenerated from
the machine-id on startup and thus always stable.
2013-02-07 12:38:58 -06:00
Aleksander Morgado
3b2556ae38 modem-manager: properly follow name-owner changes
We avoid requesting to auto-start the service when the 'MMManager' is created,
so that we can use it to follow name-owner changes (when auto-starting
requested the 'MMManager' creation may fail).

We still handle the periodic poking to the service, but instead of re-creating
the 'MMManager', we just call org.freedesktop.DBus.Peer.Ping().
2013-02-07 12:17:32 -06:00
Dan Williams
240f47c892 rfkill: set kernel WiFi rfkill state to cached state on startup
Like we do when the user sets the Wireless Enabled property at
runtime, ensure the kernel's softblock state is synced with the
user's WiFi enable preference at startup.  This helps compensate
for BIOSes that don't save rfkill state over reboots and ensures
consistency of between startup and runtime Wireless Enabled
property behavior.

Suggested by John G.
2013-02-06 13:02:29 -06:00
Aleksander Morgado
1bbcd696a4 modem-manager: plug memleak 2013-02-06 12:06:10 -06:00
Dan Williams
9ee46b45f1 dhcp: fix infinite loop when escaping DUID
Oops; only enabled when debugging was turned on, but still sucks.
2013-02-05 09:23:08 -06:00
Dan Williams
62bae8acb7 core: ensure IP interface removal doesn't remove the NMDevice
Some devices (namely PPPoE (pppX), ADSL (nasX, pppX), and
mobile broadband (pppX, bnepX)) create a kernel netdevice for IP
communication (called the "IP interface" in NM) as part of the
connection process and thus the IP interface lifetime does not
correspond to the NMDevice lifetime.  For these devices we must
ignore removal events for the IP interface name otherwise the
NMDevice would be removed.

Caused by 8cce42f2.

For example, this bug caused the NMDeviceBt to be removed when
a PAN connection's bnepX interface went down in response to a
terminated Bluetooth connection, which of course means that
you can't restart the PAN connection as your phone is no longer
in the NM device list.
2013-02-04 14:44:32 -06:00
Dan Williams
17338069e3 core: only manage those bridges created by NetworkManager (rh #905035)
Until we handle bridges non-destructively, only manage bridges
created by NM.  When quitting write out a file listing all
bridges created by NM and a timestamp, and when starting read
that file and if the timestamp is within 30 minutes, manage
any bridge that was listed in that file.  This scheme, while
not foolproof (eg, if NM crashes), should ensure that NM can
recognize bridges it created if it's restarted.  The file
is stored in /run or /var/run, which is cleaned each restart,
ensuring that the state does not persist across reboots.

If an automatic or user-initiated activation request for
a bridge NM does not manage is received, that request is
denied.  Only if the bridge interface does not yet exist, or
was present in the managed bridges file, will an
NMDeviceBridge be created and activation be possible.
2013-02-04 11:59:15 -06:00
Dan Williams
6c3178c7e2 wired: wait for carrier on master devices before proceeding with IP config
If the IP configuration requires slaves/ports, starting IP configuration
before the master device has a carrier (which means at least one slave
or port has a carrier and the device is initialized) is pointless, and
will just take longer or fail.  Recent kernels have cleaned up carrier
handling on bridge/bond devices and the carrier is now a reliable
indication of whether or not the master device is ready to send/receive
traffic.  Thus, if we don't have a carrier, obviously no IP configuration
that depends on connectivity is going to work.
2013-02-04 10:37:47 -06:00
Dan Williams
2dac2cf56e core: don't allow auto-activation of a master that has been disconnected
The master-activation code was ignoring whether or not the master device
was inhibiting automatic connections.
2013-02-04 10:37:47 -06:00
Dan Williams
454490c6d5 core: let subclasses find slaves by ifindex 2013-02-04 10:37:47 -06:00
Dan Williams
37febd6228 core: expose IP4 wait state to subclasses
We'll need to this to determine whether or not to retry IP config
from device subclasses.
2013-02-04 10:37:47 -06:00
Dan Williams
06bac8fcda core: return success when port already attached to bridge
Instead of just not logging the error, don't return failure either.
2013-02-04 10:37:47 -06:00