Skip to content

Commit

Permalink
mac80211: refactor monitor representation in sdata
Browse files Browse the repository at this point in the history
Insert the u32 monitor flags variable in a new structure
that represents a monitor interface.
This will allow to add more configuration variables to
that structure which will happen in an upcoming change.

Signed-off-by: Aviya Erenfeld <[email protected]>
Signed-off-by: Luca Coelho <[email protected]>
Signed-off-by: Johannes Berg <[email protected]>
  • Loading branch information
aerenfel authored and jmberg-intel committed Sep 12, 2016
1 parent 5a1f044 commit d821218
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 19 deletions.
8 changes: 4 additions & 4 deletions net/mac80211/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy,

if (type == NL80211_IFTYPE_MONITOR && flags) {
sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
sdata->u.mntr_flags = *flags;
sdata->u.mntr.flags = *flags;
}

return wdev;
Expand Down Expand Up @@ -89,11 +89,11 @@ static int ieee80211_change_iface(struct wiphy *wiphy,
* cooked_mntrs, monitor and all fif_* counters
* reconfigure hardware
*/
if ((*flags & mask) != (sdata->u.mntr_flags & mask))
if ((*flags & mask) != (sdata->u.mntr.flags & mask))
return -EBUSY;

ieee80211_adjust_monitor_flags(sdata, -1);
sdata->u.mntr_flags = *flags;
sdata->u.mntr.flags = *flags;
ieee80211_adjust_monitor_flags(sdata, 1);

ieee80211_configure_filter(local);
Expand All @@ -103,7 +103,7 @@ static int ieee80211_change_iface(struct wiphy *wiphy,
* and ieee80211_do_open take care of "everything"
* mentioned in the comment above.
*/
sdata->u.mntr_flags = *flags;
sdata->u.mntr.flags = *flags;
}
}

Expand Down
2 changes: 1 addition & 1 deletion net/mac80211/driver-ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ int drv_add_interface(struct ieee80211_local *local,
if (WARN_ON(sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
(sdata->vif.type == NL80211_IFTYPE_MONITOR &&
!ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF) &&
!(sdata->u.mntr_flags & MONITOR_FLAG_ACTIVE))))
!(sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE))))
return -EINVAL;

trace_drv_add_interface(local, sdata);
Expand Down
6 changes: 5 additions & 1 deletion net/mac80211/ieee80211_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,10 @@ struct txq_info {
struct ieee80211_txq txq;
};

struct ieee80211_if_mntr {
u32 flags;
};

struct ieee80211_sub_if_data {
struct list_head list;

Expand Down Expand Up @@ -922,7 +926,7 @@ struct ieee80211_sub_if_data {
struct ieee80211_if_ibss ibss;
struct ieee80211_if_mesh mesh;
struct ieee80211_if_ocb ocb;
u32 mntr_flags;
struct ieee80211_if_mntr mntr;
} u;

#ifdef CONFIG_MAC80211_DEBUGFS
Expand Down
16 changes: 8 additions & 8 deletions net/mac80211/iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ static int ieee80211_verify_mac(struct ieee80211_sub_if_data *sdata, u8 *addr,
continue;

if (iter->vif.type == NL80211_IFTYPE_MONITOR &&
!(iter->u.mntr_flags & MONITOR_FLAG_ACTIVE))
!(iter->u.mntr.flags & MONITOR_FLAG_ACTIVE))
continue;

m = iter->vif.addr;
Expand Down Expand Up @@ -217,7 +217,7 @@ static int ieee80211_change_mac(struct net_device *dev, void *addr)
return -EBUSY;

if (sdata->vif.type == NL80211_IFTYPE_MONITOR &&
!(sdata->u.mntr_flags & MONITOR_FLAG_ACTIVE))
!(sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE))
check_dup = false;

