2008-04-10 14:41:45

by Johannes Berg

[permalink] [raw]
Subject: [RFC 3/3] mac80211: annotate with __requires_rcu

As an example, this annotates mac80211 with the new __requires_rcu.

Not-yet-signed-off-by: Johannes Berg <[email protected]>
---
net/mac80211/key.c | 2 +-
net/mac80211/key.h | 2 +-
net/mac80211/rx.c | 12 ++++++------
net/mac80211/sta_info.h | 3 ++-
net/mac80211/tx.c | 3 ++-
5 files changed, 12 insertions(+), 10 deletions(-)

--- everything.orig/net/mac80211/sta_info.h 2008-04-10 15:36:20.000000000 +0200
+++ everything/net/mac80211/sta_info.h 2008-04-10 15:36:45.000000000 +0200
@@ -321,7 +321,8 @@ static inline enum plink_state sta_plink
/*
* Get a STA info, must have be under RCU read lock.
*/
-struct sta_info *sta_info_get(struct ieee80211_local *local, u8 *addr);
+struct sta_info *sta_info_get(struct ieee80211_local *local, u8 *addr) __requires_rcu;
+
/*
* Get STA info by index, BROKEN!
*/
--- everything.orig/net/mac80211/key.c 2008-04-10 15:36:20.000000000 +0200
+++ everything/net/mac80211/key.c 2008-04-10 15:36:45.000000000 +0200
@@ -299,7 +299,7 @@ struct ieee80211_key *ieee80211_key_allo

void ieee80211_key_link(struct ieee80211_key *key,
struct ieee80211_sub_if_data *sdata,
- struct sta_info *sta)
+ struct sta_info *sta) __requires_rcu
{
struct ieee80211_key *old_key;
unsigned long flags;
--- everything.orig/net/mac80211/key.h 2008-04-10 15:36:20.000000000 +0200
+++ everything/net/mac80211/key.h 2008-04-10 15:36:45.000000000 +0200
@@ -146,7 +146,7 @@ struct ieee80211_key *ieee80211_key_allo
*/
void ieee80211_key_link(struct ieee80211_key *key,
struct ieee80211_sub_if_data *sdata,
- struct sta_info *sta);
+ struct sta_info *sta) __requires(RCU);
void ieee80211_key_free(struct ieee80211_key *key);
void ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata, int idx);
void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata);
--- everything.orig/net/mac80211/rx.c 2008-04-10 15:36:20.000000000 +0200
+++ everything/net/mac80211/rx.c 2008-04-10 15:36:45.000000000 +0200
@@ -1261,7 +1261,7 @@ static bool ieee80211_frame_allowed(stru
* requires that rx->skb is a frame with ethernet header
*/
static void
-ieee80211_deliver_skb(struct ieee80211_rx_data *rx)
+ieee80211_deliver_skb(struct ieee80211_rx_data *rx) __requires_rcu
{
struct net_device *dev = rx->dev;
struct ieee80211_local *local = rx->local;
@@ -1349,7 +1349,7 @@ ieee80211_deliver_skb(struct ieee80211_r
}

static ieee80211_rx_result
-ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx)
+ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) __requires_rcu
{
struct net_device *dev = rx->dev;
struct ieee80211_local *local = rx->local;
@@ -1466,7 +1466,7 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx
}

