Newer
Older
dev->features |= NETIF_F_NETNS_LOCAL;
if (sysfs_create_link(&dev->dev.kobj, &rdev->wiphy.dev.kobj,
"phy80211")) {
pr_err("failed to add phy80211 symlink to netdev!\n");
wdev->wext.default_key = -1;
wdev->wext.default_mgmt_key = -1;
wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
if (wdev->wiphy->flags & WIPHY_FLAG_PS_ON_BY_DEFAULT)
/* allow mac80211 to determine the timeout */
wdev->ps_timeout = -1;
if ((wdev->iftype == NL80211_IFTYPE_STATION ||
wdev->iftype == NL80211_IFTYPE_P2P_CLIENT ||
wdev->iftype == NL80211_IFTYPE_ADHOC) && !wdev->use_4addr)
dev->priv_flags |= IFF_DONT_BRIDGE;
cfg80211_leave(rdev, wdev);
break;
case NETDEV_DOWN:
cfg80211_update_iface_num(rdev, wdev->iftype, -1);
if (rdev->scan_req && rdev->scan_req->wdev == wdev) {
if (WARN_ON(!rdev->scan_req->notified))
rdev->scan_req->aborted = true;
___cfg80211_scan_done(rdev, false);
sched_scan_req = rtnl_dereference(rdev->sched_scan_req);
if (WARN_ON(sched_scan_req &&
sched_scan_req->dev == wdev->netdev)) {
__cfg80211_stop_sched_scan(rdev, false);
}
rdev->opencount--;
wake_up(&rdev->dev_wait);
cfg80211_update_iface_num(rdev, wdev->iftype, 1);
#ifdef CONFIG_CFG80211_WEXT
Javier Cardona
committed
#ifdef CONFIG_MAC80211_MESH
case NL80211_IFTYPE_MESH_POINT:
Javier Cardona
committed
{
/* backward compat code... */
struct mesh_setup setup;
memcpy(&setup, &default_mesh_setup,
sizeof(setup));
/* back compat only needed for mesh_id */
setup.mesh_id = wdev->ssid;
setup.mesh_id_len = wdev->mesh_id_up_len;
if (wdev->mesh_id_up_len)
__cfg80211_join_mesh(rdev, dev,
&setup,
&default_mesh_config);
break;
}
#endif
/*
* Configure power management to the driver here so that its
* correctly set also after interface type changes etc.
*/
if ((wdev->iftype == NL80211_IFTYPE_STATION ||
wdev->iftype == NL80211_IFTYPE_P2P_CLIENT) &&
rdev->ops->set_power_mgmt)
if (rdev_set_power_mgmt(rdev, dev, wdev->ps,
wdev->ps_timeout)) {
/* assume this means it's off */
wdev->ps = false;
}
case NETDEV_UNREGISTER:
/*
* It is possible to get NETDEV_UNREGISTER
* multiple times. To detect that, check
* that the interface is still on the list
* of registered interfaces, and only then
* remove and clean it up.
*/
if (!list_empty(&wdev->list)) {
sysfs_remove_link(&dev->dev.kobj, "phy80211");
rdev->devlist_generation++;
cfg80211_mlme_purge_registrations(wdev);
kzfree(wdev->wext.keys);
/*
* synchronise (so that we won't find this netdev
* from other code any more) and then clear the list
* head so that the above code can safely check for
* !list_empty() to avoid double-cleanup.
*/
synchronize_rcu();
INIT_LIST_HEAD(&wdev->list);
/*
* Ensure that all events have been processed and
* freed.
*/
cfg80211_process_wdev_events(wdev);
if (WARN_ON(wdev->current_bss)) {
cfg80211_unhold_bss(wdev->current_bss);
cfg80211_put_bss(wdev->wiphy, &wdev->current_bss->pub);
wdev->current_bss = NULL;
}
if (!(wdev->wiphy->interface_modes & BIT(wdev->iftype)))
return notifier_from_errno(-EOPNOTSUPP);
if (rfkill_blocked(rdev->rfkill))
return notifier_from_errno(-ERFKILL);
default:
return NOTIFY_DONE;
}
static struct notifier_block cfg80211_netdev_notifier = {
.notifier_call = cfg80211_netdev_notifier_call,
};
static void __net_exit cfg80211_pernet_exit(struct net *net)
{
struct cfg80211_registered_device *rdev;
rtnl_lock();
list_for_each_entry(rdev, &cfg80211_rdev_list, list) {
if (net_eq(wiphy_net(&rdev->wiphy), net))
WARN_ON(cfg80211_switch_netns(rdev, &init_net));
}
rtnl_unlock();
}
static struct pernet_operations cfg80211_pernet_ops = {
.exit = cfg80211_pernet_exit,
};
static int __init cfg80211_init(void)
err = register_pernet_device(&cfg80211_pernet_ops);
if (err)
goto out_fail_pernet;
err = wiphy_sysfs_init();
if (err)
goto out_fail_sysfs;
err = register_netdevice_notifier(&cfg80211_netdev_notifier);
if (err)
goto out_fail_notifier;
err = nl80211_init();
if (err)
goto out_fail_nl80211;
ieee80211_debugfs_dir = debugfs_create_dir("ieee80211", NULL);
err = regulatory_init();
if (err)
goto out_fail_reg;
cfg80211_wq = create_singlethread_workqueue("cfg80211");
if (!cfg80211_wq) {
err = -ENOMEM;
return 0;
out_fail_wq:
regulatory_exit();
out_fail_reg:
debugfs_remove(ieee80211_debugfs_dir);
out_fail_nl80211:
unregister_netdevice_notifier(&cfg80211_netdev_notifier);
out_fail_notifier:
wiphy_sysfs_exit();
out_fail_sysfs:
unregister_pernet_device(&cfg80211_pernet_ops);
out_fail_pernet:
return err;
}
subsys_initcall(cfg80211_init);
static void __exit cfg80211_exit(void)
{
debugfs_remove(ieee80211_debugfs_dir);
unregister_netdevice_notifier(&cfg80211_netdev_notifier);
wiphy_sysfs_exit();
regulatory_exit();
unregister_pernet_device(&cfg80211_pernet_ops);
destroy_workqueue(cfg80211_wq);
}
module_exit(cfg80211_exit);