Skip to content

Commit 5a5c4e0

Browse files
miquelraynalStefan-Schmidt
authored andcommitted
mac802154: Fix LQI recording
Back in 2014, the LQI was saved in the skb control buffer (skb->cb, or mac_cb(skb)) without any actual reset of this area prior to its use. As part of a useful rework of the use of this region, 32edc40 ("ieee802154: change _cb handling slightly") introduced mac_cb_init() to basically memset the cb field to 0. In particular, this new function got called at the beginning of mac802154_parse_frame_start(), right before the location where the buffer got actually filled. What went through unnoticed however, is the fact that the very first helper called by device drivers in the receive path already used this area to save the LQI value for later extraction. Resetting the cb field "so late" led to systematically zeroing the LQI. If we consider the reset of the cb field needed, we can make it as soon as we get an skb from a device driver, right before storing the LQI, as is the very first time we need to write something there. Cc: [email protected] Fixes: 32edc40 ("ieee802154: change _cb handling slightly") Signed-off-by: Miquel Raynal <[email protected]> Acked-by: Alexander Aring <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stefan Schmidt <[email protected]>
1 parent 444d8ad commit 5a5c4e0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

net/mac802154/rx.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static int
132132
ieee802154_parse_frame_start(struct sk_buff *skb, struct ieee802154_hdr *hdr)
133133
{
134134
int hlen;
135-
struct ieee802154_mac_cb *cb = mac_cb_init(skb);
135+
struct ieee802154_mac_cb *cb = mac_cb(skb);
136136

137137
skb_reset_mac_header(skb);
138138

@@ -294,8 +294,9 @@ void
294294
ieee802154_rx_irqsafe(struct ieee802154_hw *hw, struct sk_buff *skb, u8 lqi)
295295
{
296296
struct ieee802154_local *local = hw_to_local(hw);
297+
struct ieee802154_mac_cb *cb = mac_cb_init(skb);
297298

298-
mac_cb(skb)->lqi = lqi;
299+
cb->lqi = lqi;
299300
skb->pkt_type = IEEE802154_RX_MSG;
300301
skb_queue_tail(&local->skb_queue, skb);
301302
tasklet_schedule(&local->tasklet);

0 commit comments

Comments
 (0)