static ieee80211_rx_result
-ieee80211_rx_h_data(struct ieee80211_rx_data *rx)
+ieee80211_rx_h_data(struct ieee80211_rx_data *rx) __requires_rcu
{
struct net_device *dev = rx->dev;
u16 fc;
@@ -1876,7 +1876,7 @@ static void __ieee80211_rx_handle_packet
struct sk_buff *skb,
struct ieee80211_rx_status *status,
u32 load,
- struct ieee80211_rate *rate)
+ struct ieee80211_rate *rate) __requires_rcu
{
struct ieee80211_local *local = hw_to_local(hw);
struct ieee80211_sub_if_data *sdata;
@@ -1997,7 +1997,7 @@ static inline u16 seq_sub(u16 sq1, u16 s
u8 ieee80211_sta_manage_reorder_buf(struct ieee80211_hw *hw,
struct tid_ampdu_rx *tid_agg_rx,
struct sk_buff *skb, u16 mpdu_seq_num,
- int bar_req)
+ int bar_req) __requires_rcu
{
struct ieee80211_local *local = hw_to_local(hw);
struct ieee80211_rx_status status;
@@ -2100,7 +2100,7 @@ u8 ieee80211_sta_manage_reorder_buf(stru
}

static u8 ieee80211_rx_reorder_ampdu(struct ieee80211_local *local,
- struct sk_buff *skb)
+ struct sk_buff *skb) __requires_rcu
{
struct ieee80211_hw *hw = &local->hw;
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
--- everything.orig/net/mac80211/tx.c 2008-04-10 15:36:20.000000000 +0200
+++ everything/net/mac80211/tx.c 2008-04-10 15:36:45.000000000 +0200
@@ -968,7 +968,7 @@ static ieee80211_tx_result
__ieee80211_tx_prepare(struct ieee80211_tx_data *tx,
struct sk_buff *skb,
struct net_device *dev,
- struct ieee80211_tx_control *control)
+ struct ieee80211_tx_control *control) __requires_rcu
{
struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
struct ieee80211_hdr *hdr;
@@ -1047,6 +1047,7 @@ static int ieee80211_tx_prepare(struct i
struct sk_buff *skb,
struct net_device *mdev,
struct ieee80211_tx_control *control)
+ __requires_rcu
{
struct ieee80211_tx_packet_data *pkt_data;
struct net_device *dev;

--



2008-04-12 13:56:59

by Michael Büsch

[permalink] [raw]
Subject: Re: [RFC 1/2] mac80211: Patch to prevent mac80211 to clobber injected sequence numbers

On Saturday 12 April 2008 15:38:00 Jory A. Pratt wrote:
>

See list archives for why these two patches are not acceptable as-is.

--
Greetings Michael.

2008-04-12 13:38:14

by Jory A. Pratt

[permalink] [raw]
Subject: [RFC 1/2] mac80211: Patch to prevent mac80211 to clobber injected sequence numbers

# Patch to prevent mac80211 to clobber injected sequence numbers

diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index f35eaea..ef3e33f 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -292,6 +292,9 @@ ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx)
{
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;

+ if (unlikely(tx->flags & IEEE80211_TXRXD_TX_INJECTED))
+ return TXRX_CONTINUE;
+
if (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control)) >= 24)
ieee80211_include_sequence(tx->sdata, hdr);


Attachments:
mac80211-wireless-testing_frag.patch (585.00 B)

2008-04-12 08:56:48

by Johannes Berg

[permalink] [raw]
Subject: Re: [RFC 3/3] mac80211: annotate with __requires_rcu

On Sat, 2008-04-12 at 10:50 +0200, Geert Uytterhoeven wrote:
> On Thu, 10 Apr 2008, Johannes Berg wrote:
> > --- everything.orig/net/mac80211/key.h 2008-04-10 15:36:20.000000000 +0200
> > +++ everything/net/mac80211/key.h 2008-04-10 15:36:45.000000000 +0200
> > @@ -146,7 +146,7 @@ struct ieee80211_key *ieee80211_key_allo
> > */
> > void ieee80211_key_link(struct ieee80211_key *key,
> > struct ieee80211_sub_if_data *sdata,
> > - struct sta_info *sta);
> > + struct sta_info *sta) __requires(RCU);
> ^^^^^^^^^^^^^^^
> __requires_rcu? (for consistency)

Yeah, forgot to fix up this one, I had been playing with it locally
without __requires_rcu first.

Thanks,
johannes


Attachments:
signature.asc (828.00 B)
This is a digitally signed message part

2008-04-12 08:50:56

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [RFC 3/3] mac80211: annotate with __requires_rcu

On Thu, 10 Apr 2008, Johannes Berg wrote:
> --- everything.orig/net/mac80211/key.h 2008-04-10 15:36:20.000000000 +0200
> +++ everything/net/mac80211/key.h 2008-04-10 15:36:45.000000000 +0200
> @@ -146,7 +146,7 @@ struct ieee80211_key *ieee80211_key_allo
> */
> void ieee80211_key_link(struct ieee80211_key *key,
> struct ieee80211_sub_if_data *sdata,
> - struct sta_info *sta);
> + struct sta_info *sta) __requires(RCU);
^^^^^^^^^^^^^^^
__requires_rcu? (for consistency)

With kind regards,

Geert Uytterhoeven
Software Architect

Sony Network and Software Technology Center Europe
The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium

Phone: +32 (0)2 700 8453
Fax: +32 (0)2 700 8622
E-mail: [email protected]
Internet: http://www.sony-europe.com/

Sony Network and Software Technology Center Europe
A division of Sony Service Centre (Europe) N.V.
Registered office: Technologielaan 7 · B-1840 Londerzeel · Belgium
VAT BE 0413.825.160 · RPR Brussels
Fortis Bank Zaventem · Swift GEBABEBB08A · IBAN BE39001382358619