1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
.\" $OpenBSD: switch.4,v 1.8 2017/10/24 09:36:13 jsg Exp $
.\"
.\" Copyright (c) 2016 YASUOKA Masahiko <yasuoka@openbsd.org>
.\"
.\" 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 24 2017 $
.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 behaves like a stream, which means that a
.Xr 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.\&
.Xr read 2
the OpenFlow message header and then the complete message).
The same applies to
.Xr write 2
calls, so it may send one or more OpenFlow messages with a single write
or use more than one
.Xr write 2
calls to send a single 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 SIOCSWGMAXFLOW 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 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 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 .
|