On Fri, Jul 31, 2020 at 06:28:32AM +0200, Klemens Nanni wrote:
> ifconfig(8) detects switch(4) through its unique SIOCSWSDPID ioctl and
> further does another switch specific ioctl for the default output
> regardless of configuration and/or members:
> 
>       SIOCSWSDPID struct ifbrparam
>               Set the datapath_id in the OpenFlow protocol of the switch named
>               in ifbrp_name to the value in the ifbrpu_datapath field.
>       
>       SIOCSWGMAXFLOW struct ifbrparam
>               Retrieve the maximum number of flows in the OpenFlow protocol of
>               the switch named in ifbrp_name into the ifbrp_maxflow field.
> 
> This is how it should look like:
> 
>       # ifconfig switch0 create
>       # ifconfig switch0
>               switch0: flags=0<>
>               index 29 llprio 3
>               groups: switch
>               datapath 0x5bea2b5b8e2456cf maxflow 10000 maxgroup 1000
> 
> But using ifconfig as unprivileged user makes it fail switch(4)
> interfaces as such and thus interprets them as bridge(4) instead:
> 
>       $ ifconfig switch0
>               switch0: flags=0<>
>               index 29 llprio 3
>               groups: switch
>               priority 32768 hellotime 2 fwddelay 15 maxage 20 holdcnt 6 
> proto rstp
>               designated: id 00:00:00:00:00:00 priority 0
> 
> This is because the above mentioned ioctls are listed together with all
> other bridge and switch related ioctls that set or write things.
> Getting datapath_id and maxflow values however is read-only and crucial
> for ifconfig as demonstrated above, so I'd like to move them out of the
> root check to fix ifconfig.
> 
> Feedback? OK?
Ping.

Last diff after dlg's feedback reattached.


Index: if.c
===================================================================
RCS file: /cvs/src/sys/net/if.c,v
retrieving revision 1.618
diff -u -p -r1.618 if.c
--- if.c        5 Aug 2020 11:07:34 -0000       1.618
+++ if.c        5 Aug 2020 22:31:44 -0000
@@ -2160,9 +2160,7 @@ ifioctl(struct socket *so, u_long cmd, c
        case SIOCBRDGSIFCOST:
        case SIOCBRDGSTXHC:
        case SIOCBRDGSPROTO:
-       case SIOCSWGDPID:
        case SIOCSWSPORTNO:
-       case SIOCSWGMAXFLOW:
 #endif
                if ((error = suser(p)) != 0)
                        break;

Reply via email to