This provides support for something like:
ip=10.10.10.42::10.10.10.1:255.255.255.0:grml:eth0:off vlan=301:eth0
to use VID 301 for device eth0.
The implementation tries to be close to what dracut provides with
its vlan boot option implementation, see
http://thread.gmane.org/gmane.linux.kernel.initramfs/2685
Though we aren't 100% identical because we only use <vid>
(e.g.: 3) instead of dract's <vlanname> (e.g.: VLAN_PLUS_VID
(vlan0003), VLAN_PLUS_VID_NO_PAD (vlan3), DEV_PLUS_VID (eth0.0003),
DEV_PLUS_VID_NO_PAD (eth0.3)) options but that might be an option
once we can bring vlan support into initramfs-tools itself.
The vlan-raw-device configuration option in
/etc/network/interfaces isn't really needed technically, but we
want to make the presence and usage of VLANs more obvious for
its users.
Development sponsored by Sipwise Gmbh
UNIONTYPE="${_PARAMETER#union=}"
export UNIONTYPE
;;
+
+ vlan=*)
+ VLANS="${VLANS} ${_PARAMETER#vlan=}"
+ export VLANS
+ ;;
esac
done
method="dhcp"
fi
- cat >> $IFFILE << EOF
+ if [ -n "$VLANS" ] ; then
+ modprobe 8021q
+
+ # vlan=<vid>:<phydevice>
+ for line in $(echo $VLANS | sed 's/ /\n'/) ; do
+ vlandev=${line#*:}
+ vlanid=${line%:*}
+
+ if [ -n "$vlandev" ] && [ -n "$vlanid" ] ; then
+ case "$vlandev" in
+ "$interface")
+ vlan_raw_dev=$interface
+ interface="${vlandev}.${vlanid}"
+ ;;
+ esac
+ fi
+ done
+ fi
+
+ if [ -n "$vlan_raw_dev" ] ; then
+ cat >> $IFFILE << EOF
+auto ${interface}
+iface ${interface} inet ${method}
+ vlan-raw-device $vlan_raw_dev
+EOF
+ else
+ cat >> $IFFILE << EOF
allow-hotplug ${interface}
iface ${interface} inet ${method}
EOF
+ fi
+
+ unset vlandev vlanid vlan_raw_dev # unset variables to have clean state for next device
# DNS for resolvconf and /etc/resolv.conf
if [ -e "${netconfig}" ]; then