diff options
| author | Alexander Aring <alex.aring@gmail.com> | 2014-11-11 21:36:53 -0500 |
|---|---|---|
| committer | Marcel Holtmann <marcel@holtmann.org> | 2014-11-11 23:10:37 -0500 |
| commit | be4fd8e5d9f5cd3fdc368e32e7957bcb83bcbb8b (patch) | |
| tree | 177a559b3871138fe989511cfc8ec6de7b5623d6 /net/mac802154 | |
| parent | 912f67aec761ea4d2107ed0bcb5aef01ae1ecd2e (diff) | |
mac802154: add ifname change notifier
This patch adds a netdev notifier for interface renaming. We have a name
attribute inside of subif data struct. This is needed to have always the
actual netdev name in sdata name attribute.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/mac802154')
| -rw-r--r-- | net/mac802154/ieee802154_i.h | 3 | ||||
| -rw-r--r-- | net/mac802154/iface.c | 35 | ||||
| -rw-r--r-- | net/mac802154/main.c | 15 |
3 files changed, 53 insertions, 0 deletions
diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h index 4be5e23c7e8b..69cb585e162f 100644 --- a/net/mac802154/ieee802154_i.h +++ b/net/mac802154/ieee802154_i.h | |||
| @@ -169,6 +169,9 @@ void mac802154_get_table(struct net_device *dev, | |||
| 169 | struct ieee802154_llsec_table **t); | 169 | struct ieee802154_llsec_table **t); |
| 170 | void mac802154_unlock_table(struct net_device *dev); | 170 | void mac802154_unlock_table(struct net_device *dev); |
| 171 | 171 | ||
| 172 | /* interface handling */ | ||
| 173 | int ieee802154_iface_init(void); | ||
| 174 | void ieee802154_iface_exit(void); | ||
| 172 | struct net_device * | 175 | struct net_device * |
| 173 | mac802154_add_iface(struct wpan_phy *phy, const char *name, int type); | 176 | mac802154_add_iface(struct wpan_phy *phy, const char *name, int type); |
| 174 | void ieee802154_if_remove(struct ieee802154_sub_if_data *sdata); | 177 | void ieee802154_if_remove(struct ieee802154_sub_if_data *sdata); |
diff --git a/net/mac802154/iface.c b/net/mac802154/iface.c index 85d215562b4a..ec92b48d1b0b 100644 --- a/net/mac802154/iface.c +++ b/net/mac802154/iface.c | |||
| @@ -548,3 +548,38 @@ void ieee802154_remove_interfaces(struct ieee802154_local *local) | |||
| 548 | } | 548 | } |
| 549 | mutex_unlock(&local->iflist_mtx); | 549 | mutex_unlock(&local->iflist_mtx); |
| 550 | } | 550 | } |
| 551 | |||
| 552 | static int netdev_notify(struct notifier_block *nb, | ||
| 553 | unsigned long state, void *ptr) | ||
| 554 | { | ||
| 555 | struct net_device *dev = netdev_notifier_info_to_dev(ptr); | ||
| 556 | struct ieee802154_sub_if_data *sdata; | ||
| 557 | |||
| 558 | if (state != NETDEV_CHANGENAME) | ||
| 559 | return NOTIFY_DONE; | ||
| 560 | |||
| 561 | if (!dev->ieee802154_ptr || !dev->ieee802154_ptr->wpan_phy) | ||
| 562 | return NOTIFY_DONE; | ||
| 563 | |||
| 564 | if (dev->ieee802154_ptr->wpan_phy->privid != mac802154_wpan_phy_privid) | ||
| 565 | return NOTIFY_DONE; | ||
| 566 | |||
| 567 | sdata = IEEE802154_DEV_TO_SUB_IF(dev); | ||
| 568 | memcpy(sdata->name, dev->name, IFNAMSIZ); | ||
| 569 | |||
| 570 | return NOTIFY_OK; | ||
| 571 | } | ||
| 572 | |||
| 573 | static struct notifier_block mac802154_netdev_notifier = { | ||
| 574 | .notifier_call = netdev_notify, | ||
| 575 | }; | ||
| 576 | |||
| 577 | int ieee802154_iface_init(void) | ||
| 578 | { | ||
| 579 | return register_netdevice_notifier(&mac802154_netdev_notifier); | ||
| 580 | } | ||
| 581 | |||
| 582 | void ieee802154_iface_exit(void) | ||
| 583 | { | ||
| 584 | unregister_netdevice_notifier(&mac802154_netdev_notifier); | ||
| 585 | } | ||
diff --git a/net/mac802154/main.c b/net/mac802154/main.c index 40a326402ec1..46c76e005446 100644 --- a/net/mac802154/main.c +++ b/net/mac802154/main.c | |||
| @@ -182,5 +182,20 @@ void ieee802154_unregister_hw(struct ieee802154_hw *hw) | |||
| 182 | } | 182 | } |
| 183 | EXPORT_SYMBOL(ieee802154_unregister_hw); | 183 | EXPORT_SYMBOL(ieee802154_unregister_hw); |
| 184 | 184 | ||
| 185 | static int __init ieee802154_init(void) | ||
| 186 | { | ||
| 187 | return ieee802154_iface_init(); | ||
| 188 | } | ||
| 189 | |||
| 190 | static void __exit ieee802154_exit(void) | ||
| 191 | { | ||
| 192 | ieee802154_iface_exit(); | ||
| 193 | |||
| 194 | rcu_barrier(); | ||
| 195 | } | ||
| 196 | |||
| 197 | subsys_initcall(ieee802154_init); | ||
| 198 | module_exit(ieee802154_exit); | ||
| 199 | |||
| 185 | MODULE_DESCRIPTION("IEEE 802.15.4 subsystem"); | 200 | MODULE_DESCRIPTION("IEEE 802.15.4 subsystem"); |
| 186 | MODULE_LICENSE("GPL v2"); | 201 | MODULE_LICENSE("GPL v2"); |
