Commit graph

262 commits

Author SHA1 Message Date
Dan Williams
ffd961febf core: properly initialize unmanaged_flags and handle carrier_changed() for unmanaged devices
Fixes the following g_warn():
    #0  0x0000003370c504e9 in g_logv () from /lib64/libglib-2.0.so.0
    #1  0x0000003370c5063f in g_log () from /lib64/libglib-2.0.so.0
    #2  0x0000003370c50956 in g_warn_message () from /lib64/libglib-2.0.so.0
    #3  0x0000000000439962 in carrier_changed (device=0x1d94300, carrier=1) at devices/nm-device.c:1021
    #4  0x0000000000488f12 in carrier_changed (device=0x1d94300, carrier=1) at devices/nm-device-ethernet.c:1646
    #5  0x0000000000434c94 in nm_device_set_carrier (device=device@entry=0x1d94300, carrier=1) at devices/nm-device.c:1104
    #6  0x0000000000434dd5 in check_carrier (device=device@entry=0x1d94300) at devices/nm-device.c:1298
    #7  0x0000000000434ef8 in constructed (object=0x1d94300) at devices/nm-device.c:550
    #8  0x0000003371c15d87 in g_object_new_internal () from /lib64/libgobject-2.0.so.0
    #9  0x0000003371c17814 in g_object_new_valist () from /lib64/libgobject-2.0.so.0
    #10 0x0000003371c17c11 in g_object_new () from /lib64/libgobject-2.0.so.0
    #11 0x000000000048bc2e in nm_device_ethernet_new (platform_device=platform_device@entry=0x1d82e58) at devices/nm-device-ethernet.c:336
    #12 0x000000000047c600 in platform_link_added (self=0x1d70150, ifindex=ifindex@entry=2, plink=plink@entry=0x1d82e58, reason=reason@entry=NM_PLATFORM_REASON_INTERNAL) at nm-manager.c:1954
    #13 0x000000000047c7db in platform_link_cb (platform=<optimized out>, ifindex=2, plink=0x1d82e58, change_type=<optimized out>, reason=NM_PLATFORM_REASON_INTERNAL, user_data=0x1d70150) at nm-manager.c:2038
    #14 0x0000003371805d8c in ffi_call_unix64 () from /lib64/libffi.so.6
    #15 0x00000033718056bc in ffi_call () from /lib64/libffi.so.6
    #16 0x0000003371c10ad8 in g_cclosure_marshal_generic () from /lib64/libgobject-2.0.so.0
    #17 0x0000003371c10298 in g_closure_invoke () from /lib64/libgobject-2.0.so.0
    #18 0x0000003371c2235d in signal_emit_unlocked_R () from /lib64/libgobject-2.0.so.0
    #19 0x0000003371c2a0f2 in g_signal_emit_valist () from /lib64/libgobject-2.0.so.0
    #20 0x0000003371c2a3af in g_signal_emit () from /lib64/libgobject-2.0.so.0
    #21 0x000000000044f6ba in nm_platform_query_devices () at platform/nm-platform.c:330
    #22 0x000000000047de4c in nm_manager_start (self=0x1d70150) at nm-manager.c:4025
    #23 0x0000000000429d31 in main (argc=1, argv=0x7fffb4c31628) at main.c:654

https://mail.gnome.org/archives/networkmanager-list/2014-June/msg00000.html

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-02 19:07:57 +02:00
Dan Williams
c4dd68bce9 core: remove unused 'error' argument to check_connection_compatible()
Nothing uses the error, so simplify some code and save 5K (0.45%) in
binary size.
2014-05-30 13:49:30 -05:00
Dan Williams
b1d2b14922 core: fix use-after-free in pending action remove debug message 2014-05-22 11:34:58 -05:00
Dan Winship
6661531062 devices: fix link-changed refactoring
Thomas points out that the previous refactoring moved the
link_changed() virtual method invocation relative to
update_for_ip_ifname_change(), which could have weird side effects
given the things that can happen there. So move it back.
2014-05-19 09:58:11 -04:00
Dan Winship
950d9fff26 devices: refactor the link-changed code
Separate out the "ifindex changed" and "ip_ifindex changed" cases.
2014-05-19 08:25:56 -04:00
Dan Winship
01b7bef6b4 devices: improve slave release log messages
Rather than putting "success %d" in the message, log different
messages (at different priorities) for success and failure.
2014-05-19 08:24:54 -04:00
Dan Winship
c48ba1ab10 devices: fix "slaves" property notification in release_slaves
Bond, bridge, and team were notifying their "slaves" properties before
the slave actually got removed from priv->slaves, meaning that
anything that looked at the property directly from a notify::slaves
handler would see the old value. Fix that.
2014-05-19 08:24:54 -04:00
Dan Winship
1f22c8859a devices: flip the ordering of priv->slaves
Keep priv->slaves in the order that slaves were attached, rather than
in reverse order.

