]> git.pld-linux.org Git - packages/NetworkManager.git/blob - NetworkManager-branch.diff
- fixes lots of bugs
[packages/NetworkManager.git] / NetworkManager-branch.diff
1 diff -urN NetworkManager/ChangeLog NetworkManager-SVN/ChangeLog
2 --- NetworkManager/ChangeLog    2007-09-08 00:09:05.000000000 +0200
3 +++ NetworkManager-SVN/ChangeLog        2007-09-08 00:07:08.000000000 +0200
4 @@ -1,3 +1,104 @@
5 +2007-08-30  Dan Williams  <dcbw@redhat.com>
6 +
7 +       * libnm-util/sha1.c
8 +               - Include config.h to get defines for endiannes (gnome.org #420216)
9 +
10 +2007-07-26  Dan Williams  <dcbw@redhat.com>
11 +
12 +       Patch from Bernhard Miklautz <bernhard.miklautz@shacknet.at>
13 +
14 +       * src/NetworkManagerSystem.c
15 +               - (nm_system_device_set_ip4_route): don't add the route if it's on the
16 +                       same subnet (#437396)
17 +
18 +2007-07-26  Dan Williams  <dcbw@redhat.com>
19 +
20 +       * src/nm-device-802-11-wireless.c
21 +               - (real_start): I hate orinoco; apparently has trouble scanning too soon
22 +                       after being brought up, so do the initial scan a bit later.
23 +
24 +2007-06-27  Dan Williams  <dcbw@redhat.com>
25 +
26 +       * src/NetworkManager.c
27 +               - (nm_hal_init): set hardware RF to enabled if no killswitches are found
28 +                       after the initial discovery
29 +
30 +2007-06-21  Dan Williams  <dcbw@redhat.com>
31 +
32 +       More fixes for Fedora #194124, gnome.org #354565
33 +
34 +       * src/nm-device-802-3-ethernet.c
35 +               - (real_act_stage1_prepare): new function; fail activation if device
36 +                       doesn't have a link
37 +
38 +       * src/NetworkManagerPolicy.c
39 +               - (nm_policy_activation_finish): ensure device is actually activated
40 +                       before sending out signals.  Fixes a race where device cancellation
41 +                       would be processed right after finish was scheduled, but not run.
42 +               - (nm_policy_device_change_check, nm_policy_schedule_device_change_check):
43 +                       ensure device change check GSource ID is locked across threads;
44 +                       allow interruption of activation of 802.3 ethernet devices that no
45 +                       longer have an active link, and ensure that 802.3 ethernet devices
46 +                       have an active link before starting activation
47 +
48 +2007-06-21  Dan Williams  <dcbw@redhat.com>
49 +
50 +       Add HAL-based rfkill support, based on a patch from Benjamin Kahn.
51 +
52 +       * src/NetworkManagerDbus.[ch]
53 +               - (nm_dbus_signal_wireless_enabled): new function, emit signals when
54 +                       wireless enabled status changes
55 +
56 +       * src/nm-dbus-nm.c
57 +               - (nm_dbus_nm_set_wireless_enabled): handle hardware rfkill correctly;
58 +                       send errors when hardware switch overrides user request, and send
59 +                       signals when wireless enabled state changes
60 +               - (nm_dbus_nm_get_wireless_enabled): send additional 'hardware rf enabled'
61 +                       argument in method reply
62 +
63 +       * src/NetworkManager.c
64 +               - (handle_killswitch_pcall_done, nm_killswitch_getpower_reply_cb,
65 +                  nm_poll_killswitches, nm_add_killswitch_device,
66 +                  nm_add_initial_killswitch_devices): new functions; detect and handle
67 +                       hardware killswitches exported by HAL.  Unfortunately we have to
68 +                       poll the switches because HAL doesn't support signals for killswitches
69 +                       yet.
70 +               - (nm_hal_device_new_capability): detect killswitches added asynchronously
71 +               - (nm_hal_init): look for killswitches when connecting to HAL
72 +               - (nm_hal_deinit): dispose of killswitches when deiniting HAL data
73 +
74 +       * src/NetworkManagerMain.h
75 +               - Add bits to track killswitches
76 +
77 +2007-06-12  Dan Williams  <dcbw@redhat.com>
78 +
79 +       * src/nm-device.c
80 +               - (real_act_stage3_ip_config_start): sometimes the device gets downed
81 +                       during the wpa_supplicant association.  Ensure the device is up
82 +                       before it's used for IP configuration.
83 +
84 +2007-06-07  Dan Williams  <dcbw@redhat.com>
85 +
86 +       Patch from Jon Nettleton <jon.nettleton@gmail.com>
87 +
88 +       * src/nm-device-802-11-wireless.c:
89 +               - (real_act_stage2_config): sleep 1 second to allow link status
90 +               to stabilize
91 +
92 +2007-06-07  Dan Williams  <dcbw@redhat.com>
93 +
94 +       * (nm_device_802_3_ethernet_link_activated,
95 +          nm_device_802_3_ethernet_link_deactivated): fix ethernet link detection
96 +               behavior due to races between the netlink code and when the
97 +               device thread recognizes the change.  Checking the link state
98 +               before scheduling the change even on the device thread is wrong.
99 +               (gnome.org #354565, rh #194124)
100 +
101 +2007-04-25  Dan Williams  <dcbw@redhat.com>
102 +
103 +       * initscript/RedHat/NetworkManager.in: remove trailing backslash
104 +               (gnome.org #432401)
105 +
106  2007-04-18  Tambet Ingo  <tambet@ximian.com>
107  
108         * src/nm-dbus-nmi.c (nm_dbus_get_user_key_for_network_cb): Update the security
109 diff -urN NetworkManager/libnm-util/sha1.c NetworkManager-SVN/libnm-util/sha1.c
110 --- NetworkManager/libnm-util/sha1.c    2007-09-08 00:09:05.000000000 +0200
111 +++ NetworkManager-SVN/libnm-util/sha1.c        2007-09-08 00:07:00.000000000 +0200
112 @@ -12,6 +12,10 @@
113   * See README and COPYING for more details.
114   */
115  
116 +#ifdef HAVE_CONFIG_H
117 +#include <config.h>
118 +#endif
119 +
120  #include <stdlib.h>
121  #include <string.h>
122  
123 diff -urN NetworkManager/src/NetworkManager.c NetworkManager-SVN/src/NetworkManager.c
124 --- NetworkManager/src/NetworkManager.c 2007-09-08 00:09:05.000000000 +0200
125 +++ NetworkManager-SVN/src/NetworkManager.c     2007-09-08 00:06:44.000000000 +0200
126 @@ -67,6 +67,7 @@
127  
128  static gboolean sigterm_pipe_handler (GIOChannel *src, GIOCondition condition, gpointer data);
129  static void nm_data_free (NMData *data);
130 +static gboolean nm_poll_killswitches(gpointer user_data);
131  
132  /*
133   * nm_get_device_interface_from_hal
134 @@ -274,6 +275,183 @@
135  }
136  
137  
138 +static void handle_killswitch_pcall_done (NMData *data, DBusPendingCall * pcall)
139 +{
140 +       GSource * source;
141 +       gboolean now_enabled = FALSE;
142 +       gboolean now_disabled = FALSE;
143 +
144 +       data->ks_pcall_list = g_slist_remove (data->ks_pcall_list, pcall);
145 +       if (g_slist_length (data->ks_pcall_list) > 0)
146 +               return;  /* not done with all killswitches yet */
147 +
148 +       if (data->hw_rf_enabled != data->tmp_hw_rf_enabled) {
149 +               nm_info ("Wireless now %s by radio killswitch",
150 +                        data->tmp_hw_rf_enabled ? "enabled" : "disabled");
151 +               if (data->tmp_hw_rf_enabled)
152 +                       now_enabled = TRUE;
153 +               else
154 +                       now_disabled = TRUE;
155 +
156 +               data->hw_rf_enabled = data->tmp_hw_rf_enabled;
157 +       }
158 +
159 +       if (data->hw_rf_enabled == data->wireless_enabled)
160 +               goto out;
161 +
162 +       /* Only re-enabled wireless if killswitch just changed, otherwise
163 +        * ignore hardware rf enabled state.
164 +        */
165 +       if (now_enabled && !data->wireless_enabled) {
166 +               data->wireless_enabled = TRUE;
167 +               nm_policy_schedule_device_change_check (data);
168 +               nm_dbus_signal_wireless_enabled (data);
169 +       } else if (!data->hw_rf_enabled && data->wireless_enabled) {
170 +               GSList * elt;
171 +
172 +               /* Deactivate all wireless devices and force them down so they
173 +                * turn off their radios.
174 +                */
175 +               nm_lock_mutex (data->dev_list_mutex, __FUNCTION__);
176 +               for (elt = data->dev_list; elt; elt = g_slist_next (elt)) {
177 +                       NMDevice * dev = (NMDevice *) elt->data;
178 +                       if (nm_device_is_802_11_wireless (dev)) {
179 +                               nm_device_deactivate (dev);
180 +                               nm_device_bring_down (dev);
181 +                       }
182 +               }
183 +               nm_unlock_mutex (data->dev_list_mutex, __FUNCTION__);
184 +
185 +               data->wireless_enabled = FALSE;
186 +               nm_policy_schedule_device_change_check (data);
187 +               nm_dbus_signal_wireless_enabled (data);
188 +       }
189 +
190 +out:
191 +       /* Schedule another killswitch poll */
192 +       source = g_timeout_source_new (6000);
193 +       g_source_set_callback (source, nm_poll_killswitches, data, NULL);
194 +       g_source_attach (source, data->main_context);
195 +       g_source_unref (source);
196 +}
197 +
198 +static void nm_killswitch_getpower_reply_cb (DBusPendingCall *pcall, NMData * data)
199 +{
200 +       DBusError               err;
201 +       DBusMessage *   reply = NULL;
202 +       guint32                 status;
203 +
204 +       g_return_if_fail (pcall != NULL);
205 +       g_return_if_fail (data != NULL);
206 +
207 +       if (!dbus_pending_call_get_completed (pcall))
208 +               goto out;
209 +
210 +       if (!(reply = dbus_pending_call_steal_reply (pcall)))
211 +               goto out;
212 +
213 +       if (message_is_error (reply)) {
214 +               dbus_error_init (&err);
215 +               dbus_set_error_from_message (&err, reply);
216 +               nm_info ("Error getting killswitch power: %s - %s", err.name, err.message);
217 +               dbus_error_free (&err);
218 +               goto out;
219 +       }
220 +
221 +       if (!dbus_message_get_args (reply, &err, DBUS_TYPE_UINT32, &status, DBUS_TYPE_INVALID)) {
222 +               nm_info ("Error getting killswitch power arguments: %s - %s", err.name, err.message);
223 +               dbus_error_free (&err);
224 +               goto out;
225 +       }
226 +
227 +       if (status == 0)
228 +               data->tmp_hw_rf_enabled = FALSE;
229 +
230 +out:
231 +       if (reply)
232 +               dbus_message_unref (reply);
233 +
234 +       handle_killswitch_pcall_done (data, pcall);
235 +       dbus_pending_call_unref (pcall);
236 +}
237 +
238 +
239 +static gboolean nm_poll_killswitches (gpointer user_data)
240 +{
241 +       NMData * data = (NMData *) user_data;
242 +       DBusConnection * connection = data->dbus_connection;
243 +       GSList * elt;
244 +
245 +       g_return_val_if_fail (data != NULL, FALSE);
246 +
247 +       data->tmp_hw_rf_enabled = TRUE;
248 +
249 +       for (elt = data->killswitch_list; elt; elt = g_slist_next (elt))
250 +       {
251 +               DBusPendingCall * pcall;
252 +               DBusMessage * message;
253 +
254 +               message = dbus_message_new_method_call ("org.freedesktop.Hal",
255 +                                                       elt->data,
256 +                                                       "org.freedesktop.Hal.Device.KillSwitch",
257 +                                                       "GetPower");
258 +               if (!dbus_connection_send_with_reply (connection, message, &pcall, 5000)) {
259 +                       nm_warning ("%s(): could not send dbus message", __func__);
260 +               } else if (!pcall) {
261 +                       nm_warning ("%s(): could not send dbus message; pcall was NULL", __func__);
262 +               } else {
263 +                       dbus_pending_call_set_notify (pcall,
264 +                                                     (DBusPendingCallNotifyFunction) nm_killswitch_getpower_reply_cb,
265 +                                                     data,
266 +                                                     NULL);
267 +                       data->ks_pcall_list = g_slist_append (data->ks_pcall_list, pcall);
268 +               }
269 +               dbus_message_unref (message);
270 +       }
271 +       return FALSE;
272 +}
273 +
274 +
275 +/*
276 + * nm_add_killswitch_device
277 + *
278 + * Adds a killswitch device to the list
279 + *
280 + */
281 +static void nm_add_killswitch_device (NMData * data, const char * udi)
282 +{
283 +       char * type;
284 +       GSList * elt;
285 +
286 +       type = libhal_device_get_property_string (data->hal_ctx, udi, "killswitch.type", NULL);
287 +       if (!type)
288 +               return;
289 +
290 +       if (strcmp (type, "wlan") != 0)
291 +               goto out;
292 +
293 +       /* see if it's already in the list */
294 +       for (elt = data->killswitch_list; elt; elt = g_slist_next (elt)) {
295 +               const char * list_udi = (const char *) elt->data;
296 +               if (strcmp (list_udi, udi) == 0)
297 +                       goto out;
298 +       }
299 +
300 +       /* Start polling switches if this is the first switch we've found */
301 +       if (g_slist_length (data->killswitch_list) == 0) {
302 +               GSource * source = g_idle_source_new ();
303 +               g_source_set_callback (source, nm_poll_killswitches, data, NULL);
304 +               g_source_attach (source, data->main_context);
305 +               g_source_unref (source);
306 +       }
307 +
308 +       data->killswitch_list = g_slist_append (data->killswitch_list, g_strdup (udi));
309 +       nm_info ("Found radio killswitch %s", udi);
310 +
311 +out:
312 +       libhal_free_string (type);
313 +}
314 +
315  /*
316   * nm_hal_device_new_capability
317   *
318 @@ -283,10 +461,9 @@
319         NMData  *data = (NMData *)libhal_ctx_get_user_data (ctx);
320  
321         g_return_if_fail (data != NULL);
322 +       g_return_if_fail (capability != NULL);
323  
324 -       /*nm_debug ("nm_hal_device_new_capability() called with udi = %s, capability = %s", udi, capability );*/
325 -
326 -       if (capability && ((strcmp (capability, "net.80203") == 0) || (strcmp (capability, "net.80211") == 0)))
327 +       if (((strcmp (capability, "net.80203") == 0) || (strcmp (capability, "net.80211") == 0)))
328         {
329                 char *iface;
330  
331 @@ -296,6 +473,10 @@
332                         g_free (iface);
333                 }
334         }
335 +       else if (strcmp (capability, "killswitch") == 0)
336 +       {
337 +               nm_add_killswitch_device (data, udi);
338 +       }
339  }
340  
341  
342 @@ -340,6 +521,30 @@
343         libhal_free_string_array (net_devices);
344  }
345  
346 +void nm_add_initial_killswitch_devices (NMData * data)
347 +{
348 +       char ** udis;
349 +       int             num_udis, i;
350 +       DBusError       error;
351 +
352 +       g_return_if_fail (data != NULL);
353 +
354 +       dbus_error_init (&error);
355 +       udis = libhal_find_device_by_capability (data->hal_ctx, "killswitch", &num_udis, &error);
356 +       if (!udis)
357 +               return;
358 +
359 +       if (dbus_error_is_set (&error)) {
360 +               nm_warning("Could not find killswitch devices: %s", error.message);
361 +               dbus_error_free (&error);
362 +               return;
363 +       }
364 +
365 +       for (i = 0; i < num_udis; i++)
366 +               nm_add_killswitch_device (data, udis[i]);
367 +       libhal_free_string_array (udis);
368 +}
369 +
370  
371  /*
372   * nm_state_change_signal_broadcast
373 @@ -616,28 +821,39 @@
374         g_return_if_fail (data != NULL);
375  
376         if ((data->hal_ctx = nm_get_hal_ctx (data)))
377 +       {
378 +               nm_add_initial_killswitch_devices (data);
379                 nm_add_initial_devices (data);
380 +       }
381 +
382 +       /* If there weren't any killswitches, mark hardware RF to on */
383 +       if (g_slist_length (data->killswitch_list) == 0)
384 +               data->hw_rf_enabled = TRUE;
385  }
386  
387  
388  void nm_hal_deinit (NMData *data)
389  {
390 +       DBusError error;
391 +
392         g_return_if_fail (data != NULL);
393  
394 -       if (data->hal_ctx)
395 -       {
396 -               DBusError error;
397 +       if (!data->hal_ctx)
398 +               return;
399  
400 -               dbus_error_init (&error);
401 -               libhal_ctx_shutdown (data->hal_ctx, &error);
402 -               if (dbus_error_is_set (&error))
403 -               {
404 -                       nm_warning ("libhal shutdown failed - %s", error.message);
405 -                       dbus_error_free (&error);
406 -               }
407 -               libhal_ctx_free (data->hal_ctx);
408 -               data->hal_ctx = NULL;
409 +       g_slist_foreach (data->killswitch_list, (GFunc) g_free, NULL);
410 +       g_slist_free (data->killswitch_list);
411 +       data->killswitch_list = NULL;
412 +
413 +       dbus_error_init (&error);
414 +       libhal_ctx_shutdown (data->hal_ctx, &error);
415 +       if (dbus_error_is_set (&error))
416 +       {
417 +               nm_warning ("libhal shutdown failed - %s", error.message);
418 +               dbus_error_free (&error);
419         }
420 +       libhal_ctx_free (data->hal_ctx);
421 +       data->hal_ctx = NULL;
422  }
423  
424  
425 diff -urN NetworkManager/src/NetworkManagerDbus.c NetworkManager-SVN/src/NetworkManagerDbus.c
426 --- NetworkManager/src/NetworkManagerDbus.c     2007-09-08 00:09:05.000000000 +0200
427 +++ NetworkManager-SVN/src/NetworkManagerDbus.c 2007-09-08 00:06:44.000000000 +0200
428 @@ -434,6 +434,29 @@
429  }
430  
431  
432 +void nm_dbus_signal_wireless_enabled (NMData * data)
433 +{
434 +       DBusMessage *   message;
435 +
436 +       g_return_if_fail (data != NULL);
437 +       g_return_if_fail (data->dbus_connection != NULL);
438 +
439 +       if (!(message = dbus_message_new_signal (NM_DBUS_PATH, NM_DBUS_INTERFACE, "WirelessEnabled")))
440 +       {
441 +               nm_warning ("%s(): Not enough memory for new dbus message!", __func__);
442 +               return;
443 +       }
444 +
445 +       dbus_message_append_args (message,
446 +                                 DBUS_TYPE_BOOLEAN, &data->wireless_enabled,
447 +                                 DBUS_TYPE_BOOLEAN, &data->hw_rf_enabled,
448 +                                 DBUS_TYPE_INVALID);
449 +       if (!dbus_connection_send (data->dbus_connection, message, NULL))
450 +               nm_warning ("%s(): Could not emit the WirelessEnabled signal!", __func__);
451 +
452 +       dbus_message_unref (message);
453 +}
454 +
455  /*
456   * nm_dbus_signal_filter
457   *
458 diff -urN NetworkManager/src/NetworkManagerDbus.h NetworkManager-SVN/src/NetworkManagerDbus.h
459 --- NetworkManager/src/NetworkManagerDbus.h     2007-09-08 00:09:05.000000000 +0200
460 +++ NetworkManager-SVN/src/NetworkManagerDbus.h 2007-09-08 00:06:44.000000000 +0200
461 @@ -68,6 +68,7 @@
462  
463  void                   nm_dbus_signal_wireless_network_change  (DBusConnection *connection, NMDevice80211Wireless *dev, NMAccessPoint *ap, NMNetworkStatus status, gint strength);
464  void                   nm_dbus_signal_device_strength_change   (DBusConnection *connection, NMDevice80211Wireless *dev, gint strength);
465 +void                   nm_dbus_signal_wireless_enabled (NMData * data);
466  
467  NMDevice *     nm_dbus_get_device_from_escaped_object_path     (NMData *data, const char *path);
468  
469 diff -urN NetworkManager/src/NetworkManagerMain.h NetworkManager-SVN/src/NetworkManagerMain.h
470 --- NetworkManager/src/NetworkManagerMain.h     2007-09-08 00:09:05.000000000 +0200
471 +++ NetworkManager-SVN/src/NetworkManagerMain.h 2007-09-08 00:06:44.000000000 +0200
472 @@ -82,6 +82,7 @@
473         GSList *                                dev_list;
474         GMutex *                                dev_list_mutex;
475  
476 +       gboolean                                hw_rf_enabled;
477         gboolean                                wireless_enabled;
478         gboolean                                modem_active;
479         gboolean                                asleep;
480 @@ -90,6 +91,10 @@
481         GSList *                                dialup_list;
482         GMutex *                                dialup_list_mutex;
483  
484 +       GSList *                                killswitch_list;
485 +       GSList *                                ks_pcall_list; /* track killswitch D-Bus pending calls */
486 +       gboolean                                tmp_hw_rf_enabled;
487 +
488         struct NMAccessPointList        *allowed_ap_list;
489         struct NMAccessPointList        *invalid_ap_list;
490  } NMData;
491 diff -urN NetworkManager/src/NetworkManagerPolicy.c NetworkManager-SVN/src/NetworkManagerPolicy.c
492 --- NetworkManager/src/NetworkManagerPolicy.c   2007-09-08 00:09:05.000000000 +0200
493 +++ NetworkManager-SVN/src/NetworkManagerPolicy.c       2007-09-08 00:06:44.000000000 +0200
494 @@ -52,6 +52,7 @@
495         NMDevice                        *dev = NULL;
496         NMData                  *data = NULL;
497         NMAccessPoint * ap = NULL;
498 +       NMActRequest * dev_req;
499  
500         g_return_val_if_fail (req != NULL, FALSE);
501  
502 @@ -61,6 +62,13 @@
503         dev = nm_act_request_get_dev (req);
504         g_assert (dev);
505  
506 +       /* Ensure that inactive devices don't get the activated signal
507 +        * sent due to race conditions.
508 +        */
509 +       dev_req = nm_device_get_act_request (dev);
510 +       if (!dev_req || (dev_req != req))
511 +               return FALSE;
512 +
513      if (nm_device_is_802_11_wireless (dev))
514          ap = nm_act_request_get_ap (req);
515  
516 @@ -265,14 +273,16 @@
517         }
518  
519  #if 0
520 -       nm_info ("AUTO: Best wired device = %s, best wireless device = %s (%s)", best_wired_dev ? nm_device_get_iface (best_wired_dev) : "(null)",
521 -                       best_wireless_dev ? nm_device_get_iface (best_wireless_dev) : "(null)", (best_wireless_dev && *ap) ? nm_ap_get_essid (*ap) : "null" );
522 +       nm_info ("AUTO: Best wired device = %s, best wireless device = %s (%s)", best_wired_dev ? nm_device_get_iface (NM_DEVICE (best_wired_dev)) : "(null)",
523 +                       best_wireless_dev ? nm_device_get_iface (NM_DEVICE (best_wireless_dev)) : "(null)", (best_wireless_dev && *ap) ? nm_ap_get_essid (*ap) : "null" );
524  #endif
525  
526         return highest_priority_dev;
527  }
528  
529  
530 +static GStaticMutex dcc_mutex = G_STATIC_MUTEX_INIT;
531 +
532  /*
533   * nm_policy_device_change_check
534   *
535 @@ -294,7 +304,9 @@
536  
537         g_return_val_if_fail (data != NULL, FALSE);
538  
539 +       g_static_mutex_lock (&dcc_mutex);
540         data->dev_change_check_idle_id = 0;
541 +       g_static_mutex_unlock (&dcc_mutex);
542  
543         old_dev = nm_get_active_device (data);
544  
545 @@ -303,11 +315,19 @@
546  
547         if (old_dev)
548         {
549 +               gboolean has_link = TRUE;
550                 guint32 caps = nm_device_get_capabilities (old_dev);
551  
552 +               /* Ensure ethernet devices have a link before starting activation,
553 +                * partially works around Fedora #194124.
554 +                */
555 +               if (nm_device_is_802_3_ethernet (old_dev))
556 +                       has_link = nm_device_has_active_link (old_dev);
557 +
558                 /* Don't interrupt a currently activating device. */
559                 if (   nm_device_is_activating (old_dev)
560 -                   && !nm_device_can_interrupt_activation (old_dev))
561 +                   && !nm_device_can_interrupt_activation (old_dev)
562 +                   && has_link)
563                 {
564                         nm_info ("Old device '%s' activating, won't change.", nm_device_get_iface (old_dev));
565                         goto out;
566 @@ -425,12 +445,35 @@
567         if (do_switch && (nm_device_is_802_3_ethernet (new_dev) || (nm_device_is_802_11_wireless (new_dev) && ap)))
568         {
569                 NMActRequest *  act_req = NULL;
570 +               gboolean has_link = TRUE;
571 +
572 +               /* Ensure ethernet devices have a link before starting activation,
573 +                * partially works around Fedora #194124.
574 +                */
575 +               if (nm_device_is_802_3_ethernet (new_dev))
576 +                       has_link = nm_device_has_active_link (new_dev);
577  
578 -               if ((act_req = nm_act_request_new (data, new_dev, ap, FALSE)))
579 +               if (has_link)
580 +               {
581 +                       if ((act_req = nm_act_request_new (data, new_dev, ap, FALSE)))
582 +                       {
583 +                               nm_info ("Will activate connection '%s%s%s'.",
584 +                                        nm_device_get_iface (new_dev),
585 +                                        ap ? "/" : "",
586 +                                        ap ? nm_ap_get_essid (ap) : "");
587 +                               nm_policy_schedule_device_activation (act_req);
588 +                               nm_act_request_unref (act_req);
589 +                       }
590 +                       else
591 +                       {
592 +                               nm_info ("Error creating activation request for %s",
593 +                                        nm_device_get_iface (new_dev));
594 +                       }
595 +               }
596 +               else
597                 {
598 -                       nm_info ("Will activate connection '%s%s%s'.", nm_device_get_iface (new_dev), ap ? "/" : "", ap ? nm_ap_get_essid (ap) : "");
599 -                       nm_policy_schedule_device_activation (act_req);
600 -                       nm_act_request_unref (act_req);
601 +                       nm_info ("Won't activate %s because it no longer has a link.",
602 +                                nm_device_get_iface (new_dev));
603                 }
604         }
605  
606 @@ -452,11 +495,9 @@
607   */
608  void nm_policy_schedule_device_change_check (NMData *data)
609  {
610 -       static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
611 -
612         g_return_if_fail (data != NULL);
613  
614 -       g_static_mutex_lock (&mutex);
615 +       g_static_mutex_lock (&dcc_mutex);
616  
617         if (data->dev_change_check_idle_id == 0)
618         {
619 @@ -466,8 +507,7 @@
620                 data->dev_change_check_idle_id = g_source_attach (source, data->main_context);
621                 g_source_unref (source);
622         }
623 -
624 -       g_static_mutex_unlock (&mutex);
625 +       g_static_mutex_unlock (&dcc_mutex);
626  }
627  
628  
629 diff -urN NetworkManager/src/NetworkManagerSystem.c NetworkManager-SVN/src/NetworkManagerSystem.c
630 --- NetworkManager/src/NetworkManagerSystem.c   2007-09-08 00:09:05.000000000 +0200
631 +++ NetworkManager-SVN/src/NetworkManagerSystem.c       2007-09-08 00:06:44.000000000 +0200
632 @@ -64,6 +64,7 @@
633         struct sockaddr_in *p;
634         const char *            iface;
635         int                             err;
636 +       NMIP4Config * config = NULL;
637  
638         iface = nm_device_get_iface (dev);
639  
640 @@ -75,6 +76,15 @@
641         if (ip4_gateway == 0)
642                 return TRUE;
643  
644 +       /*
645 +        * Do not add the route if the destination is on the same subnet.
646 +        */
647 +       config = nm_device_get_ip4_config(dev);
648 +       if (config &&
649 +           ((guint32)ip4_dest & nm_ip4_config_get_netmask(config)) ==
650 +               (nm_ip4_config_get_address(config) & nm_ip4_config_get_netmask(config)))
651 +               return TRUE;
652 +
653         if ((sk = nm_dev_sock_open (dev, NETWORK_CONTROL, __FUNCTION__, NULL)) == NULL)
654                 return FALSE;
655  
656 diff -urN NetworkManager/src/nm-ap-security-wpa-eap.c NetworkManager-SVN/src/nm-ap-security-wpa-eap.c
657 --- NetworkManager/src/nm-ap-security-wpa-eap.c 2007-09-08 00:09:05.000000000 +0200
658 +++ NetworkManager-SVN/src/nm-ap-security-wpa-eap.c     2007-09-08 00:06:44.000000000 +0200
659 @@ -57,7 +57,6 @@
660         NMAPSecurityWPA_EAP *   security = NULL;
661         int                                     eap_method;
662         int                                     key_type;
663 -       int                                     phase2_type;
664         int                                     wpa_version;
665         char *                          identity = NULL;
666         char *                          passwd = NULL;
667 diff -urN NetworkManager/src/nm-dbus-nm.c NetworkManager-SVN/src/nm-dbus-nm.c
668 --- NetworkManager/src/nm-dbus-nm.c     2007-09-08 00:09:05.000000000 +0200
669 +++ NetworkManager-SVN/src/nm-dbus-nm.c 2007-09-08 00:06:44.000000000 +0200
670 @@ -483,52 +483,83 @@
671         return (reply);
672  }
673  
674 -static DBusMessage *nm_dbus_nm_set_wireless_enabled (DBusConnection *connection, DBusMessage *message, NMDbusCBData *data)
675 +static DBusMessage *nm_dbus_nm_set_wireless_enabled (DBusConnection *connection, DBusMessage *message, NMDbusCBData *cb_data)
676  {
677         gboolean        enabled = FALSE;
678         DBusError       err;
679 -       NMData  *app_data;
680 +       NMData  *       data;
681 +       DBusMessage * ret = NULL;
682  
683 -       g_return_val_if_fail (data && data->data && connection && message, NULL);
684 +       g_return_val_if_fail (cb_data && cb_data->data && connection && message, NULL);
685  
686         dbus_error_init (&err);
687         if (!dbus_message_get_args (message, &err, DBUS_TYPE_BOOLEAN, &enabled, DBUS_TYPE_INVALID))
688 -               return NULL;
689 +               goto out;
690  
691 -       app_data = data->data;
692 -       app_data->wireless_enabled = enabled;
693 +       data = cb_data->data;
694 +       if (enabled == data->wireless_enabled)
695 +               goto out;
696 +
697 +       /* Hardware rfkill overrides whatever user wants */
698 +       if (!data->hw_rf_enabled) {
699 +               nm_info ("User request to %s wireless overridden by radio killswitch.",
700 +                        enabled ? "enable" : "disable");
701  
702 -       if (!enabled)
703 -       {
704 -               GSList  *elt;
705 +               /* Return error if user tries to re-enable wireless, or just ignore
706 +                * a disable wireless request when wireless is already disabled.
707 +                */
708 +               if (enabled) {
709 +                       ret = nm_dbus_create_error_message (message,
710 +                                                           NM_DBUS_INTERFACE,
711 +                                                           "DisabledBySystem",
712 +                                                           "Wireless disabled by hardware switch.");
713 +               }
714 +               goto out;
715 +       }
716  
717 -               /* Physically down all wireless devices */
718 -               nm_lock_mutex (app_data->dev_list_mutex, __FUNCTION__);
719 -               for (elt = app_data->dev_list; elt; elt = g_slist_next (elt))
720 -               {
721 -                       NMDevice        *dev = (NMDevice *)(elt->data);
722 -                       if (nm_device_is_802_11_wireless (dev))
723 -                       {
724 +       nm_info ("User request to %s wireless.", enabled ? "enable" : "disable");
725 +
726 +       data->wireless_enabled = enabled;
727 +       if (!data->wireless_enabled) {
728 +               GSList * elt;
729 +
730 +               /* Deactivate all wireless devices and force them down so they
731 +                * turn off their radios.
732 +                */
733 +               nm_lock_mutex (data->dev_list_mutex, __FUNCTION__);
734 +               for (elt = data->dev_list; elt; elt = g_slist_next (elt)) {
735 +                       NMDevice * dev = (NMDevice *) elt->data;
736 +                       if (nm_device_is_802_11_wireless (dev)) {
737                                 nm_device_deactivate (dev);
738                                 nm_device_bring_down (dev);
739                         }
740                 }
741 -               nm_unlock_mutex (app_data->dev_list_mutex, __FUNCTION__);
742 +               nm_unlock_mutex (data->dev_list_mutex, __FUNCTION__);
743         }
744  
745 -       nm_policy_schedule_device_change_check (data->data);
746 +       nm_policy_schedule_device_change_check (data);
747 +       nm_dbus_signal_wireless_enabled (data);
748  
749 -       return NULL;
750 +out:
751 +       return ret;
752  }
753  
754 -static DBusMessage *nm_dbus_nm_get_wireless_enabled (DBusConnection *connection, DBusMessage *message, NMDbusCBData *data)
755 +static DBusMessage *nm_dbus_nm_get_wireless_enabled (DBusConnection *connection, DBusMessage *message, NMDbusCBData *cb_data)
756  {
757 +       NMData * data;
758         DBusMessage     *reply = NULL;
759  
760 -       g_return_val_if_fail (data && data->data && connection && message, NULL);
761 +       g_return_val_if_fail (cb_data && connection && message, NULL);
762  
763 -       if ((reply = dbus_message_new_method_return (message)))
764 -               dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &data->data->wireless_enabled, DBUS_TYPE_INVALID);
765 +       data = cb_data->data;
766 +       g_return_val_if_fail (data != NULL, NULL);
767 +
768 +       if ((reply = dbus_message_new_method_return (message))) {
769 +               dbus_message_append_args (reply,
770 +                                         DBUS_TYPE_BOOLEAN, &data->wireless_enabled,
771 +                                         DBUS_TYPE_BOOLEAN, &data->hw_rf_enabled,
772 +                                         DBUS_TYPE_INVALID);
773 +       }
774  
775         return reply;
776  }
777 diff -urN NetworkManager/src/nm-device-802-11-wireless.c NetworkManager-SVN/src/nm-device-802-11-wireless.c
778 --- NetworkManager/src/nm-device-802-11-wireless.c      2007-09-08 00:09:05.000000000 +0200
779 +++ NetworkManager-SVN/src/nm-device-802-11-wireless.c  2007-09-08 00:06:44.000000000 +0200
780 @@ -617,7 +617,10 @@
781         /* Start the scanning timeout for devices that can do scanning */
782         if (nm_device_get_capabilities (dev) & NM_DEVICE_CAP_WIRELESS_SCAN)
783         {
784 -               self->priv->pending_scan = g_idle_source_new ();
785 +               /* Stupid orinoco has problems scanning immediately after being up,
786 +                * so wait a bit before triggering a scan.
787 +                */
788 +               self->priv->pending_scan = g_timeout_source_new (600);
789                 g_source_set_callback (self->priv->pending_scan,
790                                                            nm_device_802_11_wireless_scan,
791                                                            self,
792 @@ -2981,6 +2984,9 @@
793                 return NM_ACT_STAGE_RETURN_POSTPONE;
794         }
795  
796 +       /* Some cards are dumb.  Wait a second */
797 +       sleep (1);
798 +
799         iface = nm_device_get_iface (dev);
800         if (!supplicant_exec (self))
801         {
802 @@ -3446,10 +3452,9 @@
803         char *genie, *gpos, *gend, *custom;
804         NMAccessPoint *ap = NULL;
805         size_t clen;
806 -       int maxrate;
807 +       int maxrate = 0;
808         struct iw_event iwe_buf, *iwe = &iwe_buf;
809         struct stream_descr     stream;
810 -       struct wireless_scan *  wscan = NULL;
811         int                     ret;
812  
813         g_return_val_if_fail (dev != NULL, FALSE);
814 diff -urN NetworkManager/src/nm-device-802-3-ethernet.c NetworkManager-SVN/src/nm-device-802-3-ethernet.c
815 --- NetworkManager/src/nm-device-802-3-ethernet.c       2007-09-08 00:09:05.000000000 +0200
816 +++ NetworkManager-SVN/src/nm-device-802-3-ethernet.c   2007-09-08 00:06:44.000000000 +0200
817 @@ -108,18 +108,16 @@
818                                           GObject *obj,
819                                           NMDevice8023Ethernet *self)
820  {
821 +       GSource * source;
822 +
823         /* Make sure signal is for us */
824         if (NM_DEVICE (self) != NM_DEVICE (obj))
825                 return;
826  
827 -       if (!nm_device_has_active_link (NM_DEVICE (self)))
828 -       {
829 -               GSource *       source = g_idle_source_new ();
830 -
831 -               g_source_set_callback (source, (GSourceFunc) link_activated_helper, self, NULL);
832 -               g_source_attach (source, nm_device_get_main_context (NM_DEVICE (self)));
833 -               g_source_unref (source);
834 -       }
835 +       source = g_idle_source_new ();
836 +       g_source_set_callback (source, (GSourceFunc) link_activated_helper, self, NULL);
837 +       g_source_attach (source, nm_device_get_main_context (NM_DEVICE (self)));
838 +       g_source_unref (source);
839  }
840  
841  
842 @@ -135,18 +133,16 @@
843                                             GObject *obj,
844                                             NMDevice8023Ethernet *self)
845  {
846 +       GSource * source;
847 +
848         /* Make sure signal is for us */
849         if (NM_DEVICE (self) != NM_DEVICE (obj))
850                 return;
851  
852 -       if (nm_device_has_active_link (NM_DEVICE (self)))
853 -       {
854 -               GSource *       source = g_idle_source_new ();
855 -
856 -               g_source_set_callback (source, (GSourceFunc) link_deactivated_helper, self, NULL);
857 -               g_source_attach (source, nm_device_get_main_context (NM_DEVICE (self)));
858 -               g_source_unref (source);
859 -       }
860 +       source = g_idle_source_new ();
861 +       g_source_set_callback (source, (GSourceFunc) link_deactivated_helper, self, NULL);
862 +       g_source_attach (source, nm_device_get_main_context (NM_DEVICE (self)));
863 +       g_source_unref (source);
864  }
865  
866  static void
867 @@ -211,6 +207,26 @@
868         return caps;
869  }
870  
871 +
872 +static NMActStageReturn
873 +real_act_stage1_prepare (NMDevice *dev, NMActRequest *req)
874 +{
875 +       NMDevice8023Ethernet * self = NM_DEVICE_802_3_ETHERNET (dev);
876 +       NMDevice8023EthernetClass *     klass;
877 +       NMDeviceClass * parent_class;
878 +
879 +       /* Ensure ethernet devices have a link before going further with activation,
880 +        * partially works around Fedora #194124.
881 +        */
882 +       if (!nm_device_has_active_link (dev))
883 +               return NM_ACT_STAGE_RETURN_FAILURE;
884 +
885 +       /* Chain up to parent */
886 +       klass = NM_DEVICE_802_3_ETHERNET_GET_CLASS (self);
887 +       parent_class = NM_DEVICE_CLASS (g_type_class_peek_parent (klass));
888 +       return parent_class->act_stage1_prepare (dev, req);
889 +}
890 +
891  static void
892  nm_device_802_3_ethernet_dispose (GObject *object)
893  {
894 @@ -275,6 +291,7 @@
895         parent_class->get_generic_capabilities = real_get_generic_capabilities;
896         parent_class->init = real_init;
897         parent_class->update_link = real_update_link;
898 +       parent_class->act_stage1_prepare = real_act_stage1_prepare;
899  
900         g_type_class_add_private (object_class, sizeof (NMDevice8023EthernetPrivate));
901  }
902 diff -urN NetworkManager/src/nm-device.c NetworkManager-SVN/src/nm-device.c
903 --- NetworkManager/src/nm-device.c      2007-09-08 00:09:05.000000000 +0200
904 +++ NetworkManager-SVN/src/nm-device.c  2007-09-08 00:06:44.000000000 +0200
905 @@ -856,6 +856,12 @@
906         data = nm_act_request_get_data (req);
907         g_assert (data);
908  
909 +       /* Sometimes the device gets downed by wpa_supplicant; in any case, make
910 +        * sure it's up before anything tries to use it.
911 +        */
912 +       if (!nm_device_is_up (self))
913 +               nm_device_bring_up (self);
914 +
915         /* DHCP devices try DHCP, non-DHCP default to SUCCESS */
916         if (nm_device_get_use_dhcp (self))
917         {
This page took 0.250717 seconds and 4 git commands to generate.