Skip to content

Commit ffb254c

Browse files
committed
Injection
1 parent 59a668d commit ffb254c

File tree

5 files changed

+43
-14
lines changed

5 files changed

+43
-14
lines changed

drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,17 @@ static void rtl8187_tx(struct ieee80211_hw *dev,
251251
flags |= RTL818X_TX_DESC_FLAG_NO_ENC;
252252

253253
flags |= ieee80211_get_tx_rate(dev, info)->hw_value << 24;
254+
255+
// When this flag is set the firmware waits untill ALL fragments have
256+
// reached the USB device. Then it sends the first fragment and waits
257+
// for ACKS's. Of course in monitor mode it won't detect these ACK's.
254258
if (ieee80211_has_morefrags(tx_hdr->frame_control))
255-
flags |= RTL818X_TX_DESC_FLAG_MOREFRAG;
259+
{
260+
// If info->control.vif is NULL it's most likely in monitor mode
261+
if (likely(info->control.vif != NULL && info->control.vif->type != NL80211_IFTYPE_MONITOR)) {
262+
flags |= RTL818X_TX_DESC_FLAG_MOREFRAG;
263+
}
264+
}
256265

257266
/* HW will perform RTS-CTS when only RTS flags is set.
258267
* HW will perform CTS-to-self when both RTS and CTS flags are set.

drivers/net/wireless/zydas/zd1211rw/zd_mac.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,19 @@ void zd_mac_clear(struct zd_mac *mac)
242242
static int set_rx_filter(struct zd_mac *mac)
243243
{
244244
unsigned long flags;
245-
u32 filter = STA_RX_FILTER;
245+
struct zd_ioreq32 ioreqs[] = {
246+
{CR_RX_FILTER, STA_RX_FILTER},
247+
{ CR_SNIFFER_ON, 0U },
248+
};
246249

247250
spin_lock_irqsave(&mac->lock, flags);
248-
if (mac->pass_ctrl)
249-
filter |= RX_FILTER_CTRL;
251+
if (mac->pass_ctrl) {
252+
ioreqs[0].value |= 0xFFFFFFFF;
253+
ioreqs[1].value = 0x1;
254+
}
250255
spin_unlock_irqrestore(&mac->lock, flags);
251256

252-
return zd_iowrite32(&mac->chip, CR_RX_FILTER, filter);
257+
return zd_iowrite32a(&mac->chip, ioreqs, ARRAY_SIZE(ioreqs));
253258
}
254259

255260
static int set_mac_and_bssid(struct zd_mac *mac)
@@ -1056,7 +1061,8 @@ int zd_mac_rx(struct ieee80211_hw *hw, const u8 *buffer, unsigned int length)
10561061
/* Caller has to ensure that length >= sizeof(struct rx_status). */
10571062
status = (struct rx_status *)
10581063
(buffer + (length - sizeof(struct rx_status)));
1059-
if (status->frame_status & ZD_RX_ERROR) {
1064+
if ((status->frame_status & ZD_RX_ERROR) ||
1065+
(status->frame_status & ~0x21)) {
10601066
if (mac->pass_failed_fcs &&
10611067
(status->frame_status & ZD_RX_CRC32_ERROR)) {
10621068
stats.flag |= RX_FLAG_FAILED_FCS_CRC;
@@ -1399,7 +1405,7 @@ struct ieee80211_hw *zd_mac_alloc_hw(struct usb_interface *intf)
13991405
ieee80211_hw_set(hw, MFP_CAPABLE);
14001406
ieee80211_hw_set(hw, HOST_BROADCAST_PS_BUFFERING);
14011407
ieee80211_hw_set(hw, RX_INCLUDES_FCS);
1402-
ieee80211_hw_set(hw, SIGNAL_UNSPEC);
1408+
ieee80211_hw_set(hw, SIGNAL_DBM);
14031409

14041410
hw->wiphy->interface_modes =
14051411
BIT(NL80211_IFTYPE_MESH_POINT) |

net/mac80211/cfg.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,8 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
748748
ret = ieee80211_vif_use_channel(sdata, chandef,
749749
IEEE80211_CHANCTX_EXCLUSIVE);
750750
}
751-
} else if (local->open_count == local->monitors) {
751+
// Patch: Always allow channel change, even if a normal virtual interface is present
752+
} else /*if (local->open_count == local->monitors)*/ {
752753
local->_oper_chandef = *chandef;
753754
ieee80211_hw_config(local, 0);
754755
}

net/mac80211/tx.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -803,11 +803,19 @@ ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx)
803803

804804
/*
805805
* Packet injection may want to control the sequence
806-
* number, if we have no matching interface then we
807-
* neither assign one ourselves nor ask the driver to.
806+
* number, so if an injected packet is found, skip
807+
* renumbering it. Also make the packet NO_ACK to avoid
808+
* excessive retries (ACKing and retrying should be
809+
* handled by the injecting application).
810+
* FIXME This may break hostapd and some other injectors.
811+
* This should be done using a radiotap flag.
808812
*/
809-
if (unlikely(info->control.vif->type == NL80211_IFTYPE_MONITOR))
813+
if (unlikely((info->flags & IEEE80211_TX_CTL_INJECTED) &&
814+
!(tx->sdata->u.mntr.flags & MONITOR_FLAG_COOK_FRAMES))) {
815+
if (!ieee80211_has_morefrags(hdr->frame_control))
816+
info->flags |= IEEE80211_TX_CTL_NO_ACK;
810817
return TX_CONTINUE;
818+
}
811819

812820
if (unlikely(ieee80211_is_ctl(hdr->frame_control)))
813821
return TX_CONTINUE;
@@ -1935,7 +1943,10 @@ void ieee80211_xmit(struct ieee80211_sub_if_data *sdata,
19351943
}
19361944
}
19371945

1938-
ieee80211_set_qos_hdr(sdata, skb);
1946+
// Don't overwrite QoS header in monitor mode
1947+
if (likely(info->control.vif->type != NL80211_IFTYPE_MONITOR)) {
1948+
ieee80211_set_qos_hdr(sdata, skb);
1949+
}
19391950
ieee80211_tx(sdata, sta, skb, false);
19401951
}
19411952

net/wireless/chan.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -982,8 +982,10 @@ int cfg80211_set_monitor_channel(struct cfg80211_registered_device *rdev,
982982
{
983983
if (!rdev->ops->set_monitor_channel)
984984
return -EOPNOTSUPP;
985-
if (!cfg80211_has_monitors_only(rdev))
986-
return -EBUSY;
985+
// Always allow user to change channel, even if there is another normal
986+
// virtual interface using the device.
987+
//if (!cfg80211_has_monitors_only(rdev))
988+
// return -EBUSY;
987989

988990
return rdev_set_monitor_channel(rdev, chandef);
989991
}

0 commit comments

Comments
 (0)