netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafał Miłecki" <zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: "Linus Lüssing"
	<linus.luessing-djzkFPsfvsizQB+pC5nmwQ@public.gmane.org>,
	"Felix Fietkau" <nbd-Vt+b4OUoWG0@public.gmane.org>,
	"Arend van Spriel"
	<arend.vanspriel-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>,
	"Franky Lin" <franky.lin-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>,
	"Hante Meuleman"
	<hante.meuleman-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>,
	"Chi-Hsien Lin"
	<chi-hsien.lin-+wT8y+m8/X5BDgjK7y7TUQ@public.gmane.org>,
	"Wright Feng"
	<wright.feng-+wT8y+m8/X5BDgjK7y7TUQ@public.gmane.org>,
	"Pieter-Paul Giesberts"
	<pieter-paul.giesberts-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Cc: Network Development
	<netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	bridge-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	"open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER"
	<brcm80211-dev-list.pdl-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>,
	brcm80211-dev-list-+wT8y+m8/X5BDgjK7y7TUQ@public.gmane.org
Subject: Re: Problem with bridge (mcast-to-ucast + hairpin) and Broadcom's 802.11f in their FullMAC fw
Date: Mon, 12 Mar 2018 23:42:48 +0100	[thread overview]
Message-ID: <a7a21b04-025f-19e1-ec09-69cc355b9215@gmail.com> (raw)
In-Reply-To: <CACna6rz9L09g9oeHhvt209Tg1E3gKgmhGnYF653AdkXfZf=4kw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On 02/27/2018 11:08 AM, Rafał Miłecki wrote:
> I've problem when using OpenWrt/LEDE on a home router with Broadcom's
> FullMAC WiFi chipset.
>
>
> First of all OpenWrt/LEDE uses bridge interface for LAN network with:
> 1) IFLA_BRPORT_MCAST_TO_UCAST
> 2) Clients isolation in hostapd
> 3) Hairpin mode enabled
>
> For more details please see Linus's patch description:
> https://patchwork.kernel.org/patch/9530669/
> and maybe hairpin mode patch:
> https://lwn.net/Articles/347344/
>
> Short version: in that setup packets received from a bridged wireless
> interface can be handled back to it for transmission.
>
>
> Now, Broadcom's firmware for their FullMAC chipsets in AP mode
> supports an obsoleted 802.11f AKA IAPP standard. It's a roaming
> standard that was replaced by 802.11r.
>
> Whenever a new station associates, firmware generates a packet like:
> ff ff ff ff  ff ff ec 10  7b 5f ?? ??  00 06 00 01  af 81 01 00
> (just masked 2 bytes of my MAC)
>
> For mode details you can see discussion in my brcmfmac patch thread:
> https://patchwork.kernel.org/patch/10191451/
>
>
> The problem is that bridge (in setup as above) handles such a packet
> back to the device.
>
> That makes Broadcom's FullMAC firmware believe that a given station
> just connected to another AP in a network (which doesn't even exist).
> As a result firmware immediately disassociates that station. It's
> simply impossible to connect to the router. Every association is
> followed by immediate disassociation.
>
>
> Can you see any solution for this problem? Is that an option to stop
> multicast-to-unicast from touching 802.11f packets? Some other ideas?
> Obviously I can't modify Broadcom's firmware and drop that obsoleted
> standard.

I kept thinking about this for a bit more. We probably have to start
with deciding what to blame for this problem. I see two options I'll
describe below.

Please share your opinions on this.


1) Blame brcmfmac fw for implementing 802.11f

In that case we should add workaround to brcmfmac driver to drop/ignore
802.11f packets. A slightly improved version of my
[PATCH] brcmfmac: detect & reject faked packet generated by a firmware
https://patchwork.kernel.org/patch/10191451/
should work.


2) Blame bridge + mcast-to-ucast + hairpin for 802.11f incompatibility

If we agree that 802.11f support in FullMAC firmware is acceptable, then
we have to make sure Linux's bridge doesn't break it by passing 802.11f
(broadcast) frames back to the source interface. That would require a
check like in below diff + proper code for handling such packets. I'm
afraid I'm not familiar with bridge code enough to complete that.

diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
index edae702..9e5d6ea 100644
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -126,6 +126,27 @@ static void br_do_proxy_arp(struct sk_buff *skb, struct net_bridge *br,
  	}
  }

+static bool br_skb_is_iapp_add_packet(struct sk_buff *skb)
+{
+	const u8 iapp_add_packet[6] __aligned(2) = {
+		0x00, 0x01, 0xaf, 0x81, 0x01, 0x00,
+	};
+#if !defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
+	const u16 *a = (const u16 *)skb->data;
+	const u16 *b = (const u16 *)iapp_add_packet;
+#endif
+
+	if (skb->len != 6)
+		return false;
+
+#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
+	return !(((*(const u32 *)skb->data) ^ (*(const u32 *)iapp_add_packet)) |
+	         ((*(const u16 *)(skb->data + 4)) ^ (*(const u16 *)(iapp_add_packet + 4))));
+#else
+	return !((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]));
+#endif
+}
+
  /* note: already called with rcu_read_lock */
  int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
  {
@@ -155,6 +176,8 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb
  	if (is_multicast_ether_addr(dest)) {
  		/* by definition the broadcast is also a multicast address */
  		if (is_broadcast_ether_addr(dest)) {
+			if (br_skb_is_iapp_add_packet(skb))
+				pr_warn("This packet should not be passed back to the source interface!\n");
  			pkt_type = BR_PKT_BROADCAST;
  			local_rcv = true;
  		} else {

  parent reply	other threads:[~2018-03-12 22:42 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-27 10:08 Problem with bridge (mcast-to-ucast + hairpin) and Broadcom's 802.11f in their FullMAC fw Rafał Miłecki
2018-02-27 10:14 ` Rafał Miłecki
2018-02-28 11:31   ` Arend van Spriel via Bridge
     [not found]     ` <5A969313.5050501-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2018-03-12  9:49       ` Rafał Miłecki
     [not found] ` <20180227090556.02a24a0d@xeon-e3>
2018-03-12  9:46   ` Rafał Miłecki
     [not found]     ` <CACna6rxP4ATE2f6XJi7XKDLe2L_Z43aLreEHDCfGicksYTb0xg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-03-12 11:40       ` Linus Lüssing
     [not found] ` <CACna6rz9L09g9oeHhvt209Tg1E3gKgmhGnYF653AdkXfZf=4kw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-03-12 11:08   ` Linus Lüssing
2018-03-12 11:48     ` Linus Lüssing
2018-03-12 21:52       ` Rafał Miłecki
2018-03-12 21:49     ` Rafał Miłecki
2018-03-12 22:42   ` Rafał Miłecki [this message]
     [not found]     ` <20180312160103.1a043936@xeon-e3>
2018-03-13  6:23       ` Rafał Miłecki
2018-03-13  7:20   ` Felix Fietkau
     [not found]     ` <c24304cf-7e0d-137a-94b1-d8f4e61a3b70-Vt+b4OUoWG0@public.gmane.org>
2018-03-13  9:18       ` Arend van Spriel
2018-03-13  7:17 ` Felix Fietkau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a7a21b04-025f-19e1-ec09-69cc355b9215@gmail.com \
    --to=zajec5-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=arend.vanspriel-dY08KVG/lbpWk0Htik3J/w@public.gmane.org \
    --cc=brcm80211-dev-list-+wT8y+m8/X5BDgjK7y7TUQ@public.gmane.org \
    --cc=brcm80211-dev-list.pdl-dY08KVG/lbpWk0Htik3J/w@public.gmane.org \
    --cc=bridge-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=chi-hsien.lin-+wT8y+m8/X5BDgjK7y7TUQ@public.gmane.org \
    --cc=franky.lin-dY08KVG/lbpWk0Htik3J/w@public.gmane.org \
    --cc=hante.meuleman-dY08KVG/lbpWk0Htik3J/w@public.gmane.org \
    --cc=linus.luessing-djzkFPsfvsizQB+pC5nmwQ@public.gmane.org \
    --cc=linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=nbd-Vt+b4OUoWG0@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=pieter-paul.giesberts-dY08KVG/lbpWk0Htik3J/w@public.gmane.org \
    --cc=wright.feng-+wT8y+m8/X5BDgjK7y7TUQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).