From: Warren Togami <wtogami-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: RFC Bridging plan
Date: Thu, 16 Jul 2009 00:43:24 -0400 [thread overview]
Message-ID: <4A5EAFEC.4080705@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1554 bytes --]
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=<bridgename>:<ethname>
If bridge without parameters, assume bridge=br0:eth0
BASIC IDEA
==========
* When <ethname> would be configured by network scripts, instead create
a bridge named <bridgename> then add <ethname> to that bridge.
* <bridgename> automatically inherits the MAC address of <ethname>.
BOOTIF thus should be optionally workable.
* Then $netif becomes <bridgename> instead of <ethname> and all existing
scripts process netroot mount via this new $netif instead of <ethname>.
* Try only the one specified <ethname> 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-<bridgename> and ifcfg-<ethname>
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 <parameters>
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
[-- Attachment #2: 0001-Bridge-parsing-example.patch --]
[-- Type: text/x-patch, Size: 3044 bytes --]
From 329b0b77e7d63ebe2092111de31f471fd22a5b06 Mon Sep 17 00:00:00 2001
From: Warren Togami <wtogami-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
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=<bridgename>:<ethname>
+#
+# 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
next reply other threads:[~2009-07-16 4:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-16 4:43 Warren Togami [this message]
[not found] ` <4A5EAFEC.4080705-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2009-07-16 7:20 ` RFC Bridging plan Victor Lowther
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A5EAFEC.4080705@redhat.com \
--to=wtogami-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.