.\" $OpenBSD: switch.4,v 1.5 2016/10/01 18:04:25 jmc Exp $ .\" .\" Copyright (c) 2016 YASUOKA Masahiko .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above .\" copyright notice and this permission notice appear in all copies. .\" .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" .Dd $Mdocdate: October 1 2016 $ .Dt SWITCH 4 .Os .Sh NAME .Nm switch .Nd network switch pseudo device .Sh SYNOPSIS .Cd "pseudo-device switch" .Pp .In sys/types.h .In net/if.h .In netinet/in.h .In netinet/if_ether.h .In net/if_bridge.h .Sh DESCRIPTION The .Nm driver provides a network interface pseudo-device. The interface is the forwarding part of a network switch and it works along with a controller, usually .Xr switchd 8 or .Xr switchctl 8 , through the device .Pa /dev/switchN . The .Nm device and the controller communicate using the OpenFlow 1.3 protocol. .Pp A .Nm interface is created using .Ic ifconfig switch Ns Ar N Ic create or by opening the character device .Pa /dev/switchN . .Pp .Pa /dev/switchN is the OpenFlow channel of the interface .Pa switchN . It is used for exchanging OpenFlow messages. The device guarantees .Xr read 2 returns a complete OpenFlow message - it never returns a partial message. Any programs using .Pa /dev/switchN must .Xr write 2 a complete OpenFlow message. .Sh IOCTLS A .Nm interface responds to all of the .Xr ioctl 2 calls specific to other interfaces listed in .Xr netintro 4 . .Pp The following .Xr ioctl 2 calls and their structures are commonly used by .Nm and .Xr bridge 4 : .Pp .Bl -bullet -offset indent -compact .It .Dv SIOCBRDGIFS .It .Dv SIOCBRDGADD .It .Dv SIOCBRDGDEL .It .Dv SIOCBRDGGIFFLGS .El .Pp The following .Xr ioctl 2 calls are used only by the .Nm interface, as defined in .In sys/sockio.h : .Bl -tag -width Ds .It Dv SIOCBRDGADDL Fa "struct ifbreq *" Add the interface named in .Va ifbr_ifsname to the switch named in .Va ifbr_name as a local port which connects the local system's network stacks. Only one .Xr vether 4 interface can be added as a local port. .It Dv SIOCSWGDPID Retrieve the datapath_id in the OpenFlow protocol of the switch named in .Va ifbrp_name into the .Va ifbrpu_datapath field. .It Dv SIOCSWSDPID Fa "struct ifbrparam" Set the datapath_id in the OpenFlow protocol of the switch named in .Va ifbrp_name to the value in the .Va ifbrpu_datapath field. .It Dv SIOCSWGFLOWMAX Fa "struct ifbrparam" Retrieve the maximum number of flows in the OpenFlow protocol of the switch named in .Va ifbrp_name into the .Va ifbrp_maxflow field. .It Dv SIOCSWSFLOWMAX Fa "struct ifbrparam" Set the maximum number of flows in the OpenFlow protocol of the switch named in .Va ifbrp_name to the value in the .Va ifbrpu_maxflow field. .It Dv SIOCSWGMAXGROUP Fa "struct ifbrparam" Retrieve the maximum number of groups in the OpenFlow protocol of the switch named in .Va ifbrp_name into the .Va ifbrpu_maxgroup field. .It Dv SIOCSWSMAXGROUP Fa "struct ifbrparam" Set the maximum number of groups in the OpenFlow protocol of the switch named in .Va ifbrp_name to the value in the .Va ifbrpu_maxgroup field. .It Dv SIOCSWSPORTNO Fa "struct ifbreq" Set the port_no in the OpenFlow protocol of the port named in .Va ifbr_ifsname of the switch named in .Va ifbr_name to the .Va ifbr_portno field. .El .Sh FILES .Bl -tag -width /dev/switch* -compact .It Pa /dev/switch* .El .Sh ERRORS If open fails, .Xr errno 2 may be set to one of: .Bl -tag -width Er .It Bq Er ENXIO Could not create the interface. .It Bq Er EBUSY The device was already opened. .It Bq Er ENOBUF Out of memory. .El .Sh SEE ALSO .Xr bridge 4 , .Xr inet 4 , .Xr inet6 4 , .Xr vether 4 , .Xr hostname.if 5 , .Xr ifconfig 8 , .Xr netstart 8 , .Xr switchctl 8 , .Xr switchd 8 .Sh STANDARDS .Rs .%A Open Networking Foundation (ONF) .%D March 26, 2015 .%R Version 1.3.5 (Protocol version 0x04) .%T OpenFlow Switch Specification .Re .Sh HISTORY The .Nm driver first appeared in .Ox 6.1 . .Sh AUTHORS The .Nm driver was written by .An Kazuya Goda Aq Mt goda@openbsd.org .