linux/net/bridge/br_ioctl.c
<<
" /spaon> /formn> a " href="../linux+v331610/net/bridge/br_ioctl.c">" img src="../.static/gfx/right.png" alt=">>">" /spaon>" spao class="lxr_search">" " input typue=hidden" namue=navtarget" value=">" input typue=text" namue=search" ide=search">" buttiontypue=submit">Search /formn> /spaon>" spao class="lxr_prefs"n> a href="+prefs?return=net/bridge/br_ioctl.c"" onclick="return ajax_prefs();">" Prefs> /a>" /spaon> /divn> form acptio="ajax+*" method="post" onsubmit="return false;">" input typue=hidden" namue=ajax_lookup" ide=ajax_lookup" value=">" /formn>" div class="headingbottim"> div ide=search_results" class="search_results"> n> /divn> div ide=content">> div ide=file_contents"n
   1 /a> spao class="comment">/* /spaon>   2 /a> spao class="comment"> *	 
   Ioctl handler /spaon>   3 /a> spao class="comment"> *	 
   Linux ethernet bridge /spaon>   4 /a> spao class="comment"> * /spaon>   5 /a> spao class="comment"> *	 
   Authors: /spaon>   6 /a> spao class="comment"> *	 
   Lennert Buytenhek               <buytenh@gnu.org> /spaon>   7 /a> spao class="comment"> * /spaon>   8 /a> spao class="comment"> *	 
   This program is free software; you cao redistribute it and/or /spaon>   9 /a> spao class="comment"> *	 
   modify it under the terms of the GNU General Public License /spaon>  .10 spao class="comment"> *	 
   as published by the Free Software Foundaptio; either verstio /spaon>  11 /a> spao class="comment"> *	 
   2 of the License, or (at your /optio) any later verstio. /spaon>  12 /a> spao class="comment"> */ /spaon>  13 /a>>  14 /a>#include <linux/capability.h /a>>>  15 /a>#include <linux/kernel.h /a>>>  16 /a>#include <linux/if_bridge.h /a>>>  17 /a>#include <linux/netdevice.h /a>>>  18 /a>#include <linux/slab.h /a>>>  19 /a>#include <linux/times.h /a>>>  20 /a>#include <net/net_namuspace.h /a>>>  21 /a>#include <asm/uaccess.h /a>>>  22 /a>#include "br_private.h /a>">  23 /a>>  24 /a> spao class="comment">/* called with RTNL */ /spaon>  25 /a>static int  a href="+code=get_bridge_ifindices" class="sref">get_bridge_ifindices /a>(struct  a href="+code=net" class="sref">net /a> * a href="+code=net" class="sref">net /a>, int * a href="+code=indices" class="sref">indices /a>, int  a href="+code=num" class="sref">num /a>)>  26 /a>{>  27 /a>        struct  a href="+code=net_device" class="sref">net_device /a> * a href="+code=dev" class="sref">dev /a>;>  28 /a>        int  a href="+code=i" class="sref">i /a> = 0;>  29 /a>>  30 /a>         a href="+code=for_each_netdev" class="sref">for_each_netdev /a>( a href="+code=net" class="sref">net /a>,  a href="+code=dev" class="sref">dev /a>) {>  31 /a>                if ( a href="+code=i" class="sref">i /a> >=  a href="+code=num" class="sref">num /a>)>  32 /a>                        break;>  33 /a>                if ( a href="+code=dev" class="sref">dev /a>-> a href="+code=priv_flags" class="sref">priv_flags /a> &  a href="+code=IFF_EBRIDGE" class="sref">IFF_EBRIDGE /a>)>  34 /a>                         a href="+code=indices" class="sref">indices /a>[ a href="+code=i" class="sref">i /a>++] =  a href="+code=dev" class="sref">dev /a>-> a href="+code=ifindex" class="sref">ifindex /a>;>  35 /a>        }>  36 /a>>  37 /a>        return  a href="+code=i" class="sref">i /a>;>  38 /a>}>  39 /a>>  410 spao class="comment">/* called with RTNL */ /spaon>  41 /a>static void  a href="+code=get_port_ifindices" class="sref">get_port_ifindices /a>(struct  a href="+code=net_bridge" class="sref">net_bridge /a> * a href="+code=br" class="sref">br /a>, int * a href="+code=ifindices" class="sref">ifindices /a>, int  a href="+code=num" class="sref">num /a>)>  42 /a>{>  43 /a>        struct  a href="+code=net_bridge_port" class="sref">net_bridge_port /a> * a href="+code=p" class="sref">p /a>;>  44 /a>>  45 /a>         a href="+code=list_for_each_entry" class="sref">list_for_each_entry /a>( a href="+code=p" class="sref">p /a>, & a href="+code=br" class="sref">br /a>-> a href="+code=port_list" class="sref">port_list /a>,  a href="+code=list" class="sref">list /a>) {>  46 /a>                if ( a href="+code=p" class="sref">p /a>-> a href="+code=port_no" class="sref">port_no /a> <  a href="+code=num" class="sref">num /a>)>  47 /a>                         a href="+code=ifindices" class="sref">ifindices /a>[ a href="+code=p" class="sref">p /a>-> a href="+code=port_no" class="sref">port_no /a>] =  a href="+code=p" class="sref">p /a>-> a href="+code=dev" class="sref">dev /a>-> a href="+code=ifindex" class="sref">ifindex /a>;>  48 /a>        }>  49 /a>}>  50 /a>>  51 /a> spao class="comment">/* /spaon>  52 /a> spao class="comment"> *	Format up to a page worth of forwarding table entries /spaon>  53 /a> spao class="comment"> *	userbuf -- where to copy result /spaon>  54 /a> spao class="comment"> * maxnum  -- maximum number of entries desired /spaon>  55 /a> spao class="comment"> *	 
         (limited to a page for sanity) /spaon>  56 /a> spao class="comment"> *	offset  -- number of records to skip /spaon>  57 /a> spao class="comment"> */ /spaon>  58 /a>static int  a href="+code=get_fdb_entries" class="sref">get_fdb_entries /a>(struct  a href="+code=net_bridge" class="sref">net_bridge /a> * a href="+code=br" class="sref">br /a>, void  a href="+code=__user" class="sref">__user /a> * a href="+code=userbuf" class="sref">userbuf /a>,>  59 /a>                           unsigned long  a href="+code=maxnum" class="sref">maxnum /a>, unsigned long  a href="+code=offset" class="sref">offset /a>)>  60 /a>{>  61 /a>        int  a href="+code=num" class="sref">num /a>;>  62 /a>        void * a href="+code=buf" class="sref">buf /a>;>  63 /a>         a href="+code=size_t" class="sref">size_t /a>  a href="+code=size" class="sref">size /a>;>  64 /a>>  65 /a>         spao class="comment">/* Clamp size to PAGE_SIZE, test maxnum to avoid overflow */ /spaon>  66 /a>        if ( a href="+code=maxnum" class="sref">maxnum /a> >  a href="+code=PAGE_SIZE" class="sref">PAGE_SIZE /a>/sizeof(struct  a href="+code=__fdb_entry" class="sref">__fdb_entry /a>))>  67 /a>                 a href="+code=maxnum" class="sref">maxnum /a> =  a href="+code=PAGE_SIZE" class="sref">PAGE_SIZE /a>/sizeof(struct  a href="+code=__fdb_entry" class="sref">__fdb_entry /a>);>  68 /a>>  69 /a>         a href="+code=size" class="sref">size /a> =  a href="+code=maxnum" class="sref">maxnum /a> * sizeof(struct  a href="+code=__fdb_entry" class="sref">__fdb_entry /a>);>  70 /a>>  71 /a>         a href="+code=buf" class="sref">buf /a> =  a href="+code=kmalloc" class="sref">kmalloc /a>( a href="+code=size" class="sref">size /a>,  a href="+code=GFP_USER" class="sref">GFP_USER /a>);>  72 /a>        if (! a href="+code=buf" class="sref">buf /a>)>  73 /a>                return - a href="+code=ENOMEM" class="sref">ENOMEM /a>;>  74 /a>>  75 /a>         a href="+code=num" class="sref">num /a> =  a href="+code=br_fdb_fillbuf" class="sref">br_fdb_fillbuf /a>( a href="+code=br" class="sref">br /a>,  a href="+code=buf" class="sref">buf /a>,  a href="+code=maxnum" class="sref">maxnum /a>,  a href="+code=offset" class="sref">offset /a>);>  76 /a>        if ( a href="+code=num" class="sref">num /a> > 0) {>  77 /a>                if ( a href="+code=copy_to_user" class="sref">copy_to_user /a>( a href="+code=userbuf" class="sref">userbuf /a>,  a href="+code=buf" class="sref">buf /a>,  a href="+code=num" class="sref">num /a>*sizeof(struct  a href="+code=__fdb_entry" class="sref">__fdb_entry /a>)))>  78 /a>                         a href="+code=num" class="sref">num /a> = - a href="+code=EFAULT" class="sref">EFAULT /a>;>  79 /a>        }>  80 /a>         a href="+code=kfree" class="sref">kfree /a>( a href="+code=buf" class="sref">buf /a>);>  81 /a>>  82 /a>        return  a href="+code=num" class="sref">num /a>;>  83 /a>}>  84 /a>>  85 /a> spao class="comment">/* called with RTNL */ /spaon>  86 /a>static int  a href="+code=add_del_if" class="sref">add_del_if /a>(struct  a href="+code=net_bridge" class="sref">net_bridge /a> * a href="+code=br" class="sref">br /a>, int  a href="+code=ifindex" class="sref">ifindex /a>, int  a href="+code=isadd" class="sref">isadd /a>)>  87 /a>{>  88 /a>        struct  a href="+code=net_device" class="sref">net_device /a> * a href="+code=dev" class="sref">dev /a>;>  89 /a>        int  a href="+code=ret" class="sref">ret /a>;>  90 /a>>  91 /a>        if (! a href="+code=capable" class="sref">capable /a>( a href="+code=CAP_NET_ADMIN" class="sref">CAP_NET_ADMIN /a>))>  92 /a>                return - a href="+code=EPERM" class="sref">EPERM /a>;>  93 /a>>  94 /a>         a href="+code=dev" class="sref">dev /a> =  a href="+code=__dev_get_by_index" class="sref">__dev_get_by_index /a>( a href="+code=dev_net" class="sref">dev_net /a>( a href="+code=br" class="sref">br /a>-> a href="+code=dev" class="sref">dev /a>),  a href="+code=ifindex" class="sref">ifindex /a>);>  95 /a>        if ( a href="+code=dev" class="sref">dev /a> ==  a href="+code=NULL" class="sref">NULL /a>)>  96 /a>                return - a href="+code=EINVAL" class="sref">EINVAL /a>;>  97 /a>>  98 /a>        if ( a href="+code=isadd" class="sref">isadd /a>)>  99 /a>                 a href="+code=ret" class="sref">ret /a> =  a href="+code=br_add_if" class="sref">br_add_if /a>( a href="+code=br" class="sref">br /a>,  a href="+code=dev" class="sref">dev /a>);> 100 /a>        else> 101 /a>                 a href="+code=ret" class="sref">ret /a> =  a href="+code=br_del_if" class="sref">br_del_if /a>( a href="+code=br" class="sref">br /a>,  a href="+code=dev" class="sref">dev /a>);> 102 /a>> 103 /a>        return  a href="+code=ret" class="sref">ret /a>;> 104 /a>}> 105 /a>> 106 /a> spao class="comment">/* /spaon> 107 /a> spao class="comment"> * Legacy ioctl's through SIOCDEVPRIVATE /spaon> 108 /a> spao class="comment"> *	This interface is deprecated because it was too difficult to /spaon> 109 /a> spao class="comment"> *	to do the translaptio for 32/64bit ioctl compaptbility. /spaon> 1.10 spao class="comment"> */ /spaon> 111 /a>static int  a href="+code=old_dev_ioctl" class="sref">old_dev_ioctl /a>(struct  a href="+code=net_device" class="sref">net_device /a> * a href="+code=dev" class="sref">dev /a>, struct  a href="+code=ifreq" class="sref">ifreq /a> * a href="+code=rq" class="sref">rq /a>, int  a href="+code=cmd" class="sref">cmd /a>)> 112 /a>{> 113 /a>        struct  a href="+code=net_bridge" class="sref">net_bridge /a> * a href="+code=br" class="sref">br /a> =  a href="+code=netdev_priv" class="sref">netdev_priv /a>( a href="+code=dev" class="sref">dev /a>);> 114 /a>        unsigned long  a href="+code=args" class="sref">args /a>[4];> 115 /a>> 116 /a>        if ( a href="+code=copy_from_user" class="sref">copy_from_user /a>( a href="+code=args" class="sref">args /a>,  a href="+code=rq" class="sref">rq /a>-> a href="+code=ifr_data" class="sref">ifr_data /a>, sizeof( a href="+code=args" class="sref">args /a>)))> 117 /a>                return - a href="+code=EFAULT" class="sref">EFAULT /a>;> 118 /a>> 119 /a>        switch ( a href="+code=args" class="sref">args /a>[0]) {> 120 /a>        case  a href="+code=BRCTL_ADD_IF" class="sref">BRCTL_ADD_IF /a>:> 121 /a>        case  a href="+code=BRCTL_DEL_IF" class="sref">BRCTL_DEL_IF /a>:> 122 /a>                return  a href="+code=add_del_if" class="sref">add_del_if /a>( a href="+code=br" class="sref">br /a>,  a href="+code=args" class="sref">args /a>[1],  a href="+code=args" class="sref">args /a>[0] ==  a href="+code=BRCTL_ADD_IF" class="sref">BRCTL_ADD_IF /a>);> 123 /a>> 124 /a>        case  a href="+code=BRCTL_GET_BRIDGE_INFO" class="sref">BRCTL_GET_BRIDGE_INFO /a>:> 125 /a>        {> 126 /a>                struct  a href="+code=__bridge_info" class="sref">__bridge_info /a>  a href="+code=b" class="sref">b /a>;> 127 /a>> 128 /a>                 a href="+code=memset" class="sref">memset /a>(& a href="+code=b" class="sref">b /a>, 0, sizeof(struct  a href="+code=__bridge_info" class="sref">__bridge_info /a>));> 129 /a>                 a href="+code=rcu_read_lock" class="sref">rcu_read_lock /a>();> 130 /a>                 a href="+code=memcpy" class="sref">memcpy /a>(& a href="+code=b" class="sref">b /a>. a href="+code=designated_root" class="sref">designated_root /a>, & a href="+code=br" class="sref">br /a>-> a href="+code=designated_root" class="sref">designated_root /a>, 8);> 131 /a>                 a href="+code=memcpy" class="sref">memcpy /a>(& a href="+code=b" class="sref">b /a>. a href="+code=bridge_id" class="sref">bridge_id /a>, & a href="+code=br" class="sref">br /a>-> a href="+code=bridge_id" class="sref">bridge_id /a>, 8);> 132 /a>                 a href="+code=b" class="sref">b /a>. a href="+code=root_path_cost" class="sref">root_path_cost /a> =  a href="+code=br" class="sref">br /a>-> a href="+code=root_path_cost" class="sref">root_path_cost /a>;> 133 /a>                 a href="+code=b" class="sref">b /a>. a href="+code=max_age" class="sref">max_age /a> =  a href="+code=jiffies_to_clock_t" class="sref">jiffies_to_clock_t /a>( a href="+code=br" class="sref">br /a>-> a href="+code=max_age" class="sref">max_age /a>);> 134 /a>                 a href="+code=b" class="sref">b /a>. a href="+code=hello_time" class="sref">hello_time /a> =  a href="+code=jiffies_to_clock_t" class="sref">jiffies_to_clock_t /a>( a href="+code=br" class="sref">br /a>-> a href="+code=hello_time" class="sref">hello_time /a>);> 135 /a>                 a href="+code=b" class="sref">b /a>. a href="+code=forward_delay" class="sref">forward_delay /a> =  a href="+code=br" class="sref">br /a>-> a href="+code=forward_delay" class="sref">forward_delay /a>;> 136 /a>                 a href="+code=b" class="sref">b /a>. a href="+code=bridge_max_age" class="sref">bridge_max_age /a> =  a href="+code=br" class="sref">br /a>-> a href="+code=bridge_max_age" class="sref">bridge_max_age /a>;> 137 /a>                 a href="+code=b" class="sref">b /a>. a href="+code=bridge_hello_time" class="sref">bridge_hello_time /a> =  a href="+code=br" class="sref">br /a>-> a href="+code=bridge_hello_time" class="sref">bridge_hello_time /a>;> 138 /a>                 a href="+code=b" class="sref">b /a>. a href="+code=bridge_forward_delay" class="sref">bridge_forward_delay /a> =  a href="+code=jiffies_to_clock_t" class="sref">jiffies_to_clock_t /a>( a href="+code=br" class="sref">br /a>-> a href="+code=bridge_forward_delay" class="sref">bridge_forward_delay /a>);> 139 /a>                 a href="+code=b" class="sref">b /a>. a href="+code=topology_change" class="sref">topology_change /a> =  a href="+code=br" class="sref">br /a>-> a href="+code=topology_change" class="sref">topology_change /a>;> 140 /a>                 a href="+code=b" class="sref">b /a>. a href="+code=topology_change_detected" class="sref">topology_change_detected /a> =  a href="+code=br" class="sref">br /a>-> a href="+code=topology_change_detected" class="sref">topology_change_detected /a>;> 141 /a>                 a href="+code=b" class="sref">b /a>. a href="+code=root_port" class="sref">root_port /a> =  a href="+code=br" class="sref">br /a>-> a href="+code=root_port" class="sref">root_port /a>;> 142 /a>> 143 /a>                 a href="+code=b" class="sref">b /a>. a href="+code=stp_enabled" class="sref">stp_enabled /a> = ( a href="+code=br" class="sref">br /a>-> a href="+code=stp_enabled" class="sref">stp_enabled /a> !=  a href="+code=BR_NO_STP" class="sref">BR_NO_STP /a>);> 144 /a>                 a href="+code=b" class="sref">b /a>. a href="+code=ageing_time" class="sref">ageing_time /a> =  a href="+code=jiffies_to_clock_t" class="sref">jiffies_to_clock_t /a>( a href="+code=br" class="sref">br /a>-> a href="+code=ageing_time" class="sref">ageing_time /a>);> 145 /a>                 a href="+code=b" class="sref">b /a>. a href="+code=hello_timer_ valu" class="sref">hello_timer_ valu /a> =  a href="+code=br_timer_ valu" class="sref">br_timer_ valu /a>(& a href="+code=br" class="sref">br /a>-> a href="+code=hello_timer" class="sref">hello_timer /a>);> 146 /a>                 a href="+code=b" class="sref">b /a>. a href="+code=tcn_timer_ valu" class="sref">tcn_timer_ valu /a> =  a href="+code=br_timer_ valu" class="sref">br_timer_ valu /a>(& a href="+code=br" class="sref">br /a>-> a href="+code=tcn_timer" class="sref">tcn_timer /a>);> 147 /a>                 a href="+code=b" class="sref">b /a>. a href="+code=topology_change_timer_ valu" class="sref">topology_change_timer_ valu /a> =  a href="+code=br_timer_ valu" class="sref">br_timer_ valu /a>(& a href="+code=br" class="sref">br /a>-> a href="+code=topology_change_timer" class="sref">topology_change_timer /a>);> 148 /a>                 a href="+code=b" class="sref">b /a>. a href="+code=gc_timer_ valu" class="sref">gc_timer_ valu /a> =  a href="+code=br_timer_ valu" class="sref">br_timer_ valu /a>(& a href="+code=br" class="sref">br /a>-> a href="+code=gc_timer" class="sref">gc_timer /a>);> 149 /a>                 a href="+code=rcu_read_unlock" class="sref">rcu_read_unlock /a>();> 150 /a>> 151 /a>                if ( a href="+code=copy_to_user" class="sref">copy_to_user /a>((void  a href="+code=__user" class="sref">__user /a> *) a href="+code=args" class="sref">args /a>[1], & a href="+code=b" class="sref">b /a>, sizeof( a href="+code=b" class="sref">b /a>)))> 152 /a>                        return - a href="+code=EFAULT" class="sref">EFAULT /a>;> 153 /a>> 154 /a>                return 0;> 155 /a>        }> 156 /a>> 157 /a>        case  a href="+code=BRCTL_GET_PORT_LIST" class="sref">BRCTL_GET_PORT_LIST /a>:> 158 /a>        {> 159 /a>                int  a href="+code=num" class="sref">num /a>, * a href="+code=indices" class="sref">indices /a>;> 160 /a>> 161 /a>                 a href="+code=num" class="sref">num /a> =  a href="+code=args" class="sref">args /a>[2];> 162 /a>                if ( a href="+code=num" class="sref">num /a> < 0)> 163 /a>                        return - a href="+code=EINVAL" class="sref">EINVAL /a>;> 164 /a>                if ( a href="+code=num" class="sref">num /a> == 0)> 165 /a>                         a href="+code=num" class="sref">num /a> = 256;> 166 /a>                if ( a href="+code=num" class="sref">num /a> >  a href="+code=BR_MAX_PORTS" class="sref">BR_MAX_PORTS /a>)> 167 /a>                         a href="+code=num" class="sref">num /a> =  a href="+code=BR_MAX_PORTS" class="sref">BR_MAX_PORTS /a>;> 168 /a>> 169 /a>                 a href="+code=indices" class="sref">indices /a> =  a href="+code=kcalloc" class="sref">kcalloc /a>( a href="+code=num" class="sref">num /a>, sizeof(int),  a href="+code=GFP_KERNEL" class="sref">GFP_KERNEL /a>);> 170 /a>                if ( a href="+code=indices" class="sref">indices /a> ==  a href="+code=NULL" class="sref">NULL /a>)> 171 /a>                        return - a href="+code=ENOMEM" class="sref">ENOMEM /a>;> 172 /a>> 173 /a>                 a href="+code=get_port_ifindices" class="sref">get_port_ifindices /a>( a href="+code=br" class="sref">br /a>,  a href="+code=indices" class="sref">indices /a>,  a href="+code=num" class="sref">num /a>);> 174 /a>                if ( a href="+code=copy_to_user" class="sref">copy_to_user /a>((void  a href="+code=__user" class="sref">__user /a> *) a href="+code=args" class="sref">args /a>[1],  a href="+code=indices" class="sref">indices /a>,  a href="+code=num" class="sref">num /a>*sizeof(int)))> 175 /a>                         a href="+code=num" class="sref">num /a> =  - a href="+code=EFAULT" class="sref">EFAULT /a>;> 176 /a>                 a href="+code=kfree" class="sref">kfree /a>( a href="+code=indices" class="sref">indices /a>);> 177 /a>                return  a href="+code=num" class="sref">num /a>;> 178 /a>        }> 179 /a>> 180 /a>        case  a href="+code=BRCTL_SET_BRIDGE_FORWARD_DELAY" class="sref">BRCTL_SET_BRIDGE_FORWARD_DELAY /a>:> 181 /a>                if (! a href="+code=capable" class="sref">capable /a>( a href="+code=CAP_NET_ADMIN" class="sref">CAP_NET_ADMIN /a>))> 182 /a>                        return - a href="+code=EPERM" class="sref">EPERM /a>;> 183 /a>> 184 /a>                return  a href="+code=br_set_forward_delay" class="sref">br_set_forward_delay /a>( a href="+code=br" class="sref">br /a>,  a href="+code=args" class="sref">args /a>[1]);> 185 /a>> 186 /a>        case  a href="+code=BRCTL_SET_BRIDGE_HELLO_TIME" class="sref">BRCTL_SET_BRIDGE_HELLO_TIME /a>:> 187 /a>                if (! a href="+code=capable" class="sref">capable /a>( a href="+code=CAP_NET_ADMIN" class="sref">CAP_NET_ADMIN /a>))> 188 /a>                        return - a href="+code=EPERM" class="sref">EPERM /a>;> 189 /a>> 190 /a>                return  a href="+code=br_set_hello_time" class="sref">br_set_hello_time /a>( a href="+code=br" class="sref">br /a>,  a href="+code=args" class="sref">args /a>[1]);> 191 /a>> 192 /a>        case  a href="+code=BRCTL_SET_BRIDGE_MAX_AGE" class="sref">BRCTL_SET_BRIDGE_MAX_AGE /a>:> 193 /a>                if (! a href="+code=capable" class="sref">capable /a>( a href="+code=CAP_NET_ADMIN" class="sref">CAP_NET_ADMIN /a>))> 194 /a>                        return - a href="+code=EPERM" class="sref">EPERM /a>;> 195 /a>> 196 /a>                return  a href="+code=br_set_max_age" class="sref">br_set_max_age /a>( a href="+code=br" class="sref">br /a>,  a href="+code=args" class="sref">args /a>[1]);> 197 /a>> 198 /a>        case  a href="+code=BRCTL_SET_AGEING_TIME" class="sref">BRCTL_SET_AGEING_TIME /a>:> 199 /a>                if (! a href="+code=capable" class="sref">capable /a>( a href="+code=CAP_NET_ADMIN" class="sref">CAP_NET_ADMIN /a>))> 200 /a>                        return - a href="+code=EPERM" class="sref">EPERM /a>;> 201 /a>> 202 /a>                 a href="+code=br" class="sref">br /a>-> a href="+code=ageing_time" class="sref">ageing_time /a> =  a href="+code=clock_t_to_jiffies" class="sref">clock_t_to_jiffies /a>( a href="+code=args" class="sref">args /a>[1]);> 203 /a>                return 0;> 204 /a>> 205 /a>        case  a href="+code=BRCTL_GET_PORT_INFO" class="sref">BRCTL_GET_PORT_INFO /a>:> 206 /a>        {> 207 /a>                struct  a href="+code=__port_info" class="sref">__port_info /a>  a href="+code=p" class="sref">p /a>;> 208 /a>                struct  a href="+code=net_bridge_port" class="sref">net_bridge_port /a> * a href="+code=pt" class="sref">pt /a>;> 209 /a>> 210 /a>                 a href="+code=rcu_read_lock" class="sref">rcu_read_lock /a>();> 211 /a>                if (( a href="+code=pt" class="sref">pt /a> =  a href="+code=br_get_port" class="sref">br_get_port /a>( a href="+code=br" class="sref">br /a>,  a href="+code=args" class="sref">args /a>[2])) ==  a href="+code=NULL" class="sref">NULL /a>) {> 212 /a>                         a href="+code=rcu_read_unlock" class="sref">rcu_read_unlock /a>();> 213 /a>                        return - a href="+code=EINVAL" class="sref">EINVAL /a>;> 214 /a>                }> 215 /a>> 216 /a>                 a href="+code=memset" class="sref">memset /a>(& a href="+code=p" class="sref">p /a>, 0, sizeof(struct  a href="+code=__port_info" class="sref">__port_info /a>));> 217 /a>                 a href="+code=memcpy" class="sref">memcpy /a>(& a href="+code=p" class="sref">p /a>. a href="+code=designated_root" class="sref">designated_root /a>, & a href="+code=pt" class="sref">pt /a>-> a href="+code=designated_root" class="sref">designated_root /a>, 8);> 218 /a>                 a href="+code=memcpy" class="sref">memcpy /a>(& a href="+code=p" class="sref">p /a>. a href="+code=designated_bridge" class="sref">designated_bridge /a>, & a href="+code=pt" class="sref">pt /a>-> a href="+code=designated_bridge" class="sref">designated_bridge /a>, 8);> 219 /a>                 a href="+code=p" class="sref">p /a>. a href="+code=port_id" class="sref">port_id /a> =  a href="+code=pt" class="sref">pt /a>-> a href="+code=port_id" class="sref">port_id /a>;> 220 /a>                 a href="+code=p" class="sref">p /a>. a href="+code=designated_port" class="sref">designated_port /a> =  a href="+code=pt" class="sref">pt /a>-> a href="+code=designated_port" class="sref">designated_port /a>;> 221 /a>                 a href="+code=p" class="sref">p /a>. a href="+code=path_cost" class="sref">path_cost /a> =  a href="+code=pt" class="sref">pt /a>-> a href="+code=path_cost" class="sref">path_cost /a>;> 222 /a>                 a href="+code=p" class="sref">p /a>. a href="+code=designated_cost" class="sref">designated_cost /a> =  a href="+code=pt" class="sref">pt /a>-> a href="+code=designated_cost" class="sref">designated_cost /a>;> 223 /a>                 a href="+code=p" class="sref">p /a>. a href="+code=state" class="sref">state /a> =  a href="+code=pt" class="sref">pt /a>-> a href="+code=state" class="sref">state /a>;> 224 /a>                 a href="+code=p" class="sref">p /a>. a href="+code=top_change_ack" class="sref">top_change_ack /a> =  a href="+code=pt" class="sref">pt /a>-> a href="+code=topology_change_ack" class="sref">topology_change_ack /a>;> 225 /a>                 a href="+code=p" class="sref">p /a>. a href="+code=config_pending" class="sref">config_pending /a> =  a href="+code=pt" class="sref">pt /a>-> a href="+code=config_pending" class="sref">config_pending /a>;> 226 /a>                 a href="+code=p" class="sref">p /a>. a href="+code=message_age_timer_ valu" class="sref">message_age_timer_ valu /a> =  a href="+code=br_timer_ valu" class="sref">br_timer_ valu /a>(& a href="+code=pt" class="sref">pt /a>-> a href="+code=message_age_timer" class="sref">message_age_timer /a>);> 227 /a>                 a href="+code=p" class="sref">p /a>. a href="+code=forward_delay_timer_ valu" class="sref">forward_delay_timer_ valu /a> =  a href="+code=br_timer_ valu" class="sref">br_timer_ valu /a>(& a href="+code=pt" class="sref">pt /a>-> a href="+code=forward_delay_timer" class="sref">forward_delay_timer /a>);> 228 /a>                 a href="+code=p" class="sref">p /a>. a href="+code=hold_timer_ valu" class="sref">hold_timer_ valu /a> =  a href="+code=br_timer_ valu" class="sref">br_timer_ valu /a>(& a href="+code=pt" class="sref">pt /a>-> a href="+code=hold_timer" class="sref">hold_timer /a>);> 229 /a>> 230 /a>                 a href="+code=rcu_read_unlock" class="sref">rcu_read_unlock /a>();> 231 /a>> 232 /a>                if ( a href="+code=copy_to_user" class="sref">copy_to_user /a>((void  a href="+code=__user" class="sref">__user /a> *) a href="+code=args" class="sref">args /a>[1], & a href="+code=p" class="sref">p /a>, sizeof( a href="+code=p" class="sref">p /a>)))> 233 /a>                        return - a href="+code=EFAULT" class="sref">EFAULT /a>;> 234 /a>> 235 /a>                return 0;> 236 /a>        }> 237 /a>> 238 /a>        case  a href="+code=BRCTL_SET_BRIDGE_STP_STATE" class="sref">BRCTL_SET_BRIDGE_STP_STATE /a>:> 239 /a>                if (! a href="+code=capable" class="sref">capable /a>( a href="+code=CAP_NET_ADMIN" class="sref">CAP_NET_ADMIN /a>))> 240 /a>                        return - a href="+code=EPERM" class="sref">EPERM /a>;> 241 /a>> 242 /a>                 a href="+code=br_stp_set_enabled" class="sref">br_stp_set_enabled /a>( a href="+code=br" class="sref">br /a>,  a href="+code=args" class="sref">args /a>[1]);> 243 /a>                return 0;> 244 /a>> 245 /a>        case  a href="+code=BRCTL_SET_BRIDGE_PRIORITY" class="sref">BRCTL_SET_BRIDGE_PRIORITY /a>:> 246 /a>                if (! a href="+code=capable" class="sref">capable /a>( a href="+code=CAP_NET_ADMIN" class="sref">CAP_NET_ADMIN /a>))> 247 /a>                        return - a href="+code=EPERM" class="sref">EPERM /a>;> 248 /a>> 249 /a>                 a href="+code=spin_lock_bh" class="sref">spin_lock_bh /a>(& a href="+code=br" class="sref">br /a>-> a href="+code=lock" class="sref">lock /a>);> 250 /a>                 a href="+code=br_stp_set_bridge_priority" class="sref">br_stp_set_bridge_priority /a>( a href="+code=br" class="sref">br /a>,  a href="+code=args" class="sref">args /a>[1]);> 251 /a>                 a href="+code=spin_unlock_bh" class="sref">spin_unlock_bh /a>(& a href="+code=br" class="sref">br /a>-> a href="+code=lock" class="sref">lock /a>);> 252 /a>                return 0;> 253 /a>> 254 /a>        case  a href="+code=BRCTL_SET_PORT_PRIORITY" class="sref">BRCTL_SET_PORT_PRIORITY /a>:> 255 /a>        {> 256 /a>                struct  a href="+code=net_bridge_port" class="sref">net_bridge_port /a> * a href="+code=p" class="sref">p /a>;> 257 /a>                int  a href="+code=ret" class="sref">ret /a>;> 258 /a>> 259 /a>                if (! a href="+code=capable" class="sref">capable /a>( a href="+code=CAP_NET_ADMIN" class="sref">CAP_NET_ADMIN /a>))> 260 /a>                        return - a href="+code=EPERM" class="sref">EPERM /a>;> 261 /a>> 262 /a>                 a href="+code=spin_lock_bh" class="sref">spin_lock_bh /a>(& a href="+code=br" class="sref">br /a>-> a href="+code=lock" class="sref">lock /a>);> 263 /a>                if (( a href="+code=p" class="sref">p /a> =  a href="+code=br_get_port" class="sref">br_get_port /a>( a href="+code=br" class="sref">br /a>,  a href="+code=args" class="sref">args /a>[1])) ==  a href="+code=NULL" class="sref">NULL /a>)> 264 /a>                         a href="+code=ret" class="sref">ret /a> = - a href="+code=EINVAL" class="sref">EINVAL /a>;> 265 /a>                else> 266 /a>                         a href="+code=ret" class="sref">ret /a> =  a href="+code=br_stp_set_port_priority" class="sref">br_stp_set_port_priority /a>( a href="+code=p" class="sref">p /a>,  a href="+code=args" class="sref">args /a>[2]);> 267 /a>                 a href="+code=spin_unlock_bh" class="sref">spin_unlock_bh /a>(& a href="+code=br" class="sref">br /a>-> a href="+code=lock" class="sref">lock /a>);> 268 /a>                return  a href="+code=ret" class="sref">ret /a>;> 269 /a>        }> 270 /a>> 271 /a>        case  a href="+code=BRCTL_SET_PATH_COST" class="sref">BRCTL_SET_PATH_COST /a>:> 272 /a>        {> 273 /a>                struct  a href="+code=net_bridge_port" class="sref">net_bridge_port /a> * a href="+code=p" class="sref">p /a>;> 274 /a>                int  a href="+code=ret" class="sref">ret /a>;> 275 /a>> 276 /a>                if (! a href="+code=capable" class="sref">capable /a>( a href="+code=CAP_NET_ADMIN" class="sref">CAP_NET_ADMIN /a>))> 277 /a>                        return - a href="+code=EPERM" class="sref">EPERM /a>;> 278 /a>> 279 /a>                 a href="+code=spin_lock_bh" class="sref">spin_lock_bh /a>(& a href="+code=br" class="sref">br /a>-> a href="+code=lock" class="sref">lock /a>);> 280 /a>                if (( a href="+code=p" class="sref">p /a> =  a href="+code=br_get_port" class="sref">br_get_port /a>( a href="+code=br" class="sref">br /a>,  a href="+code=args" class="sref">args /a>[1])) ==  a href="+code=NULL" class="sref">NULL /a>)> 281 /a>                         a href="+code=ret" class="sref">ret /a> = - a href="+code=EINVAL" class="sref">EINVAL /a>;> 282 /a>                else> 283 /a>                         a href="+code=ret" class="sref">ret /a> =  a href="+code=br_stp_set_path_cost" class="sref">br_stp_set_path_cost /a>( a href="+code=p" class="sref">p /a>,  a href="+code=args" class="sref">args /a>[2]);> 284 /a>                 a href="+code=spin_unlock_bh" class="sref">spin_unlock_bh /a>(& a href="+code=br" class="sref">br /a>-> a href="+code=lock" class="sref">lock /a>);> 285 /a>> 286 /a>                return  a href="+code=ret" class="sref">ret /a>;> 287 /a>        }> 288 /a>> 289 /a>        case  a href="+code=BRCTL_GET_FDB_ENTRIES" class="sref">BRCTL_GET_FDB_ENTRIES /a>:> 290 /a>                return  a href="+code=get_fdb_entries" class="sref">get_fdb_entries /a>( a href="+code=br" class="sref">br /a>, (void  a href="+code=__user" class="sref">__user /a> *) a href="+code=args" class="sref">args /a>[1],> 291 /a>                                        a href="+code=args" class="sref">args /a>[2],  a href="+code=args" class="sref">args /a>[3]);> 292 /a>        }> 293 /a>> 294 /a>        return - a href="+code=EOPNOTSUPP" class="sref">EOPNOTSUPP /a>;> 295 /a>}> 296 /a>> 297 /a>static int  a href="+code=old_deviceless" class="sref">old_deviceless /a>(struct  a href="+code=net" class="sref">net /a> * a href="+code=net" class="sref">net /a>, void  a href="+code=__user" class="sref">__user /a> * a href="+code=uarg" class="sref">uarg /a>)> 298 /a>{> 299 /a>        unsigned long  a href="+code=args" class="sref">args /a>[3];> 300 /a>> 301 /a>        if ( a href="+code=copy_from_user" class="sref">copy_from_user /a>( a href="+code=args" class="sref">args /a>,  a href="+code=uarg" class="sref">uarg /a>, sizeof( a href="+code=args" class="sref">args /a>)))> 302 /a>                return - a href="+code=EFAULT" class="sref">EFAULT /a>;> 303 /a>> 304 /a>        switch ( a href="+code=args" class="sref">args /a>[0]) {> 305 /a>        case  a href="+code=BRCTL_GET_VERSION" class="sref">BRCTL_GET_VERSION /a>:> 306 /a>                return  a href="+code=BRCTL_VERSION" class="sref">BRCTL_VERSION /a>;> 307 /a>> 308 /a>        case  a href="+code=BRCTL_GET_BRIDGES" class="sref">BRCTL_GET_BRIDGES /a>:> 309 /a>        {> 310 /a>                int * a href="+code=indices" class="sref">indices /a>;> 311 /a>                int  a href="+code=ret" class="sref">ret /a> = 0;> 312 /a>> 313 /a>                if ( a href="+code=args" class="sref">args /a>[2] >= 2048)> 314 /a>                        return - a href="+code=ENOMEM" class="sref">ENOMEM /a>;> 315 /a>                 a href="+code=indices" class="sref">indices /a> =  a href="+code=kcalloc" class="sref">kcalloc /a>( a href="+code=args" class="sref">args /a>[2], sizeof(int),  a href="+code=GFP_KERNEL" class="sref">GFP_KERNEL /a>);> 316 /a>                if ( a href="+code=indices" class="sref">indices /a> ==  a href="+code=NULL" class="sref">NULL /a>)> 317 /a>                        return - a href="+code=ENOMEM" class="sref">ENOMEM /a>;> 318 /a>> 319 /a>                 a href="+code=args" class="sref">args /a>[2] =  a href="+code=get_bridge_ifindices" class="sref">get_bridge_ifindices /a>( a href="+code=net" class="sref">net /a>,  a href="+code=indices" class="sref">indices /a>,  a href="+code=args" class="sref">args /a>[2]);> 320 /a>> 321 /a>                 a href="+code=ret" class="sref">ret /a> =  a href="+code=copy_to_user" class="sref">copy_to_user /a>((void  a href="+code=__user" class="sref">__user /a> *) a href="+code=args" class="sref">args /a>[1],  a href="+code=indices" class="sref">indices /a>,  a href="+code=args" class="sref">args /a>[2]*sizeof(int))> 322 /a>                        ? - a href="+code=EFAULT" class="sref">EFAULT /a> :  a href="+code=args" class="sref">args /a>[2];> 323 /a>> 324 /a>                 a href="+code=kfree" class="sref">kfree /a>( a href="+code=indices" class="sref">indices /a>);> 325 /a>                return  a href="+code=ret" class="sref">ret /a>;> 326 /a>        }> 327 /a>> 328 /a>        case  a href="+code=BRCTL_ADD_BRIDGE" class="sref">BRCTL_ADD_BRIDGE /a>:> 329 /a>        case  a href="+code=BRCTL_DEL_BRIDGE" class="sref">BRCTL_DEL_BRIDGE /a>:> 330 /a>        {> 331 /a>                char  a href="+code=buf" class="sref">buf /a>[ a href="+code=IFNAMSIZ" class="sref">IFNAMSIZ /a>];> 332 /a>> 333 /a>                if (! a href="+code=capable" class="sref">capable /a>( a href="+code=CAP_NET_ADMIN" class="sref">CAP_NET_ADMIN /a>))> 334 /a>                        return - a href="+code=EPERM" class="sref">EPERM /a>;> 335 /a>> 336 /a>                if ( a href="+code=copy_from_user" class="sref">copy_from_user /a>( a href="+code=buf" class="sref">buf /a>, (void  a href="+code=__user" class="sref">__user /a> *) a href="+code=args" class="sref">args /a>[1],  a href="+code=IFNAMSIZ" class="sref">IFNAMSIZ /a>))> 337 /a>                        return - a href="+code=EFAULT" class="sref">EFAULT /a>;> 338 /a>> 339 /a>                 a href="+code=buf" class="sref">buf /a>[ a href="+code=IFNAMSIZ" class="sref">IFNAMSIZ /a>-1] = 0;> 340 /a>> 341 /a>                if ( a href="+code=args" class="sref">args /a>[0] ==  a href="+code=BRCTL_ADD_BRIDGE" class="sref">BRCTL_ADD_BRIDGE /a>)> 342 /a>                        return  a href="+code=br_add_bridge" class="sref">br_add_bridge /a>( a href="+code=net" class="sref">net /a>,  a href="+code=buf" class="sref">buf /a>);> 343 /a>> 344 /a>                return  a href="+code=br_del_bridge" class="sref">br_del_bridge /a>( a href="+code=net" class="sref">net /a>,  a href="+code=buf" class="sref">buf /a>);> 345 /a>        }> 346 /a>        }> 347 /a>> 348 /a>        return - a href="+code=EOPNOTSUPP" class="sref">EOPNOTSUPP /a>;> 349 /a>}> 350 /a>> 351 /a>int  a href="+code=br_ioctl_deviceless_stub" class="sref">br_ioctl_deviceless_stub /a>(struct  a href="+code=net" class="sref">net /a> * a href="+code=net" class="sref">net /a>, unsigned int  a href="+code=cmd" class="sref">cmd /a>, void  a href="+code=__user" class="sref">__user /a> * a href="+code=uarg" class="sref">uarg /a>)> 352 /a>{> 353 /a>        switch ( a href="+code=cmd" class="sref">cmd /a>) {> 354 /a>        case  a href="+code=SIOCGIFBR" class="sref">SIOCGIFBR /a>:> 355 /a>        case  a href="+code=SIOCSIFBR" class="sref">SIOCSIFBR /a>:> 356 /a>                return  a href="+code=old_deviceless" class="sref">old_deviceless /a>( a href="+code=net" class="sref">net /a>,  a href="+code=uarg" class="sref">uarg /a>);> 357 /a>> 358 /a>        case  a href="+code=SIOCBRADDBR" class="sref">SIOCBRADDBR /a>:> 359 /a>        case  a href="+code=SIOCBRDELBR" class="sref">SIOCBRDELBR /a>:> 360 /a>        {> 361 /a>                char  a href="+code=buf" class="sref">buf /a>[ a href="+code=IFNAMSIZ" class="sref">IFNAMSIZ /a>];> 362 /a>> 363 /a>                if (! a href="+code=capable" class="sref">capable /a>( a href="+code=CAP_NET_ADMIN" class="sref">CAP_NET_ADMIN /a>))> 364 /a>                        return - a href="+code=EPERM" class="sref">EPERM /a>;> 365 /a>> 366 /a>                if ( a href="+code=copy_from_user" class="sref">copy_from_user /a>( a href="+code=buf" class="sref">buf /a>,  a href="+code=uarg" class="sref">uarg /a>,  a href="+code=IFNAMSIZ" class="sref">IFNAMSIZ /a>))> 367 /a>                        return - a href="+code=EFAULT" class="sref">EFAULT /a>;> 368 /a>> 369 /a>                 a href="+code=buf" class="sref">buf /a>[ a href="+code=IFNAMSIZ" class="sref">IFNAMSIZ /a>-1] = 0;> 370 /a>                if ( a href="+code=cmd" class="sref">cmd /a> ==  a href="+code=SIOCBRADDBR" class="sref">SIOCBRADDBR /a>)> 371 /a>                        return  a href="+code=br_add_bridge" class="sref">br_add_bridge /a>( a href="+code=net" class="sref">net /a>,  a href="+code=buf" class="sref">buf /a>);> 372 /a>> 373 /a>                return  a href="+code=br_del_bridge" class="sref">br_del_bridge /a>( a href="+code=net" class="sref">net /a>,  a href="+code=buf" class="sref">buf /a>);> 374 /a>        }> 375 /a>        }> 376 /a>        return - a href="+code=EOPNOTSUPP" class="sref">EOPNOTSUPP /a>;> 377 /a>}> 378 /a>> 379 /a>int  a href="+code=br_dev_ioctl" class="sref">br_dev_ioctl /a>(struct  a href="+code=net_device" class="sref">net_device /a> * a href="+code=dev" class="sref">dev /a>, struct  a href="+code=ifreq" class="sref">ifreq /a> * a href="+code=rq" class="sref">rq /a>, int  a href="+code=cmd" class="sref">cmd /a>)> 380 /a>{> 381 /a>        struct  a href="+code=net_bridge" class="sref">net_bridge /a> * a href="+code=br" class="sref">br /a> =  a href="+code=netdev_priv" class="sref">netdev_priv /a>( a href="+code=dev" class="sref">dev /a>);> 382 /a>> 383 /a>        switch( a href="+code=cmd" class="sref">cmd /a>) {> 384 /a>        case  a href="+code=SIOCDEVPRIVATE" class="sref">SIOCDEVPRIVATE /a>:> 385 /a>                return  a href="+code=old_dev_ioctl" class="sref">old_dev_ioctl /a>( a href="+code=dev" class="sref">dev /a>,  a href="+code=rq" class="sref">rq /a>,  a href="+code=cmd" class="sref">cmd /a>);> 386 /a>> 387 /a>        case  a href="+code=SIOCBRADDIF" class="sref">SIOCBRADDIF /a>:> 388 /a>        case  a href="+code=SIOCBRDELIF" class="sref">SIOCBRDELIF /a>:> 389 /a>                return  a href="+code=add_del_if" class="sref">add_del_if /a>( a href="+code=br" class="sref">br /a>,  a href="+code=rq" class="sref">rq /a>-> a href="+code=ifr_ifindex" class="sref">ifr_ifindex /a>,  a href="+code=cmd" class="sref">cmd /a> ==  a href="+code=SIOCBRADDIF" class="sref">SIOCBRADDIF /a>);> 390 /a>> 391 /a>        }> 392 /a>> 393 /a>         a href="+code=br_debug" class="sref">br_debug /a>( a href="+code=br" class="sref">br /a>,  span class="string">"Bridge does not support ioctl 0x%x\n",  a href="+code=cmd" class="sref">cmd /a>);> 394 /a>        return - a href="+code=EOPNOTSUPP" class="sref">EOPNOTSUPP /a>;> 395 /a>}> 396 /a>
lxr.linux.no kindly hosted by a href="http://www.redpill-linpro.no">Redpill Linpro AS /a>, provider of Linux consulting and operations services since 1995.