netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bridge (2.6.5) - lift ioctl limits on number of bridges/ports.
@ 2004-04-01 21:41 Stephen Hemminger
  2004-04-01 21:50 ` David S. Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Hemminger @ 2004-04-01 21:41 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, bridge

Get rid of some arbitrary API restrictions that limit the kernel
to 64 bridges and 256 ports.  

Retain compatibility in GET_PORT_LIST, the existing bridge API
passes 0 for the third argument, and expects 256 entries.

Note: there still is limit of 256 ports due to STP, but this
shouldn't show up in the API, it needs to be handled by the
"add port to bridge ioctl".

diff -Nru a/net/bridge/br_if.c b/net/bridge/br_if.c
--- a/net/bridge/br_if.c	Thu Apr  1 12:50:36 2004
+++ b/net/bridge/br_if.c	Thu Apr  1 12:50:36 2004
@@ -262,13 +262,14 @@
 	return i;
 }
 
-void br_get_port_ifindices(struct net_bridge *br, int *ifindices)
+void br_get_port_ifindices(struct net_bridge *br, int *ifindices, int num)
 {
 	struct net_bridge_port *p;
 
 	rcu_read_lock();
 	list_for_each_entry_rcu(p, &br->port_list, list) {
-		ifindices[p->port_no] = p->dev->ifindex;
+		if (p->port_no < num)
+			ifindices[p->port_no] = p->dev->ifindex;
 	}
 	rcu_read_unlock();
 }
diff -Nru a/net/bridge/br_ioctl.c b/net/bridge/br_ioctl.c
--- a/net/bridge/br_ioctl.c	Thu Apr  1 12:50:36 2004
+++ b/net/bridge/br_ioctl.c	Thu Apr  1 12:50:36 2004
@@ -104,17 +104,18 @@
 
 	case BRCTL_GET_PORT_LIST:
 	{
-		int *indices;
+		int num = arg1 ? arg1 : 256;	/* compatiablity */
 		int ret = 0;
+		int *indices;
 
-		indices = kmalloc(256*sizeof(int), GFP_KERNEL);
+		indices = kmalloc(num*sizeof(int), GFP_KERNEL);
 		if (indices == NULL)
 			return -ENOMEM;
 
-		memset(indices, 0, 256*sizeof(int));
+		memset(indices, 0, num*sizeof(int));
 
-		br_get_port_ifindices(br, indices);
-		if (copy_to_user((void *)arg0, indices, 256*sizeof(int)))
+		br_get_port_ifindices(br, indices, num);
+		if (copy_to_user((void *)arg0, indices, num*sizeof(int)))
 			ret =  -EFAULT;
 		kfree(indices);
 		return ret;
@@ -263,9 +264,6 @@
 	{
 		int *indices;
 		int ret = 0;
-
-		if (arg1 > 64)
-			arg1 = 64;
 
 		indices = kmalloc(arg1*sizeof(int), GFP_KERNEL);
 		if (indices == NULL)
diff -Nru a/net/bridge/br_private.h b/net/bridge/br_private.h
--- a/net/bridge/br_private.h	Thu Apr  1 12:50:36 2004
+++ b/net/bridge/br_private.h	Thu Apr  1 12:50:36 2004
@@ -167,7 +167,7 @@
 extern int br_get_bridge_ifindices(int *indices,
 			    int num);
 extern void br_get_port_ifindices(struct net_bridge *br,
-			   int *ifindices);
+			   int *ifindices, int num);
 
 /* br_input.c */
 extern int br_handle_frame_finish(struct sk_buff *skb);

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

* Re: [PATCH] bridge (2.6.5) - lift ioctl limits on number of bridges/ports.
  2004-04-01 21:41 [PATCH] bridge (2.6.5) - lift ioctl limits on number of bridges/ports Stephen Hemminger
@ 2004-04-01 21:50 ` David S. Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David S. Miller @ 2004-04-01 21:50 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, bridge


Applied, thanks Stephen.

Again, send 2.4.x variant if applicable.

Thanks.

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

end of thread, other threads:[~2004-04-01 21:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-01 21:41 [PATCH] bridge (2.6.5) - lift ioctl limits on number of bridges/ports Stephen Hemminger
2004-04-01 21:50 ` David S. Miller

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