netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bridge-2.6.11] bridge hub_enabled option
@ 2005-03-27  8:19 Alpt
  0 siblings, 0 replies; 4+ messages in thread
From: Alpt @ 2005-03-27  8:19 UTC (permalink / raw)
  To: netdev; +Cc: bridge


[-- Attachment #1.1.1: Type: text/plain, Size: 1712 bytes --]


Bridge hub_enabled patch:
this patch adds the hub_enabled option for bridge.

By default the hub_enabled flag is set to 1. In this case nothing changes, the
bridge, as usually, acts as a hub and flood_forward the input pkts to all its
ports. When hun_enabled is set to 0, the bridge stops to flood_forward the input
traffic and takes only the pkts sent to it.
Disabling the hub option is useful to join multiple interfaces into a unique virtual
one, thus becomes possible to have easily an ad-hoc network topology using multiple
interfaces. 

For example:


	A(eth0) --- (eth1)B(eth0) --- (eth1)C
		       BRIDGE
		       NO HUB
		        br0
A and C must not be directly connected, and B must have only one interface, in
this case br0.
This scenario is possible only disabling the hub behavior of the bridge.

To clarify, this topology is the same of having:

	A(wlan0)\	     /(wlan0)C
		 \	    /
		  \	   /
		    (wlan0)
		      B
A and C don't see each other.


Maybe the hub_enabled option may be useful for something else ^_-

The patch is simple and stupid, and it seems to work.

It can be found also here:
http://freaknet.org/alpt/src/bridge-hub/bridge-2.6.11-hub.patch

The patch to update the bridge-utils is here:
http://freaknet.org/alpt/src/bridge-hub/bridge-utils-1.0.6-hub.patch

Here attached there is only the patch for the net/bridge code.

Best Regards

PS: I'm resending this mail because after 7 hours I don't see it in the ml.
-- 
:wq!
"I don't know nothing" The One Who reached the Thinking Matter   '.'

[ Alpt --- Freaknet Medialab ]
[ GPG Key ID 441CF0EE ]
[ Key fingerprint = 8B02 26E8 831A 7BB9 81A9  5277 BFF8 037E 441C F0EE ]

[-- Attachment #1.1.2: bridge-2.6.11-hub.patch --]
[-- Type: text/plain, Size: 4135 bytes --]

diff -ru a-2.6.11/include/linux/if_bridge.h b-2.6.11/include/linux/if_bridge.h
--- a-2.6.11/include/linux/if_bridge.h	2005-03-26 21:14:05.000000000 +0100
+++ b-2.6.11/include/linux/if_bridge.h	2005-03-25 23:57:19.000000000 +0100
@@ -44,6 +44,7 @@
 #define BRCTL_SET_PORT_PRIORITY 16
 #define BRCTL_SET_PATH_COST 17
 #define BRCTL_GET_FDB_ENTRIES 18
+#define BRCTL_SET_BRIDGE_HUB_STATE 19
 
 #define BR_STATE_DISABLED 0
 #define BR_STATE_LISTENING 1
@@ -65,6 +66,7 @@
 	__u8 topology_change;
 	__u8 topology_change_detected;
 	__u8 root_port;
+	__u8 hub_enabled;
 	__u8 stp_enabled;
 	__u32 ageing_time;
 	__u32 gc_interval;
diff -ru a-2.6.11/net/bridge/br_if.c b-2.6.11/net/bridge/br_if.c
--- a-2.6.11/net/bridge/br_if.c	2005-03-26 21:14:05.000000000 +0100
+++ b-2.6.11/net/bridge/br_if.c	2005-03-25 23:56:56.000000000 +0100
@@ -155,6 +155,8 @@
 	br->bridge_id.prio[1] = 0x00;
 	memset(br->bridge_id.addr, 0, ETH_ALEN);
 
+	br->hub_enabled = 1;
+	
 	br->stp_enabled = 0;
 	br->designated_root = br->bridge_id;
 	br->root_path_cost = 0;
diff -ru a-2.6.11/net/bridge/br_input.c b-2.6.11/net/bridge/br_input.c
--- a-2.6.11/net/bridge/br_input.c	2005-03-26 21:14:05.000000000 +0100
+++ b-2.6.11/net/bridge/br_input.c	2005-03-26 22:08:38.000000000 +0100
@@ -80,12 +80,13 @@
 		goto out;
 	}
 
-	if (dst != NULL) {
+	if (dst != NULL && br->hub_enabled) {
 		br_forward(dst->dst, skb);
 		goto out;
 	}
 
-	br_flood_forward(br, skb, 0);
+	if(br->hub_enabled)
+		br_flood_forward(br, skb, 0);
 
 out:
 	return 0;
diff -ru a-2.6.11/net/bridge/br_ioctl.c b-2.6.11/net/bridge/br_ioctl.c
--- a-2.6.11/net/bridge/br_ioctl.c	2005-03-26 21:14:05.000000000 +0100
+++ b-2.6.11/net/bridge/br_ioctl.c	2005-03-25 23:56:56.000000000 +0100
@@ -135,6 +135,7 @@
 		b.topology_change = br->topology_change;
 		b.topology_change_detected = br->topology_change_detected;
 		b.root_port = br->root_port;
+		b.hub_enabled = br->hub_enabled;
 		b.stp_enabled = br->stp_enabled;
 		b.ageing_time = jiffies_to_clock_t(br->ageing_time);
 		b.hello_timer_value = br_timer_value(&br->hello_timer);
@@ -247,6 +248,13 @@
 		return 0;
 	}
 
+	case BRCTL_SET_BRIDGE_HUB_STATE:
+		if (!capable(CAP_NET_ADMIN))
+			return -EPERM;
+
+		br->hub_enabled = args[1]?1:0;
+		return 0;
+
 	case BRCTL_SET_BRIDGE_STP_STATE:
 		if (!capable(CAP_NET_ADMIN))
 			return -EPERM;
diff -ru a-2.6.11/net/bridge/br_private.h b-2.6.11/net/bridge/br_private.h
--- a-2.6.11/net/bridge/br_private.h	2005-03-26 21:14:05.000000000 +0100
+++ b-2.6.11/net/bridge/br_private.h	2005-03-25 23:56:56.000000000 +0100
@@ -93,6 +93,8 @@
 	struct hlist_head		hash[BR_HASH_SIZE];
 	struct list_head		age_list;
 
+	unsigned char			hub_enabled;
+	
 	/* STP */
 	bridge_id			designated_root;
 	bridge_id			bridge_id;
diff -ru a-2.6.11/net/bridge/br_sysfs_br.c b-2.6.11/net/bridge/br_sysfs_br.c
--- a-2.6.11/net/bridge/br_sysfs_br.c	2005-03-26 21:14:05.000000000 +0100
+++ b-2.6.11/net/bridge/br_sysfs_br.c	2005-03-25 23:56:56.000000000 +0100
@@ -136,6 +136,28 @@
 
 static CLASS_DEVICE_ATTR(ageing_time, S_IRUGO | S_IWUSR, show_ageing_time,
 			 store_ageing_time);
+
+static ssize_t show_hub_state(struct class_device *cd, char *buf)
+{
+	struct net_bridge *br = to_bridge(cd);
+	return sprintf(buf, "%d\n", br->hub_enabled);
+}
+
+static void set_hub_state(struct net_bridge *br, unsigned long val)
+{
+	br->hub_enabled = val;
+}
+
+static ssize_t store_hub_state(struct class_device *cd,
+			       const char *buf, size_t len)
+{
+	return store_bridge_parm(cd, buf, len, set_hub_state);
+}
+
+static CLASS_DEVICE_ATTR(hub_state, S_IRUGO | S_IWUSR, show_hub_state,
+			 store_hub_state);
+
+
 static ssize_t show_stp_state(struct class_device *cd, char *buf)
 {
 	struct net_bridge *br = to_bridge(cd);
@@ -246,6 +268,7 @@
 	&class_device_attr_hello_time.attr,
 	&class_device_attr_max_age.attr,
 	&class_device_attr_ageing_time.attr,
+	&class_device_attr_hub_state.attr,
 	&class_device_attr_stp_state.attr,
 	&class_device_attr_priority.attr,
 	&class_device_attr_bridge_id.attr,

[-- Attachment #1.2: Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 140 bytes --]

_______________________________________________
Bridge mailing list
Bridge@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/bridge

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

* Re: [PATCH bridge-2.6.11] bridge hub_enabled option
       [not found] <20050327092700.GA19972@nihil>
@ 2005-03-29 11:27 ` Alpt
  2005-04-04 16:22   ` Alpt
  0 siblings, 1 reply; 4+ messages in thread
From: Alpt @ 2005-03-29 11:27 UTC (permalink / raw)
  To: linux-net; +Cc: craig, netdev, linux-kernel, bridge


[-- Attachment #1.1: Type: text/plain, Size: 1331 bytes --]

On Sun, Mar 27, 2005 at 11:27:00AM +0200, Alpt after a spiritual call wrote  :
~> Bridge hub_enabled patch:
~> this patch adds the hub_enabled option for bridge.
~> 
~> By default the hub_enabled flag is set to 1. In this case nothing changes, the
~> bridge, as usually, acts as a hub and flood_forward the input pkts to all its
~> ports. When hun_enabled is set to 0, the bridge stops to flood_forward the input
~> traffic and takes only the pkts sent to it.
~> Disabling the hub option is useful to join multiple interfaces into a unique virtual
~> one, thus becomes possible to have easily an ad-hoc network topology using multiple
~> interfaces. 
~> 

[...]

The document describing this patch is here:
http://www.freaknet.org/alpt/src/bridge-hub/readme

There is a small correction for this patch. The new version is attached
here and be be found also here:
http://www.freaknet.org/alpt/src/bridge-hub/bridge-2.6.11-hub.patch

The patch for the bridge-utils:
http://www.freaknet.org/alpt/src/bridge-hub/bridge-utils-1.0.6-hub.patch

Thanks go to Craig Robson.

Regards,
let me know.
-- 
:wq!
"I don't know nothing" The One Who reached the Thinking Matter   '.'

[ Alpt --- Freaknet Medialab ]
[ GPG Key ID 441CF0EE ]
[ Key fingerprint = 8B02 26E8 831A 7BB9 81A9  5277 BFF8 037E 441C F0EE ]

[-- Attachment #1.2: bridge-2.6.11-hub.patch --]
[-- Type: text/plain, Size: 4358 bytes --]

diff -ru a-2.6.11/include/linux/if_bridge.h b-2.6.11/include/linux/if_bridge.h
--- a-2.6.11/include/linux/if_bridge.h	2005-03-02 08:38:09.000000000 +0100
+++ b-2.6.11/include/linux/if_bridge.h	2005-03-25 23:57:19.000000000 +0100
@@ -44,6 +44,7 @@
 #define BRCTL_SET_PORT_PRIORITY 16
 #define BRCTL_SET_PATH_COST 17
 #define BRCTL_GET_FDB_ENTRIES 18
+#define BRCTL_SET_BRIDGE_HUB_STATE 19
 
 #define BR_STATE_DISABLED 0
 #define BR_STATE_LISTENING 1
@@ -65,6 +66,7 @@
 	__u8 topology_change;
 	__u8 topology_change_detected;
 	__u8 root_port;
+	__u8 hub_enabled;
 	__u8 stp_enabled;
 	__u32 ageing_time;
 	__u32 gc_interval;
diff -ru a-2.6.11/net/bridge/br_if.c b-2.6.11/net/bridge/br_if.c
--- a-2.6.11/net/bridge/br_if.c	2005-03-02 08:38:33.000000000 +0100
+++ b-2.6.11/net/bridge/br_if.c	2005-03-25 23:56:56.000000000 +0100
@@ -155,6 +155,8 @@
 	br->bridge_id.prio[1] = 0x00;
 	memset(br->bridge_id.addr, 0, ETH_ALEN);
 
+	br->hub_enabled = 1;
+	
 	br->stp_enabled = 0;
 	br->designated_root = br->bridge_id;
 	br->root_path_cost = 0;
diff -ru a-2.6.11/net/bridge/br_input.c b-2.6.11/net/bridge/br_input.c
--- a-2.6.11/net/bridge/br_input.c	2005-03-02 08:37:50.000000000 +0100
+++ b-2.6.11/net/bridge/br_input.c	2005-03-29 13:07:04.000000000 +0200
@@ -65,7 +65,8 @@
 	}
 
 	if (dest[0] & 1) {
-		br_flood_forward(br, skb, !passedup);
+		if(br->hub_enabled)
+			br_flood_forward(br, skb, !passedup);
 		if (!passedup)
 			br_pass_frame_up(br, skb);
 		goto out;
@@ -80,12 +81,13 @@
 		goto out;
 	}
 
-	if (dst != NULL) {
+	if (dst != NULL && br->hub_enabled) {
 		br_forward(dst->dst, skb);
 		goto out;
 	}
 
-	br_flood_forward(br, skb, 0);
+	if(br->hub_enabled)
+		br_flood_forward(br, skb, 0);
 
 out:
 	return 0;
diff -ru a-2.6.11/net/bridge/br_ioctl.c b-2.6.11/net/bridge/br_ioctl.c
--- a-2.6.11/net/bridge/br_ioctl.c	2005-03-02 08:37:49.000000000 +0100
+++ b-2.6.11/net/bridge/br_ioctl.c	2005-03-25 23:56:56.000000000 +0100
@@ -135,6 +135,7 @@
 		b.topology_change = br->topology_change;
 		b.topology_change_detected = br->topology_change_detected;
 		b.root_port = br->root_port;
+		b.hub_enabled = br->hub_enabled;
 		b.stp_enabled = br->stp_enabled;
 		b.ageing_time = jiffies_to_clock_t(br->ageing_time);
 		b.hello_timer_value = br_timer_value(&br->hello_timer);
@@ -247,6 +248,13 @@
 		return 0;
 	}
 
+	case BRCTL_SET_BRIDGE_HUB_STATE:
+		if (!capable(CAP_NET_ADMIN))
+			return -EPERM;
+
+		br->hub_enabled = args[1]?1:0;
+		return 0;
+
 	case BRCTL_SET_BRIDGE_STP_STATE:
 		if (!capable(CAP_NET_ADMIN))
 			return -EPERM;
diff -ru a-2.6.11/net/bridge/br_private.h b-2.6.11/net/bridge/br_private.h
--- a-2.6.11/net/bridge/br_private.h	2005-03-02 08:37:50.000000000 +0100
+++ b-2.6.11/net/bridge/br_private.h	2005-03-25 23:56:56.000000000 +0100
@@ -93,6 +93,8 @@
 	struct hlist_head		hash[BR_HASH_SIZE];
 	struct list_head		age_list;
 
+	unsigned char			hub_enabled;
+	
 	/* STP */
 	bridge_id			designated_root;
 	bridge_id			bridge_id;
diff -ru a-2.6.11/net/bridge/br_sysfs_br.c b-2.6.11/net/bridge/br_sysfs_br.c
--- a-2.6.11/net/bridge/br_sysfs_br.c	2005-03-02 08:38:08.000000000 +0100
+++ b-2.6.11/net/bridge/br_sysfs_br.c	2005-03-25 23:56:56.000000000 +0100
@@ -136,6 +136,28 @@
 
 static CLASS_DEVICE_ATTR(ageing_time, S_IRUGO | S_IWUSR, show_ageing_time,
 			 store_ageing_time);
+
+static ssize_t show_hub_state(struct class_device *cd, char *buf)
+{
+	struct net_bridge *br = to_bridge(cd);
+	return sprintf(buf, "%d\n", br->hub_enabled);
+}
+
+static void set_hub_state(struct net_bridge *br, unsigned long val)
+{
+	br->hub_enabled = val;
+}
+
+static ssize_t store_hub_state(struct class_device *cd,
+			       const char *buf, size_t len)
+{
+	return store_bridge_parm(cd, buf, len, set_hub_state);
+}
+
+static CLASS_DEVICE_ATTR(hub_state, S_IRUGO | S_IWUSR, show_hub_state,
+			 store_hub_state);
+
+
 static ssize_t show_stp_state(struct class_device *cd, char *buf)
 {
 	struct net_bridge *br = to_bridge(cd);
@@ -246,6 +268,7 @@
 	&class_device_attr_hello_time.attr,
 	&class_device_attr_max_age.attr,
 	&class_device_attr_ageing_time.attr,
+	&class_device_attr_hub_state.attr,
 	&class_device_attr_stp_state.attr,
 	&class_device_attr_priority.attr,
 	&class_device_attr_bridge_id.attr,

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [PATCH bridge-2.6.11] bridge hub_enabled option
  2005-03-29 11:27 ` [PATCH bridge-2.6.11] bridge hub_enabled option Alpt
@ 2005-04-04 16:22   ` Alpt
  2005-04-04 16:30     ` Stephen Hemminger
  0 siblings, 1 reply; 4+ messages in thread
From: Alpt @ 2005-04-04 16:22 UTC (permalink / raw)
  To: linux-net, netdev, bridge

[-- Attachment #1: Type: text/plain, Size: 727 bytes --]

On Tue, Mar 29, 2005 at 01:27:33PM +0200, Alpt wrote  :
~> The document describing this patch is here:
~> http://www.freaknet.org/alpt/src/bridge-hub/readme
~> 
~> There is a small correction for this patch. The new version is attached
~> here and be be found also here:
~> http://www.freaknet.org/alpt/src/bridge-hub/bridge-2.6.11-hub.patch
~> 
~> The patch for the bridge-utils:
~> http://www.freaknet.org/alpt/src/bridge-hub/bridge-utils-1.0.6-hub.patch

so.. is it applied or not?

Best Regards
-- 
:wq!
"I don't know nothing" The One Who reached the Thinking Matter   '.'

[ Alpt --- Freaknet Medialab ]
[ GPG Key ID 441CF0EE ]
[ Key fingerprint = 8B02 26E8 831A 7BB9 81A9  5277 BFF8 037E 441C F0EE ]

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [PATCH bridge-2.6.11] bridge hub_enabled option
  2005-04-04 16:22   ` Alpt
@ 2005-04-04 16:30     ` Stephen Hemminger
  0 siblings, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2005-04-04 16:30 UTC (permalink / raw)
  To: Alpt; +Cc: linux-net, netdev, bridge

On Mon, 4 Apr 2005 18:22:01 +0200
Alpt <alpt@freaknet.org> wrote:

> On Tue, Mar 29, 2005 at 01:27:33PM +0200, Alpt wrote  :
> ~> The document describing this patch is here:
> ~> http://www.freaknet.org/alpt/src/bridge-hub/readme
> ~> 
> ~> There is a small correction for this patch. The new version is attached
> ~> here and be be found also here:
> ~> http://www.freaknet.org/alpt/src/bridge-hub/bridge-2.6.11-hub.patch
> ~> 
> ~> The patch for the bridge-utils:
> ~> http://www.freaknet.org/alpt/src/bridge-hub/bridge-utils-1.0.6-hub.patch
> 
> so.. is it applied or not?
> 
> Best Regards

I would rather it not be applied to mainline since it only has specialized usage.
I am willing to hold keep it in the patches area of the bridge site so others
can find it.

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

end of thread, other threads:[~2005-04-04 16:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20050327092700.GA19972@nihil>
2005-03-29 11:27 ` [PATCH bridge-2.6.11] bridge hub_enabled option Alpt
2005-04-04 16:22   ` Alpt
2005-04-04 16:30     ` Stephen Hemminger
2005-03-27  8:19 Alpt

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