>Synopsis: vxlan_set_parent() (sys/net/if_vxlan.c) rejects a requested
parent only if it does not exist, is not IFF_MULTICAST, is the
parent already set, or the vxlan is running. A vxlan(4) is
itself
a multicast-capable Ethernet interface, so "ifconfig vxlanN
parent
vxlanN" is accepted, and so is the second half of a two-vxlan
cycle ("vxlanA parent vxlanB; vxlanB parent vxlanA"). The
vxlan is
left using itself (or its peer in the loop) as its multicast
underlay; it still comes up, but every frame it encapsulates
fails
to transmit. No crash: vxlan has a fixed media and does not
forward SIOCGIFMEDIA to its parent, so the media recursion that
makes the same mistake fatal in vlan(4) and bpe(4) (reported
separately) does not occur here. vxlan(4) is a separate driver.
>Category: kernel
>Severity: non-critical
>Priority: low
>Class: sw-bug
>Release: OpenBSD 8.0-current (source as of 2026-11-03, git d5b06e73;
also present on master afb08c4d5)
>Environment:
System : OpenBSD 8.0-current
Details : OpenBSD 8.0-current (GENERIC.MP as shipped: DIAGNOSTIC,
POOL_DEBUG)
Architecture: OpenBSD.amd64
Machine : amd64 (QEMU/KVM guest, 2 vcpu)
Source : sys/net/if_vxlan.c rev 1.107, openbsd/src as of
2026-11-03, git d5b06e73
>Description:
vxlan_set_parent() (sys/net/if_vxlan.c):
ifp0 = if_unit(p->ifp_parent);
if (ifp0 == NULL)
return (ENXIO);
if (!ISSET(ifp0->if_flags, IFF_MULTICAST)) {
error = ENXIO;
goto put;
}
if (sc->sc_if_index0 == ifp0->if_index)
goto put; /* only catches re-setting the
SAME parent, not self on first
configuration (sc_if_index0 == 0)
*/
if (ISSET(ifp->if_flags, IFF_RUNNING)) {
error = EBUSY;
goto put;
}
...
sc->sc_if_index0 = ifp0->if_index; /* commit */
A vxlan is IFF_MULTICAST, so the vxlan itself, or another vxlan whose
parent is this one, passes every check and is committed. The parent is
then used as the multicast egress interface (vxlan_send_ipv4/ipv6:
imo_ifidx = sc->sc_if_index0) and for the group join in vxlan_up().
Observed on the unpatched kernel: the self- or loop-parented vxlan is
accepted silently ("ifconfig vxlan200" shows "parent vxlan200"),
comes up (RUNNING) in learning mode with a group and a local tunnel
source, and every frame it encapsulates fails at output (Opkts and
Ofail grow together: +3/+3 for two pings, where a vxlan with a real
vether parent gives +2/0 for the same steps); no mbuf growth, no
amplification, no crash in 20 s of observation. The configuration is
meaningless and should be refused at SIOCSIFPARENT time.
>How-To-Repeat:
As root (vxlan200, vxlan201 unused):
ifconfig vxlan200 create
ifconfig vxlan200 parent vxlan200 # should fail, succeeds
ifconfig vxlan200 | grep encap
encap: vnetid none parent vxlan200 txprio 0 rxprio outer
Two-vxlan loop:
ifconfig vxlan201 create
ifconfig vxlan200 parent vxlan201
ifconfig vxlan201 parent vxlan200 # closes the loop, succeeds
>Fix:
Reject a parent that is the vxlan itself or that leads back to it
along the vxlan parent chain (the same loop check proposed for
vlan(4) and bpe(4)). The walk is bounded in case a loop already
exists. A vxlan on top of another vxlan without a loop is still
accepted.
--- sys/net/if_vxlan.c
+++ sys/net/if_vxlan.c
@@ -181,6 +181,7 @@
static int vxlan_del_vnetid(struct vxlan_softc *);
static int vxlan_set_parent(struct vxlan_softc *,
const struct if_parent *);
+static int vxlan_parent_loop(struct ifnet *, struct ifnet *);
static int vxlan_get_parent(struct vxlan_softc *, struct if_parent *);
static int vxlan_del_parent(struct vxlan_softc *);
@@ -1590,6 +1591,12 @@
if (sc->sc_if_index0 == ifp0->if_index)
goto put;
+ if (vxlan_parent_loop(ifp, ifp0)) {
+ /* a vxlan cannot be (indirectly) its own parent */
+ error = EINVAL;
+ goto put;
+ }
+
if (ISSET(ifp->if_flags, IFF_RUNNING)) {
error = EBUSY;
goto put;
@@ -1606,6 +1613,35 @@
return (error);
}
+/*
+ * Return non-zero if making ifp0 the parent of ifp would create a loop,
+ * i.e. ifp is ifp0 or is reachable by following the vxlan parent chain
+ * from ifp0. The walk is bounded in case a loop already exists.
+ */
+static int
+vxlan_parent_loop(struct ifnet *ifp, struct ifnet *ifp0)
+{
+ struct ifnet *p, *next;
+ unsigned int depth = 0;
+ int loop = 0;
+
+ p = if_ref(ifp0);
+ while (p != NULL) {
+ if (p == ifp || ++depth > 64) {
+ loop = 1;
+ break;
+ }
+ if (p->if_ioctl != vxlan_ioctl)
+ break;
+ next = if_get(((struct vxlan_softc
*)p->if_softc)->sc_if_index0);
+ if_put(p);
+ p = next;
+ }
+ if_put(p);
+
+ return (loop);
+}
+
static int
vxlan_get_parent(struct vxlan_softc *sc, struct if_parent *p)
{
>Verification:
Diff applied exactly as shown with patch -p0 to sys/net/if_vxlan.c
r1.107 of a tree exported with git archive from openbsd/src d5b06e73
(2026-11-03), no fuzz or
offset; kernel GENERIC.MP, amd64, built with -Werror, no warnings.
Unpatched = the same tree without the diff, same config (the patched
kernel is an incremental rebuild of that tree; the diff was reverted
afterwards and the source md5 checked). The diff also applies to
master afb08c4d5 (offset -1 line, no fuzz). VM with 2 vcpu; every
check below ran on a freshly booted kernel.
Unpatched (3 fresh boots, 8 runs):
"ifconfig vxlan200 parent vxlan200" accepted 8/8, no diagnostic,
"parent vxlan200" shown;
two-vxlan loop ("vxlan200 parent vxlan201; vxlan201 parent
vxlan200") accepted 8/8;
self-parent and loop, brought up (learning mode, group, local
tunnel source on a vether): RUNNING, every encapsulated frame
fails at output, no mbuf growth, no crash (1 run each).
Patched (3 fresh boots, 5 runs):
self-parent refused 5/5 with "SIOCSIFPARENT: Invalid argument",
the vxlan keeps "parent none";
the loop-closing "vxlan201 parent vxlan200" refused 5/5 with the
same error; "vxlan200 parent vxlan201" (vxlan on vxlan, no loop)
is still accepted;
nvgre(4) on the same kernel still accepts its own self-parent 1/1
(the diff touches vxlan only).
Normal use, patched 5/5 and unpatched 5/5, identical: a real
multicast underlay = pair(4) link between rdomain 200 (pair290,
192.0.2.1/24) and rdomain 201 (pair291, 192.0.2.2/24); vxlan200
(tunneldomain 200, tunnel 192.0.2.1 239.0.0.11, parent pair290,
vnetid 111, rdomain 202, 198.51.100.1/24) and vxlan201 (tunneldomain
201, tunnel 192.0.2.2 239.0.0.11, parent pair291, vnetid 111,
rdomain 203, 198.51.100.2/24): both accept the parent and come up
RUNNING, "ping -V 202 198.51.100.2" through the tunnel is answered,
both destroy cleanly.