wifi: mac80211: expand __ieee80211_data_to_8023() status
Make __ieee80211_data_to_8023() return more individual drop reasons instead of just doing RX_DROP_U_INVALID_8023. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
parent
6c02fab724
commit
2a1c5c7de4
@ -62,6 +62,10 @@ typedef unsigned int __bitwise ieee80211_rx_result;
|
||||
R(RX_DROP_U_SHORT_CMAC) \
|
||||
R(RX_DROP_U_SHORT_CMAC256) \
|
||||
R(RX_DROP_U_SHORT_GMAC) \
|
||||
R(RX_DROP_U_UNEXPECTED_VLAN_4ADDR) \
|
||||
R(RX_DROP_U_UNEXPECTED_STA_4ADDR) \
|
||||
R(RX_DROP_U_UNEXPECTED_VLAN_MCAST) \
|
||||
R(RX_DROP_U_NOT_PORT_CONTROL) \
|
||||
/* this line for the trailing \ - add before this */
|
||||
|
||||
/* having two enums allows for checking ieee80211_rx_result use with sparse */
|
||||
|
@ -2476,7 +2476,7 @@ static int ieee80211_drop_unencrypted_mgmt(struct ieee80211_rx_data *rx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
static ieee80211_rx_result
|
||||
__ieee80211_data_to_8023(struct ieee80211_rx_data *rx, bool *port_control)
|
||||
{
|
||||
struct ieee80211_sub_if_data *sdata = rx->sdata;
|
||||
@ -2488,32 +2488,31 @@ __ieee80211_data_to_8023(struct ieee80211_rx_data *rx, bool *port_control)
|
||||
*port_control = false;
|
||||
if (ieee80211_has_a4(hdr->frame_control) &&
|
||||
sdata->vif.type == NL80211_IFTYPE_AP_VLAN && !sdata->u.vlan.sta)
|
||||
return -1;
|
||||
return RX_DROP_U_UNEXPECTED_VLAN_4ADDR;
|
||||
|
||||
if (sdata->vif.type == NL80211_IFTYPE_STATION &&
|
||||
!!sdata->u.mgd.use_4addr != !!ieee80211_has_a4(hdr->frame_control)) {
|
||||
|
||||
if (!sdata->u.mgd.use_4addr)
|
||||
return -1;
|
||||
return RX_DROP_U_UNEXPECTED_STA_4ADDR;
|
||||
else if (!ether_addr_equal(hdr->addr1, sdata->vif.addr))
|
||||
check_port_control = true;
|
||||
}
|
||||
|
||||
if (is_multicast_ether_addr(hdr->addr1) &&
|
||||
sdata->vif.type == NL80211_IFTYPE_AP_VLAN && sdata->u.vlan.sta)
|
||||
return -1;
|
||||
return RX_DROP_U_UNEXPECTED_VLAN_MCAST;
|
||||
|
||||
ret = ieee80211_data_to_8023(rx->skb, sdata->vif.addr, sdata->vif.type);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
return RX_DROP_U_INVALID_8023;
|
||||
|
||||
ehdr = (struct ethhdr *) rx->skb->data;
|
||||
if (ehdr->h_proto == rx->sdata->control_port_protocol)
|
||||
*port_control = true;
|
||||
else if (check_port_control)
|
||||
return -1;
|
||||
return RX_DROP_U_NOT_PORT_CONTROL;
|
||||
|
||||
return 0;
|
||||
return RX_CONTINUE;
|
||||
}
|
||||
|
||||
bool ieee80211_is_our_addr(struct ieee80211_sub_if_data *sdata,
|
||||
@ -3124,7 +3123,6 @@ ieee80211_rx_h_data(struct ieee80211_rx_data *rx)
|
||||
__le16 fc = hdr->frame_control;
|
||||
ieee80211_rx_result res;
|
||||
bool port_control;
|
||||
int err;
|
||||
|
||||
if (unlikely(!ieee80211_is_data(hdr->frame_control)))
|
||||
return RX_CONTINUE;
|
||||
@ -3145,9 +3143,9 @@ ieee80211_rx_h_data(struct ieee80211_rx_data *rx)
|
||||
return RX_DROP_MONITOR;
|
||||
}
|
||||
|
||||
err = __ieee80211_data_to_8023(rx, &port_control);
|
||||
if (unlikely(err))
|
||||
return RX_DROP_U_INVALID_8023;
|
||||
res = __ieee80211_data_to_8023(rx, &port_control);
|
||||
if (unlikely(res != RX_CONTINUE))
|
||||
return res;
|
||||
|
||||
res = ieee80211_rx_mesh_data(rx->sdata, rx->sta, rx->skb);
|
||||
if (res != RX_CONTINUE)
|
||||
|
Loading…
x
Reference in New Issue
Block a user