Commit Graph

273 Commits

Author SHA1 Message Date
Denis Kenzior 92a51805c4 netdev: Finalize disconnects on device removal
When device is removed or otherwise freed, netdev_connect callbacks are
invoked.  Treat disconnects similarly
2016-09-21 15:23:06 -05:00
Denis Kenzior f77d363840 netdev: Add netdev_connect_wsc 2016-09-13 20:50:24 -05:00
Denis Kenzior db8794460f eapol: Remove io argument from eapol_start 2016-09-13 17:37:13 -05:00
Denis Kenzior baf72d7f86 eapol: Move to a single PAE socket
We used to open a socket for each wireless interface.  This patch uses a
single socket with an attached BPF to handle all EAPoL traffic via a
single file descriptor.
2016-09-12 10:02:04 -05:00
Denis Kenzior 0a6ffdf029 netdev: Fix double-free
We should only call eapol_cancel if netdev_connect_free was not
triggered as a result of handshake failure.
2016-08-23 13:15:00 -05:00
Andrew Zaborowski 2c88c37f99 netdev: Cancel the CMD_CONNECT genl command on disconnect
CMD_DISCONNECT fails on some occasions when CMD_CONNECT is still
running.  When this happens the DBus disconnect command receives an
error reply but iwd's device state is left as disconnected even though
there's a connection at the kernel level which times out a few seconds
later.  If the CMD_CONNECT is cancelled I couldn't reproduce this so far.

src/network.c:network_connect()
src/network.c:network_connect_psk()
src/network.c:network_connect_psk() psk:
69ae3f8b2f84a438cf6a44275913182dd2714510ccb8cbdf8da9dc8b61718560
src/network.c:network_connect_psk() len: 32
src/network.c:network_connect_psk() ask_psk: false
src/device.c:device_enter_state() Old State: disconnected, new state:
connecting
src/scan.c:scan_notify() Scan notification 33
src/device.c:device_netdev_event() Associating
src/netdev.c:netdev_mlme_notify() MLME notification 60
MLME notification is missing ifindex attribute
src/device.c:device_dbus_disconnect()
src/device.c:device_connect_cb() 6, result: 5
src/device.c:device_enter_state() Old State: connecting, new state:
disconnecting
src/device.c:device_disconnect_cb() 6, success: 0
src/device.c:device_enter_state() Old State: disconnecting, new state:
disconnected
src/scan.c:scan_notify() Scan notification 34
src/netdev.c:netdev_mlme_notify() MLME notification 19
src/netdev.c:netdev_mlme_notify() MLME notification 60
MLME notification is missing ifindex attribute
src/netdev.c:netdev_mlme_notify() MLME notification 37
src/netdev.c:netdev_authenticate_event()
src/scan.c:get_scan_callback() get_scan_callback
src/scan.c:get_scan_done() get_scan_done
src/netdev.c:netdev_mlme_notify() MLME notification 60
MLME notification is missing ifindex attribute
src/netdev.c:netdev_mlme_notify() MLME notification 19
MLME notification is missing ifindex attribute
src/netdev.c:netdev_mlme_notify() MLME notification 38
src/netdev.c:netdev_associate_event()
src/netdev.c:netdev_mlme_notify() MLME notification 46
src/netdev.c:netdev_connect_event()

<delay>

src/netdev.c:netdev_mlme_notify() MLME notification 60
MLME notification is missing ifindex attribute
src/netdev.c:netdev_mlme_notify() MLME notification 20
MLME notification is missing ifindex attribute
src/netdev.c:netdev_mlme_notify() MLME notification 20
src/netdev.c:netdev_mlme_notify() MLME notification 39
src/netdev.c:netdev_deauthenticate_event()
2016-08-05 11:07:29 -05:00
Andrew Zaborowski 11d322aad7 netdev: Call netdev_free in netdev_shutdown
This is to make sure device_remove and netdev_connect_free are called
early so we don't continue setting up a connection and don't let DBus
clients power device back up after we've called netdev_set_powered.
2016-08-04 12:22:43 -05:00
Denis Kenzior 8248c1c7d2 netdev: Clear connect_cb when connected
Prevents situations like this:
src/device.c:device_enter_state() Old State: connecting, new state:
connected
src/scan.c:scan_periodic_stop() Stopping periodic scan for ifindex: 3
src/device.c:device_dbus_disconnect()
src/device.c:device_connect_cb() 3
src/device.c:device_disassociated() 3
src/device.c:device_enter_state() Old State: connected, new state:
autoconnect
2016-08-04 12:22:43 -05:00
Andrew Zaborowski c4eab62ba4 netdev: Improve netdev_connect error/cancel logic
Try to make the connect and disconnect operations look more like a
transaction where the callback is always called eventually, also with a
clear indication if the operation is in profress.  The connected state
lasts from the start of the connection attempt until the disconnect.