ret = ieee80211_verify_mac(sdata, sa->sa_data, check_dup);
Expand Down Expand Up @@ -357,7 +357,7 @@ void ieee80211_adjust_monitor_flags(struct ieee80211_sub_if_data *sdata,
const int offset)
{
struct ieee80211_local *local = sdata->local;
u32 flags = sdata->u.mntr_flags;
u32 flags = sdata->u.mntr.flags;

#define ADJUST(_f, _s) do { \
if (flags & MONITOR_FLAG_##_f) \
Expand Down Expand Up @@ -589,12 +589,12 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
}
break;
case NL80211_IFTYPE_MONITOR:
if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) {
if (sdata->u.mntr.flags & MONITOR_FLAG_COOK_FRAMES) {
local->cooked_mntrs++;
break;
}

if (sdata->u.mntr_flags & MONITOR_FLAG_ACTIVE) {
if (sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE) {
res = drv_add_interface(local, sdata);
if (res)
goto err_stop;
Expand Down Expand Up @@ -926,7 +926,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
/* no need to tell driver */
break;
case NL80211_IFTYPE_MONITOR:
if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) {
if (sdata->u.mntr.flags & MONITOR_FLAG_COOK_FRAMES) {
local->cooked_mntrs--;
break;
}
Expand Down Expand Up @@ -1012,7 +1012,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
ieee80211_recalc_idle(local);
mutex_unlock(&local->mtx);

if (!(sdata->u.mntr_flags & MONITOR_FLAG_ACTIVE))
if (!(sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE))
break;

/* fall through */
Expand Down Expand Up @@ -1444,7 +1444,7 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,
case NL80211_IFTYPE_MONITOR:
sdata->dev->type = ARPHRD_IEEE80211_RADIOTAP;
sdata->dev->netdev_ops = &ieee80211_monitorif_ops;
sdata->u.mntr_flags = MONITOR_FLAG_CONTROL |
sdata->u.mntr.flags = MONITOR_FLAG_CONTROL |
MONITOR_FLAG_OTHER_BSS;
break;
case NL80211_IFTYPE_WDS:
Expand Down
4 changes: 2 additions & 2 deletions net/mac80211/rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb,
if (sdata->vif.type != NL80211_IFTYPE_MONITOR)
continue;

if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES)
if (sdata->u.mntr.flags & MONITOR_FLAG_COOK_FRAMES)
continue;

if (!ieee80211_sdata_running(sdata))
Expand Down Expand Up @@ -3147,7 +3147,7 @@ static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx,
continue;

if (sdata->vif.type != NL80211_IFTYPE_MONITOR ||
!(sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES))
!(sdata->u.mntr.flags & MONITOR_FLAG_COOK_FRAMES))
continue;

if (prev_dev) {
Expand Down
2 changes: 1 addition & 1 deletion net/mac80211/status.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ void ieee80211_tx_monitor(struct ieee80211_local *local, struct sk_buff *skb,
if (!ieee80211_sdata_running(sdata))
continue;

if ((sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) &&
if ((sdata->u.mntr.flags & MONITOR_FLAG_COOK_FRAMES) &&
!send_to_cooked)
continue;

Expand Down
2 changes: 1 addition & 1 deletion net/mac80211/tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1643,7 +1643,7 @@ static bool __ieee80211_tx(struct ieee80211_local *local,

switch (sdata->vif.type) {
case NL80211_IFTYPE_MONITOR:
if (sdata->u.mntr_flags & MONITOR_FLAG_ACTIVE) {
if (sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE) {
vif = &sdata->vif;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion net/mac80211/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ static void __iterate_interfaces(struct ieee80211_local *local,
list_for_each_entry_rcu(sdata, &local->interfaces, list) {
switch (sdata->vif.type) {
case NL80211_IFTYPE_MONITOR:
if (!(sdata->u.mntr_flags & MONITOR_FLAG_ACTIVE))
if (!(sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE))
continue;
break;
case NL80211_IFTYPE_AP_VLAN:
Expand Down

0 comments on commit d821218

Please sign in to comment.