linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mac80211: drop non-auth 3-addr data frames when running as a 4-addr station
@ 2011-01-18 14:48 Felix Fietkau
  2011-01-18 14:55 ` Johannes Berg
  0 siblings, 1 reply; 3+ messages in thread
From: Felix Fietkau @ 2011-01-18 14:48 UTC (permalink / raw)
  To: linux-wireless; +Cc: linville, johannes

When running as a 4-addr station against an AP that has the 4-addr VLAN
interface and the main 3-addr AP interface bridged together, sometimes
frames originating from the station were looping back from the 3-addr AP
interface, causing the bridge code to emit warnings about receiving frames
with its own source address.
I'm not sure why this is happening yet, but I think it's a good idea to
drop all frames (except 802.1x/EAP frames) that do not match the configured
addressing mode, including 4-address frames sent to a 3-address station.
User test reports indicate that the problem goes away with this patch.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
---
 net/mac80211/rx.c |   25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index a6701ed..1236710 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1556,17 +1556,36 @@ __ieee80211_data_to_8023(struct ieee80211_rx_data *rx)
 {
 	struct ieee80211_sub_if_data *sdata = rx->sdata;
 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
+	bool check_port_control = false;
+	struct ethhdr *ehdr;
+	int ret;
 
 	if (ieee80211_has_a4(hdr->frame_control) &&
 	    sdata->vif.type == NL80211_IFTYPE_AP_VLAN && !sdata->u.vlan.sta)
 		return -1;
 
+	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;
+		else
+			check_port_control = true;
+	}
+
 	if (is_multicast_ether_addr(hdr->addr1) &&
-	    ((sdata->vif.type == NL80211_IFTYPE_AP_VLAN && sdata->u.vlan.sta) ||
-	     (sdata->vif.type == NL80211_IFTYPE_STATION && sdata->u.mgd.use_4addr)))
+	    sdata->vif.type == NL80211_IFTYPE_AP_VLAN && sdata->u.vlan.sta)
 		return -1;
 
-	return ieee80211_data_to_8023(rx->skb, sdata->vif.addr, sdata->vif.type);
+	ret = ieee80211_data_to_8023(rx->skb, sdata->vif.addr, sdata->vif.type);
+	if (ret < 0 || !check_port_control)
+		return ret;
+
+	ehdr = (struct ethhdr *) rx->skb->data;
+	if (ehdr->h_proto != rx->sdata->control_port_protocol)
+		return -1;
+
+	return 0;
 }
 
 /*
-- 
1.7.3.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] mac80211: drop non-auth 3-addr data frames when running as a 4-addr station
  2011-01-18 14:48 [PATCH v2] mac80211: drop non-auth 3-addr data frames when running as a 4-addr station Felix Fietkau
@ 2011-01-18 14:55 ` Johannes Berg
  2011-01-18 15:02   ` Felix Fietkau
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Berg @ 2011-01-18 14:55 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless, linville

On Tue, 2011-01-18 at 15:48 +0100, Felix Fietkau wrote:
> When running as a 4-addr station against an AP that has the 4-addr VLAN
> interface and the main 3-addr AP interface bridged together, sometimes
> frames originating from the station were looping back from the 3-addr AP
> interface, causing the bridge code to emit warnings about receiving frames
> with its own source address.
> I'm not sure why this is happening yet, but I think it's a good idea to
> drop all frames (except 802.1x/EAP frames) that do not match the configured
> addressing mode, including 4-address frames sent to a 3-address station.
> User test reports indicate that the problem goes away with this patch.

This looks better, thanks. But did they really test _this_ patch? :)

johannes

> Signed-off-by: Felix Fietkau <nbd@openwrt.org>
> ---
>  net/mac80211/rx.c |   25 ++++++++++++++++++++++---
>  1 files changed, 22 insertions(+), 3 deletions(-)
> 
> diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
> index a6701ed..1236710 100644
> --- a/net/mac80211/rx.c
> +++ b/net/mac80211/rx.c
> @@ -1556,17 +1556,36 @@ __ieee80211_data_to_8023(struct ieee80211_rx_data *rx)
>  {
>  	struct ieee80211_sub_if_data *sdata = rx->sdata;
>  	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data;
> +	bool check_port_control = false;
> +	struct ethhdr *ehdr;
> +	int ret;
>  
>  	if (ieee80211_has_a4(hdr->frame_control) &&
>  	    sdata->vif.type == NL80211_IFTYPE_AP_VLAN && !sdata->u.vlan.sta)
>  		return -1;
>  
> +	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;
> +		else
> +			check_port_control = true;
> +	}
> +
>  	if (is_multicast_ether_addr(hdr->addr1) &&
> -	    ((sdata->vif.type == NL80211_IFTYPE_AP_VLAN && sdata->u.vlan.sta) ||
> -	     (sdata->vif.type == NL80211_IFTYPE_STATION && sdata->u.mgd.use_4addr)))
> +	    sdata->vif.type == NL80211_IFTYPE_AP_VLAN && sdata->u.vlan.sta)
>  		return -1;
>  
> -	return ieee80211_data_to_8023(rx->skb, sdata->vif.addr, sdata->vif.type);
> +	ret = ieee80211_data_to_8023(rx->skb, sdata->vif.addr, sdata->vif.type);
> +	if (ret < 0 || !check_port_control)
> +		return ret;
> +
> +	ehdr = (struct ethhdr *) rx->skb->data;
> +	if (ehdr->h_proto != rx->sdata->control_port_protocol)
> +		return -1;
> +
> +	return 0;
>  }
>  
>  /*



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] mac80211: drop non-auth 3-addr data frames when running as a 4-addr station
  2011-01-18 14:55 ` Johannes Berg
@ 2011-01-18 15:02   ` Felix Fietkau
  0 siblings, 0 replies; 3+ messages in thread
From: Felix Fietkau @ 2011-01-18 15:02 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless, linville

On 2011-01-18 3:55 PM, Johannes Berg wrote:
> On Tue, 2011-01-18 at 15:48 +0100, Felix Fietkau wrote:
>> When running as a 4-addr station against an AP that has the 4-addr VLAN
>> interface and the main 3-addr AP interface bridged together, sometimes
>> frames originating from the station were looping back from the 3-addr AP
>> interface, causing the bridge code to emit warnings about receiving frames
>> with its own source address.
>> I'm not sure why this is happening yet, but I think it's a good idea to
>> drop all frames (except 802.1x/EAP frames) that do not match the configured
>> addressing mode, including 4-address frames sent to a 3-address station.
>> User test reports indicate that the problem goes away with this patch.
> 
> This looks better, thanks. But did they really test _this_ patch? :)
A few users tested this and told me that it didn't make things worse
compared to my first patch - which did fix some, but not all issues
related to this.

- Felix

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-01-18 15:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-18 14:48 [PATCH v2] mac80211: drop non-auth 3-addr data frames when running as a 4-addr station Felix Fietkau
2011-01-18 14:55 ` Johannes Berg
2011-01-18 15:02   ` Felix Fietkau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).