1. Non-null netdev->connected or disconnect_cb indicate that the operation
   is active.
2. Every entry-point in netdev.c checks if connected is still set
   before executing the next step of the connection setup.  CMD_CONNECT and
   the subsequent commands may succeed even if CMD_DISCONNECT is called
   in the middle so they can't only rely on the error value for that.
3. netdev->connect_cb and other elements of the connection state are
   reset by netdev_connect_free which groups the clean-up operations to
   make sure we don't miss anything.  Since the callback pointers are
   reset device.c doesn't need to check that it receives a spurious
   event in those callbacks for example after calling netdev_disconnect.
2016-08-04 12:21:44 -05:00
Andrew Zaborowski 3863f6d2bb netdev: Allow ERFKILL during initial bring up
If initial bring up returns ERFKILL proceed and the inteface can be
explicitly brought up by the client once rfkill is disabled.

Also fix the error number returned to netdev_set_powered callback to be
negative as expected by netdev_initial_up_cb.
2016-08-01 13:13:24 -05:00
Andrew Zaborowski 50b5234976 netdev: Fix use of l_genl_msg_unref in netdev_connect
Also drop netdev.associate_msg which is now unused.
2016-08-01 12:49:07 -05:00
Denis Kenzior fba5ada1a1 netdev: Make enum naming consistent with guidelines 2016-07-19 18:03:21 -05:00
Denis Kenzior 1c5438d3ab netdev: simplify 2016-07-19 17:52:36 -05:00
Denis Kenzior 480332226d netdev: Fix memory leak:
==3059== 7 bytes in 1 blocks are still reachable in loss record 1 of 2
==3059==    at 0x4C2C970: malloc (vg_replace_malloc.c:296)
==3059==    by 0x50BB319: strndup (in /lib64/libc-2.22.so)
==3059==    by 0x417B4D: l_strndup (util.c:180)
==3059==    by 0x417E1B: l_strsplit (util.c:311)
==3059==    by 0x4057FC: netdev_init (netdev.c:1658)
==3059==    by 0x402E26: nl80211_appeared (main.c:112)
==3059==    by 0x41F577: get_family_callback (genl.c:1038)
==3059==    by 0x41EE3F: process_unicast (genl.c:390)
==3059==    by 0x41EE3F: received_data (genl.c:506)
==3059==    by 0x41C6F4: io_callback (io.c:120)
==3059==    by 0x41BAA9: l_main_run (main.c:381)
==3059==    by 0x402B9C: main (main.c:234)
2016-07-19 17:48:21 -05:00
Denis Kenzior 295ccf62d5 netdev: Properly cleanup removed interfaces 2016-07-19 17:45:48 -05:00
Denis Kenzior de6dddce76 netdev: Remove redundant associate_msg 2016-07-19 16:22:24 -05:00
Denis Kenzior c977b8092c netdev: Skip non-STA interfaces 2016-07-19 16:03:26 -05:00
Denis Kenzior 94f204b994 netdev: Act on NEW_INTERFACE & DEL_INTERFACE cmds 2016-07-19 16:02:37 -05:00
Denis Kenzior 37ea99d09e netdev: Remove netdev_new_wiphy_hint 2016-07-19 15:49:22 -05:00
Andrew Zaborowski 940f4fce46 netdev: Track interface name changes 2016-07-14 19:00:14 -05:00
Andrew Zaborowski 19fa024bd8 netdev: Reset interface state on init and exit
Take any managed interface down when iwd detects it and bring it back
up to start with a clean state.  On exit take interfaces down.
2016-07-13 12:36:35 -05:00
Andrew Zaborowski 6f51950f46 netdev: Add netdev_set_powered 2016-07-13 10:27:41 -05:00
Andrew Zaborowski 9c99166e7a netdev: Fix command length passed to l_netlink_send
Quiet the following dmesg warning:
netlink: 16 bytes leftover after parsing attributes in process `iwd'.
2016-07-06 10:38:55 -05:00
Denis Kenzior e421af2a58 netdev: React to removed netdevs 2016-07-01 14:49:34 -05:00
Denis Kenzior 005213a3d4 netdev: Implement new_wiphy hint
When a new wiphy is added, the kernel usually adds a default STA
interface as well.  This interface is currently not signaled over
nl80211 in any way.

This implements a selective dump of the wiphy interfaces in order to
obtain the newly added netdev.  Selective dump is currently not
supported by the kernel, so all netdevs will be returned.  A patch on
linux-wireless is pending that implements the selective dump
functionality.
2016-07-01 14:39:25 -05:00
Denis Kenzior 943acddb49 eapol: Refactor eapol tx path 2016-06-28 18:45:49 -05:00
Denis Kenzior de84aff10b netdev: Cleanup EAPoL state machine
In case of disconnection by AP or lost beacon, cancel EAPoL state
machine
2016-06-28 18:28:39 -05:00
Denis Kenzior 45dabb9e44 netdev: Call eapol_cancel if operstate fails 2016-06-28 18:24:53 -05:00
Denis Kenzior 830af391e2 netdev: Fix memory leak
==24934== 16 bytes in 1 blocks are definitely lost in loss record 1 of 1
==24934==    at 0x4C2C970: malloc (vg_replace_malloc.c:296)
==24934==    by 0x41675D: l_malloc (util.c:62)
==24934==    by 0x4033B3: netdev_set_linkmode_and_operstate
(netdev.c:149)
==24934==    by 0x4042B9: netdev_free (netdev.c:221)
==24934==    by 0x41735D: l_queue_clear (queue.c:107)
==24934==    by 0x4173A8: l_queue_destroy (queue.c:82)
==24934==    by 0x40543D: netdev_exit (netdev.c:1459)
==24934==    by 0x402D6F: nl80211_vanished (main.c:126)
==24934==    by 0x41E607: l_genl_family_unref (genl.c:1057)
==24934==    by 0x402B50: main (main.c:237)
2016-06-28 18:18:50 -05:00
Denis Kenzior efe5bed7c5 netdev: Move eapol_read to eapol.c 2016-06-28 18:18:47 -05:00
Denis Kenzior 746b0e5cb1 netdev: Free sm if connect fails 2016-06-28 17:26:03 -05:00
Denis Kenzior 5c6024185d netdev: Use CMD_CONNECT 2016-06-27 18:55:56 -05:00
Denis Kenzior 49abd4556f netdev: Remove device when netdev is freed 2016-06-24 23:17:06 -05:00
Denis Kenzior 105f5f8d8e netdev: Rearrange netdev structure
Keep flags co-located
2016-06-24 23:17:06 -05:00
Denis Kenzior e76daf224c netdev: Implement interface filtering 2016-06-23 17:34:47 -05:00
Denis Kenzior 0eee94a264 netdev: Fix some uninitialized warnings 2016-06-23 17:34:11 -05:00
Denis Kenzior cda2026b23 netdev: Actually set rekey_offload into eapol 2016-06-22 19:18:38 -05:00
Rahul Rahul 5853440dfa netdev: support for REKEY_OFFLOAD and its event handling 2016-06-22 18:44:46 -05:00
Denis Kenzior dc721a6ae2 netdev: Set callbacks for operstate
When setting operstate to dormant or down, give it a callback for debug
purposes.  It looks like that operstate down message does not have a
chance to go out currently.
2016-06-21 15:18:50 -05:00
Andrew Zaborowski b6c22fc1b9 netdev: netdev watch support 2016-06-21 14:08:21 -05:00
Andrew Zaborowski aa7a6a4619 netdev: Track interface UP flag 2016-06-21 14:08:19 -05:00
Denis Kenzior 0fe815f870 netdev: Move deauthenticate handling out of wiphy.c 2016-06-16 16:37:14 -05:00
Denis Kenzior 49c7515ac1 netdev: Move eapol_io handling 2016-06-16 16:37:12 -05:00
Denis Kenzior 75ce550de9 netdev: Move operstate operations out of wiphy.c
Also make netdev_set_linkmode_and_operstate static
2016-06-16 15:13:43 -05:00
Denis Kenzior dd4b0dc3d3 netdev: Move key setting logic out of wiphy.c 2016-06-16 15:13:43 -05:00
Denis Kenzior c714b20102 wiphy: Move handshake_failed handler out of wiphy.c 2016-06-16 15:13:43 -05:00
Denis Kenzior 64d382cc89 netdev: Move disconnect event handling
.. out of wiphy.c
2016-06-16 15:13:43 -05:00
Denis Kenzior 0eeb71e4eb netdev: Move CQM event handling out of wiphy.c 2016-06-16 15:13:43 -05:00
Denis Kenzior d526dbc175 netdev: Move associate event handling
.. out of wiphy.c
2016-06-16 15:13:39 -05:00
Denis Kenzior d82754636b netdev: Move deauthenticate event handling
.. out of wiphy.c
2016-06-15 14:02:24 -05:00
Denis Kenzior 31a0e42772 wiphy: Move association logic out of wiphy.c
The eapol state machine parameters are now built inside device.c when
the network connection is attempted.  The reason is that the device
object knows about network settings, wiphy constraints and should
contain the main 'management' logic.

netdev now manages the actual low-level process of building association
messages, detecting authentication events, etc.
2016-06-15 10:54:13 -05:00
Denis Kenzior d297fbb215 netdev: Add stubs for netdev_disconnect 2016-06-14 19:57:21 -05:00
Denis Kenzior 51f89e34e9 netdev: Add initial netdev_connect logic 2016-06-14 19:57:18 -05:00
Denis Kenzior d6c6e4acda netdev: Move netdev enumeration to netdev.c 2016-06-06 12:03:23 -05:00
Denis Kenzior 833ed20b9a netdev: Add netdev_get_name 2016-06-03 09:53:47 -05:00
Denis Kenzior 1573bf7d99 netdev: Add netdev_get_iftype 2016-06-03 09:53:47 -05:00
Denis Kenzior 1bd7baf44b netdev: Add netdev_find 2016-06-03 09:53:46 -05:00
Denis Kenzior 8e7829e1ab netdev: Add netdev_get_address 2016-06-03 09:53:46 -05:00
Denis Kenzior 7a3f823d26 netdev: Add netdev_get_ifindex 2016-06-03 09:53:46 -05:00
Denis Kenzior 7c359ee2c2 netdev: Add netdev struct definition 2016-06-03 09:53:46 -05:00
Denis Kenzior 61b50cf81f netdev: Parse NEW_INTERFACE and DEL_INTERFACE 2016-06-03 09:53:46 -05:00
Denis Kenzior e5821f6ade netdev: Remove unneeded comment 2016-06-03 09:53:46 -05:00
Denis Kenzior 280f2d40ad netdev: Make netdev_init accept nl80211 2016-06-03 09:53:46 -05:00
Denis Kenzior 3563c65111 netdev: Don't track NEWLINK & DELLINK
The plan is to use the much more reliable NEW_WIPHY, DEL_WIPHY,
NEW_INTERFACE, DEL_INTERFACE events.
2016-06-01 13:07:04 -05:00
Denis Kenzior e48ca5a5a6 wiphy: Rename netdev to device 2016-06-01 13:06:59 -05:00
Denis Kenzior f3fc0ea1f9 device: Refactor netdev watches
Turn netdev watches into device watches.  The intent is to refactor out
netdev specific details into its own class and move device specific
logic into device.c away from wiphy.c
2016-05-05 12:14:59 -05:00
Denis Kenzior 08decb340e netdev: Move rta_add_u8
Move closer to where it is used
2016-05-05 11:32:11 -05:00
Denis Kenzior e1bdd7ce1e netdev: Add netdev watch infrastructure 2015-09-28 20:37:08 -05:00
Jukka Rissanen 6dbd544a55 netdev: Add function to set the linkmode and operstate of the link
This is needed after connecting successfully to AP.
2015-03-27 13:13:33 -05:00
Marcel Holtmann b7a421673c core: Add sanity check to sync RTNL link deletion with nl80211 2014-08-06 23:52:42 -07:00
Marcel Holtmann af2bb68e07 core: Only enable RTNL debugging when IWD_RTNL_DEBUG is set 2014-08-07 05:28:58 +02:00
Marcel Holtmann 188917cc29 core: Add missing include for network interface tracking 2014-06-21 20:54:58 +02:00
Marcel Holtmann 37cba460a8 core: Add tracking of network interfaces via RTNL 2014-06-21 13:41:40 +02:00