Commit 0e981847 authored by Stephen Hemminger's avatar Stephen Hemminger

[BRIDGE]: Lift ioctl limits on number of bridges/ports.

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'.
parent 0c2b1878
......@@ -262,13 +262,14 @@ int br_get_bridge_ifindices(int *indices, int num)
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();
}
......
......@@ -104,17 +104,18 @@ int br_ioctl_device(struct net_bridge *br, unsigned int cmd,
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;
......@@ -264,9 +265,6 @@ static int br_ioctl_deviceless(unsigned int cmd,
int *indices;
int ret = 0;
if (arg1 > 64)
arg1 = 64;
indices = kmalloc(arg1*sizeof(int), GFP_KERNEL);
if (indices == NULL)
return -ENOMEM;
......
......@@ -167,7 +167,7 @@ extern int br_del_if(struct net_bridge *br,
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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment