aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Aring <alex.aring@gmail.com>2014-11-09 02:36:57 -0500
committerMarcel Holtmann <marcel@holtmann.org>2014-11-09 13:50:29 -0500
commit7bea1ea7b4c16af7c9263648e10f7edc88e5fc21 (patch)
tree8092b084c39e45226260d031c9e4d477abbeed0a
parentb03c9cccfa808f1b314097b162a36c3937cb818e (diff)
ieee802154: netlink add rtnl lock
This patch adds rtnl lock hold mechanism while accessing wpan_dev attributes. Furthermore these attributes should be protected by rtnl lock and netif_running only. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r--net/ieee802154/nl-mac.c6
-rw-r--r--net/mac802154/mac_cmd.c10
2 files changed, 12 insertions, 4 deletions
diff --git a/net/ieee802154/nl-mac.c b/net/ieee802154/nl-mac.c
index 7127b9d1a684..50e9863823a5 100644
--- a/net/ieee802154/nl-mac.c
+++ b/net/ieee802154/nl-mac.c
@@ -113,7 +113,9 @@ static int ieee802154_nl_fill_iface(struct sk_buff *msg, u32 portid,
113 if (ops->get_mac_params) { 113 if (ops->get_mac_params) {
114 struct ieee802154_mac_params params; 114 struct ieee802154_mac_params params;
115 115
116 rtnl_lock();
116 ops->get_mac_params(dev, &params); 117 ops->get_mac_params(dev, &params);
118 rtnl_unlock();
117 119
118 if (nla_put_s8(msg, IEEE802154_ATTR_TXPOWER, 120 if (nla_put_s8(msg, IEEE802154_ATTR_TXPOWER,
119 params.transmit_power) || 121 params.transmit_power) ||
@@ -348,8 +350,10 @@ int ieee802154_start_req(struct sk_buff *skb, struct genl_info *info)
348 return -EINVAL; 350 return -EINVAL;
349 } 351 }
350 352
353 rtnl_lock();
351 ret = ieee802154_mlme_ops(dev)->start_req(dev, &addr, channel, page, 354 ret = ieee802154_mlme_ops(dev)->start_req(dev, &addr, channel, page,
352 bcn_ord, sf_ord, pan_coord, blx, coord_realign); 355 bcn_ord, sf_ord, pan_coord, blx, coord_realign);
356 rtnl_unlock();
353 357
354 /* FIXME: add validation for unused parameters to be sane 358 /* FIXME: add validation for unused parameters to be sane
355 * for SoftMAC 359 * for SoftMAC
@@ -497,6 +501,7 @@ int ieee802154_set_macparams(struct sk_buff *skb, struct genl_info *info)
497 phy = dev->ieee802154_ptr->wpan_phy; 501 phy = dev->ieee802154_ptr->wpan_phy;
498 get_device(&phy->dev); 502 get_device(&phy->dev);
499 503
504 rtnl_lock();
500 ops->get_mac_params(dev, &params); 505 ops->get_mac_params(dev, &params);
501 506
502 if (info->attrs[IEEE802154_ATTR_TXPOWER]) 507 if (info->attrs[IEEE802154_ATTR_TXPOWER])
@@ -524,6 +529,7 @@ int ieee802154_set_macparams(struct sk_buff *skb, struct genl_info *info)
524 params.frame_retries = nla_get_s8(info->attrs[IEEE802154_ATTR_FRAME_RETRIES]); 529 params.frame_retries = nla_get_s8(info->attrs[IEEE802154_ATTR_FRAME_RETRIES]);
525 530
526 rc = ops->set_mac_params(dev, &params); 531 rc = ops->set_mac_params(dev, &params);
532 rtnl_unlock();
527 533
528 wpan_phy_put(phy); 534 wpan_phy_put(phy);
529 dev_put(dev); 535 dev_put(dev);
diff --git a/net/mac802154/mac_cmd.c b/net/mac802154/mac_cmd.c
index b8bd95263aab..6aacb1816889 100644
--- a/net/mac802154/mac_cmd.c
+++ b/net/mac802154/mac_cmd.c
@@ -39,6 +39,8 @@ static int mac802154_mlme_start_req(struct net_device *dev,
39 struct ieee802154_mlme_ops *ops = ieee802154_mlme_ops(dev); 39 struct ieee802154_mlme_ops *ops = ieee802154_mlme_ops(dev);
40 int rc = 0; 40 int rc = 0;
41 41
42 ASSERT_RTNL();
43
42 BUG_ON(addr->mode != IEEE802154_ADDR_SHORT); 44 BUG_ON(addr->mode != IEEE802154_ADDR_SHORT);
43 45
44 mac802154_dev_set_pan_id(dev, addr->pan_id); 46 mac802154_dev_set_pan_id(dev, addr->pan_id);
@@ -75,7 +77,8 @@ static int mac802154_set_mac_params(struct net_device *dev,
75 struct wpan_dev *wpan_dev = &sdata->wpan_dev; 77 struct wpan_dev *wpan_dev = &sdata->wpan_dev;
76 int ret; 78 int ret;
77 79
78 mutex_lock(&sdata->local->iflist_mtx); 80 ASSERT_RTNL();
81
79 /* PHY */ 82 /* PHY */
80 wpan_dev->wpan_phy->transmit_power = params->transmit_power; 83 wpan_dev->wpan_phy->transmit_power = params->transmit_power;
81 wpan_dev->wpan_phy->cca_mode = params->cca_mode; 84 wpan_dev->wpan_phy->cca_mode = params->cca_mode;
@@ -87,7 +90,6 @@ static int mac802154_set_mac_params(struct net_device *dev,
87 wpan_dev->csma_retries = params->csma_retries; 90 wpan_dev->csma_retries = params->csma_retries;
88 wpan_dev->frame_retries = params->frame_retries; 91 wpan_dev->frame_retries = params->frame_retries;
89 wpan_dev->lbt = params->lbt; 92 wpan_dev->lbt = params->lbt;
90 mutex_unlock(&sdata->local->iflist_mtx);
91 93
92 if (local->hw.flags & IEEE802154_HW_TXPOWER) { 94 if (local->hw.flags & IEEE802154_HW_TXPOWER) {
93 ret = drv_set_tx_power(local, params->transmit_power); 95 ret = drv_set_tx_power(local, params->transmit_power);
@@ -116,7 +118,8 @@ static void mac802154_get_mac_params(struct net_device *dev,
116 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); 118 struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
117 struct wpan_dev *wpan_dev = &sdata->wpan_dev; 119 struct wpan_dev *wpan_dev = &sdata->wpan_dev;
118 120
119 mutex_lock(&sdata->local->iflist_mtx); 121 ASSERT_RTNL();
122
120 /* PHY */ 123 /* PHY */
121 params->transmit_power = wpan_dev->wpan_phy->transmit_power; 124 params->transmit_power = wpan_dev->wpan_phy->transmit_power;
122 params->cca_mode = wpan_dev->wpan_phy->cca_mode; 125 params->cca_mode = wpan_dev->wpan_phy->cca_mode;
@@ -128,7 +131,6 @@ static void mac802154_get_mac_params(struct net_device *dev,
128 params->csma_retries = wpan_dev->csma_retries; 131 params->csma_retries = wpan_dev->csma_retries;
129 params->frame_retries = wpan_dev->frame_retries; 132 params->frame_retries = wpan_dev->frame_retries;
130 params->lbt = wpan_dev->lbt; 133 params->lbt = wpan_dev->lbt;
131 mutex_unlock(&sdata->local->iflist_mtx);
132} 134}
133 135
134static struct ieee802154_llsec_ops mac802154_llsec_ops = { 136static struct ieee802154_llsec_ops mac802154_llsec_ops = {