Commit Graph

7207 Commits

Author SHA1 Message Date
Dan Williams
3f079f3265 core: remove nm_device_can_interrupt_activation()
No longer used anywhere.
2014-03-04 15:21:58 -06:00
Dan Williams
46abe332b8 core: remove nm_device_ignore_carrier()
No longer used anywhere.
2014-03-04 15:21:58 -06:00
Dan Williams
3a7f07e2f0 core: postpone non-static master IP configuration until carrier
This got broken at some point.  The intent of ignore-carrier was always
to ignore the carrier for IP configuration for static/manual connections,
but never for DHCP/SLAAC where a link is actually required.  Thus
when checking whether to postpone IP configuration for a master interface
that's using DHCP/SLAAC, don't allow ignore-carrier to factor into
the decision.
2014-03-04 15:21:58 -06:00
Dan Williams
1d5847c8a6 core: match IPv4 'disabled' method to 'auto' when device has no link
If IPv4 configuration did not succeed or the device has no IPv4 addresses
when NM restarts, it will detect the existing device configuration as
'disabled'.  This can happen when a bridge has no slaves and thus cannot
perform IPv4 addressing because it has no carrier (since bridge carrier
status depends on slave carriers).  When NM starts or restarts, it
sees the bridge has no IPv4 address and assumes the IPv4 method is
'disabled'.  This creates a new connection, which blocks any slave
connections from activating if they specify their master via UUID
 (since the bridge's active connection is generated).

Fix this by allowing matches from 'disabled' to 'auto' if the device
has no carrier, and there are no other differences between the
original and the candidate connections.
2014-03-04 15:21:58 -06:00
Dan Williams
7b65f8934e core: refactor connection matching and add testcase
Refactor in preparation for some additional matching, and add testcases.
2014-03-04 15:21:58 -06:00
Dan Williams
2fe5ebe21c core: correctly handle pre-activation dependency failure (rh #1069695)
Dependencies may fail before the activation actually starts, like
when a software device gets removed while the activation is
scheduled but before it has started.  In these cases, the
activation request should fail.
2014-03-04 15:21:29 -06:00
Dan Williams
b7598bbb8c core: ensure ActiveConnections stay alive over activation paths
With some upcoming changes, ActiveConnection objects could change to
DEACTIVATED state during activation, for example if the AC's device
was removed while the AC was being authorized.

To ensure the AC stays alive and is not used after being freed,
keep a reference to the AC across authorization operations.
2014-03-04 15:21:29 -06:00
Thomas Haller
3e9ba55c3a platform: move asserts for sysctl_get/set functions to nm-linux-platform
Also assert inside of sysctl_get() that we read the expected file
locations. Especially because now we might log the content of these
files.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-04 21:21:35 +01:00
Thomas Haller
087c88f729 platform: add logging when reading and writing sysctl values
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-04 21:06:21 +01:00
Thomas Haller
6655d5c949 platform: remove logging about check_cache_items()
We don't thoroughly log the pointer values of our libnl objects,
so the logging in check_cache_items() is not usefull, it only
clutters the logfile.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-04 18:21:37 +01:00
Jiří Klimeš
b8915dae3c policy: fix crash caused by calling functions on connection==NULL
Crash appeared in:
nm_settings_connection_set_autoconnect_blocked_reason()
2014-03-04 16:53:35 +01:00
Dan Williams
7bfbd5e52a core: #include <gmodule.h> for G_MODULE_EXPORT
When some configure-time options aren't used, <gmodule.h> is not
included.  Fix that.
2014-03-04 09:11:23 -06:00
Jiří Klimeš
9e0f4179fd devices: fix compilation of nm_device_factory_new_link()
We have to return a value.
2014-03-04 11:07:33 +01:00
Dan Williams
493bbbeb4a core: consolidate auto-activation recheck signals
Add a generic signal that devices can use to indicate that something
material in the network situation changed, and that auto-activation
may now be possible.  This reduces specific knowledge of device types
in the policy.
2014-03-03 09:32:41 -06:00
Dan Williams
aeb1e103d8 mobile: make WWAN support a plugin
Make WWAN support a plugin using the new device factory interface.
Provides a 5% size reduction in the core NM binary.

     Before    After
NM: 1187224  1125208  (-5%)
MM:       0   100576

(all results from stripped files)
2014-03-03 09:32:41 -06:00
Dan Williams
a9591aecaf bluez: make Bluetooth support a plugin
Make Bluetooth support a plugin using the new device factory interface.
Provides a 5% size reduction in the core NM binary.

     Before   After
NM: 1253016 1187224 (-5%)
BT:       0   85752

(all results from stripped files)
2014-03-03 09:32:41 -06:00
Dan Williams
71a52347f3 atm: make ADSL support a plugin
Make ADSL support a plugin using the new device factory interface.
Provides a 1% size reduction in the core NM binary.

      Before    After
NM:  1265336  1253016  (-1%)
ATM:       0    27360

(all results from stripped files)
2014-03-03 09:32:41 -06:00
Dan Williams
2a04df856b devices: rework device plugin interface to be more flexible
In preparation for making WWAN and Bluetooth plugins, rework
the device plugin interface to meet those plugins' needs and
port WiMAX over in the process.
2014-03-03 09:32:41 -06:00
Dan Williams
8e9b9fe423 mobile: convert to device removed signals
Instead of having NMManager listen directly to the ModemManager
for modem removal signals, have the NMDeviceModem and NMDeviceBt
listen for them (since they obviously have a pointer to the backing
NMModem object) and then re-emit any necessary device removal
signals to the manager.
2014-03-03 09:32:40 -06:00
Dan Williams
ee66964208 core: allow devices to indicate when they should be removed
Devices created by plugins will use this to indicate when their
backing resources have disappeared, at which point the manager
should remove them.
2014-03-03 09:32:40 -06:00
Dan Williams
fd3fe2200c core: add nm_connection_provider_get()
In reality the connection provider (NMSettings) is always the same
object, and some device plugins need access to it.  Instead of
cluttering up the device plugin API by passing the provider into
every plugin regardless of whether the plugin needs it, create
a getter function.
2014-03-03 09:32:40 -06:00
Dan Williams
fe6b86a078 core: don't ref the Manager singleton
The OLPC mesh code did rely on nm_manager_get() referencing the
singleton when returning it, but all other callers of nm_manager_get()
did not.  Thus the manager's refcount would always increase and
almost never decrease.  Fix the refcounting so that the manager
always has only one ref, and it's lifetime is controlled by
main() and nothing else.
2014-03-03 09:32:40 -06:00
Jiří Klimeš
cb680c5b54 ifcfg-rh: add missing functionality for reading/writing subject matches
subject-match              - IEEE_8021X_SUBJECT_MATCH
altsubject-matches         - IEEE_8021X_ALTSUBJECT_MATCHES
phase2-subject-match       - IEEE_8021X_PHASE2_SUBJECT_MATCH
phase2-altsubject-matches  - IEEE_8021X_PHASE2_ALTSUBJECT_MATCHES

And a testcase of course.
2014-02-28 10:17:40 +01:00
Dan Winship
10a4df690c devices: propagate the hop limit from an IPv6 RA to the kernel config
If we set accept_ra_defrtr=0 then the kernel will ignore the "hop
limit" too. So parse it out of the RA and set it manually.
2014-02-27 15:28:11 -05:00
Dan Winship
10b699c51f rdisc: expose the "hop limit" from the RA 2014-02-27 15:28:11 -05:00
Dan Winship
c04db133fc devices: be more precise about kernel IPv6 RA handling
We don't want the kernel to do IPv6 addrconf, but we do want it to
notice the non-router-related fields in the RA (eg, Retrans Timer) and
update the interface state to reflect them. So instead of turning off
accept_ra, we leave it turned on, and turn off accept_ra_defrtr,
accept_ra_rtr_pref, and accept_ra_pinfo instead.
2014-02-27 15:28:11 -05:00
Dan Winship
6136630163 devices: abstract the handling of IPv6 sysfs properties
We're about to start using a bunch more IPv6 sysfs properties, so
let's start by making the code more extensible.
2014-02-27 15:28:11 -05:00
Dan Winship
5fe94852ef platform: change sysctl_get/set error logging
Remove the "silent_on_error" flag from nm_platform_sysctl_get(), and
make both get() and set() log at debug level on ENOENT and error level
on all other errors, always.

Also ensure that we don't sometimes write "failed to set 'x' to 'y':
Success" when a partial write occurs.
2014-02-27 15:28:11 -05:00
Thomas Haller
0332850627 core: default route should stay on the current active device
get_best_ip4_device() and get_best_ip6_device() iterate over
the list of devices to find the device with the default route.
The order of iteration is arbitrarly choosen.

Before, if two devices had the same priority, it would choose
the first one. Change it so that the device which currently has
the default route keeps it -- until it gets deactivated or a higher
priorty device gets connected.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-27 20:00:20 +01:00
Dan Williams
39ab68481c core: fix ActiveConnection handling of device disconnected state after e19f48ec (rh #1058843)
e19f48ec was incomplete; it failed to handle device disconnections.
NMDevice will clear its internal activation request *before*
emitting the state change, which meant that when the
NMActRequest processes the DISCONNECTED state change, the:

if (NM_ACTIVE_CONNECTION (nm_device_get_act_request (device)) != active)
    return;

statement triggered and the DISCONNECTED state change was not
processed.

Instead of having NMDevice keep the activation request alive over
the entire DISCONNECTED state transition, which may have much
greater implications, handle the special-case locally in the
NMActRequest code itself.
2014-02-27 12:57:59 -06:00
Thomas Haller
7d73ee75df trivial: more wrong compiler warnings
connection_parser.c: In function 'make_ip4_setting':
  connection_parser.c:660:33: error: 'method' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    if (!is_static_block && strstr (method, "dhcp")) {

  connections.c: In function ‘load_cmd_line_edit_lib’:
  connections.c:5744:17: error: ‘module’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
    g_module_close (module);

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-27 18:31:07 +01:00
Thomas Haller
0550a14fbe trivial: omit wrong compiler warning in ifcfg-rh reader about uninitialized use
reader.c: In function 'parse_infiniband_p_key':
  reader.c:3947:5: error: 'id' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    id = (id | 0x8000);
       ^

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-27 18:26:28 +01:00
Thomas Haller
f0a8b3a76d core: fix alignment of logging timestamp
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-26 19:06:00 +01:00
Dan Williams
834c6f32b3 build: clean 0.9.8 generated files
Makes it easier to switch between 0.9.8 and git master.
2014-02-26 09:58:15 -06:00
Dan Williams
e19f48ec26 core: better ignore deactivations before a new activation starts (rh #1058843)
When a new activation request comes in and the device is already
activated, two NMActRequests will exist for the device in parallel.
The old one handles de-activation of the device and is then disposed,
while the new one waits until the device is de-activated and then
takes over and starts the new activation.

Both requests are watching device state, and the new request may
mis-interpret the de-activation states and clean up its device pointer,
leading to assertion failures when the new activation starts.

To fix this (and because NMVPNConnection *does* always want to see
de-activation events from the device) remove the code that tries to
ignore de-activation from NMActiveConnection's device state handler.

Instead, have NMActRequest skip any reaction to device state changes
unless it is the current activation request on the device.  The VPN
code always wants to see the device's state, so it doesn't need this
check.
2014-02-25 18:03:03 -06:00
Dan Williams
4040198b47 core: queue re-activations to allow DEACTIVATING state
If a device is already activated, queue the new activation to allow
the transition through the DEACTIVATING state.

---

Also remove the "HACK" bits in nm_device_deactivate(). This hack was
added on 2007-09-25 in commit 9c2848d.  At the time, with user settings
services, if a client created a connection and requested that NM
activate it, NM may not have read the connection from the client over
D-Bus yet.  So NM created a "deferred" activation request which waited
until the connection was read from the client, and then began activation.

The Policy watched for device state changes and other events (like
it does now) and activated a new device if the old one was no longer
valid.  It specifically checked for deferred activations and then
did nothing.  However, when the client's connection was read, then
nm-device.c cleared the deferred activation bit, leading to a short
period of time where the device was in DISCONNECTED state but there
was no deferred activation, because the device only changes state to
PREPARE from the idle handler for stage1.  If other events happened
during this time, the policy would tear down the device that was
about to be activated. This early state transition to PREPARE
worked around that.

We need to remove it now though, because (a) the reason for its
existence is no longer valid, and (b) _device_activate() may now
be called from inside nm_device_state_changed() and thus it cannot
change to a new state inside the function.
2014-02-25 18:03:02 -06:00
Dan Williams
037c67f471 firewall: ignore UNKNOWN_INTERFACE errors
If the firewall didn't know about the interface, don't log errors
about it because there's nothing NM can do.  Also, sometimes NM
sends the not-IP interface, like when disconnecting WWAN when the
PPP interface is already gone.
2014-02-25 17:22:08 -06:00
Thomas Haller
72f5542488 platform: downgrade error logging about NLE_DUMP_INTR on event socket
Such a failure can happen easily, because we now request an initial dump
to get AF_INET6 addresses in order to check for extended ifa flags support.

This is not critical, so downgrade the error log.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-25 16:31:53 +01:00
Jiří Klimeš
4141e69b3a settings: free memory in finalize(), not in dispose() in NMSecretAgent (rh #1061911)
Even if the code changed in master compared to the bug report, the issues would
still occur when we freed members in dispose.

https://bugzilla.redhat.com/show_bug.cgi?id=1061911
2014-02-25 14:27:48 +01:00
Thomas Haller
79f0f72b84 trivial: rename function in platform
To make the name analog to init_ip4_address, etc. which start with
init_*.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-24 22:06:07 +01:00
Thomas Haller
8b294541d8 platform: share the static buffer for platform to_string functions
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-24 21:58:51 +01:00
Thomas Haller
0024c72586 trivial: fix whitespace
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-24 21:35:33 +01:00
Thomas Haller
d3a2219cee replace snprintf by g_snprintf
Use the glib wrapper for snprintf.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-24 21:35:33 +01:00
Thomas Haller
6c0db3107e platform: align debugging output in platform signals
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-24 18:29:25 +01:00
Thomas Haller
184d93ea60 rdisc: print gateway for routes in rdisc debugging output
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-24 18:29:25 +01:00
Thomas Haller
076ca1e3e2 rdisc: fix invalid cast when printing addresses in config_changed()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-24 18:29:25 +01:00
Jiří Klimeš
c2a1cb1a44 docs: use %TRUE, %FALSE macros instead of plain TRUE, FALSE values for gtkdoc 2014-02-24 17:00:39 +01:00
Thomas Haller
93e4e0f8a1 core: minor fix to ensure we call platform functions with positive ifindex
Actually, get_ip_ifindex() should always return 0 or > 0. Just in case,
be extra careful and modify the conditions.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-23 22:31:49 +01:00
Thomas Haller
dd2ce3dfbc core: fix waiting for bringing up/taking down device
This fixes a regression introduced in 5074898591.
The while loop did only refetch the cached value (because the glib main loop
was blocked and only the cached device flags were checked).

Also, instead on relying of g_usleep(), wait until a maximum time of waiting
is expired. The duration of g_usleep() might not be very accurate.

Also, do no longer check the cached device state before setting the
device flag. The cache might be out of date, so we just set the flag.

https://bugzilla.gnome.org/show_bug.cgi?id=724363

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-23 22:31:49 +01:00
Thomas Haller
66f5256b94 core: add nm_platform_link_refresh() function to refresh the libnl cache for links
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-23 22:31:42 +01:00