diff options
author | Alexander Aring <alex.aring@gmail.com> | 2014-11-12 03:36:53 +0100 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-11-12 05:10:37 +0100 |
commit | be4fd8e5d9f5cd3fdc368e32e7957bcb83bcbb8b (patch) | |
tree | 177a559b3871138fe989511cfc8ec6de7b5623d6 /net/mac802154/iface.c | |
parent | 912f67aec761ea4d2107ed0bcb5aef01ae1ecd2e (diff) | |
download | talos-obmc-linux-be4fd8e5d9f5cd3fdc368e32e7957bcb83bcbb8b.tar.gz talos-obmc-linux-be4fd8e5d9f5cd3fdc368e32e7957bcb83bcbb8b.zip |
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/iface.c')
-rw-r--r-- | net/mac802154/iface.c | 35 |
1 files changed, 35 insertions, 0 deletions
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) } mutex_unlock(&local->iflist_mtx); } + +static int netdev_notify(struct notifier_block *nb, + unsigned long state, void *ptr) +{ + struct net_device *dev = netdev_notifier_info_to_dev(ptr); + struct ieee802154_sub_if_data *sdata; + + if (state != NETDEV_CHANGENAME) + return NOTIFY_DONE; + + if (!dev->ieee802154_ptr || !dev->ieee802154_ptr->wpan_phy) + return NOTIFY_DONE; + + if (dev->ieee802154_ptr->wpan_phy->privid != mac802154_wpan_phy_privid) + return NOTIFY_DONE; + + sdata = IEEE802154_DEV_TO_SUB_IF(dev); + memcpy(sdata->name, dev->name, IFNAMSIZ); + + return NOTIFY_OK; +} + +static struct notifier_block mac802154_netdev_notifier = { + .notifier_call = netdev_notify, +}; + +int ieee802154_iface_init(void) +{ + return register_netdevice_notifier(&mac802154_netdev_notifier); +} + +void ieee802154_iface_exit(void) +{ + unregister_netdevice_notifier(&mac802154_netdev_notifier); +} |