From 805c2188a4e6faea1c355e52a757954d5d2e6192 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Thu, 13 Mar 2014 16:02:51 +0100 Subject: [PATCH] VLAN support via boot option "vlan=:" 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 (e.g.: 3) instead of dract's (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 --- debian/patches/29_support_dns_in_initramfs.patch | 15 ++++--- debian/patches/41_vlan_support.patch | 57 ++++++++++++++++++++++++ debian/patches/series | 1 + 3 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 debian/patches/41_vlan_support.patch diff --git a/debian/patches/29_support_dns_in_initramfs.patch b/debian/patches/29_support_dns_in_initramfs.patch index 501c607..f481eea 100644 --- a/debian/patches/29_support_dns_in_initramfs.patch +++ b/debian/patches/29_support_dns_in_initramfs.patch @@ -6,11 +6,9 @@ Date: Fri Mar 25 23:02:38 2011 +0100 Thanks to Ulrich Dangel for discovering this. [Closes: issue848] -Index: live-boot-grml/backend/initramfs-tools/live.hook -=================================================================== ---- live-boot-grml.orig/backend/initramfs-tools/live.hook 2014-03-08 13:36:37.835196873 +0100 -+++ live-boot-grml/backend/initramfs-tools/live.hook 2014-03-08 13:36:37.835196873 +0100 -@@ -228,23 +228,19 @@ +--- a/backend/initramfs-tools/live.hook ++++ b/backend/initramfs-tools/live.hook +@@ -228,23 +228,26 @@ # Some experimental stuff @@ -46,5 +44,12 @@ Index: live-boot-grml/backend/initramfs-tools/live.hook +# might be needed if /etc/hosts is used +#mkdir -p "${DESTDIR}/etc" +#cp -p /etc/nsswitch.conf "${DESTDIR}/etc" ++ ++# vlan support ++if [ -x /sbin/vconfig ] ++then ++ copy_exec /sbin/vconfig ++ manual_add_modules 8021q ++fi [ "${QUIET}" ] || echo . diff --git a/debian/patches/41_vlan_support.patch b/debian/patches/41_vlan_support.patch new file mode 100644 index 0000000..9551b2c --- /dev/null +++ b/debian/patches/41_vlan_support.patch @@ -0,0 +1,57 @@ +--- a/components/9990-cmdline-old ++++ b/components/9990-cmdline-old +@@ -266,6 +266,11 @@ + UNIONTYPE="${_PARAMETER#union=}" + export UNIONTYPE + ;; ++ ++ vlan=*) ++ VLANS="${VLANS} ${_PARAMETER#vlan=}" ++ export VLANS ++ ;; + esac + done + +--- a/components/9990-grml-networking.sh ++++ b/components/9990-grml-networking.sh +@@ -67,10 +67,39 @@ + method="dhcp" + fi + +- cat >> $IFFILE << EOF ++ if [ -n "$VLANS" ] ; then ++ modprobe 8021q ++ ++ # vlan=: ++ 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 diff --git a/debian/patches/series b/debian/patches/series index 6bfd3cb..dce736d 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -16,3 +16,4 @@ grml-specific/package_rename.patch 40_support_multiple_hooks.patch reverts/drop_nameserver_from_ip_option.patch reverts/restore_support_for_old_persistence.patch +41_vlan_support.patch -- 2.1.4