Among other things, this makes the errors from
nm_device_master_check_slave_physical_port() more consistent.
2014-05-19 08:24:54 -04:00
Dan Williams
d336a78a0e core: don't ref/unref the DHCP manager
It's a singleton anyway, so no need to ref/unref it.  Just use it.
2014-05-09 15:33:32 -05:00
Dan Williams
11f9855223 core: emit dhcp4/dhcp6-change dispatcher events if other IP completes first (rh #1091296) (bgo #729284)
If IPv6 completes first it would emit the "up" dispatcher event with IPv6
details and move the device to ACTIVATED state.  But if DHCPv4 was still
running, no dispatcher event would be emitted with the DHCPv4 information
until the first lease renew.  Thus dispatcher scripts would not receive
DHCPv4 information for quite some time.

Ensure that if the other IP version completes first, that when the slower
method's DHCP completes, that it emits the appropriate dhcp4-change
or dhcp6-change event so that dispatcher scripts get the information
as soon as it's available.

https://bugzilla.gnome.org/show_bug.cgi?id=729284
2014-05-09 15:25:27 -05:00
Dan Williams
d043094195 wwan: disable autoconnect if the given SIM PIN was wrong
If the given PIN was wrong, we really don't want to try that PIN
again automatically because it might lock the SIM.  To ensure that
doesn't happen, disable autoconnect so that the user must manually
request reconnection.

(this doesn't fix auto-connect-with-a-wrong-PIN completely, as
autoconnect is reset when resuming from sleep, but it's a start)
2014-05-06 21:51:24 -05:00
Dan Williams
6080425088 wwan: use modem states instead of enabled/connected properties
Determining when the NMDeviceModem is available and when different
connections are available is easier if the modem's state is tracked,
instead of using the separate Enabled and Connected properties.
These properties could not accurately represent the SIM lock state
and prevented NetworkManager from making the modem available for
auto-activation when locked, even if a PIN was available.

In this new scheme, the NMDeviceModem is UNAVAILABLE when the
ModemManager modem state is FAILED, UNKNOWN, or INITIALIZING.  It
transitions to the NM DISCONNECTED state when the modem has finished
initializing and has not failed.

Once the NMDeviceModem is in DISCONNECTED state it can be activated
even if the SIM is locked and a PIN is required; the PIN will be
requested when starting activation, either from the connection itself
or via a secrets request.  This makes auto-activation of WWAN
connections possible.

This also allows us to consolidate code dealing with modem enable/disable
into the base NMModem class using the modem state, and to log more modem
information for debugging purposes.
2014-05-06 21:48:55 -05:00
Thomas Haller
7b65c80712 core: minor cleanup to release GValue for G_TYPE_OBJECT
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-05 20:59:51 +02:00
Thomas Haller
09d3c833fd platform: refactor signals by combining added/changed/removed
Before platform raised 3 signals for each object type. Combine
them into one and add a new parameter @change_type to distinguish
between the change type.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-03 03:44:22 +02:00
Thomas Haller
516d66210f core: wait with "startup complete" for both IPv4 and IPv6 dynamic configuration
In case of DHCP4, DHCP6 and/or SLAAC, delay "startup complete" until
both IPv4 and IPv6 are ready. This especially has an effect on
nm-online/NetworkManager-wait-online.service, which blocks until
configuration of both IPv4 and IPv6 is ready.

We queue a pending_action when automatic configuration starts and
remove it again, when we receive an address. Before, "startup complete"
was reached when either one of the two IP protocols was configured.

https://bugzilla.redhat.com/show_bug.cgi?id=1086906

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-01 22:06:52 +02:00
Thomas Haller
a16faa3985 core: add parameter to ignore error in add/remove pending action
Add a parameter to nm_device_add_pending_action() to silently
accept adding duplicate actions.

Same for nm_device_remove_pending_action(), to silently ignore
removing non-pending actions.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-01 22:06:52 +02:00
Thomas Haller
2941109d3b dhcp: refactor using named defines for signal names instead of plain string
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-11 11:31:34 +02:00
Thomas Haller
d14ffbdb9c dhcp: refactor dhcp code to use @dhcp_anycast_addr as #GByteArray type
At a later point, we will have to make a copy of @dhcp_anycast_addr to start
the client asynchronously. Although the length of the guint8 array *should*
always be 6 byte (being a MAC address), it's nicer to just pass on the
GByteArray instance instead, which knows how many byte are actually
set.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-11 11:30:57 +02:00
Thomas Haller
86f8066177 core: sort IPv6 addresses (add nm_ip6_config_addresses_sort())
Clients such as gnome-control-center or nm-applet show
at some places only one (IPv6) address. They most likely
just pick the first address from the list of addresses,
so we should order them.

Sorting has the advantage to make the order deterministic --
contrary to before where the order depended on run time conditions.

Note, that it might be desirable to show the address that the kernel
will use as source address for new connections. However, this depends
on routing and cannot be easily determined in general. Still, the
ordering tries to account for this and sorts the addresses accordingly.

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-11 11:13:06 +02:00
Thomas Haller
fc1351504d core: fix hanging pending_action "queued state lock"
This bug caused nm-online to hang because "startup complete" state
is never reached. Sometimes you also see this error in the logfile:

  <warn> (em1): add_pending_action (3): 'queued state lock' already added
  file devices/nm-device.c: line 7178 (nm_device_add_pending_action): should not be reached

https://bugzilla.redhat.com/show_bug.cgi?id=1084554
https://bugzilla.redhat.com/show_bug.cgi?id=1084556
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1082045

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-07 17:45:38 +02:00
Dan Williams
6c299bc19b core: convert unmanaged bits to flags
Instead of tracking unmanaged-ness in a couple variables (and because
I'd like to add one for user-unmanaged later) let's do it in a single
flags variable, and consolidate setting of the unmanaged states in one
place.
2014-04-07 09:52:07 -05:00
Dan Williams
0b664ad4a4 core: fix bug with ignore-carrier and master/slave devices (rh #1083521)
Even ignore-carrier devices need to be aware of carrier-up events so
they can continue DHCP when the link comes up.  They just ignore all
carrier-down events.
2014-04-02 09:15:54 -05:00
Dan Winship
726e84cfbf devices: if a generated connection doesn't verify, log why 2014-03-26 12:56:57 -04:00
Dan Winship
01f41506fb devices: send ARPs when configuring static IPv4 addresses (rh #1073447)
After applying a configuration with static IPv4 addresses, call
/sbin/arping to announce the new addresses to the host's neighbors.
(Basic idea copied from Fedora ifup-eth.)
2014-03-21 09:26:19 -04:00
Jiří Klimeš
7ff7df7640 core: improve ifname matching of existing x generated connections (rh #1077743)
DEVICE="ens3"
ONBOOT=yes
NETBOOT=yes
UUID="23466771-f5fa-4ca9-856f-eaf4a8e20c3f"
BOOTPROTO=none
IPADDR="10.0.0.2"
PREFIX="24"
GATEWAY="10.0.0.1"
HWADDR="52:54:00:12:34:56"
TYPE=Ethernet
NAME="ens3"

This ifcfg file results in connection.interface-name=ens3.
However, device-generated connection didn't set interface-name property.

Fix that by setting interface-name property when generating a connection. Also
allow matching connections if interface-name is not set in a connection.

https://bugzilla.redhat.com/show_bug.cgi?id=1077743
2014-03-21 09:24:13 +01:00
Dan Williams
e4bcfc20ca core: export ActiveConnection before handing it to the device (bgo #723783)
The AC doesn't get a D-Bus path until it's exported, but that happens after
it's handed to the Device it will be activated on.  The Device emits a
PropertyChanged event when it's handed the AC, but it ignores ACs that
aren't exported yet.  Thus when activating, the Device doesn't emit the
AC's path at all in the ActiveConnection property because it's NULL.

Fix that by exporting the AC immediately before starting activation
with it.

Second, move the notification of the Device.ActiveConnection property
to be emitted along with the state change to PREPARE instead of long
before it.  While we don't guarantee signal ordering in general, this
seems like a more correct ordering.

https://bugzilla.gnome.org/show_bug.cgi?id=723783
2014-03-20 19:26:40 -05:00
Dan Williams
73d128bbd1 core: emit PropertyChanged signal for ActiveConnection when disconnecting 2014-03-18 15:37:37 -05:00
Dan Winship
c3aa2890f5 devices: change log message when "deactivating" device on startup
nm_device_deactivate() is used when deactivating a device, but also
when initializing it when it is first managed. Rename it to
nm_device_cleanup(), and use a different log message ("preparing
device") in the NM_DEVICE_STATE_REASON_NOW_MANAGED case.
2014-03-18 16:29:04 -04:00
Thomas Haller
3232361f1b core: add debug logging when setting IP[46]Config instance of a NMDevice
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-17 20:38:23 +01:00
Dan Williams
3302fba21c core: fix auto-activation of ignore-carrier devices when carrier appears (rh #1076592)
If a device had its carrier ignored, and did not have a carrier on startup,
then NetworkManager would not re-check autoconnect connections when the
device's carrier appeared.  Because ignore-carrier devices are always
in DISCONNECTED state when they are managed, the nm-device.c::carrier_changed()
code essentially did nothing when the carrier appeared.  It needs to
also trigger an auto-activation recheck signal when the carrier appears
to ensure that now-valid connections (like those that require DHCP or
IPv6) can be auto-activated.
2014-03-17 10:34:53 -05:00
Thomas Haller
0553e1b36c core: add debug logging for link disconnect action
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-13 21:40:42 +01:00
Dan Williams
11d8f21b68 wifi: fix some warnings caused by hidden SSID patches (23a5ae2f) (rh #1069844)
It could also cause nm_device_connection_is_available() to return TRUE
for wifi devices, for connections that were not wifi.
2014-03-13 11:04:56 -05:00
Jiří Klimeš
b02353e954 core: fix a regression in manual device disconnection (bgo #726239)
Devices disconnected explicitly by user should stay disconnected, preventing
auto-connecting until manual request.

Introduction of NM_DEVICE_STATE_DEACTIVATING state broke this feature.

disconnect_cb() correctly set autoconnect device property to FALSE, however
nm_device_state_changed() put it to TRUE again. Thus only the active connection
was blocked instead of the whole device.

https://bugzilla.gnome.org/show_bug.cgi?id=726239
2014-03-13 16:06:35 +01:00
Thomas Haller
1f383bc53f core: support renaming of NMDevice (changes of ifname)
https://bugzilla.gnome.org/show_bug.cgi?id=726177
https://bugzilla.redhat.com/show_bug.cgi?id=907836

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-12 17:13:02 +01:00
Dan Williams
23a5ae2f44 wifi: bypass available check for hidden APs during activation (rh #1069844)
Because not all clients set the 'hidden' property in a connection for
hidden/non-SSID-broadcasting networks, they may not show up in
the device's available-connections property.  After the
PendingActivation object removal, all activations require the
connection to be in available-connections, and thus hidden SSID
networks could not be activated.

Unfortunately check_connection_available() is used both during
activation and to populate the available-connections array, but we
only want to special-case activation paths, and still ensure that
SSIDs not found in the scan list are not in available-connections.

To make it clear this is a WiFi only hack, and that we should
remove it at some point in the future, create another class method
specifically for hidden WiFi and use that in activation paths to
special-case hidden WiFi connection activation.
2014-03-12 08:42:55 -05:00
Thomas Haller
066ce42ce1 core: refactor delete_on_deactivate in nm-device
Instead of only passing the ifindex to the callback, pack
additional data. This allows for better logging by also
writing the g_idle_add id which allows to associate the scheduling
with cancel calls.

Also, this fixes that the callback could not clear the
@delete_on_deactivate_id of the device, so that a following
delete_on_deactivate_unschedule() would think that there is
still something to cancel.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-11 21:27:22 +01:00
Jiří Klimeš
a2ac5bb382 device: fix uninitialized ifa_flags
Pointed by Coverity.
2014-03-07 23:51:13 +01:00
Dan Williams
5ed2a9430a core: unschedule deletion of software device when starting an activation request
This fixes queued activation request to be aborted because the software
device gets removed before the device reaches the PREPARED state.
This happens, because when the previous connection disconnects, the
device will schedule its removal.

https://bugzilla.redhat.com/show_bug.cgi?id=1073015

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-06 19:17:50 +01:00
Thomas Haller
d6f6ccef43 core: fix adding gateway route for IPv6
Setting the address flag IFA_F_NOPREFIXROUTE broke adding the device route to
the IPv6 prefix because the check for nm_ip6_config_destination_is_direct()
caused the route to be skipped. This, together with the kernel no
longer adding the prefix route resulted in no device route for autoconf
/64 prefixes.

https://bugzilla.redhat.com/show_bug.cgi?id=1068632
https://bugzilla.redhat.com/show_bug.cgi?id=1072410

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-05 11:00:53 +01:00
Thomas Haller
8cd0de231a tivial/core: move common #defines to header file
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-05 10:59:24 +01:00
Thomas Haller
bd93117cad trivial/core: remove duplicate #include
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-05 10:58:12 +01:00
Dan Winship
ba75ad2d95 rdisc: obey rtr_solicitations and rtr_solicitation_interval
The IPv6 spec say that when performing SLAAC, you should sent at most
3 RSes, at least 4 seconds apart. We were previously continuing to
send RSes forever if we didn't get back a response. Fix that.

(Since the fix involves making nm-lndp-rdisc use NMPlatform, it was
necessary to rewrite the rdisc test program a bit, to not try to
include <net/if.h>, which is incompatible with <linux/if.h>.)
2014-03-04 17:04:01 -05:00
Dan Winship
a10bd9991f core: move NMDevice's ip6_property_path() to NetworkManagerUtils 2014-03-04 17:04:01 -05:00
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
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
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
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