todo: remove ADSL item
[NetworkManager.git] / TODO
1 So you're interested in hacking on NetworkManager?  Here's some cool
2 stuff you could do...
3
4 * Internet Connectivity Detection Enhancements
5
6 Current connectivity checking is global, while what we really want is to check
7 connectivity per-interface and update the global state based on the composite
8 of each device's state.  Unfortunately that requires two things:
9
10 1) latest libsoup and glib for using libsoup connection state signals, which
11    allow us to set socket options before the actual connection is made; here
12    we'd bind the socket to the specific IP address of the interface we're
13    using, and possibly set SO_BINDTODEVICE as well
14 2) setting /proc/sys/net/ipv4/conf/<iface>/rp_filter to "2" which tells the
15    kernel to route the incoming and outgoing packet properly even though the
16    interface may not have the necessary routes
17
18 The first is the largest obstacle, but ideally we implement this and enable it
19 when we have the required glib and libsoup versions available.  One other
20 complication is that this checking should be done during the
21 NM_DEVICE_STATE_IP_CHECK phase (along with other operations like WiFi hotspot
22 auto-login) while the current checks are done globally in nm-manager.c, so 
23 keeping both code paths might be complex.
24
25 But ideally, once the device has successfully gotten an IPv4 or IPv6 address, it
26 should enter the state NM_DEVICE_STATE_IP_CHECK, where a connectivity check is
27 started.  After the check returns, the device would set a property in
28 NMDevicePrivate to indicate whether Internet access was successful or not, and
29 advance to the NM_DEVICE_STATE_ACTIVATED state.
30
31 The NMManager object, when determining the overall NM_STATE_* state in the
32 nm_manager_update_state() function, would query this property and set
33 NM_STATE_CONNECTED_LOCAL, NM_STATE_CONNECTED_SITE, or NM_STATE_CONNECTED_GLOBAL
34 based on it and the device's state.
35
36
37 * Real Access Point mode support
38
39 Now that NetworkManager requires wpa_supplicant 0.7.x or later, we can add
40 full Access Point (AP) mode support.  NetworkManager currently implements
41 connection sharing via AdHoc mode support, which has some limitations.  Instead,
42 we should check whether the wifi device supports AP mode, and if so, use
43 that mode instead.  wpa_supplicant has support for a "lightweight AP" mode which
44 we should use.  Witold Sowa started this support a while ago and wrote the new
45 D-Bus API for wpa_supplicant that makes all this possible, but some NM pieces
46 are still missing.  If the wifi driver supports AP mode, then in
47 src/supplicant-manager/ NM should send an AP-mode config instead of sending
48 the adhoc config.
49
50 Note that some devices (airo, ipw2100, ipw2200, iwl3945, iwl4965, atmel, zd1201)
51 will never support AP mode due to firmware limitations, so we clearly must still
52 provide Ad-Hoc connection sharing support for those devices and switch between
53 Ad-Hoc and AP mode depending on device capabilities.
54
55
56 * On-Demand WiFi Scan support
57
58 Single-user and embedded devices often use a continuous wifi scan when the
59 networking configuration interface is open to quickly allow users to find their
60 wifi network.  NM periodically scans, but this could take as long as 2 mintues
61 to update the list.  Note that WiFi scans require 2 - 10 seconds to complete,
62 and during this time normal traffic (video, VOIP, streaming music, downloads,
63 etc) is not transmitted, so a WiFi scan is a disruptive operation to the user.
64
65 A D-Bus method should be added to the NMDeviceWifi device to allow user
66 applications to request a scan.  This request should be rate-limited to no
67 more than once every 10 seconds to give time for traffic to resume when the
68 scan is done, and to lessen the effect of any DDoS by malicious user
69 applications.  This request should also be restricted by one or more PolicyKit
70 permissions like org.freedesktop.NetworkManager.network-control.
71
72 To begin, a new method definition should be added to the
73 introspection/nm-device-wifi.xml for a method called "RequestScan" which takes
74 an argument called "options" of type of "a{sv}".  This argument will be used
75 later.  An annotation (like the other functions have) should be added so that
76 the method will be called "impl_device_request_scan".
77
78 Next, the corresponding method implementation should be added to
79 src/nm-device-wifi.c by adding the prototype for impl_device_request_scan
80 near the top of the file, and implementing it below.  The implementation will
81 recieve a GHashTable corresponding to the "a{sv}" argument list from the XML
82 file, but we can ignore that for now.
83
84 The incoming request should be authenticated using nm_auth_get_caller_uid()
85 and additionally starting a PolicyKit authentication check with
86 with nm_auth_chain_new().  See the function manager_device_disconnect_request()
87 in src/nm-manager.c for an example of this.
88
89 Only after the caller is authorized to scan should the request be checked
90 against the last scan timestamp, and if the last scan was 10 seconds or more
91 ago, a new scan should be requested.
92
93
94 * Reconnect to WiFi Networks Only If They Succeeded Once
95
96 Currently, NetworkManager will attempt to connect to a previously attempted
97 WiFi network even if that network was never successfully connected to.  This
98 causes confusion because sometimes users will randomly try various WiFi networks
99 hoping to find an open AP, and then wonder why NM tries to reconnect to any of
100 those APs later when none of them worked originally due to AP-side MAC filtering
101 or other failures.  What should happen is that NetworkManager should set a flag
102 on a connection when that connection is successfully connected at least once,
103 and only autoconnect the wifi network if that flag is present *and* the
104 NMSettingConnection's 'autoconnect' property is TRUE.
105
106 This is a bit tricky because we want to consider all connections that don't have
107 this flag as having succeeded so that we don't break users' existing connections,
108 while holding all newly created connections to this policy.  This flag should
109 be determined and set for all connections, even if we only use it to determine
110 WiFi behavior for now.
111
112 This flag should be a new gboolean property on the NMSettingConnection object
113 called "connect-success", with a default value of TRUE.  It should default to
114 TRUE to ensure that existing connections are assumed to have connected
115 successfully in the past.  New connections created via the AddConnection and
116 AddAndActivateConnection D-Bus method calls should have the 'connect-success'
117 property explicitly set to FALSE.  Then, in nm-device.c's device_state_changed()
118 function where the NM_DEVICE_STATE_ACTIVATED state is handled, the
119 'connect-success' property should be set to TRUE.
120
121 For WiFi then, in nm-device-wifi.c's get_best_auto_connection() method, the
122 'connect-success' property should be checked and if it is FALSE, the connection
123 is not considered for auto-activation.
124
125
126 * Implement NM_DEVICE_STATE_DISCONNECTING
127
128 To allow for "pre-down" scenarios, this state should be implemented before a
129 device is taken down while it still has connectivity.  If the device is
130 taken down because it's ethernet carrier was dropped, or because the WiFi
131 connection was terminated by the supplicant, this state is pointless and should
132 be skipped.  But if the user requested a manual "disconnect", or NM is dropping
133 connections on exit, etc, then this state should be entered.  In the future
134 this state should hook into a new dispatcher action in src/NetworkManagerUtils.c
135 to exectue dispatcher scripts during the disconnection, and to wait a limited
136 amount of time for each script to complete before allowing the device to
137 proceed to the NM_DEVICE_STATE_DISCONNECTED state, fully implementing pre-down.
138
139
140 * Ethernet Network Auto-detection
141
142 There are various methods we can use to autodetect which wired network connection
143 to use if the user connects to more than one wired network on a frequent basis.
144 First, 802.1x enterprise switches broadcast frames which can be used to indicate
145 that the switch supports 802.1x and thus allow NetworkManager to select an
146 802.1x connection instead of blindly trying DHCP.  Second, NetworkManager could
147 listen for traffic from a list of MAC addresses.  Third, NetworkManager could
148 integrate 'arping' functionality to determine if a given IP address matches a
149 given MAC address, and thus automatically select that connection.  All these
150 methods can co-exist and be used in parallel.
151
152 One small caveat is that MAC addresses are trivial to spoof, so just because
153 NetworkManager has discovered a certain MAC address does not mean the network
154 is authenticated; only 802.1x security can assure that a network is the network
155 the user expects it to be.
156
157 In any case, a new 'anchor-addresses' property of type string-array should be
158 added to the NMSettingWired setting.  Each string element of this property
159 should be of the format "<ip>/<mac>" or simply "<mac>".  The first format with
160 an IP address would indicate that "arping"-type behavior should be used to
161 actively detect the given MAC address; obviously if the given MAC address is
162 used for passive discovery as well.  The second format simply lists a MAC
163 address to passively listen for.
164
165 One drawback of listening or probing for known MAC addresses is an increase in
166 latency during connections to ethernet networks.  The probing/listening delay
167 should be a reasonable amount of time, like 4 - 5 seconds or so, and should
168 only be used when a visible connection has anchor addresses.
169
170 Next a gboolean 'anchor-probing' variable should be added to the
171 NMDeviceEthernetPrivate structure in src/nm-device-ethernet.c.  This variable
172 should be set to TRUE whenever the device's carrier turns on *and* there are
173 visible NMConnections with anchor addresses (ie, connections which are system-
174 wide or where one of the allowed users of that connection is logged in).  Then
175 probing and listening are started, which involves opening a low-level socket
176 on the interface and starting the arping run or listening for MAC addresses.
177 A timer is also started (don't forget to cache the timer's source ID in the
178 NMDeviceEthernetPrivate data, and to cancel the timer whenever the device
179 transitions to any state other than DISCONNECTED).
180
181 If a known MAC address is discovered as a result of probing or listening, the
182 probe/listen socket, timeout, and data are cleaned up, and NetworkManager
183 would begin activation of the NMConnection that specified the found MAC address
184 in the 'anchor-addresses' property.  If two or more connections specify the
185 same MAC address, the connection with the most recent timestamp should be
186 preferred.
187
188 Similarly, if the probing/listening process detects 802.1x frames the device
189 should be marked as requring 802.1x authentication until the carrier drops.
190 This would be accomplished by adding a new property to the NMDeviceEthernet
191 object and exporting that property through the
192 introspection/nm-device-ethernet.xml file.  This would allow clients like
193 applets to ensure that users are aware that the device will not allow
194 un-authenticated connections and that additional credentials are required to
195 successfully connect to this network.
196
197
198 * VPN re-connect
199
200 NM should remember whether a VPN was connected if a connection disconnects
201 (like WiFi drops out or short carrier drop) or if the laptop goes to sleep.
202 Upon reconnect, if the same Connection is again active, the previously
203 connected VPN should be activated again as well.  Basically, don't just drop
204 the VPN because WiFi choked for 10 seconds, but reconnect the VPN if it was
205 connected before the drop.
206
207
208 * VPN autoconnect
209
210 We should add a property to the NMSettingConnection object in
211 libnm-util/nm-setting-connection.c called "vpns" that is a string list,
212 containing a list of Connection UUIDs that should be activated when the base
213 connection itself is activated.  This will allow a VPN connection to be
214 started every time another connection is started, so that if you choose you're
215 always on the VPN in your favorite coffee shop.
216
217 The NM_DEVICE_STATE_SECONDARIES state was added specifically for cases like
218 this.  Thus, after the base device has IP connectivity, but before it has
219 signaled that it's fully activated, the device should enter the SECONDARIES
220 state and kick off activation of the given VPN connection.  Only after this
221 VPN connection has successfully connected should the base device to the
222 NM_DEVICE_STATE_ACTIVATED state.
223
224
225 * VPN and IPv6
226
227 The internal VPN capability should support IPv6.  Essentially, the D-Bus
228 interface between NetworkManager and the VPN service daemons should be extended
229 with an IP6Config signal that passes up the IPv6 addressing and routing details
230 if the VPN daemon is IPv6 capable.  NM should then process those details like it
231 does with IPv4.  include/NetworkManagerVPN.h should be updated with key/value
232 pairs defining the various IPv6 attributes much like the IPv4 ones are defined.
233
234
235 * VPN IP Methods
236
237 Some VPNs (openvpn with TAP for example) require that DHCP is run on a
238 pseudo-ethernet device to obtain addressing information.  This is not currently
239 possible, but NM already has all the code for DHCP.  Thus, a new "method"
240 key should be defined in include/NetworkManagerVPN.h to allow for DHCP to
241 be performed if the VPN service daemon requests it in the IP4Config or IP6Config
242 signals.  A patch here:
243
244 http://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?h=vpn-ip-method
245
246 shows that.  In nm-vpn-connection.c, upon receipt of the D-Bus Ip4Config signal
247 from the VPN plugin, NetworkManager would inspect the "method" property of the
248 ip4 config dictionary.  If that property was present and set to "auto" then
249 DHCP would be started using the network interface returned in the dict.  The
250 nm_vpn_connection_ip4_config_get() function should be split up into two
251 functions, one containing the existing code for static configuration, and a
252 second for handling DHCP kickoff.  Minimal parsing of the response should be
253 handled in the newly reduced nm_vpn_connection_ip4_config_get() function.
254
255 To handle DHCP, the NMVPNConnectionPrivate structure should have two members
256 added:
257
258     NMDHCPManager *dhcp_manager;
259     NMDHCPClient  *dhcp4_client;
260
261 which would be initialized in the new DHCP handler code split off from
262 nm_vpn_connection_ip4_config_get().  These new members would be disposed of in
263 both vpn_cleanup() and dispose(), though remember to stop any ongoing DHCP
264 transaction when doing so (see dhcp4_cleanup() in nm-device.c for example code).
265 For basic code to start the DHCP transaction, see dhcp4_start() in nm-device.c
266 as well.  After calling nm_dhcp_manager_start_ip4() and connecting the signals
267 to monitor success and failure, the VPN IP4 config handler would simply return
268 without changing VPN state, unless a failure occurred.
269
270 Then, when the DHCP transaction succeeds, which we'd know by checking the
271 DHCP client state changes in the "state-changed" signal handler we attached to
272 the DHCP client object returned from nm_dhcp_manager_start_ip4(), the code
273 would retrieve the completed NMIP4Config object from the DHCP client using the
274 nm_dhcp_client_get_ip4_config() function, and then proceed to execute
275 essentially the bottom-half of the existing nm_vpn_connection_ip4_config_get()
276 function to merge that config with user overrides and apply it to the VPN
277 tunnel interface.  Other state changes from the DHCP client might trigger a
278 failure of the VPN connection, just like DHCP timeouts and lease-renewal
279 failures do for other devices (see dhcp_state_changed() in nm-device.c).
280
281
282 * VPN Service Daemon Secret Requests
283
284 In addition to NM asking the service daemons whether more secrets are required,
285 VPN service daemons (like nm-vpnc-service, nm-openvpn-service, etc) should be
286 able to ask NetworkManager to provide secrets during the connection attempt. To
287 do this, the plugin should advertise its ability to handle out-of-band secrets
288 in its .service file via the key 'async-secrets=true'.  NetworkManager would
289 check that key and if present activate the VPN as normal, but skip the explicit
290 NeedSecrets calls.
291
292 Instead, a new "SecretsRequired" signal would be added to
293 introspection/nm-vpn-plugin.xml (and corresponding helper code added to
294 libnm-glib/nm-vpn-plugin.c) that would be emitted when the plugin determined
295 that secrets were required.  This signal would have D-Bus signature of "sas"
296 for the arguments [ <s:uuid>, <as:secrets> ] with the <uuid> obviously being
297 the connection UUID, and <secrets> being an array of strings of plugin-specific
298 strings the plugin requires secrets for.  This array of strings would then be
299 passed as the "hints" parameter in nm-vpn-connection.c when secrets are
300 requested from agents in a subsequent nm_settings_connection_get_secrets() call.
301 At this time the agent code only allows one hint per request, so we may need to
302 extend that to allow more than one hint.
303
304 Thus when connecting if the plugin supported async secrets NetworkManager would
305 still request existing secrets (without interactivity) and send them to the
306 VPN service daemon in the Connect D-Bus method, then wait for the service daemon
307 to either request secrets asynchronously via the SecretsRequired signal or to
308 signal successful connection via the Ip4Config signal.
309
310 The vpnc plugin would need to be reworked to open a pipe to vpnc's stdout and
311 stdin file descriptors to capture any authentication messages, and to match
312 these messages to known secrets request strings.  When receiving one of these
313 strings the plugin would determine which secret was being requested and then
314 emit the SecretsRequired signal to NetworkManager.  This would also imply that
315 nm-vpnc-service exectutes vpnc with the "--xauth-inter" argument to enable
316 challenge-response and does not use the "--non-inter" flag which suppresses that
317 behavior.
318
319
320 * WPS
321
322 wpa_supplicant has support for WPS (Wifi Protected Setup, basically Bluetooth-
323 like PIN codes for setting up a wifi connection) and we should add support for
324 this to NetworkManager too.  APs that support WPS will say so in their beacon
325 IEs which are contained in the "WPA" and "RSN" properties of the BSS object
326 exported by the supplicant, and can be processed in src/nm-wifi-ap.c's
327 foreach_property_cb() function.  We should add some private fields to the
328 NMAccessPoint object (defined in nm-wifi-ap.c) to remember whether a specific
329 AP supports WPS and what WPS methods it supports, and expose that over D-Bus to
330 GUI clients as well.
331
332 There are two common WPS setup methods: PIN and button.  For PIN, the router
333 either displays a random PIN on an LCD or the router's web UI, or a static PIN
334 is printed on the router itself.  The user enters that PIN instead of a PSK
335 when connecting.  For the "button" method, the router has a physical button that
336 when pushed, allows any client to connect for a short period of time.
337
338 We'll then need to add some properties to the NMSettingWirelessSecurity setting
339 for the WPS PIN code so that when the user enters it through the GUI, it can
340 be passed back to NM.  And we'll need to figure out some mechanism for passing
341 back an indication that the user pushed the button on the router for the
342 pushbutton method.
343
344 When connecting to a new access point that supports WPS, the GUI client would
345 call the AddAndActivateConnection method and wait for NM to request secrets.
346 NM would determine that the AP supports WPS, and request WPS secrets from the
347 applet.  The applet would ask the user for a PIN, or to push the button on the
348 AP, instead of asking for a passphrase or PSK.  When the user has entered the
349 PIN or pushed the button, the applet returns this information to NM, which
350 proceeds with the connection.
351
352 NM sends the correct wpa_supplicant config for WPS to the supplicant, and waits
353 for the connection to occur.  WPS can only be used the *first* time, so after a
354 first successfull connection, NM must request the actual hexadecimal PSK from 
355 wpa_supplicant via D-Bus, and store that PSK in the connection, clear any WPS
356 PIN code from the connection, and save the connection to backing storage.
357
358 Any applet GUI should also allow the user to enter the PSK instead of completing
359 association using WPS, since quite a few routers out there are broken, or
360 because the user has no physical access to the router itself, but has been given
361 as passphrase/PSK instead.
362
363
364 * Proxies
365
366 HTTP and other proxies are per-connection configuration.  It's highly unlikely
367 that the same proxy you need to use at work is used at home or in a coffee shop.
368 Thus, it makes sense that which proxy settings to use should be updated when
369 network connections change.  NetworkManager is a perfect place to do this since
370 it tracks which network connections are active, and it already queries the
371 network for automatic proxy configuration via DHCP and WPAD.
372
373 We should add a new NMSetting subclass called NMSettingProxy that holds
374 necessary proxy configuration.  The properties of this setting should be a
375 superset of what is provided in the Firefox proxy configuration screen and the
376 various desktop environment proxy configuration tools like the GNOME Network
377 Proxy control panel; this should include at a minimum:
378
379   method: "auto", "manual", "none"
380   default-proxy: string
381   default-proxy-port: uint
382   default-always: boolean (use default proxy for all protocols)
383   ssl-proxy: string
384   ssl-proxy-port: uint
385   ftp-proxy: string
386   ftp-proxy-port: uint
387   socks-proxy: string
388   socks-proxy-port: uint
389   socks-version: uint, either 4 or 5
390   no-proxy-for: array of strings (things not to use the proxy for, ie ".foobar.com",
391                  "192.168.0.1/24", an IPv6 address, etc)
392   pac-url: string (URL of PAC file, overrides DHCP-provided WPAD value)
393   (FIXME: proxy authentication?  do we need separate user/pass properties for
394     each protocol type?  should NM handle proxy auth or should it be punted
395     to each application?)
396
397 After completing IP configuration but still during the NM_DEVICE_STATE_IP_CONFIG
398 activation stage, NetworkManager would merge the automatically supplied proxy
399 configuration (from DHCP's WPAD option) with user-provided overrides from the
400 NMSettingProxy and send the results to the system.  The 'default' connection's
401 proxy configuration would be preferred, so we'd have to update proxy
402 configuration from nm-policy.c the same time we update DNS information and the
403 default route.
404
405 The merged proxy configuration would then be sent to the system.  There is no
406 canonical proxy daemon in-use, so we should have plugins (if not separate
407 shared libraries, then certainly encapsulated source files that implement a
408 common glib GInterface or are subclasses of eg a parent NMProxyHandler class)
409 that handle different system proxy handlers.  Some of the proxy handlers are:
410
411   libproxy: need to figure out how it gets proxy info and have NM write merged
412              proxy config out to that location
413   pacrunner: a D-Bus enabled daemon, NM would call D-Bus methods of the
414                pacrunner service with the proxy information
415   GNOME/KDE: how do these desktop environments retrieve proxy configuration?
416
417
418 * Better Tablet/Mobile Behavior
419
420 There are a few components to this:
421
422 1) kernel driver and hardware capabilities: most mobile devices use periodic
423 background scanning to quickly determine whether a known SSID is available and
424 notify the connection manager to connect to it.  This typically requires special
425 capabilities and good powersave/sleep support from the WiFi kernel driver.
426 There is a background scanning API in nl80211, but we need to determine how many
427 SSIDs each driver allows for background scanning, and based on that number, give
428 the driver the most recent N SSIDs.  We still need to periodically wake the
429 device up and do a full scan just in case the user is near a known SSID that was
430 not in the N top recently used networks.  This is also beneficial to normal
431 desktop use-cases.
432
433 wpa_supplicant doesn't currently provide an explicit interface for sending SSIDs
434 to the driver for background scanning, but could simply send a list using
435 configured networks.  However, NM currently does not send *all* configured
436 connections' SSIDs to the supplicant, so that's something we should do first
437 to optimize connection times.  To do this, NM would need to order all networks
438 using the NM timestamp and convert that into a supplicant priority number, which
439 would need to be adjusted periodically when the timestamp was updated.  This
440 would involve tracking each network (exposed by the supplicant as a D-Bus
441 object) and making sure they were added, deleted, and updated when the backing
442 NMConnection objects changed.  One complication is that the supplicant
443 requires secrets for various network types when the network is added via D-Bus,
444 and NetworkManager might not have those secrets yet.  We may need to modify
445 the supplicant allow for *all* secrets (PSKs, WEP keys, etc) to be requested
446 on-demand, not just EAP secrets like 802.1x passwords.  We then need to fix
447 up the supplicant's D-Bus interface to actually send requests for secrets out
448 over D-Bus (like wpa_supplicant_eap_param_needed() does for the socket-based
449 control interface) and to handle the resulting reply from a D-Bus client like
450 wpa_supplicant_ctrl_iface_ctrl_rsp() does.
451
452 With the secrets request stuff and priority handling in place, wpa_supplicant
453 would control network selection and roaming (based on the priorities NM gave it
454 of course) instead of NetworkManager itself, and hopefully lead to a faster WiFi
455 connection process.
456
457 2) single-device-at-a-time with overlapping connections: this is also probably
458 the best route to go for desktop use-cases as well.  Instead of bringing all
459 available connections up, only bring up the "best" connection at any given
460 time based on the current priority list (which is rougly Ethernet > WiFi >
461 3G/Bluetooth/WiMAX).  However, to ensure seamless connectivity, when one
462 connection begins to degrade, the next-best connection should be started before
463 the current one is terminated, such that there is a small amount of overlap.
464 Consequently the same behavior should be used when a better connection becomes
465 available.  This behavior should be suspended when special connections like
466 Internet Connection Sharing ones are started, where clearly the priorities
467 are different (ie, for Mobile Hotspot 3G > WiFi).