From mboxrd@z Thu Jan 1 00:00:00 1970 From: Warren Togami Subject: RFC Bridging plan Date: Thu, 16 Jul 2009 00:43:24 -0400 Message-ID: <4A5EAFEC.4080705@redhat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------090000090207030802000303" Return-path: Sender: initramfs-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: To: initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org This is a multi-part message in MIME format. --------------090000090207030802000303 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Attached is the parser of this bridging plan. Bridge details if parsed from cmdline are written to /tmp/bridge.info for later use by network scripts with the following behavior. Any comments? SYNTAX ====== bridge=: If bridge without parameters, assume bridge=br0:eth0 BASIC IDEA ========== * When would be configured by network scripts, instead create a bridge named then add to that bridge. * automatically inherits the MAC address of . BOOTIF thus should be optionally workable. * Then $netif becomes instead of and all existing scripts process netroot mount via this new $netif instead of . * Try only the one specified interface, do not try others. (I suppose trying others in the "bridge root=dhcp" case would be possible, but let's get the basics working first.) * write-ifcfg.sh writes out both ifcfg- and ifcfg- files for later use by NetworkManager. BOOT EXAMPLE ============ ifconfig eth0 up brctl addbr br0 brctl setfd br0 0 brctl addif br0 eth0 dhclient br0 ifconfig br0 mount -t nfs server:/path /sysroot switch_root /sysroot ifcfg-br0 example ================= # Generated by dracut initrd DEVICE=br0 TYPE=Bridge ONBOOT=yes BOOTPROTO=dhcp STP=off USERCTL=no ifcfg-eth0 example ================== # Generated by dracut initrd TYPE=Ethernet DEVICE=eth0 HWADDR=52:54:00:12:34:56 ONBOOT=yes BRIDGE=br0 USERCTL=no Warren Togami wtogami-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org --------------090000090207030802000303 Content-Type: text/x-patch; name="0001-Bridge-parsing-example.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Bridge-parsing-example.patch" >From 329b0b77e7d63ebe2092111de31f471fd22a5b06 Mon Sep 17 00:00:00 2001 From: Warren Togami Date: Thu, 16 Jul 2009 00:09:07 -0400 Subject: [PATCH] Bridge parsing example --- modules.d/40network/check | 2 +- modules.d/40network/install | 3 +- modules.d/40network/parse-bridge.sh | 55 +++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 2 deletions(-) create mode 100755 modules.d/40network/parse-bridge.sh diff --git a/modules.d/40network/check b/modules.d/40network/check index 79a6d97..3d45030 100755 --- a/modules.d/40network/check +++ b/modules.d/40network/check @@ -1,4 +1,4 @@ #!/bin/sh -which ip dhclient hostname >/dev/null 2>&1 || exit 1 +which ip dhclient hostname brctl >/dev/null 2>&1 || exit 1 exit 255 diff --git a/modules.d/40network/install b/modules.d/40network/install index 0b76cbd..216d203 100755 --- a/modules.d/40network/install +++ b/modules.d/40network/install @@ -1,5 +1,5 @@ #!/bin/bash -dracut_install ip dhclient hostname +dracut_install ip dhclient hostname brctl # Include wired net drivers, excluding wireless for modname in $(find "/lib/modules/$kernel/kernel/drivers" -name '*.ko'); do if nm -uPA $modname | grep -q eth_type_trans; then @@ -18,6 +18,7 @@ instmods ecb arc4 inst_hook pre-udev 60 "$moddir/net-genrules.sh" inst_hook cmdline 91 "$moddir/dhcp-root.sh" inst_hook cmdline 99 "$moddir/parse-ip-opts.sh" +inst_hook cmdline 98 "$moddir/parse-bridge.sh" inst_hook pre-pivot 10 "$moddir/kill-dhclient.sh" # TODO ifcfg config style is redhat specific, this should probably diff --git a/modules.d/40network/parse-bridge.sh b/modules.d/40network/parse-bridge.sh new file mode 100755 index 0000000..adc28bb --- /dev/null +++ b/modules.d/40network/parse-bridge.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# +# Format: +# bridge=: +# +# bridge without parameters assumes bridge=br0:eth0 +# + +# return if bridge already parsed +[ -n "$bridgename" ] && return + +# Check if bridge parameter is valid +if getarg ip= >/dev/null ; then + if [ -z "$netroot" ] ; then + die "No netboot configured, bridge is invalid" + fi +fi + +parsebridge() { + local v=${1}: + set -- + while [ -n "$v" ]; do + set -- "$@" "${v%%:*}" + v=${v#*:} + done + + unset bridgename ethname + case $# in + 0) bridgename=br0; ethname=eth0 ;; + 1) die "bridge= requires two parameters" ;; + 2) bridgename=$1; ethname=$2 ;; + *) die "bridge= requires two parameters" ;; + esac +} + +unset bridgename ethname + +# Simple bridge +if getarg bridge; then + bridgename=br0 + ethname=eth0 + echo "bridgename=$bridgename" > /tmp/bridge.info + echo "ethname=$ethname" >> /tmp/bridge.info + return +fi + +# Defined bridge +bridge="$(getarg bridge=)" +if [ -n "$bridge" ]; then + parsebridge "$bridge" + unset bridge + echo "bridgename=$bridgename" > /tmp/bridge.info + echo "ethname=$ethname" >> /tmp/bridge.info + return +fi -- 1.6.2.5 --------------090000090207030802000303-- -- To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html