Commit 959eb2fd authored by Johannes Berg's avatar Johannes Berg

mac80211_hwsim: stop using pointers as cookies

Instead of using pointers, use sequentially assigned cookies.
This is easier to understand while debugging and also avoids
problems when the pointer is reused for the next allocation.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 00eeccc4
...@@ -517,6 +517,7 @@ struct mac80211_hwsim_data { ...@@ -517,6 +517,7 @@ struct mac80211_hwsim_data {
bool ps_poll_pending; bool ps_poll_pending;
struct dentry *debugfs; struct dentry *debugfs;
uintptr_t pending_cookie;
struct sk_buff_head pending; /* packets pending */ struct sk_buff_head pending; /* packets pending */
/* /*
* Only radios in the same group can communicate together (the * Only radios in the same group can communicate together (the
...@@ -963,6 +964,7 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw, ...@@ -963,6 +964,7 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw,
unsigned int hwsim_flags = 0; unsigned int hwsim_flags = 0;
int i; int i;
struct hwsim_tx_rate tx_attempts[IEEE80211_TX_MAX_RATES]; struct hwsim_tx_rate tx_attempts[IEEE80211_TX_MAX_RATES];
uintptr_t cookie;
if (data->ps != PS_DISABLED) if (data->ps != PS_DISABLED)
hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM);
...@@ -1021,7 +1023,10 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw, ...@@ -1021,7 +1023,10 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw,
goto nla_put_failure; goto nla_put_failure;
/* We create a cookie to identify this skb */ /* We create a cookie to identify this skb */
if (nla_put_u64(skb, HWSIM_ATTR_COOKIE, (unsigned long) my_skb)) data->pending_cookie++;
cookie = data->pending_cookie;
info->rate_driver_data[0] = (void *)cookie;
if (nla_put_u64(skb, HWSIM_ATTR_COOKIE, cookie))
goto nla_put_failure; goto nla_put_failure;
genlmsg_end(skb, msg_head); genlmsg_end(skb, msg_head);
...@@ -2749,7 +2754,7 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2, ...@@ -2749,7 +2754,7 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2,
struct mac80211_hwsim_data *data2; struct mac80211_hwsim_data *data2;
struct ieee80211_tx_info *txi; struct ieee80211_tx_info *txi;
struct hwsim_tx_rate *tx_attempts; struct hwsim_tx_rate *tx_attempts;
unsigned long ret_skb_ptr; u64 ret_skb_cookie;
struct sk_buff *skb, *tmp; struct sk_buff *skb, *tmp;
const u8 *src; const u8 *src;
unsigned int hwsim_flags; unsigned int hwsim_flags;
...@@ -2767,7 +2772,7 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2, ...@@ -2767,7 +2772,7 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2,
src = (void *)nla_data(info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER]); src = (void *)nla_data(info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER]);
hwsim_flags = nla_get_u32(info->attrs[HWSIM_ATTR_FLAGS]); hwsim_flags = nla_get_u32(info->attrs[HWSIM_ATTR_FLAGS]);
ret_skb_ptr = nla_get_u64(info->attrs[HWSIM_ATTR_COOKIE]); ret_skb_cookie = nla_get_u64(info->attrs[HWSIM_ATTR_COOKIE]);
data2 = get_hwsim_data_ref_from_addr(src); data2 = get_hwsim_data_ref_from_addr(src);
if (!data2) if (!data2)
...@@ -2775,7 +2780,12 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2, ...@@ -2775,7 +2780,12 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2,
/* look for the skb matching the cookie passed back from user */ /* look for the skb matching the cookie passed back from user */
skb_queue_walk_safe(&data2->pending, skb, tmp) { skb_queue_walk_safe(&data2->pending, skb, tmp) {
if ((unsigned long)skb == ret_skb_ptr) { u64 skb_cookie;
txi = IEEE80211_SKB_CB(skb);
skb_cookie = (u64)(uintptr_t)txi->rate_driver_data[0];
if (skb_cookie == ret_skb_cookie) {
skb_unlink(skb, &data2->pending); skb_unlink(skb, &data2->pending);
found = true; found = true;
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment