netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] mac80211: disallow bridging managed/adhoc interfaces
@ 2009-11-17 13:46 Johannes Berg
       [not found] ` <1258465585.3682.7.camel-YfaajirXv2244ywRPIzf9A@public.gmane.org>
                   ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Johannes Berg @ 2009-11-17 13:46 UTC (permalink / raw)
  To: netdev; +Cc: linux-wireless, Stephen Hemminger, Felix Fietkau

A number of people have tried to add a wireless interface
(in managed mode) to a bridge and then complained that it
doesn't work. It cannot work, however, because in 802.11
networks all packets need to be acknowledged and as such
need to be sent to the right address. Promiscuous doesn't
help here. The wireless address format used for these
links has only space for three addresses, the
 * transmitter, which must be equal to the sender (origin)
 * receiver (on the wireless medium), which is the AP in
   the case of managed mode
 * the recipient (destination), which is on the APs local
   network segment

In an IBSS, it is similar, but the receiver and recipient
must match and the third address is used as the BSSID.

To avoid such mistakes in the future, disallow adding a
wireless interface to a bridge.

Felix has recently added a four-address mode to the AP
and client side that can be used (after negotiating that
it is possible, which must happen out-of-band by setting
up both sides) for bridging, so allow that case.

Signed-off-by: Johannes Berg <johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
---
 include/linux/if.h   |    1 +
 net/bridge/br_if.c   |    4 ++++
 net/mac80211/cfg.c   |    9 ++++++++-
 net/mac80211/iface.c |   17 +++++++++++++++--
 4 files changed, 28 insertions(+), 3 deletions(-)

--- wireless-testing.orig/include/linux/if.h	2009-11-17 14:18:36.000000000 +0100
+++ wireless-testing/include/linux/if.h	2009-11-17 14:19:04.000000000 +0100
@@ -70,6 +70,7 @@
 #define IFF_XMIT_DST_RELEASE 0x400	/* dev_hard_start_xmit() is allowed to
 					 * release skb->dst
 					 */
+#define IFF_DONT_BRIDGE 0x800		/* disallow bridging this ether dev */
 
 #define IF_GET_IFACE	0x0001		/* for querying only */
 #define IF_GET_PROTO	0x0002
--- wireless-testing.orig/net/bridge/br_if.c	2009-11-17 14:19:17.000000000 +0100
+++ wireless-testing/net/bridge/br_if.c	2009-11-17 14:20:03.000000000 +0100
@@ -390,6 +390,10 @@ int br_add_if(struct net_bridge *br, str
 	if (dev->br_port != NULL)
 		return -EBUSY;
 
+	/* No bridging devices that dislike that (e.g. wireless) */
+	if (dev->priv_flags & IFF_DONT_BRIDGE)
+		return -EINVAL;
+
 	p = new_nbp(br, dev);
 	if (IS_ERR(p))
 		return PTR_ERR(p);
--- wireless-testing.orig/net/mac80211/cfg.c	2009-11-17 14:21:24.000000000 +0100
+++ wireless-testing/net/mac80211/cfg.c	2009-11-17 14:37:13.000000000 +0100
@@ -106,8 +106,15 @@ static int ieee80211_change_iface(struct
 					    params->mesh_id_len,
 					    params->mesh_id);
 
-	if (params->use_4addr >= 0)
+	if (params->use_4addr >= 0) {
 		sdata->use_4addr = !!params->use_4addr;
+		sdata->dev->priv_flags &= ~IFF_DONT_BRIDGE;
+
+		if ((sdata->vif.type == NL80211_IFTYPE_STATION ||
+		     sdata->vif.type == NL80211_IFTYPE_ADHOC) &&
+		    !sdata->use_4addr)
+			sdata->dev->priv_flags |= IFF_DONT_BRIDGE;
+	}
 
 	if (sdata->vif.type != NL80211_IFTYPE_MONITOR || !flags)
 		return 0;
--- wireless-testing.orig/net/mac80211/iface.c	2009-11-17 14:20:19.000000000 +0100
+++ wireless-testing/net/mac80211/iface.c	2009-11-17 14:33:25.000000000 +0100
@@ -769,6 +769,11 @@ int ieee80211_if_change_type(struct ieee
 			sdata->local->hw.conf.channel->band);
 	sdata->drop_unencrypted = 0;
 	sdata->use_4addr = 0;
+	if (sdata->vif.type == NL80211_IFTYPE_STATION ||
+	    sdata->vif.type == NL80211_IFTYPE_ADHOC)
+		sdata->dev->priv_flags |= IFF_DONT_BRIDGE;
+	else
+		sdata->dev->priv_flags &= ~IFF_DONT_BRIDGE;
 
 	return 0;
 }
@@ -843,8 +848,16 @@ int ieee80211_if_add(struct ieee80211_lo
 					    params->mesh_id_len,
 					    params->mesh_id);
 
-	if (params && params->use_4addr >= 0)
-		sdata->use_4addr = !!params->use_4addr;
+	if (sdata->vif.type == NL80211_IFTYPE_STATION ||
+	    sdata->vif.type == NL80211_IFTYPE_ADHOC)
+		sdata->dev->priv_flags |= IFF_DONT_BRIDGE;
+	else
+		sdata->dev->priv_flags &= ~IFF_DONT_BRIDGE;
+
+	if (params && params->use_4addr > 0) {
+		sdata->use_4addr = true;
+		sdata->dev->priv_flags &= ~IFF_DONT_BRIDGE;
+	}
 
 	mutex_lock(&local->iflist_mtx);
 	list_add_tail_rcu(&sdata->list, &local->interfaces);


--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2009-11-18 10:52 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-17 13:46 [RFC] mac80211: disallow bridging managed/adhoc interfaces Johannes Berg
     [not found] ` <1258465585.3682.7.camel-YfaajirXv2244ywRPIzf9A@public.gmane.org>
2009-11-17 13:58   ` John W. Linville
2009-11-17 14:04     ` Johannes Berg
2009-11-17 14:04 ` Michael Buesch
     [not found]   ` <200911171504.54170.mb-fseUSCV1ubazQB+pC5nmwQ@public.gmane.org>
2009-11-17 14:06     ` John W. Linville
2009-11-17 14:07     ` Johannes Berg
     [not found]       ` <1258466868.3682.13.camel-YfaajirXv2244ywRPIzf9A@public.gmane.org>
2009-11-17 16:37         ` Stephen Hemminger
2009-11-17 16:43           ` Johannes Berg
     [not found]             ` <1258476223.21197.0.camel-YfaajirXv2244ywRPIzf9A@public.gmane.org>
2009-11-17 17:04               ` Stephen Hemminger
2009-11-17 17:05                 ` Johannes Berg
2009-11-17 20:41                 ` Dan Williams
2009-11-17 20:48 ` [RFC v2] " Johannes Berg
     [not found]   ` <1258490898.21197.42.camel-YfaajirXv2244ywRPIzf9A@public.gmane.org>
2009-11-17 22:42     ` Julian Calaby
2009-11-17 22:46       ` Johannes Berg
2009-11-17 22:50         ` Julian Calaby
2009-11-17 22:42   ` Stephen Hemminger
2009-11-17 22:45     ` Johannes Berg
2009-11-18  1:59   ` Stefan Monnier
     [not found]     ` <jwvy6m4bnqp.fsf-monnier+gmane.linux.kernel.wireless.general-mXXj517/zsQ@public.gmane.org>
2009-11-18  2:59       ` John W. Linville
     [not found]         ` <20091118025920.GA4588-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
2009-11-18 10:52           ` Johannes Berg

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).