We now know how to configure the network interfaces.

Provided that you are configuring them via DHCP. RARP, BOOTP, and static
configuration are not written yet.

Also, adding nic drivers really bloats the initrd.

I am looking for feedback on these patches from people who actually implement
booting over the network.  This patch series does not include support for that
yet -- you will not find nfsroot= handling, or booting to a fs supplied by
dhcp yet.  I do want to make it as easy as possible to add support for booting
over the network, as well as making it easy for people to customize things to
meet their site requirements.

This patch series is also available as the network-configurability branch at
http://git.fnordovax.org/dracut.  It may be rebased without warning to keep
it in sync with the rest of dracut.
This commit is contained in:
Victor Lowther 2009-02-25 18:42:05 -08:00 committed by Harald Hoyer
parent 8177ca3e1e
commit 0ac9584ded
6 changed files with 59 additions and 1 deletions

6
README
View File

@ -37,7 +37,11 @@ Some general rules for writing modules:
* Generator modules should have a two digit numeric prefix -- they run in
ascending sort order. Anything in the 90-99 range is stuff that dracut
relies on, so try not to break those hooks.
* Generator modules and hooks must have a .sh extension.
* Generator modules and hooks must have a .sh extension.
* We have some breakpoints for debugging your hooks. If you pass 'break'
as a kernel parameter, the initramfs will drop to a shell just before
switching to a new root. You can pass 'break=hookpoint', and the initramfs
will break just before hooks in that hookpoint run.
Also, there is an attempt to keep things as distribution-agnostic as
possible. Every distribution has their own tool here and it's not

24
dhclient-script Executable file
View File

@ -0,0 +1,24 @@
#!/bin/sh
# very simple dhclient-script. All it cares about is bringing the interface
# up, and it does not even try to do anything else.
case $reason in
PREINIT) ip link set "$interface" up ;;
BOUND) ipopts="$new_ip_address"
[ "$new_interface_mtu" ] && ip link set $interface mtu $new_interface_mtu
[ "$new_subnet_mask" ] && ipopts="$ipopts/$new_subnet_mask"
[ "$new_broadcast_address" ] && ipopts="$ipopts broadcast $new_broadcast_address"
ip addr add $ipopts dev $interface
[ "$new_routers" ] && ip route add default via ${new_routers%%,*} dev $interface
[ "$new_domain_name" ] && echo "domain $new_domain_name" > /etc/resolv.conf
if [ "$new_domain_search" ]; then
echo "search $new_domain_search" |sed 's/,//g' >> /etc/resolv.conf
elif [ "$new_domain_name" ]; then
echo "search $new_domain_name" >> /etc/resolv.conf
fi
( IFS=",";
for s in $new_domain_name_servers; do
echo "nameserver $s" >> /etc/resolv.conf
done ) ;;
*) ;;
esac

2
hooks/kill-dhclient.sh Normal file
View File

@ -0,0 +1,2 @@
#!/bin/sh
kill $(pidof dhclient)

20
ifup Executable file
View File

@ -0,0 +1,20 @@
#!/bin/sh
echo "$*" >>/dev/net-interfaces-found
# loopback is always handled the same way
[ "$1" = "lo" ] && {
ip link set lo up
ip addr add 127.0.0.1/8 dev lo
exit 0
}
# spin through the kernel command line, looking for ip= lines
while read p; do
case $p in
'ip=none'|'ip=off') exit 0;; # we were told to not configure anything
'ip=dhcp'|'ip=on'|'ip=any') dhclient -nw "$1"; exit 0;;
'ip=bootp'|'ip=rarp'|'ip=both') exit 0;; #dunno how to do this
ip=*) exit 0;; #to be written
*) continue;;
esac
done

7
modules/40network.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
dracut_install ip dhclient
inst "$dsrc/ifup" "/sbin/ifup"
inst "$dsrc/dhclient-script" "/sbin/dhclient-script"
instmods =networking ecb arc4
inst_rules "$dsrc/rules.d/60-net.rules"
inst_hook pre-pivot 10 "$dsrc/hooks/kill-dhclient.sh"

1
rules.d/60-net.rules Normal file
View File

@ -0,0 +1 @@
ACTION=="add", SUBSYSTEM=="net", RUN+="/sbin/ifup $env{INTERFACE}"