#!/bin/sh
# DF-3395: SIOCSIFNAME fires ifnet_detach_event (sys/net/if.c:2206);
# vlan_ifdetach() treats it as parent destruction and unconfigures every
# vlan(4) sitting on the renamed parent.  Renaming an interface back does
# NOT restore the vlans: the L2 config (parent+tag) is permanently wiped.
#
# Run as root.  Guest: DragonFly 6.5-DEVELOPMENT #0 (X86_64_GENERIC).
set -e
echo "=== setup: vlan100 on vtnet0 ==="
ifconfig vlan0 destroy 2>/dev/null || true
ifconfig tap0 destroy 2>/dev/null || true
ifconfig vlan0 create
ifconfig vlan0 vlan 100 vlandev vtnet0
ifconfig vlan0 | grep -E 'vlan:|status|mtu'
echo
echo "=== rename the PARENT (SIOCSIFNAME) ==="
ifconfig vtnet0 name vtnet0r
ifconfig vlan0 | grep -E 'vlan:|status|mtu'
echo
echo "=== rename back ==="
ifconfig vtnet0r name vtnet0
ifconfig vlan0 | grep -E 'vlan:|status|mtu'
echo
echo "=== cleanup ==="
ifconfig vlan0 destroy
