Commit Graph

67 Commits

Author SHA1 Message Date
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