xref: /freebsd/share/man/man4/vxlan.4 (revision dece5b05f577fc4c6b89af7ad48dfbdf7cc4945c)
1.\"
2.\" SPDX-License-Identifier: BSD-2-Clause
3.\"
4.\" Copyright (c) 2014 Bryan Venteicher
5.\" All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.Dd March 30, 2021
29.Dt VXLAN 4
30.Os
31.Sh NAME
32.Nm vxlan
33.Nd Virtual eXtensible LAN interface
34.Sh SYNOPSIS
35.Cd device vxlan
36.Pp
37In
38.Xr loader.conf 5 :
39.Cd if_vxlan_load="YES"
40.Sh DESCRIPTION
41The
42.Nm
43driver creates a virtual tunnel endpoint in a
44.Nm
45segment.
46A
47.Nm
48segment is a virtual Layer 2 (Ethernet) network that is overlaid
49in a Layer 3 (IP/UDP) network.
50.Nm
51is analogous to
52.Xr vlan 4
53but is designed to be better suited for large, multiple tenant
54data center environments.
55.Pp
56Each
57.Nm
58interface is created at runtime using interface cloning.
59This is most easily done with the
60.Xr ifconfig 8
61.Cm create
62command or using the
63.Va cloned_interfaces
64variable in
65.Xr rc.conf 5 .
66The interface may be removed with the
67.Xr ifconfig 8
68.Cm destroy
69command.
70.Pp
71The
72.Nm
73driver creates a pseudo Ethernet network interface
74that supports the usual network
75.Xr ioctl 2 Ns s
76and thus can be used with
77.Xr ifconfig 8
78like any other Ethernet interface.
79The
80.Nm
81interface encapsulates the Ethernet frame
82by prepending IP/UDP and
83.Nm
84headers.
85Thus, the encapsulated (inner) frame is able to be transmitted
86over a routed, Layer 3 network to the remote host.
87.Pp
88The
89.Nm
90interface may be configured in either unicast or multicast mode.
91When in unicast mode,
92the interface creates a tunnel to a single remote host,
93and all traffic is transmitted to that host.
94When in multicast mode,
95the interface joins an IP multicast group,
96and receives packets sent to the group address,
97and transmits packets to either the multicast group address,
98or directly to the remote host if there is an appropriate
99forwarding table entry.
100.Pp
101When the
102.Nm
103interface is brought up, a
104.Xr udp 4
105.Xr socket 9
106is created based on the configuration,
107such as the local address for unicast mode or
108the group address for multicast mode,
109and the listening (local) port number.
110Since multiple
111.Nm
112interfaces may be created that either
113use the same local address
114or join the same group address,
115and use the same port,
116the driver may share a socket among multiple interfaces.
117However, each interface within a socket must belong to
118a unique
119.Nm
120segment.
121The analogous
122.Xr vlan 4
123configuration would be a physical interface configured as
124the parent device for multiple VLAN interfaces, each with
125a unique VLAN tag.
126Each
127.Nm
128segment is identified by a 24-bit value in the
129.Nm
130header called the
131.Dq VXLAN Network Identifier ,
132or VNI.
133.Pp
134When configured with the
135.Xr ifconfig 8
136.Cm vxlanlearn
137parameter, the interface dynamically creates forwarding table entries
138from received packets.
139An entry in the forwarding table maps the inner source MAC address
140to the outer remote IP address.
141During transmit, the interface attempts to lookup an entry for
142the encapsulated destination MAC address.
143If an entry is found, the IP address in the entry is used to directly
144transmit the encapsulated frame to the destination.
145Otherwise, when configured in multicast mode,
146the interface must flood the frame to all hosts in the group.
147The maximum number of entries in the table is configurable with the
148.Xr ifconfig 8
149.Cm vxlanmaxaddr
150command.
151Stale entries in the table are periodically pruned.
152The timeout is configurable with the
153.Xr ifconfig 8
154.Cm vxlantimeout
155command.
156The table may be viewed with the
157.Xr sysctl 8
158.Cm net.link.vxlan.N.ftable.dump
159command.
160.Sh MTU
161Since the
162.Nm
163interface encapsulates the Ethernet frame with an IP, UDP, and
164.Nm
165header, the resulting frame may be larger than the MTU of the
166physical network.
167The
168.Nm
169specification recommends the physical network MTU be configured
170to use jumbo frames to accommodate the encapsulated frame size.
171.Pp
172By default, the
173.Nm
174driver sets its MTU to usual ethernet MTU of 1500 bytes, reduced by
175the size of vxlan headers prepended to the encapsulated packets.
176.Pp
177Alternatively, the
178.Xr ifconfig 8
179.Cm mtu
180command may be used to set the fixed MTU size on the
181.Nm
182interface to allow the encapsulated frame to fit in the
183current MTU of the physical network.
184If the
185.Cm mtu
186command was used, system no longer adjust the
187.Nm
188interface MTU on routing or address changes.
189.Sh HARDWARE
190The
191.Nm
192driver supports hardware checksum offload (receive and transmit) and TSO on the
193encapsulated traffic over physical interfaces that support these features.
194The
195.Nm
196interface examines the
197.Cm vxlandev
198interface, if one is specified, or the interface hosting the
199.Cm vxlanlocal
200address, and configures its capabilities based on the hardware offload
201capabilities of that physical interface.
202If multiple physical interfaces will transmit or receive traffic for the
203.Nm
204then they all must have the same hardware capabilities.
205The transmit routine of a
206.Nm
207interface may fail with
208.Er ENXIO
209if an outbound physical interface does not support
210an offload that the
211.Nm
212interface is requesting.
213This can happen if there are multiple physical interfaces involved, with
214different hardware capabilities, or an interface capability was disabled after
215the
216.Nm
217interface had already started.
218.Pp
219At present, these devices are capable of generating checksums and performing TSO
220on the inner frames in hardware:
221.Xr cxgbe 4 .
222.Sh EXAMPLES
223Create a
224.Nm
225interface in unicast mode
226with the
227.Cm vxlanlocal
228tunnel address of 192.168.100.1,
229and the
230.Cm vxlanremote
231tunnel address of 192.168.100.2.
232.Bd -literal -offset indent
233ifconfig vxlan create vxlanid 108 vxlanlocal 192.168.100.1 vxlanremote 192.168.100.2
234.Ed
235.Pp
236Create a
237.Nm
238interface in multicast mode,
239with the
240.Cm local
241address of 192.168.10.95,
242and the
243.Cm group
244address of 224.0.2.6.
245The em0 interface will be used to transmit multicast packets.
246.Bd -literal -offset indent
247ifconfig vxlan create vxlanid 42 vxlanlocal 192.168.10.95 vxlangroup 224.0.2.6 vxlandev em0
248.Ed
249.Pp
250Once created, the
251.Nm
252interface can be configured with
253.Xr ifconfig 8 .
254.Pp
255The following when placed in the file
256.Pa /etc/rc.conf
257will cause a vxlan interface called
258.Dq Li vxlan0
259to be created, and will configure the interface in unicast mode.
260.Bd -literal -offset indent
261cloned_interfaces="vxlan0"
262create_args_vxlan0="vxlanid 108 vxlanlocal 192.168.100.1 vxlanremote 192.168.100.2"
263.Ed
264.Sh SEE ALSO
265.Xr inet 4 ,
266.Xr inet6 4 ,
267.Xr vlan 4 ,
268.Xr rc.conf 5 ,
269.Xr ifconfig 8 ,
270.Xr sysctl 8
271.Rs
272.%A "M. Mahalingam"
273.%A "et al"
274.%T "Virtual eXtensible Local Area Network (VXLAN): A Framework for Overlaying Virtualized Layer 2 Networks over Layer 3 Networks"
275.%D August 2014
276.%O "RFC 7348"
277.Re
278.Sh AUTHORS
279.An -nosplit
280The
281.Nm
282driver was written by
283.An Bryan Venteicher Aq Mt bryanv@FreeBSD.org .
284Support for stateless hardware offloads was added by
285.An Navdeep Parhar Aq Mt np@FreeBSD.org
286in
287.Fx 13.0 .
288