NAME
switch
—
network switch pseudo device
SYNOPSIS
pseudo-device switch
#include <sys/types.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <net/if_bridge.h>
DESCRIPTION
The switch
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
switchd(8) or
switchctl(8), through the device
/dev/switchN. The switch
device and the controller communicate using the OpenFlow 1.3 protocol.
A switch
interface is created using
ifconfig switch
N
create
or by opening the character device
/dev/switchN.
/dev/switchN is the OpenFlow channel of the interface switchN. It is used for exchanging OpenFlow messages. The device behaves like a stream, which means that a read(2) may return one or more OpenFlow messages depending on the number of bytes requested. It may also read the message partially (e.g. read(2) the OpenFlow message header and then the complete message). The same applies to write(2) calls, so it may send one or more OpenFlow messages with a single write or use more than one write(2) calls to send a single message.
IOCTLS
A switch
interface responds to all of the
ioctl(2) calls specific to other interfaces listed in
netintro(4).
The following
ioctl(2) calls and their structures are commonly used by
switch
and
bridge(4):
The following
ioctl(2) calls are used only by the switch
interface, as defined in
<sys/sockio.h>
:
SIOCBRDGADDL
struct ifbreq *- Add the interface named in ifbr_ifsname to the switch named in ifbr_name as a local port which connects the local system's network stacks. Only one vether(4) interface can be added as a local port.
SIOCSWGDPID
- Retrieve the datapath_id in the OpenFlow protocol of the switch named in ifbrp_name into the ifbrpu_datapath field.
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.
SIOCSWSMAXFLOW
struct ifbrparam- Set the maximum number of flows in the OpenFlow protocol of the switch named in ifbrp_name to the value in the ifbrpu_maxflow field.
SIOCSWGMAXGROUP
struct ifbrparam- Retrieve the maximum number of groups in the OpenFlow protocol of the switch named in ifbrp_name into the ifbrpu_maxgroup field.
SIOCSWSMAXGROUP
struct ifbrparam- Set the maximum number of groups in the OpenFlow protocol of the switch named in ifbrp_name to the value in the ifbrpu_maxgroup field.
SIOCSWSPORTNO
struct ifbreq- Set the port_no in the OpenFlow protocol of the port named in ifbr_ifsname of the switch named in ifbr_name to the ifbr_portno field.
FILES
- /dev/switch*
ERRORS
If open fails, errno(2) may be set to one of:
- [
ENXIO
] - Could not create the interface.
- [
EBUSY
] - The device was already opened.
- [
ENOBUF
] - Out of memory.
SEE ALSO
bridge(4), inet(4), inet6(4), vether(4), hostname.if(5), ifconfig(8), netstart(8), switchctl(8), switchd(8)
STANDARDS
Open Networking Foundation (ONF), OpenFlow Switch Specification, Version 1.3.5 (Protocol version 0x04), March 26, 2015.
HISTORY
The switch
driver first appeared in
OpenBSD 6.1.
AUTHORS
The switch
driver was written by
Kazuya Goda
<goda@openbsd.org>.