Commit 2f3a247c authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'net-extend-drop-reasons'

Johannes Berg says:

====================
net: extend drop reasons

Here's v4 of the extended drop reasons, with fixes to kernel-doc
and checkpatch.
====================

Link: https://lore.kernel.org/r/20230419125254.20789-1-johannes@sipsolutions.netSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 7ab75456 baa951a1
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
#include <linux/rbtree.h> #include <linux/rbtree.h>
#include <net/net_trackers.h> #include <net/net_trackers.h>
#include <net/net_debug.h> #include <net/net_debug.h>
#include <net/dropreason.h> #include <net/dropreason-core.h>
struct netpoll_info; struct netpoll_info;
struct device; struct device;
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include <linux/netfilter/nf_conntrack_common.h> #include <linux/netfilter/nf_conntrack_common.h>
#endif #endif
#include <net/net_debug.h> #include <net/net_debug.h>
#include <net/dropreason.h> #include <net/dropreason-core.h>
/** /**
* DOC: skb checksums * DOC: skb checksums
......
This diff is collapsed.
This diff is collapsed.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include <linux/in6.h> #include <linux/in6.h>
#include <linux/rbtree_types.h> #include <linux/rbtree_types.h>
#include <linux/refcount.h> #include <linux/refcount.h>
#include <net/dropreason.h> #include <net/dropreason-core.h>
/* Per netns frag queues directory */ /* Per netns frag queues directory */
struct fqdir { struct fqdir {
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/netlink.h> #include <linux/netlink.h>
#include <linux/net_dropmon.h> #include <linux/net_dropmon.h>
#include <linux/bitfield.h>
#include <linux/percpu.h> #include <linux/percpu.h>
#include <linux/timer.h> #include <linux/timer.h>
#include <linux/bitops.h> #include <linux/bitops.h>
...@@ -29,6 +30,7 @@ ...@@ -29,6 +30,7 @@
#include <net/genetlink.h> #include <net/genetlink.h>
#include <net/netevent.h> #include <net/netevent.h>
#include <net/flow_offload.h> #include <net/flow_offload.h>
#include <net/dropreason.h>
#include <net/devlink.h> #include <net/devlink.h>
#include <trace/events/skb.h> #include <trace/events/skb.h>
...@@ -504,8 +506,6 @@ static void net_dm_packet_trace_kfree_skb_hit(void *ignore, ...@@ -504,8 +506,6 @@ static void net_dm_packet_trace_kfree_skb_hit(void *ignore,
if (!nskb) if (!nskb)
return; return;
if (unlikely(reason >= SKB_DROP_REASON_MAX || reason <= 0))
reason = SKB_DROP_REASON_NOT_SPECIFIED;
cb = NET_DM_SKB_CB(nskb); cb = NET_DM_SKB_CB(nskb);
cb->reason = reason; cb->reason = reason;
cb->pc = location; cb->pc = location;
...@@ -552,9 +552,9 @@ static size_t net_dm_in_port_size(void) ...@@ -552,9 +552,9 @@ static size_t net_dm_in_port_size(void)
} }
#define NET_DM_MAX_SYMBOL_LEN 40 #define NET_DM_MAX_SYMBOL_LEN 40
#define NET_DM_MAX_REASON_LEN 50
static size_t net_dm_packet_report_size(size_t payload_len, static size_t net_dm_packet_report_size(size_t payload_len)
enum skb_drop_reason reason)
{ {
size_t size; size_t size;
...@@ -576,7 +576,7 @@ static size_t net_dm_packet_report_size(size_t payload_len, ...@@ -576,7 +576,7 @@ static size_t net_dm_packet_report_size(size_t payload_len,
/* NET_DM_ATTR_PROTO */ /* NET_DM_ATTR_PROTO */
nla_total_size(sizeof(u16)) + nla_total_size(sizeof(u16)) +
/* NET_DM_ATTR_REASON */ /* NET_DM_ATTR_REASON */
nla_total_size(strlen(drop_reasons[reason]) + 1) + nla_total_size(NET_DM_MAX_REASON_LEN + 1) +
/* NET_DM_ATTR_PAYLOAD */ /* NET_DM_ATTR_PAYLOAD */
nla_total_size(payload_len); nla_total_size(payload_len);
} }
...@@ -610,6 +610,8 @@ static int net_dm_packet_report_fill(struct sk_buff *msg, struct sk_buff *skb, ...@@ -610,6 +610,8 @@ static int net_dm_packet_report_fill(struct sk_buff *msg, struct sk_buff *skb,
size_t payload_len) size_t payload_len)
{ {
struct net_dm_skb_cb *cb = NET_DM_SKB_CB(skb); struct net_dm_skb_cb *cb = NET_DM_SKB_CB(skb);
const struct drop_reason_list *list = NULL;
unsigned int subsys, subsys_reason;
char buf[NET_DM_MAX_SYMBOL_LEN]; char buf[NET_DM_MAX_SYMBOL_LEN];
struct nlattr *attr; struct nlattr *attr;
void *hdr; void *hdr;
...@@ -627,9 +629,24 @@ static int net_dm_packet_report_fill(struct sk_buff *msg, struct sk_buff *skb, ...@@ -627,9 +629,24 @@ static int net_dm_packet_report_fill(struct sk_buff *msg, struct sk_buff *skb,
NET_DM_ATTR_PAD)) NET_DM_ATTR_PAD))
goto nla_put_failure; goto nla_put_failure;
rcu_read_lock();
subsys = u32_get_bits(cb->reason, SKB_DROP_REASON_SUBSYS_MASK);
if (subsys < SKB_DROP_REASON_SUBSYS_NUM)
list = rcu_dereference(drop_reasons_by_subsys[subsys]);
subsys_reason = cb->reason & ~SKB_DROP_REASON_SUBSYS_MASK;
if (!list ||
subsys_reason >= list->n_reasons ||
!list->reasons[subsys_reason] ||
strlen(list->reasons[subsys_reason]) > NET_DM_MAX_REASON_LEN) {
list = rcu_dereference(drop_reasons_by_subsys[SKB_DROP_REASON_SUBSYS_CORE]);
subsys_reason = SKB_DROP_REASON_NOT_SPECIFIED;
}
if (nla_put_string(msg, NET_DM_ATTR_REASON, if (nla_put_string(msg, NET_DM_ATTR_REASON,
drop_reasons[cb->reason])) list->reasons[subsys_reason])) {
rcu_read_unlock();
goto nla_put_failure; goto nla_put_failure;
}
rcu_read_unlock();
snprintf(buf, sizeof(buf), "%pS", cb->pc); snprintf(buf, sizeof(buf), "%pS", cb->pc);
if (nla_put_string(msg, NET_DM_ATTR_SYMBOL, buf)) if (nla_put_string(msg, NET_DM_ATTR_SYMBOL, buf))
...@@ -687,9 +704,7 @@ static void net_dm_packet_report(struct sk_buff *skb) ...@@ -687,9 +704,7 @@ static void net_dm_packet_report(struct sk_buff *skb)
if (net_dm_trunc_len) if (net_dm_trunc_len)
payload_len = min_t(size_t, net_dm_trunc_len, payload_len); payload_len = min_t(size_t, net_dm_trunc_len, payload_len);
msg = nlmsg_new(net_dm_packet_report_size(payload_len, msg = nlmsg_new(net_dm_packet_report_size(payload_len), GFP_KERNEL);
NET_DM_SKB_CB(skb)->reason),
GFP_KERNEL);
if (!msg) if (!msg)
goto out; goto out;
......
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
#include <linux/scatterlist.h> #include <linux/scatterlist.h>
#include <linux/errqueue.h> #include <linux/errqueue.h>
#include <linux/prefetch.h> #include <linux/prefetch.h>
#include <linux/bitfield.h>
#include <linux/if_vlan.h> #include <linux/if_vlan.h>
#include <linux/mpls.h> #include <linux/mpls.h>
#include <linux/kcov.h> #include <linux/kcov.h>
...@@ -72,6 +73,7 @@ ...@@ -72,6 +73,7 @@
#include <net/mptcp.h> #include <net/mptcp.h>
#include <net/mctp.h> #include <net/mctp.h>
#include <net/page_pool.h> #include <net/page_pool.h>
#include <net/dropreason.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <trace/events/skb.h> #include <trace/events/skb.h>
...@@ -122,11 +124,59 @@ EXPORT_SYMBOL(sysctl_max_skb_frags); ...@@ -122,11 +124,59 @@ EXPORT_SYMBOL(sysctl_max_skb_frags);
#undef FN #undef FN
#define FN(reason) [SKB_DROP_REASON_##reason] = #reason, #define FN(reason) [SKB_DROP_REASON_##reason] = #reason,
const char * const drop_reasons[] = { static const char * const drop_reasons[] = {
[SKB_CONSUMED] = "CONSUMED", [SKB_CONSUMED] = "CONSUMED",
DEFINE_DROP_REASON(FN, FN) DEFINE_DROP_REASON(FN, FN)
}; };
EXPORT_SYMBOL(drop_reasons);
static const struct drop_reason_list drop_reasons_core = {
.reasons = drop_reasons,
.n_reasons = ARRAY_SIZE(drop_reasons),
};
const struct drop_reason_list __rcu *
drop_reasons_by_subsys[SKB_DROP_REASON_SUBSYS_NUM] = {
[SKB_DROP_REASON_SUBSYS_CORE] = RCU_INITIALIZER(&drop_reasons_core),
};
EXPORT_SYMBOL(drop_reasons_by_subsys);
/**
* drop_reasons_register_subsys - register another drop reason subsystem
* @subsys: the subsystem to register, must not be the core
* @list: the list of drop reasons within the subsystem, must point to
* a statically initialized list
*/
void drop_reasons_register_subsys(enum skb_drop_reason_subsys subsys,
const struct drop_reason_list *list)
{
if (WARN(subsys <= SKB_DROP_REASON_SUBSYS_CORE ||
subsys >= ARRAY_SIZE(drop_reasons_by_subsys),
"invalid subsystem %d\n", subsys))
return;
/* must point to statically allocated memory, so INIT is OK */
RCU_INIT_POINTER(drop_reasons_by_subsys[subsys], list);
}
EXPORT_SYMBOL_GPL(drop_reasons_register_subsys);
/**
* drop_reasons_unregister_subsys - unregister a drop reason subsystem
* @subsys: the subsystem to remove, must not be the core
*
* Note: This will synchronize_rcu() to ensure no users when it returns.
*/
void drop_reasons_unregister_subsys(enum skb_drop_reason_subsys subsys)
{
if (WARN(subsys <= SKB_DROP_REASON_SUBSYS_CORE ||
subsys >= ARRAY_SIZE(drop_reasons_by_subsys),
"invalid subsystem %d\n", subsys))
return;
RCU_INIT_POINTER(drop_reasons_by_subsys[subsys], NULL);
synchronize_rcu();
}
EXPORT_SYMBOL_GPL(drop_reasons_unregister_subsys);
/** /**
* skb_panic - private function for out-of-line support * skb_panic - private function for out-of-line support
...@@ -986,7 +1036,10 @@ bool __kfree_skb_reason(struct sk_buff *skb, enum skb_drop_reason reason) ...@@ -986,7 +1036,10 @@ bool __kfree_skb_reason(struct sk_buff *skb, enum skb_drop_reason reason)
if (unlikely(!skb_unref(skb))) if (unlikely(!skb_unref(skb)))
return false; return false;
DEBUG_NET_WARN_ON_ONCE(reason <= 0 || reason >= SKB_DROP_REASON_MAX); DEBUG_NET_WARN_ON_ONCE(reason == SKB_NOT_DROPPED_YET ||
u32_get_bits(reason,
SKB_DROP_REASON_SUBSYS_MASK) >=
SKB_DROP_REASON_SUBSYS_NUM);
if (reason == SKB_CONSUMED) if (reason == SKB_CONSUMED)
trace_consume_skb(skb, __builtin_return_address(0)); trace_consume_skb(skb, __builtin_return_address(0));
......
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* mac80211 drop reason list
*
* Copyright (C) 2023 Intel Corporation
*/
#ifndef MAC80211_DROP_H
#define MAC80211_DROP_H
#include <net/dropreason.h>
typedef unsigned int __bitwise ieee80211_rx_result;
#define MAC80211_DROP_REASONS_MONITOR(R) \
R(RX_DROP_M_UNEXPECTED_4ADDR_FRAME) \
R(RX_DROP_M_BAD_BCN_KEYIDX) \
R(RX_DROP_M_BAD_MGMT_KEYIDX) \
/* this line for the trailing \ - add before this */
#define MAC80211_DROP_REASONS_UNUSABLE(R) \
R(RX_DROP_U_MIC_FAIL) \
R(RX_DROP_U_REPLAY) \
R(RX_DROP_U_BAD_MMIE) \
/* this line for the trailing \ - add before this */
/* having two enums allows for checking ieee80211_rx_result use with sparse */
enum ___mac80211_drop_reason {
/* if we get to the end of handlers with RX_CONTINUE this will be the reason */
___RX_CONTINUE = SKB_CONSUMED,
/* this never gets used as an argument to kfree_skb_reason() */
___RX_QUEUED = SKB_NOT_DROPPED_YET,
#define ENUM(x) ___ ## x,
___RX_DROP_MONITOR = SKB_DROP_REASON_SUBSYS_MAC80211_MONITOR <<
SKB_DROP_REASON_SUBSYS_SHIFT,
MAC80211_DROP_REASONS_MONITOR(ENUM)
___RX_DROP_UNUSABLE = SKB_DROP_REASON_SUBSYS_MAC80211_UNUSABLE <<
SKB_DROP_REASON_SUBSYS_SHIFT,
MAC80211_DROP_REASONS_UNUSABLE(ENUM)
#undef ENUM
};
enum mac80211_drop_reason {
RX_CONTINUE = (__force ieee80211_rx_result)___RX_CONTINUE,
RX_QUEUED = (__force ieee80211_rx_result)___RX_QUEUED,
RX_DROP_MONITOR = (__force ieee80211_rx_result)___RX_DROP_MONITOR,
RX_DROP_UNUSABLE = (__force ieee80211_rx_result)___RX_DROP_UNUSABLE,
#define DEF(x) x = (__force ieee80211_rx_result)___ ## x,
MAC80211_DROP_REASONS_MONITOR(DEF)
MAC80211_DROP_REASONS_UNUSABLE(DEF)
#undef DEF
};
#endif /* MAC80211_DROP_H */
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "key.h" #include "key.h"
#include "sta_info.h" #include "sta_info.h"
#include "debug.h" #include "debug.h"
#include "drop.h"
extern const struct cfg80211_ops mac80211_config_ops; extern const struct cfg80211_ops mac80211_config_ops;
...@@ -170,13 +171,6 @@ struct ieee80211_tx_data { ...@@ -170,13 +171,6 @@ struct ieee80211_tx_data {
unsigned int flags; unsigned int flags;
}; };
typedef unsigned __bitwise ieee80211_rx_result;
#define RX_CONTINUE ((__force ieee80211_rx_result) 0u)
#define RX_DROP_UNUSABLE ((__force ieee80211_rx_result) 1u)
#define RX_DROP_MONITOR ((__force ieee80211_rx_result) 2u)
#define RX_QUEUED ((__force ieee80211_rx_result) 3u)
/** /**
* enum ieee80211_packet_rx_flags - packet RX flags * enum ieee80211_packet_rx_flags - packet RX flags
* @IEEE80211_RX_AMSDU: a-MSDU packet * @IEEE80211_RX_AMSDU: a-MSDU packet
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <linux/bitmap.h> #include <linux/bitmap.h>
#include <linux/inetdevice.h> #include <linux/inetdevice.h>
#include <net/net_namespace.h> #include <net/net_namespace.h>
#include <net/dropreason.h>
#include <net/cfg80211.h> #include <net/cfg80211.h>
#include <net/addrconf.h> #include <net/addrconf.h>
...@@ -1542,6 +1543,28 @@ void ieee80211_free_hw(struct ieee80211_hw *hw) ...@@ -1542,6 +1543,28 @@ void ieee80211_free_hw(struct ieee80211_hw *hw)
} }
EXPORT_SYMBOL(ieee80211_free_hw); EXPORT_SYMBOL(ieee80211_free_hw);
static const char * const drop_reasons_monitor[] = {
#define V(x) #x,
[0] = "RX_DROP_MONITOR",
MAC80211_DROP_REASONS_MONITOR(V)
};
static struct drop_reason_list drop_reason_list_monitor = {
.reasons = drop_reasons_monitor,
.n_reasons = ARRAY_SIZE(drop_reasons_monitor),
};
static const char * const drop_reasons_unusable[] = {
[0] = "RX_DROP_UNUSABLE",
MAC80211_DROP_REASONS_UNUSABLE(V)
#undef V
};
static struct drop_reason_list drop_reason_list_unusable = {
.reasons = drop_reasons_unusable,
.n_reasons = ARRAY_SIZE(drop_reasons_unusable),
};
static int __init ieee80211_init(void) static int __init ieee80211_init(void)
{ {
struct sk_buff *skb; struct sk_buff *skb;
...@@ -1559,6 +1582,11 @@ static int __init ieee80211_init(void) ...@@ -1559,6 +1582,11 @@ static int __init ieee80211_init(void)
if (ret) if (ret)
goto err_netdev; goto err_netdev;
drop_reasons_register_subsys(SKB_DROP_REASON_SUBSYS_MAC80211_MONITOR,
&drop_reason_list_monitor);
drop_reasons_register_subsys(SKB_DROP_REASON_SUBSYS_MAC80211_UNUSABLE,
&drop_reason_list_unusable);
return 0; return 0;
err_netdev: err_netdev:
rc80211_minstrel_exit(); rc80211_minstrel_exit();
...@@ -1574,6 +1602,9 @@ static void __exit ieee80211_exit(void) ...@@ -1574,6 +1602,9 @@ static void __exit ieee80211_exit(void)
ieee80211_iface_exit(); ieee80211_iface_exit();
drop_reasons_unregister_subsys(SKB_DROP_REASON_SUBSYS_MAC80211_MONITOR);
drop_reasons_unregister_subsys(SKB_DROP_REASON_SUBSYS_MAC80211_UNUSABLE);
rcu_barrier(); rcu_barrier();
} }
......
...@@ -1826,7 +1826,7 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) ...@@ -1826,7 +1826,7 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
cfg80211_rx_unexpected_4addr_frame( cfg80211_rx_unexpected_4addr_frame(
rx->sdata->dev, sta->sta.addr, rx->sdata->dev, sta->sta.addr,
GFP_ATOMIC); GFP_ATOMIC);
return RX_DROP_MONITOR; return RX_DROP_M_UNEXPECTED_4ADDR_FRAME;
} }
/* /*
* Update counter and free packet here to avoid * Update counter and free packet here to avoid
...@@ -1961,7 +1961,7 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx) ...@@ -1961,7 +1961,7 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)
cfg80211_rx_unprot_mlme_mgmt(rx->sdata->dev, cfg80211_rx_unprot_mlme_mgmt(rx->sdata->dev,
skb->data, skb->data,
skb->len); skb->len);
return RX_DROP_MONITOR; /* unexpected BIP keyidx */ return RX_DROP_M_BAD_BCN_KEYIDX;
} }
rx->key = ieee80211_rx_get_bigtk(rx, mmie_keyidx); rx->key = ieee80211_rx_get_bigtk(rx, mmie_keyidx);
...@@ -1975,7 +1975,7 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx) ...@@ -1975,7 +1975,7 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)
if (mmie_keyidx < NUM_DEFAULT_KEYS || if (mmie_keyidx < NUM_DEFAULT_KEYS ||
mmie_keyidx >= NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS) mmie_keyidx >= NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS)
return RX_DROP_MONITOR; /* unexpected BIP keyidx */ return RX_DROP_M_BAD_MGMT_KEYIDX; /* unexpected BIP keyidx */
if (rx->link_sta) { if (rx->link_sta) {
if (ieee80211_is_group_privacy_action(skb) && if (ieee80211_is_group_privacy_action(skb) &&
test_sta_flag(rx->sta, WLAN_STA_MFP)) test_sta_flag(rx->sta, WLAN_STA_MFP))
...@@ -3960,7 +3960,8 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx) ...@@ -3960,7 +3960,8 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx)
} }
static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx, static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx,
struct ieee80211_rate *rate) struct ieee80211_rate *rate,
ieee80211_rx_result reason)
{ {
struct ieee80211_sub_if_data *sdata; struct ieee80211_sub_if_data *sdata;
struct ieee80211_local *local = rx->local; struct ieee80211_local *local = rx->local;
...@@ -4024,42 +4025,38 @@ static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx, ...@@ -4024,42 +4025,38 @@ static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx,
} }
out_free_skb: out_free_skb:
dev_kfree_skb(skb); kfree_skb_reason(skb, (__force u32)reason);
} }
static void ieee80211_rx_handlers_result(struct ieee80211_rx_data *rx, static void ieee80211_rx_handlers_result(struct ieee80211_rx_data *rx,
ieee80211_rx_result res) ieee80211_rx_result res)
{ {
switch (res) { struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb);
case RX_DROP_MONITOR: struct ieee80211_supported_band *sband;
I802_DEBUG_INC(rx->sdata->local->rx_handlers_drop); struct ieee80211_rate *rate = NULL;
if (rx->sta)
rx->link_sta->rx_stats.dropped++;
fallthrough;
case RX_CONTINUE: {
struct ieee80211_rate *rate = NULL;
struct ieee80211_supported_band *sband;
struct ieee80211_rx_status *status;
status = IEEE80211_SKB_RXCB((rx->skb));
sband = rx->local->hw.wiphy->bands[status->band]; if (res == RX_QUEUED) {
if (status->encoding == RX_ENC_LEGACY) I802_DEBUG_INC(rx->sdata->local->rx_handlers_queued);
rate = &sband->bitrates[status->rate_idx]; return;
}
ieee80211_rx_cooked_monitor(rx, rate); if (res != RX_CONTINUE) {
break;
}
case RX_DROP_UNUSABLE:
I802_DEBUG_INC(rx->sdata->local->rx_handlers_drop); I802_DEBUG_INC(rx->sdata->local->rx_handlers_drop);
if (rx->sta) if (rx->sta)
rx->link_sta->rx_stats.dropped++; rx->link_sta->rx_stats.dropped++;
dev_kfree_skb(rx->skb);
break;
case RX_QUEUED:
I802_DEBUG_INC(rx->sdata->local->rx_handlers_queued);
break;
} }
if (u32_get_bits((__force u32)res, SKB_DROP_REASON_SUBSYS_MASK) ==
SKB_DROP_REASON_SUBSYS_MAC80211_UNUSABLE) {
kfree_skb_reason(rx->skb, (__force u32)res);
return;
}
sband = rx->local->hw.wiphy->bands[status->band];
if (status->encoding == RX_ENC_LEGACY)
rate = &sband->bitrates[status->rate_idx];
ieee80211_rx_cooked_monitor(rx, rate, res);
} }
static void ieee80211_rx_handlers(struct ieee80211_rx_data *rx, static void ieee80211_rx_handlers(struct ieee80211_rx_data *rx,
......
...@@ -550,7 +550,7 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx, ...@@ -550,7 +550,7 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx,
if (res < 0 || if (res < 0 ||
(!res && !(status->flag & RX_FLAG_ALLOW_SAME_PN))) { (!res && !(status->flag & RX_FLAG_ALLOW_SAME_PN))) {
key->u.ccmp.replays++; key->u.ccmp.replays++;
return RX_DROP_UNUSABLE; return RX_DROP_U_REPLAY;
} }
if (!(status->flag & RX_FLAG_DECRYPTED)) { if (!(status->flag & RX_FLAG_DECRYPTED)) {
...@@ -564,7 +564,7 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx, ...@@ -564,7 +564,7 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx,
skb->data + hdrlen + IEEE80211_CCMP_HDR_LEN, skb->data + hdrlen + IEEE80211_CCMP_HDR_LEN,
data_len, data_len,
skb->data + skb->len - mic_len)) skb->data + skb->len - mic_len))
return RX_DROP_UNUSABLE; return RX_DROP_U_MIC_FAIL;
} }
memcpy(key->u.ccmp.rx_pn[queue], pn, IEEE80211_CCMP_PN_LEN); memcpy(key->u.ccmp.rx_pn[queue], pn, IEEE80211_CCMP_PN_LEN);
...@@ -746,7 +746,7 @@ ieee80211_crypto_gcmp_decrypt(struct ieee80211_rx_data *rx) ...@@ -746,7 +746,7 @@ ieee80211_crypto_gcmp_decrypt(struct ieee80211_rx_data *rx)
if (res < 0 || if (res < 0 ||
(!res && !(status->flag & RX_FLAG_ALLOW_SAME_PN))) { (!res && !(status->flag & RX_FLAG_ALLOW_SAME_PN))) {
key->u.gcmp.replays++; key->u.gcmp.replays++;
return RX_DROP_UNUSABLE; return RX_DROP_U_REPLAY;
} }
if (!(status->flag & RX_FLAG_DECRYPTED)) { if (!(status->flag & RX_FLAG_DECRYPTED)) {
...@@ -761,7 +761,7 @@ ieee80211_crypto_gcmp_decrypt(struct ieee80211_rx_data *rx) ...@@ -761,7 +761,7 @@ ieee80211_crypto_gcmp_decrypt(struct ieee80211_rx_data *rx)
data_len, data_len,
skb->data + skb->len - skb->data + skb->len -
IEEE80211_GCMP_MIC_LEN)) IEEE80211_GCMP_MIC_LEN))
return RX_DROP_UNUSABLE; return RX_DROP_U_MIC_FAIL;
} }
memcpy(key->u.gcmp.rx_pn[queue], pn, IEEE80211_GCMP_PN_LEN); memcpy(key->u.gcmp.rx_pn[queue], pn, IEEE80211_GCMP_PN_LEN);
...@@ -930,13 +930,13 @@ ieee80211_crypto_aes_cmac_decrypt(struct ieee80211_rx_data *rx) ...@@ -930,13 +930,13 @@ ieee80211_crypto_aes_cmac_decrypt(struct ieee80211_rx_data *rx)
(skb->data + skb->len - sizeof(*mmie)); (skb->data + skb->len - sizeof(*mmie));
if (mmie->element_id != WLAN_EID_MMIE || if (mmie->element_id != WLAN_EID_MMIE ||
mmie->length != sizeof(*mmie) - 2) mmie->length != sizeof(*mmie) - 2)
return RX_DROP_UNUSABLE; /* Invalid MMIE */ return RX_DROP_U_BAD_MMIE; /* Invalid MMIE */
bip_ipn_swap(ipn, mmie->sequence_number); bip_ipn_swap(ipn, mmie->sequence_number);
if (memcmp(ipn, key->u.aes_cmac.rx_pn, 6) <= 0) { if (memcmp(ipn, key->u.aes_cmac.rx_pn, 6) <= 0) {
key->u.aes_cmac.replays++; key->u.aes_cmac.replays++;
return RX_DROP_UNUSABLE; return RX_DROP_U_REPLAY;
} }
if (!(status->flag & RX_FLAG_DECRYPTED)) { if (!(status->flag & RX_FLAG_DECRYPTED)) {
...@@ -946,7 +946,7 @@ ieee80211_crypto_aes_cmac_decrypt(struct ieee80211_rx_data *rx) ...@@ -946,7 +946,7 @@ ieee80211_crypto_aes_cmac_decrypt(struct ieee80211_rx_data *rx)
skb->data + 24, skb->len - 24, mic); skb->data + 24, skb->len - 24, mic);
if (crypto_memneq(mic, mmie->mic, sizeof(mmie->mic))) { if (crypto_memneq(mic, mmie->mic, sizeof(mmie->mic))) {
key->u.aes_cmac.icverrors++; key->u.aes_cmac.icverrors++;
return RX_DROP_UNUSABLE; return RX_DROP_U_MIC_FAIL;
} }
} }
...@@ -986,7 +986,7 @@ ieee80211_crypto_aes_cmac_256_decrypt(struct ieee80211_rx_data *rx) ...@@ -986,7 +986,7 @@ ieee80211_crypto_aes_cmac_256_decrypt(struct ieee80211_rx_data *rx)
if (memcmp(ipn, key->u.aes_cmac.rx_pn, 6) <= 0) { if (memcmp(ipn, key->u.aes_cmac.rx_pn, 6) <= 0) {
key->u.aes_cmac.replays++; key->u.aes_cmac.replays++;
return RX_DROP_UNUSABLE; return RX_DROP_U_REPLAY;
} }
if (!(status->flag & RX_FLAG_DECRYPTED)) { if (!(status->flag & RX_FLAG_DECRYPTED)) {
...@@ -996,7 +996,7 @@ ieee80211_crypto_aes_cmac_256_decrypt(struct ieee80211_rx_data *rx) ...@@ -996,7 +996,7 @@ ieee80211_crypto_aes_cmac_256_decrypt(struct ieee80211_rx_data *rx)
skb->data + 24, skb->len - 24, mic); skb->data + 24, skb->len - 24, mic);
if (crypto_memneq(mic, mmie->mic, sizeof(mmie->mic))) { if (crypto_memneq(mic, mmie->mic, sizeof(mmie->mic))) {
key->u.aes_cmac.icverrors++; key->u.aes_cmac.icverrors++;
return RX_DROP_UNUSABLE; return RX_DROP_U_MIC_FAIL;
} }
} }
...@@ -1079,13 +1079,13 @@ ieee80211_crypto_aes_gmac_decrypt(struct ieee80211_rx_data *rx) ...@@ -1079,13 +1079,13 @@ ieee80211_crypto_aes_gmac_decrypt(struct ieee80211_rx_data *rx)
(skb->data + skb->len - sizeof(*mmie)); (skb->data + skb->len - sizeof(*mmie));
if (mmie->element_id != WLAN_EID_MMIE || if (mmie->element_id != WLAN_EID_MMIE ||
mmie->length != sizeof(*mmie) - 2) mmie->length != sizeof(*mmie) - 2)
return RX_DROP_UNUSABLE; /* Invalid MMIE */ return RX_DROP_U_BAD_MMIE; /* Invalid MMIE */
bip_ipn_swap(ipn, mmie->sequence_number); bip_ipn_swap(ipn, mmie->sequence_number);
if (memcmp(ipn, key->u.aes_gmac.rx_pn, 6) <= 0) { if (memcmp(ipn, key->u.aes_gmac.rx_pn, 6) <= 0) {
key->u.aes_gmac.replays++; key->u.aes_gmac.replays++;
return RX_DROP_UNUSABLE; return RX_DROP_U_REPLAY;
} }
if (!(status->flag & RX_FLAG_DECRYPTED)) { if (!(status->flag & RX_FLAG_DECRYPTED)) {
...@@ -1104,7 +1104,7 @@ ieee80211_crypto_aes_gmac_decrypt(struct ieee80211_rx_data *rx) ...@@ -1104,7 +1104,7 @@ ieee80211_crypto_aes_gmac_decrypt(struct ieee80211_rx_data *rx)
crypto_memneq(mic, mmie->mic, sizeof(mmie->mic))) { crypto_memneq(mic, mmie->mic, sizeof(mmie->mic))) {
key->u.aes_gmac.icverrors++; key->u.aes_gmac.icverrors++;
kfree(mic); kfree(mic);
return RX_DROP_UNUSABLE; return RX_DROP_U_MIC_FAIL;
} }
kfree(mic); kfree(mic);
} }
......
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