14 #include <linux/capability.h>
15 #include <linux/kernel.h>
16 #include <linux/if_bridge.h>
17 #include <linux/netdevice.h>
18 #include <linux/slab.h>
21 #include <asm/uaccess.h>
25 static int get_bridge_ifindices(
struct net *
net,
int *indices,
int num)
41 static void get_port_ifindices(
struct net_bridge *br,
int *ifindices,
int num)
58 static int get_fdb_entries(
struct net_bridge *br,
void __user *userbuf,
59 unsigned long maxnum,
unsigned long offset)
86 static int add_del_if(
struct net_bridge *br,
int ifindex,
int isadd)
114 unsigned long args[4];
122 return add_del_if(br, args[1], args[0] ==
BRCTL_ADD_IF);
169 indices = kcalloc(num,
sizeof(
int),
GFP_KERNEL);
173 get_port_ifindices(br, indices, num);
174 if (
copy_to_user((
void __user *)args[1], indices, num*
sizeof(
int)))
232 if (
copy_to_user((
void __user *)args[1], &p,
sizeof(p)))
249 spin_lock_bh(&br->
lock);
251 spin_unlock_bh(&br->
lock);
262 spin_lock_bh(&br->
lock);
267 spin_unlock_bh(&br->
lock);
279 spin_lock_bh(&br->
lock);
284 spin_unlock_bh(&br->
lock);
290 return get_fdb_entries(br, (
void __user *)args[1],
297 static int old_deviceless(
struct net *net,
void __user *uarg)
299 unsigned long args[3];
315 indices = kcalloc(args[2],
sizeof(
int),
GFP_KERNEL);
319 args[2] = get_bridge_ifindices(net, indices, args[2]);
321 ret =
copy_to_user((
void __user *)args[1], indices, args[2]*
sizeof(
int))
356 return old_deviceless(net, uarg);
385 return old_dev_ioctl(dev, rq, cmd);
389 return add_del_if(br, rq->ifr_ifindex, cmd ==
SIOCBRADDIF);
393 br_debug(br,
"Bridge does not support ioctl 0x%x\n", cmd);