2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* Ioctl handler
|
|
|
|
* Linux ethernet bridge
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Lennert Buytenhek <buytenh@gnu.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 2 of the License, or (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
2006-01-11 21:17:47 +01:00
|
|
|
#include <linux/capability.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/if_bridge.h>
|
|
|
|
#include <linux/netdevice.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 09:04:11 +01:00
|
|
|
#include <linux/slab.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <linux/times.h>
|
2007-09-17 20:56:21 +02:00
|
|
|
#include <net/net_namespace.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <asm/uaccess.h>
|
|
|
|
#include "br_private.h"
|
|
|
|
|
|
|
|
/* called with RTNL */
|
2008-09-09 01:19:58 +02:00
|
|
|
static int get_bridge_ifindices(struct net *net, int *indices, int num)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
struct net_device *dev;
|
|
|
|
int i = 0;
|
|
|
|
|
2008-09-09 01:19:58 +02:00
|
|
|
for_each_netdev(net, dev) {
|
2007-05-04 00:13:45 +02:00
|
|
|
if (i >= num)
|
|
|
|
break;
|
2007-02-09 15:24:35 +01:00
|
|
|
if (dev->priv_flags & IFF_EBRIDGE)
|
2005-04-17 00:20:36 +02:00
|
|
|
indices[i++] = dev->ifindex;
|
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* called with RTNL */
|
|
|
|
static void get_port_ifindices(struct net_bridge *br, int *ifindices, int num)
|
|
|
|
{
|
|
|
|
struct net_bridge_port *p;
|
|
|
|
|
|
|
|
list_for_each_entry(p, &br->port_list, list) {
|
|
|
|
if (p->port_no < num)
|
|
|
|
ifindices[p->port_no] = p->dev->ifindex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Format up to a page worth of forwarding table entries
|
|
|
|
* userbuf -- where to copy result
|
|
|
|
* maxnum -- maximum number of entries desired
|
|
|
|
* (limited to a page for sanity)
|
|
|
|
* offset -- number of records to skip
|
|
|
|
*/
|
2007-02-09 15:24:35 +01:00
|
|
|
static int get_fdb_entries(struct net_bridge *br, void __user *userbuf,
|
2005-04-17 00:20:36 +02:00
|
|
|
unsigned long maxnum, unsigned long offset)
|
|
|
|
{
|
|
|
|
int num;
|
|
|
|
void *buf;
|
2006-11-21 00:02:49 +01:00
|
|
|
size_t size;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2006-11-21 00:02:49 +01:00
|
|
|
/* Clamp size to PAGE_SIZE, test maxnum to avoid overflow */
|
|
|
|
if (maxnum > PAGE_SIZE/sizeof(struct __fdb_entry))
|
2005-04-17 00:20:36 +02:00
|
|
|
maxnum = PAGE_SIZE/sizeof(struct __fdb_entry);
|
2006-11-21 00:02:49 +01:00
|
|
|
|
|
|
|
size = maxnum * sizeof(struct __fdb_entry);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
buf = kmalloc(size, GFP_USER);
|
|
|
|
if (!buf)
|
|
|
|
return -ENOMEM;
|
2007-02-09 15:24:35 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
num = br_fdb_fillbuf(br, buf, maxnum, offset);
|
|
|
|
if (num > 0) {
|
|
|
|
if (copy_to_user(userbuf, buf, num*sizeof(struct __fdb_entry)))
|
|
|
|
num = -EFAULT;
|
|
|
|
}
|
|
|
|
kfree(buf);
|
|
|
|
|
|
|
|
return num;
|
|
|
|
}
|
|
|
|
|
2009-11-06 05:47:35 +01:00
|
|
|
/* called with RTNL */
|
2005-04-17 00:20:36 +02:00
|
|
|
static int add_del_if(struct net_bridge *br, int ifindex, int isadd)
|
|
|
|
{
|
2012-11-16 04:03:08 +01:00
|
|
|
struct net *net = dev_net(br->dev);
|
2005-04-17 00:20:36 +02:00
|
|
|
struct net_device *dev;
|
|
|
|
int ret;
|
|
|
|
|
2012-11-16 04:03:08 +01:00
|
|
|
if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EPERM;
|
|
|
|
|
2012-11-16 04:03:08 +01:00
|
|
|
dev = __dev_get_by_index(net, ifindex);
|
2005-04-17 00:20:36 +02:00
|
|
|
if (dev == NULL)
|
|
|
|
return -EINVAL;
|
2007-02-09 15:24:35 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
if (isadd)
|
|
|
|
ret = br_add_if(br, dev);
|
|
|
|
else
|
|
|
|
ret = br_del_if(br, dev);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Legacy ioctl's through SIOCDEVPRIVATE
|
|
|
|
* This interface is deprecated because it was too difficult to
|
2011-03-31 03:57:33 +02:00
|
|
|
* to do the translation for 32/64bit ioctl compatibility.
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
|
|
|
static int old_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
|
|
|
|
{
|
|
|
|
struct net_bridge *br = netdev_priv(dev);
|
|
|
|
unsigned long args[4];
|
2007-02-09 15:24:35 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
if (copy_from_user(args, rq->ifr_data, sizeof(args)))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
switch (args[0]) {
|
|
|
|
case BRCTL_ADD_IF:
|
|
|
|
case BRCTL_DEL_IF:
|
|
|
|
return add_del_if(br, args[1], args[0] == BRCTL_ADD_IF);
|
|
|
|
|
|
|
|
case BRCTL_GET_BRIDGE_INFO:
|
|
|
|
{
|
|
|
|
struct __bridge_info b;
|
|
|
|
|
|
|
|
memset(&b, 0, sizeof(struct __bridge_info));
|
|
|
|
rcu_read_lock();
|
|
|
|
memcpy(&b.designated_root, &br->designated_root, 8);
|
|
|
|
memcpy(&b.bridge_id, &br->bridge_id, 8);
|
|
|
|
b.root_path_cost = br->root_path_cost;
|
|
|
|
b.max_age = jiffies_to_clock_t(br->max_age);
|
|
|
|
b.hello_time = jiffies_to_clock_t(br->hello_time);
|
|
|
|
b.forward_delay = br->forward_delay;
|
|
|
|
b.bridge_max_age = br->bridge_max_age;
|
|
|
|
b.bridge_hello_time = br->bridge_hello_time;
|
|
|
|
b.bridge_forward_delay = jiffies_to_clock_t(br->bridge_forward_delay);
|
|
|
|
b.topology_change = br->topology_change;
|
|
|
|
b.topology_change_detected = br->topology_change_detected;
|
|
|
|
b.root_port = br->root_port;
|
2007-03-21 22:22:44 +01:00
|
|
|
|
|
|
|
b.stp_enabled = (br->stp_enabled != BR_NO_STP);
|
2005-04-17 00:20:36 +02:00
|
|
|
b.ageing_time = jiffies_to_clock_t(br->ageing_time);
|
|
|
|
b.hello_timer_value = br_timer_value(&br->hello_timer);
|
|
|
|
b.tcn_timer_value = br_timer_value(&br->tcn_timer);
|
|
|
|
b.topology_change_timer_value = br_timer_value(&br->topology_change_timer);
|
|
|
|
b.gc_timer_value = br_timer_value(&br->gc_timer);
|
2007-02-09 15:24:35 +01:00
|
|
|
rcu_read_unlock();
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
if (copy_to_user((void __user *)args[1], &b, sizeof(b)))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
case BRCTL_GET_PORT_LIST:
|
|
|
|
{
|
|
|
|
int num, *indices;
|
|
|
|
|
|
|
|
num = args[2];
|
|
|
|
if (num < 0)
|
|
|
|
return -EINVAL;
|
|
|
|
if (num == 0)
|
|
|
|
num = 256;
|
|
|
|
if (num > BR_MAX_PORTS)
|
|
|
|
num = BR_MAX_PORTS;
|
|
|
|
|
2006-07-21 23:51:30 +02:00
|
|
|
indices = kcalloc(num, sizeof(int), GFP_KERNEL);
|
2005-04-17 00:20:36 +02:00
|
|
|
if (indices == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
get_port_ifindices(br, indices, num);
|
|
|
|
if (copy_to_user((void __user *)args[1], indices, num*sizeof(int)))
|
|
|
|
num = -EFAULT;
|
|
|
|
kfree(indices);
|
|
|
|
return num;
|
|
|
|
}
|
|
|
|
|
|
|
|
case BRCTL_SET_BRIDGE_FORWARD_DELAY:
|
2012-11-16 04:03:08 +01:00
|
|
|
if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN))
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EPERM;
|
|
|
|
|
2011-04-04 16:03:33 +02:00
|
|
|
return br_set_forward_delay(br, args[1]);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
case BRCTL_SET_BRIDGE_HELLO_TIME:
|
2012-11-16 04:03:08 +01:00
|
|
|
if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN))
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EPERM;
|
|
|
|
|
2011-04-04 16:03:33 +02:00
|
|
|
return br_set_hello_time(br, args[1]);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
case BRCTL_SET_BRIDGE_MAX_AGE:
|
2012-11-16 04:03:08 +01:00
|
|
|
if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN))
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EPERM;
|
|
|
|
|
2011-04-04 16:03:33 +02:00
|
|
|
return br_set_max_age(br, args[1]);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
case BRCTL_SET_AGEING_TIME:
|
2012-11-16 04:03:08 +01:00
|
|
|
if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN))
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EPERM;
|
|
|
|
|
|
|
|
br->ageing_time = clock_t_to_jiffies(args[1]);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case BRCTL_GET_PORT_INFO:
|
|
|
|
{
|
|
|
|
struct __port_info p;
|
|
|
|
struct net_bridge_port *pt;
|
|
|
|
|
|
|
|
rcu_read_lock();
|
|
|
|
if ((pt = br_get_port(br, args[2])) == NULL) {
|
|
|
|
rcu_read_unlock();
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&p, 0, sizeof(struct __port_info));
|
|
|
|
memcpy(&p.designated_root, &pt->designated_root, 8);
|
|
|
|
memcpy(&p.designated_bridge, &pt->designated_bridge, 8);
|
|
|
|
p.port_id = pt->port_id;
|
|
|
|
p.designated_port = pt->designated_port;
|
|
|
|
p.path_cost = pt->path_cost;
|
|
|
|
p.designated_cost = pt->designated_cost;
|
|
|
|
p.state = pt->state;
|
|
|
|
p.top_change_ack = pt->topology_change_ack;
|
|
|
|
p.config_pending = pt->config_pending;
|
|
|
|
p.message_age_timer_value = br_timer_value(&pt->message_age_timer);
|
|
|
|
p.forward_delay_timer_value = br_timer_value(&pt->forward_delay_timer);
|
|
|
|
p.hold_timer_value = br_timer_value(&pt->hold_timer);
|
|
|
|
|
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
|
|
if (copy_to_user((void __user *)args[1], &p, sizeof(p)))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
case BRCTL_SET_BRIDGE_STP_STATE:
|
2012-11-16 04:03:08 +01:00
|
|
|
if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN))
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EPERM;
|
|
|
|
|
2007-03-21 22:22:44 +01:00
|
|
|
br_stp_set_enabled(br, args[1]);
|
2005-04-17 00:20:36 +02:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
case BRCTL_SET_BRIDGE_PRIORITY:
|
2012-11-16 04:03:08 +01:00
|
|
|
if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN))
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EPERM;
|
|
|
|
|
|
|
|
spin_lock_bh(&br->lock);
|
|
|
|
br_stp_set_bridge_priority(br, args[1]);
|
|
|
|
spin_unlock_bh(&br->lock);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case BRCTL_SET_PORT_PRIORITY:
|
|
|
|
{
|
|
|
|
struct net_bridge_port *p;
|
2011-04-04 16:03:33 +02:00
|
|
|
int ret;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2012-11-16 04:03:08 +01:00
|
|
|
if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN))
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EPERM;
|
|
|
|
|
|
|
|
spin_lock_bh(&br->lock);
|
2007-02-09 15:24:35 +01:00
|
|
|
if ((p = br_get_port(br, args[1])) == NULL)
|
2005-04-17 00:20:36 +02:00
|
|
|
ret = -EINVAL;
|
|
|
|
else
|
2011-04-04 16:03:33 +02:00
|
|
|
ret = br_stp_set_port_priority(p, args[2]);
|
2005-04-17 00:20:36 +02:00
|
|
|
spin_unlock_bh(&br->lock);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
case BRCTL_SET_PATH_COST:
|
|
|
|
{
|
|
|
|
struct net_bridge_port *p;
|
2011-04-04 16:03:33 +02:00
|
|
|
int ret;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2012-11-16 04:03:08 +01:00
|
|
|
if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN))
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EPERM;
|
|
|
|
|
2011-04-04 16:03:33 +02:00
|
|
|
spin_lock_bh(&br->lock);
|
2005-04-17 00:20:36 +02:00
|
|
|
if ((p = br_get_port(br, args[1])) == NULL)
|
|
|
|
ret = -EINVAL;
|
|
|
|
else
|
2011-04-04 16:03:33 +02:00
|
|
|
ret = br_stp_set_path_cost(p, args[2]);
|
|
|
|
spin_unlock_bh(&br->lock);
|
2007-02-27 18:55:07 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
case BRCTL_GET_FDB_ENTRIES:
|
2007-02-09 15:24:35 +01:00
|
|
|
return get_fdb_entries(br, (void __user *)args[1],
|
2005-04-17 00:20:36 +02:00
|
|
|
args[2], args[3]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2008-09-09 01:19:58 +02:00
|
|
|
static int old_deviceless(struct net *net, void __user *uarg)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
unsigned long args[3];
|
|
|
|
|
|
|
|
if (copy_from_user(args, uarg, sizeof(args)))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
switch (args[0]) {
|
|
|
|
case BRCTL_GET_VERSION:
|
|
|
|
return BRCTL_VERSION;
|
|
|
|
|
|
|
|
case BRCTL_GET_BRIDGES:
|
|
|
|
{
|
|
|
|
int *indices;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (args[2] >= 2048)
|
|
|
|
return -ENOMEM;
|
2006-07-21 23:51:30 +02:00
|
|
|
indices = kcalloc(args[2], sizeof(int), GFP_KERNEL);
|
2005-04-17 00:20:36 +02:00
|
|
|
if (indices == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2008-09-09 01:19:58 +02:00
|
|
|
args[2] = get_bridge_ifindices(net, indices, args[2]);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
ret = copy_to_user((void __user *)args[1], indices, args[2]*sizeof(int))
|
|
|
|
? -EFAULT : args[2];
|
|
|
|
|
|
|
|
kfree(indices);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
case BRCTL_ADD_BRIDGE:
|
|
|
|
case BRCTL_DEL_BRIDGE:
|
|
|
|
{
|
|
|
|
char buf[IFNAMSIZ];
|
|
|
|
|
2012-11-16 04:03:08 +01:00
|
|
|
if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EPERM;
|
|
|
|
|
|
|
|
if (copy_from_user(buf, (void __user *)args[1], IFNAMSIZ))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
buf[IFNAMSIZ-1] = 0;
|
|
|
|
|
|
|
|
if (args[0] == BRCTL_ADD_BRIDGE)
|
2008-09-09 01:19:58 +02:00
|
|
|
return br_add_bridge(net, buf);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-09-09 01:19:58 +02:00
|
|
|
return br_del_bridge(net, buf);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2007-09-17 20:56:21 +02:00
|
|
|
int br_ioctl_deviceless_stub(struct net *net, unsigned int cmd, void __user *uarg)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
switch (cmd) {
|
|
|
|
case SIOCGIFBR:
|
|
|
|
case SIOCSIFBR:
|
2008-09-09 01:19:58 +02:00
|
|
|
return old_deviceless(net, uarg);
|
2007-02-09 15:24:35 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
case SIOCBRADDBR:
|
|
|
|
case SIOCBRDELBR:
|
|
|
|
{
|
|
|
|
char buf[IFNAMSIZ];
|
|
|
|
|
2012-11-16 04:03:08 +01:00
|
|
|
if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EPERM;
|
|
|
|
|
|
|
|
if (copy_from_user(buf, uarg, IFNAMSIZ))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
buf[IFNAMSIZ-1] = 0;
|
|
|
|
if (cmd == SIOCBRADDBR)
|
2008-09-09 01:19:58 +02:00
|
|
|
return br_add_bridge(net, buf);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-09-09 01:19:58 +02:00
|
|
|
return br_del_bridge(net, buf);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
int br_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
|
|
|
|
{
|
|
|
|
struct net_bridge *br = netdev_priv(dev);
|
|
|
|
|
|
|
|
switch(cmd) {
|
|
|
|
case SIOCDEVPRIVATE:
|
|
|
|
return old_dev_ioctl(dev, rq, cmd);
|
|
|
|
|
|
|
|
case SIOCBRADDIF:
|
|
|
|
case SIOCBRDELIF:
|
|
|
|
return add_del_if(br, rq->ifr_ifindex, cmd == SIOCBRADDIF);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-05-10 11:31:09 +02:00
|
|
|
br_debug(br, "Bridge does not support ioctl 0x%x\n", cmd);
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|