~ubuntu-branches/debian/sid/network-manager/sid

« back to all changes in this revision

Viewing changes to src/nm-udev-manager.c

  • Committer: Package Import Robot
  • Author(s): Michael Biebl
  • Date: 2011-11-03 21:32:50 UTC
  • mfrom: (1.4.6)
  • Revision ID: package-import@ubuntu.com-20111103213250-w49ucjmux3hbwnta
Tags: 0.9.1.95-1
* New upstream release (0.9.2 rc1).
  - Fix connection sharing with newer iptables versions. (Closes: #638995)
  - Fix handling of numeric SSIDs in the keyfile plugin. (Closes: #642912)
* debian/watch: Track .xz tarballs.
* debian/libnm-util2.symbols: Add new symbols for libnm-util.
* debian/patches/04-dont-update-routing-and-dns-for-unmanaged-devices.patch
  - Avoid blowing away existing routes and resolv.conf if NM never managed
    any devices. (Closes: #546893, #624159, #637005, #641904)
* debian/control: Add Build-Depends on libglib2.0-doc for proper
  cross-references in the gtk-doc API documentation.
* Enable default hardening options from dpkg-buildflags.
  - Use buildflags.mk snippet in debian/rules.
  - Add Build-Depends on dpkg-dev (>= 1.6.1).

Show diffs side-by-side

added added

removed removed

Lines of Context:
195
195
        NMUdevManagerPrivate *priv = NM_UDEV_MANAGER_GET_PRIVATE (self);
196
196
        GSList *iter;
197
197
        RfKillState poll_states[RFKILL_TYPE_MAX];
 
198
        RfKillState platform_states[RFKILL_TYPE_MAX];
198
199
        gboolean platform_checked[RFKILL_TYPE_MAX];
199
200
        int i;
200
201
 
201
202
        /* Default state is unblocked */
202
203
        for (i = 0; i < RFKILL_TYPE_MAX; i++) {
203
204
                poll_states[i] = RFKILL_UNBLOCKED;
 
205
                platform_states[i] = RFKILL_UNBLOCKED;
204
206
                platform_checked[i] = FALSE;
205
207
        }
206
208
 
207
 
        /* Perform two passes here; the first pass is for non-platform switches,
208
 
         * which typically if hardkilled cannot be changed except by a physical
209
 
         * hardware switch.  The second pass checks platform killswitches, which
210
 
         * take precedence over device killswitches, because typically platform
211
 
         * killswitches control device killswitches.  That is, a hardblocked device
212
 
         * switch can often be unblocked by a platform switch.  Thus if we have
213
 
         * a hardblocked device switch and a softblocked platform switch, the
214
 
         * combined state should be softblocked since the platform switch can be
215
 
         * unblocked to change the device switch.
216
 
         */
217
 
 
218
 
        /* Device switches first */
 
209
        /* Poll the states of all killswitches */
219
210
        for (iter = priv->killswitches; iter; iter = g_slist_next (iter)) {
220
211
                Killswitch *ks = iter->data;
221
212
                GUdevDevice *device;
222
213
                RfKillState dev_state;
223
214
                int sysfs_state;
224
215
 
225
 
                if (ks->platform == FALSE) {
226
 
                        device = g_udev_client_query_by_subsystem_and_name (priv->client, "rfkill", ks->name);
227
 
                        if (device) {
228
 
                                sysfs_state = g_udev_device_get_property_as_int (device, "RFKILL_STATE");
229
 
                                dev_state = sysfs_state_to_nm_state (sysfs_state);
 
216
                device = g_udev_client_query_by_subsystem_and_name (priv->client, "rfkill", ks->name);
 
217
                if (device) {
 
218
                        sysfs_state = g_udev_device_get_property_as_int (device, "RFKILL_STATE");
 
219
                        dev_state = sysfs_state_to_nm_state (sysfs_state);
 
220
                        if (ks->platform == FALSE) {
230
221
                                if (dev_state > poll_states[ks->rtype])
231
222
                                        poll_states[ks->rtype] = dev_state;
232
 
                                g_object_unref (device);
233
 
                        }
234
 
                }
235
 
        }
236
 
 
237
 
        /* Platform switches next; their state overwrites device state */
238
 
        for (iter = priv->killswitches; iter; iter = g_slist_next (iter)) {
239
 
                Killswitch *ks = iter->data;
240
 
                GUdevDevice *device;
241
 
                RfKillState dev_state;
242
 
                int sysfs_state;
243
 
 
244
 
                if (ks->platform == TRUE) {
245
 
                        device = g_udev_client_query_by_subsystem_and_name (priv->client, "rfkill", ks->name);
246
 
                        if (device) {
247
 
                                sysfs_state = g_udev_device_get_property_as_int (device, "RFKILL_STATE");
248
 
                                dev_state = sysfs_state_to_nm_state (sysfs_state);
249
 
 
250
 
                                if (platform_checked[ks->rtype] == FALSE) {
251
 
                                        /* Overwrite device state with platform state for first
252
 
                                         * platform switch found.
253
 
                                         */
254
 
                                        poll_states[ks->rtype] = dev_state;
255
 
                                        platform_checked[ks->rtype] = TRUE;
256
 
                                } else {
257
 
                                        /* If there are multiple platform switches of the same type,
258
 
                                         * take the "worst" state for all of that type.
259
 
                                         */
260
 
                                        if (dev_state > poll_states[ks->rtype])
261
 
                                                poll_states[ks->rtype] = dev_state;
262
 
                                }
263
 
                                g_object_unref (device);
264
 
                        }
 
223
                        } else {
 
224
                                platform_checked[ks->rtype] = TRUE;
 
225
                                if (dev_state > platform_states[ks->rtype])
 
226
                                        platform_states[ks->rtype] = dev_state;
 
227
                        }
 
228
                        g_object_unref (device);
265
229
                }
266
230
        }
267
231
 
268
232
        /* Log and emit change signal for final rfkill states */
269
233
        for (i = 0; i < RFKILL_TYPE_MAX; i++) {
 
234
                if (platform_checked[i] == TRUE) {
 
235
                        /* blocked platform switch state overrides device state, otherwise
 
236
                         * let the device state stand. (bgo #655773)
 
237
                         */
 
238
                        if (platform_states[i] != RFKILL_UNBLOCKED)
 
239
                                poll_states[i] = platform_states[i];
 
240
                }
 
241
 
270
242
                if (poll_states[i] != priv->rfkill_states[i]) {
271
243
                        nm_log_dbg (LOGD_RFKILL, "%s rfkill state now '%s'",
272
244
                                    rfkill_type_to_desc (i),
515
487
         * FIXME: use something other than interface name to detect CTC here.
516
488
         */
517
489
        if ((etype != 1) && (is_ctc == FALSE)) {
518
 
                nm_log_dbg (LOGD_HW, "ignoring interface with type %d", etype);
 
490
                nm_log_dbg (LOGD_HW, "(%s): ignoring interface with type %d", iface, etype);
519
491
                return;
520
492
        }
521
493
 
528
500
         */
529
501
        tmp = g_udev_device_get_property (device, "DEVTYPE");
530
502
        if (g_strcmp0 (tmp, "wwan") == 0) {
531
 
                nm_log_dbg (LOGD_HW, "ignoring interface with devtype '%s'", tmp);
 
503
                nm_log_dbg (LOGD_HW, "(%s): ignoring interface with devtype '%s'", iface, tmp);
532
504
                return;
533
505
        }
534
506
 
539
511
        if (g_strcmp0 (tmp, "0421") == 0) { /* Nokia vendor ID */
540
512
                tmp = g_udev_device_get_property (device, "ID_MODEL");
541
513
                if (tmp && (strstr (tmp, "PC-Suite") || strstr (tmp, "PC Suite"))) {
542
 
                        nm_log_dbg (LOGD_HW, "ignoring Nokia PC-Suite ethernet interface");
 
514
                        nm_log_dbg (LOGD_HW, "(%s): ignoring Nokia PC-Suite ethernet interface", iface);
543
515
                        return;
544
516
                }
545
517
        }