Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

network-legacy: Support for static Wicked configuration #155

Open
wants to merge 4 commits into
base: SUSE/056
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion man/dracut.cmdline.7.asc
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ module. Other network modules might support a slightly different set of
options; refer to the documentation of the specific network module in use. For
NetworkManager, see *nm-initrd-generator*(8).

**ip=**__{dhcp|on|any|dhcp6|auto6|either6|link6|single-dhcp}__::
**ip=**__{dhcp|on|any|dhcp6|auto6|either6|link6|single-dhcp|wicked-static}__::
dhcp|on|any::: get ip from dhcp server from all interfaces. If netroot=dhcp,
loop sequentially through all interfaces (eth0, eth1, ...) and use the first
with a valid DHCP root-path.
Expand All @@ -599,6 +599,11 @@ NetworkManager, see *nm-initrd-generator*(8).

link6::: bring up interface for IPv6 link-local addressing

wicked-static::: Apply static network configuration from the installed system.
Files from /etc/sysconfig/network/ are copied upon buildtime. Changes require
the initramfs to be rebuilt.
This is a SUSE specific feature.

**ip=**__<interface>__:__{dhcp|on|any|dhcp6|auto6|link6}__[:[__<mtu>__][:__<macaddr>__]]::
This parameter can be specified multiple times.
+
Expand Down
58 changes: 57 additions & 1 deletion modules.d/35network-legacy/ifup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,59 @@ do_ipv6link() {
return "$ret"
}

# Prepare static IP configuration based on wicked ifcfg
do_wicked_static() {
unset BOOTPROTO IPADDR PREFIXLEN NETMASK GATEWAY NETCONFIG_DNS_STATIC_SERVERS NETCONFIG_DNS_STATIC_SEARCHLIST \
autoconf ip mask

if [ -e /etc/sysconfig/network/ifcfg-${netif} ] ; then
# Pull in existing interface configuration
. /etc/sysconfig/network/ifcfg-${netif}

if [ "$BOOTPROTO" = "static" ] ; then
autoconf=${BOOTPROTO}
if [ -n "$IPADDR" ] ; then
# respect netmask priority described in ifcfg(5)
local cidr=${IPADDR#*/}
if [ "$cidr" != "$IPADDR" ] ; then
mask=${cidr}
ip=${IPADDR%/*}
elif [ -n "$PREFIXLEN" ] ; then
mask=${PREFIXLEN}
ip=${IPADDR}
elif [ -n "$NETMASK" ] ; then
mask=${NETMASK}
ip=${IPADDR}
fi
[ -n "$GATEWAY" ] && gw=${GATEWAY}
fi
if [ -z "$IPADDR" ] ; then
warn "Blank interface configuration for $netif!"
return 1
fi
else
warn "Non-static interface configuration for $netif!"
return 1
fi
fi

if [ -e /etc/sysconfig/network/config ] ; then
# Pull in existing configuration for name resolution
. /etc/sysconfig/network/config

if [ -n "$NETCONFIG_DNS_STATIC_SERVERS" ] ; then
for ns in "$NETCONFIG_DNS_STATIC_SERVERS" ; do
echo "nameserver $ns" >> /etc/resolv.conf
done
fi
if [ -n "$NETCONFIG_DNS_STATIC_SEARCHLIST" ] ; then
echo "search $NETCONFIG_DNS_STATIC_SEARCHLIST" >> /etc/resolv.conf
fi
fi

do_static
}

# Handle static ip configuration
do_static() {
strglobin "$ip" '*:*:*' && load_ipv6
Expand Down Expand Up @@ -657,6 +710,9 @@ for p in $(getargs ip=); do
link6)
do_ipv6link
;;
wicked-static)
do_wicked_static
;;
*)
do_static
;;
Expand Down Expand Up @@ -732,4 +788,4 @@ if [ -z "$NO_AUTO_DHCP" ] && [ ! -e "/tmp/net.${netif}.up" ]; then
fi
fi

exit 0
exit 0
1 change: 1 addition & 0 deletions modules.d/35network-legacy/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ install() {

# SUSE specific files
for f in \
/etc/sysconfig/network/config \
/etc/sysconfig/network/ifcfg-* \
/etc/sysconfig/network/ifroute-* \
/etc/sysconfig/network/routes \
Expand Down
3 changes: 2 additions & 1 deletion modules.d/35network-legacy/parse-ip-opts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ for p in $(getargs ip=); do
[ -n "$ip" ] \
&& die "For argument 'ip=$p'\nSorry, setting client-ip does not make sense for '$autoopt'"
;;
wicked-static) ;;
*) die "For argument 'ip=$p'\nSorry, unknown value '$autoopt'" ;;
esac
done
Expand Down Expand Up @@ -112,7 +113,7 @@ for p in $(getargs ip=); do
[ -n "$DHCPORSERVER" ] && [ -n "$srv" ] && continue
# dhcp? (It's simpler to check for a set ip. Checks above ensure that if
# ip is there, we're static
[ -z "$ip" ] && continue
[ -z "$ip" -o "$autoopt" = "wicked-static" ] && continue
# Not good!
die "Server-ip or dhcp for netboot needed, but current arguments say otherwise"
fi
Expand Down