11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds * Ioctl handler 31da177e4SLinus Torvalds * Linux ethernet bridge 41da177e4SLinus Torvalds * 51da177e4SLinus Torvalds * Authors: 61da177e4SLinus Torvalds * Lennert Buytenhek <buytenh@gnu.org> 71da177e4SLinus Torvalds * 81da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or 91da177e4SLinus Torvalds * modify it under the terms of the GNU General Public License 101da177e4SLinus Torvalds * as published by the Free Software Foundation; either version 111da177e4SLinus Torvalds * 2 of the License, or (at your option) any later version. 121da177e4SLinus Torvalds */ 131da177e4SLinus Torvalds 144fc268d2SRandy Dunlap #include <linux/capability.h> 151da177e4SLinus Torvalds #include <linux/kernel.h> 161da177e4SLinus Torvalds #include <linux/if_bridge.h> 171da177e4SLinus Torvalds #include <linux/netdevice.h> 185a0e3ad6STejun Heo #include <linux/slab.h> 191da177e4SLinus Torvalds #include <linux/times.h> 20881d966bSEric W. Biederman #include <net/net_namespace.h> 211da177e4SLinus Torvalds #include <asm/uaccess.h> 221da177e4SLinus Torvalds #include "br_private.h" 231da177e4SLinus Torvalds 241da177e4SLinus Torvalds /* called with RTNL */ 254aa678baSAlexey Dobriyan static int get_bridge_ifindices(struct net *net, int *indices, int num) 261da177e4SLinus Torvalds { 271da177e4SLinus Torvalds struct net_device *dev; 281da177e4SLinus Torvalds int i = 0; 291da177e4SLinus Torvalds 304aa678baSAlexey Dobriyan for_each_netdev(net, dev) { 317562f876SPavel Emelianov if (i >= num) 327562f876SPavel Emelianov break; 331da177e4SLinus Torvalds if (dev->priv_flags & IFF_EBRIDGE) 341da177e4SLinus Torvalds indices[i++] = dev->ifindex; 351da177e4SLinus Torvalds } 361da177e4SLinus Torvalds 371da177e4SLinus Torvalds return i; 381da177e4SLinus Torvalds } 391da177e4SLinus Torvalds 401da177e4SLinus Torvalds /* called with RTNL */ 411da177e4SLinus Torvalds static void get_port_ifindices(struct net_bridge *br, int *ifindices, int num) 421da177e4SLinus Torvalds { 431da177e4SLinus Torvalds struct net_bridge_port *p; 441da177e4SLinus Torvalds 451da177e4SLinus Torvalds list_for_each_entry(p, &br->port_list, list) { 461da177e4SLinus Torvalds if (p->port_no < num) 471da177e4SLinus Torvalds ifindices[p->port_no] = p->dev->ifindex; 481da177e4SLinus Torvalds } 491da177e4SLinus Torvalds } 501da177e4SLinus Torvalds 511da177e4SLinus Torvalds /* 521da177e4SLinus Torvalds * Format up to a page worth of forwarding table entries 531da177e4SLinus Torvalds * userbuf -- where to copy result 541da177e4SLinus Torvalds * maxnum -- maximum number of entries desired 551da177e4SLinus Torvalds * (limited to a page for sanity) 561da177e4SLinus Torvalds * offset -- number of records to skip 571da177e4SLinus Torvalds */ 581da177e4SLinus Torvalds static int get_fdb_entries(struct net_bridge *br, void __user *userbuf, 591da177e4SLinus Torvalds unsigned long maxnum, unsigned long offset) 601da177e4SLinus Torvalds { 611da177e4SLinus Torvalds int num; 621da177e4SLinus Torvalds void *buf; 63ba8379b2SChris Wright size_t size; 641da177e4SLinus Torvalds 65ba8379b2SChris Wright /* Clamp size to PAGE_SIZE, test maxnum to avoid overflow */ 66ba8379b2SChris Wright if (maxnum > PAGE_SIZE/sizeof(struct __fdb_entry)) 671da177e4SLinus Torvalds maxnum = PAGE_SIZE/sizeof(struct __fdb_entry); 68ba8379b2SChris Wright 69ba8379b2SChris Wright size = maxnum * sizeof(struct __fdb_entry); 701da177e4SLinus Torvalds 711da177e4SLinus Torvalds buf = kmalloc(size, GFP_USER); 721da177e4SLinus Torvalds if (!buf) 731da177e4SLinus Torvalds return -ENOMEM; 741da177e4SLinus Torvalds 751da177e4SLinus Torvalds num = br_fdb_fillbuf(br, buf, maxnum, offset); 761da177e4SLinus Torvalds if (num > 0) { 771da177e4SLinus Torvalds if (copy_to_user(userbuf, buf, num*sizeof(struct __fdb_entry))) 781da177e4SLinus Torvalds num = -EFAULT; 791da177e4SLinus Torvalds } 801da177e4SLinus Torvalds kfree(buf); 811da177e4SLinus Torvalds 821da177e4SLinus Torvalds return num; 831da177e4SLinus Torvalds } 841da177e4SLinus Torvalds 8531ef30c7SEric Dumazet /* called with RTNL */ 861da177e4SLinus Torvalds static int add_del_if(struct net_bridge *br, int ifindex, int isadd) 871da177e4SLinus Torvalds { 88cb990503SEric W. Biederman struct net *net = dev_net(br->dev); 891da177e4SLinus Torvalds struct net_device *dev; 901da177e4SLinus Torvalds int ret; 911da177e4SLinus Torvalds 92cb990503SEric W. Biederman if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) 931da177e4SLinus Torvalds return -EPERM; 941da177e4SLinus Torvalds 95cb990503SEric W. Biederman dev = __dev_get_by_index(net, ifindex); 961da177e4SLinus Torvalds if (dev == NULL) 971da177e4SLinus Torvalds return -EINVAL; 981da177e4SLinus Torvalds 991da177e4SLinus Torvalds if (isadd) 1001da177e4SLinus Torvalds ret = br_add_if(br, dev); 1011da177e4SLinus Torvalds else 1021da177e4SLinus Torvalds ret = br_del_if(br, dev); 1031da177e4SLinus Torvalds 1041da177e4SLinus Torvalds return ret; 1051da177e4SLinus Torvalds } 1061da177e4SLinus Torvalds 1071da177e4SLinus Torvalds /* 1081da177e4SLinus Torvalds * Legacy ioctl's through SIOCDEVPRIVATE 1091da177e4SLinus Torvalds * This interface is deprecated because it was too difficult to 11025985edcSLucas De Marchi * to do the translation for 32/64bit ioctl compatibility. 1111da177e4SLinus Torvalds */ 1121da177e4SLinus Torvalds static int old_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 1131da177e4SLinus Torvalds { 1141da177e4SLinus Torvalds struct net_bridge *br = netdev_priv(dev); 115*bf871ad7SXin Long struct net_bridge_port *p = NULL; 1161da177e4SLinus Torvalds unsigned long args[4]; 117*bf871ad7SXin Long int ret = -EOPNOTSUPP; 1181da177e4SLinus Torvalds 1191da177e4SLinus Torvalds if (copy_from_user(args, rq->ifr_data, sizeof(args))) 1201da177e4SLinus Torvalds return -EFAULT; 1211da177e4SLinus Torvalds 1221da177e4SLinus Torvalds switch (args[0]) { 1231da177e4SLinus Torvalds case BRCTL_ADD_IF: 1241da177e4SLinus Torvalds case BRCTL_DEL_IF: 1251da177e4SLinus Torvalds return add_del_if(br, args[1], args[0] == BRCTL_ADD_IF); 1261da177e4SLinus Torvalds 1271da177e4SLinus Torvalds case BRCTL_GET_BRIDGE_INFO: 1281da177e4SLinus Torvalds { 1291da177e4SLinus Torvalds struct __bridge_info b; 1301da177e4SLinus Torvalds 1311da177e4SLinus Torvalds memset(&b, 0, sizeof(struct __bridge_info)); 1321da177e4SLinus Torvalds rcu_read_lock(); 1331da177e4SLinus Torvalds memcpy(&b.designated_root, &br->designated_root, 8); 1341da177e4SLinus Torvalds memcpy(&b.bridge_id, &br->bridge_id, 8); 1351da177e4SLinus Torvalds b.root_path_cost = br->root_path_cost; 1361da177e4SLinus Torvalds b.max_age = jiffies_to_clock_t(br->max_age); 1371da177e4SLinus Torvalds b.hello_time = jiffies_to_clock_t(br->hello_time); 1381da177e4SLinus Torvalds b.forward_delay = br->forward_delay; 1391da177e4SLinus Torvalds b.bridge_max_age = br->bridge_max_age; 1401da177e4SLinus Torvalds b.bridge_hello_time = br->bridge_hello_time; 1411da177e4SLinus Torvalds b.bridge_forward_delay = jiffies_to_clock_t(br->bridge_forward_delay); 1421da177e4SLinus Torvalds b.topology_change = br->topology_change; 1431da177e4SLinus Torvalds b.topology_change_detected = br->topology_change_detected; 1441da177e4SLinus Torvalds b.root_port = br->root_port; 1459cde0708SStephen Hemminger 1469cde0708SStephen Hemminger b.stp_enabled = (br->stp_enabled != BR_NO_STP); 1471da177e4SLinus Torvalds b.ageing_time = jiffies_to_clock_t(br->ageing_time); 1481da177e4SLinus Torvalds b.hello_timer_value = br_timer_value(&br->hello_timer); 1491da177e4SLinus Torvalds b.tcn_timer_value = br_timer_value(&br->tcn_timer); 1501da177e4SLinus Torvalds b.topology_change_timer_value = br_timer_value(&br->topology_change_timer); 1511da177e4SLinus Torvalds b.gc_timer_value = br_timer_value(&br->gc_timer); 1521da177e4SLinus Torvalds rcu_read_unlock(); 1531da177e4SLinus Torvalds 1541da177e4SLinus Torvalds if (copy_to_user((void __user *)args[1], &b, sizeof(b))) 1551da177e4SLinus Torvalds return -EFAULT; 1561da177e4SLinus Torvalds 1571da177e4SLinus Torvalds return 0; 1581da177e4SLinus Torvalds } 1591da177e4SLinus Torvalds 1601da177e4SLinus Torvalds case BRCTL_GET_PORT_LIST: 1611da177e4SLinus Torvalds { 1621da177e4SLinus Torvalds int num, *indices; 1631da177e4SLinus Torvalds 1641da177e4SLinus Torvalds num = args[2]; 1651da177e4SLinus Torvalds if (num < 0) 1661da177e4SLinus Torvalds return -EINVAL; 1671da177e4SLinus Torvalds if (num == 0) 1681da177e4SLinus Torvalds num = 256; 1691da177e4SLinus Torvalds if (num > BR_MAX_PORTS) 1701da177e4SLinus Torvalds num = BR_MAX_PORTS; 1711da177e4SLinus Torvalds 1720da974f4SPanagiotis Issaris indices = kcalloc(num, sizeof(int), GFP_KERNEL); 1731da177e4SLinus Torvalds if (indices == NULL) 1741da177e4SLinus Torvalds return -ENOMEM; 1751da177e4SLinus Torvalds 1761da177e4SLinus Torvalds get_port_ifindices(br, indices, num); 1771da177e4SLinus Torvalds if (copy_to_user((void __user *)args[1], indices, num*sizeof(int))) 1781da177e4SLinus Torvalds num = -EFAULT; 1791da177e4SLinus Torvalds kfree(indices); 1801da177e4SLinus Torvalds return num; 1811da177e4SLinus Torvalds } 1821da177e4SLinus Torvalds 1831da177e4SLinus Torvalds case BRCTL_SET_BRIDGE_FORWARD_DELAY: 184cb990503SEric W. Biederman if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN)) 1851da177e4SLinus Torvalds return -EPERM; 1861da177e4SLinus Torvalds 187*bf871ad7SXin Long ret = br_set_forward_delay(br, args[1]); 188*bf871ad7SXin Long break; 1891da177e4SLinus Torvalds 1901da177e4SLinus Torvalds case BRCTL_SET_BRIDGE_HELLO_TIME: 191cb990503SEric W. Biederman if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN)) 1921da177e4SLinus Torvalds return -EPERM; 1931da177e4SLinus Torvalds 194*bf871ad7SXin Long ret = br_set_hello_time(br, args[1]); 195*bf871ad7SXin Long break; 1961da177e4SLinus Torvalds 1971da177e4SLinus Torvalds case BRCTL_SET_BRIDGE_MAX_AGE: 198cb990503SEric W. Biederman if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN)) 1991da177e4SLinus Torvalds return -EPERM; 2001da177e4SLinus Torvalds 201*bf871ad7SXin Long ret = br_set_max_age(br, args[1]); 202*bf871ad7SXin Long break; 2031da177e4SLinus Torvalds 2041da177e4SLinus Torvalds case BRCTL_SET_AGEING_TIME: 205cb990503SEric W. Biederman if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN)) 2061da177e4SLinus Torvalds return -EPERM; 2071da177e4SLinus Torvalds 208*bf871ad7SXin Long ret = br_set_ageing_time(br, args[1]); 209*bf871ad7SXin Long break; 2101da177e4SLinus Torvalds 2111da177e4SLinus Torvalds case BRCTL_GET_PORT_INFO: 2121da177e4SLinus Torvalds { 2131da177e4SLinus Torvalds struct __port_info p; 2141da177e4SLinus Torvalds struct net_bridge_port *pt; 2151da177e4SLinus Torvalds 2161da177e4SLinus Torvalds rcu_read_lock(); 2171da177e4SLinus Torvalds if ((pt = br_get_port(br, args[2])) == NULL) { 2181da177e4SLinus Torvalds rcu_read_unlock(); 2191da177e4SLinus Torvalds return -EINVAL; 2201da177e4SLinus Torvalds } 2211da177e4SLinus Torvalds 2221da177e4SLinus Torvalds memset(&p, 0, sizeof(struct __port_info)); 2231da177e4SLinus Torvalds memcpy(&p.designated_root, &pt->designated_root, 8); 2241da177e4SLinus Torvalds memcpy(&p.designated_bridge, &pt->designated_bridge, 8); 2251da177e4SLinus Torvalds p.port_id = pt->port_id; 2261da177e4SLinus Torvalds p.designated_port = pt->designated_port; 2271da177e4SLinus Torvalds p.path_cost = pt->path_cost; 2281da177e4SLinus Torvalds p.designated_cost = pt->designated_cost; 2291da177e4SLinus Torvalds p.state = pt->state; 2301da177e4SLinus Torvalds p.top_change_ack = pt->topology_change_ack; 2311da177e4SLinus Torvalds p.config_pending = pt->config_pending; 2321da177e4SLinus Torvalds p.message_age_timer_value = br_timer_value(&pt->message_age_timer); 2331da177e4SLinus Torvalds p.forward_delay_timer_value = br_timer_value(&pt->forward_delay_timer); 2341da177e4SLinus Torvalds p.hold_timer_value = br_timer_value(&pt->hold_timer); 2351da177e4SLinus Torvalds 2361da177e4SLinus Torvalds rcu_read_unlock(); 2371da177e4SLinus Torvalds 2381da177e4SLinus Torvalds if (copy_to_user((void __user *)args[1], &p, sizeof(p))) 2391da177e4SLinus Torvalds return -EFAULT; 2401da177e4SLinus Torvalds 2411da177e4SLinus Torvalds return 0; 2421da177e4SLinus Torvalds } 2431da177e4SLinus Torvalds 2441da177e4SLinus Torvalds case BRCTL_SET_BRIDGE_STP_STATE: 245cb990503SEric W. Biederman if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN)) 2461da177e4SLinus Torvalds return -EPERM; 2471da177e4SLinus Torvalds 2489cde0708SStephen Hemminger br_stp_set_enabled(br, args[1]); 249*bf871ad7SXin Long ret = 0; 250*bf871ad7SXin Long break; 2511da177e4SLinus Torvalds 2521da177e4SLinus Torvalds case BRCTL_SET_BRIDGE_PRIORITY: 253cb990503SEric W. Biederman if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN)) 2541da177e4SLinus Torvalds return -EPERM; 2551da177e4SLinus Torvalds 2561da177e4SLinus Torvalds br_stp_set_bridge_priority(br, args[1]); 257*bf871ad7SXin Long ret = 0; 258*bf871ad7SXin Long break; 2591da177e4SLinus Torvalds 2601da177e4SLinus Torvalds case BRCTL_SET_PORT_PRIORITY: 2611da177e4SLinus Torvalds { 262cb990503SEric W. Biederman if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN)) 2631da177e4SLinus Torvalds return -EPERM; 2641da177e4SLinus Torvalds 2651da177e4SLinus Torvalds spin_lock_bh(&br->lock); 2661da177e4SLinus Torvalds if ((p = br_get_port(br, args[1])) == NULL) 2671da177e4SLinus Torvalds ret = -EINVAL; 2681da177e4SLinus Torvalds else 26914f98f25Sstephen hemminger ret = br_stp_set_port_priority(p, args[2]); 2701da177e4SLinus Torvalds spin_unlock_bh(&br->lock); 271*bf871ad7SXin Long break; 2721da177e4SLinus Torvalds } 2731da177e4SLinus Torvalds 2741da177e4SLinus Torvalds case BRCTL_SET_PATH_COST: 2751da177e4SLinus Torvalds { 276cb990503SEric W. Biederman if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN)) 2771da177e4SLinus Torvalds return -EPERM; 2781da177e4SLinus Torvalds 27914f98f25Sstephen hemminger spin_lock_bh(&br->lock); 2801da177e4SLinus Torvalds if ((p = br_get_port(br, args[1])) == NULL) 2811da177e4SLinus Torvalds ret = -EINVAL; 2821da177e4SLinus Torvalds else 28314f98f25Sstephen hemminger ret = br_stp_set_path_cost(p, args[2]); 28414f98f25Sstephen hemminger spin_unlock_bh(&br->lock); 285*bf871ad7SXin Long break; 2861da177e4SLinus Torvalds } 2871da177e4SLinus Torvalds 2881da177e4SLinus Torvalds case BRCTL_GET_FDB_ENTRIES: 2891da177e4SLinus Torvalds return get_fdb_entries(br, (void __user *)args[1], 2901da177e4SLinus Torvalds args[2], args[3]); 2911da177e4SLinus Torvalds } 2921da177e4SLinus Torvalds 293*bf871ad7SXin Long if (!ret) { 294*bf871ad7SXin Long if (p) 295*bf871ad7SXin Long br_ifinfo_notify(RTM_NEWLINK, p); 296*bf871ad7SXin Long else 297*bf871ad7SXin Long netdev_state_change(br->dev); 298*bf871ad7SXin Long } 299*bf871ad7SXin Long 300*bf871ad7SXin Long return ret; 3011da177e4SLinus Torvalds } 3021da177e4SLinus Torvalds 3034aa678baSAlexey Dobriyan static int old_deviceless(struct net *net, void __user *uarg) 3041da177e4SLinus Torvalds { 3051da177e4SLinus Torvalds unsigned long args[3]; 3061da177e4SLinus Torvalds 3071da177e4SLinus Torvalds if (copy_from_user(args, uarg, sizeof(args))) 3081da177e4SLinus Torvalds return -EFAULT; 3091da177e4SLinus Torvalds 3101da177e4SLinus Torvalds switch (args[0]) { 3111da177e4SLinus Torvalds case BRCTL_GET_VERSION: 3121da177e4SLinus Torvalds return BRCTL_VERSION; 3131da177e4SLinus Torvalds 3141da177e4SLinus Torvalds case BRCTL_GET_BRIDGES: 3151da177e4SLinus Torvalds { 3161da177e4SLinus Torvalds int *indices; 3171da177e4SLinus Torvalds int ret = 0; 3181da177e4SLinus Torvalds 3191da177e4SLinus Torvalds if (args[2] >= 2048) 3201da177e4SLinus Torvalds return -ENOMEM; 3210da974f4SPanagiotis Issaris indices = kcalloc(args[2], sizeof(int), GFP_KERNEL); 3221da177e4SLinus Torvalds if (indices == NULL) 3231da177e4SLinus Torvalds return -ENOMEM; 3241da177e4SLinus Torvalds 3254aa678baSAlexey Dobriyan args[2] = get_bridge_ifindices(net, indices, args[2]); 3261da177e4SLinus Torvalds 3271da177e4SLinus Torvalds ret = copy_to_user((void __user *)args[1], indices, args[2]*sizeof(int)) 3281da177e4SLinus Torvalds ? -EFAULT : args[2]; 3291da177e4SLinus Torvalds 3301da177e4SLinus Torvalds kfree(indices); 3311da177e4SLinus Torvalds return ret; 3321da177e4SLinus Torvalds } 3331da177e4SLinus Torvalds 3341da177e4SLinus Torvalds case BRCTL_ADD_BRIDGE: 3351da177e4SLinus Torvalds case BRCTL_DEL_BRIDGE: 3361da177e4SLinus Torvalds { 3371da177e4SLinus Torvalds char buf[IFNAMSIZ]; 3381da177e4SLinus Torvalds 339cb990503SEric W. Biederman if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) 3401da177e4SLinus Torvalds return -EPERM; 3411da177e4SLinus Torvalds 3421da177e4SLinus Torvalds if (copy_from_user(buf, (void __user *)args[1], IFNAMSIZ)) 3431da177e4SLinus Torvalds return -EFAULT; 3441da177e4SLinus Torvalds 3451da177e4SLinus Torvalds buf[IFNAMSIZ-1] = 0; 3461da177e4SLinus Torvalds 3471da177e4SLinus Torvalds if (args[0] == BRCTL_ADD_BRIDGE) 3484aa678baSAlexey Dobriyan return br_add_bridge(net, buf); 3491da177e4SLinus Torvalds 3504aa678baSAlexey Dobriyan return br_del_bridge(net, buf); 3511da177e4SLinus Torvalds } 3521da177e4SLinus Torvalds } 3531da177e4SLinus Torvalds 3541da177e4SLinus Torvalds return -EOPNOTSUPP; 3551da177e4SLinus Torvalds } 3561da177e4SLinus Torvalds 357881d966bSEric W. Biederman int br_ioctl_deviceless_stub(struct net *net, unsigned int cmd, void __user *uarg) 3581da177e4SLinus Torvalds { 3591da177e4SLinus Torvalds switch (cmd) { 3601da177e4SLinus Torvalds case SIOCGIFBR: 3611da177e4SLinus Torvalds case SIOCSIFBR: 3624aa678baSAlexey Dobriyan return old_deviceless(net, uarg); 3631da177e4SLinus Torvalds 3641da177e4SLinus Torvalds case SIOCBRADDBR: 3651da177e4SLinus Torvalds case SIOCBRDELBR: 3661da177e4SLinus Torvalds { 3671da177e4SLinus Torvalds char buf[IFNAMSIZ]; 3681da177e4SLinus Torvalds 369cb990503SEric W. Biederman if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) 3701da177e4SLinus Torvalds return -EPERM; 3711da177e4SLinus Torvalds 3721da177e4SLinus Torvalds if (copy_from_user(buf, uarg, IFNAMSIZ)) 3731da177e4SLinus Torvalds return -EFAULT; 3741da177e4SLinus Torvalds 3751da177e4SLinus Torvalds buf[IFNAMSIZ-1] = 0; 3761da177e4SLinus Torvalds if (cmd == SIOCBRADDBR) 3774aa678baSAlexey Dobriyan return br_add_bridge(net, buf); 3781da177e4SLinus Torvalds 3794aa678baSAlexey Dobriyan return br_del_bridge(net, buf); 3801da177e4SLinus Torvalds } 3811da177e4SLinus Torvalds } 3821da177e4SLinus Torvalds return -EOPNOTSUPP; 3831da177e4SLinus Torvalds } 3841da177e4SLinus Torvalds 3851da177e4SLinus Torvalds int br_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 3861da177e4SLinus Torvalds { 3871da177e4SLinus Torvalds struct net_bridge *br = netdev_priv(dev); 3881da177e4SLinus Torvalds 3891da177e4SLinus Torvalds switch (cmd) { 3901da177e4SLinus Torvalds case SIOCDEVPRIVATE: 3911da177e4SLinus Torvalds return old_dev_ioctl(dev, rq, cmd); 3921da177e4SLinus Torvalds 3931da177e4SLinus Torvalds case SIOCBRADDIF: 3941da177e4SLinus Torvalds case SIOCBRDELIF: 3951da177e4SLinus Torvalds return add_del_if(br, rq->ifr_ifindex, cmd == SIOCBRADDIF); 3961da177e4SLinus Torvalds 3971da177e4SLinus Torvalds } 3981da177e4SLinus Torvalds 39928a16c97Sstephen hemminger br_debug(br, "Bridge does not support ioctl 0x%x\n", cmd); 4001da177e4SLinus Torvalds return -EOPNOTSUPP; 4011da177e4SLinus Torvalds } 402