Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:15.5:Update
dracut.28355
0015-40network-replace-dhclient-with-wickedd-dh...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0015-40network-replace-dhclient-with-wickedd-dhcp-supplic.patch of Package dracut.28355
From 3b7df07e27efd2ef2df4d9d40253ee8185eb4152 Mon Sep 17 00:00:00 2001 From: Pavel Wieczorkiewicz <pwieczorkiewicz@suse.com> Date: Mon, 7 Apr 2014 16:26:57 +0200 Subject: 40network: replace dhclient with wickedd-dhcp-supplicant SLES12 is using wickedd, so we need to replace dhclient with wickedd-dhcp-supplicant. References: bnc#866771 Signed-off-by: Hannes Reinecke <hare@suse.de> --- modules.d/40network/dhclient.conf | 3 - modules.d/40network/ifup.sh | 109 ++++++++++++++++++++++++++++------- modules.d/40network/kill-dhclient.sh | 15 ----- modules.d/40network/module-setup.sh | 15 +++-- 4 files changed, 98 insertions(+), 44 deletions(-) delete mode 100644 modules.d/40network/dhclient.conf delete mode 100755 modules.d/40network/kill-dhclient.sh diff --git a/modules.d/40network/dhclient.conf b/modules.d/40network/dhclient.conf deleted file mode 100644 index dbf5882..0000000 --- a/modules.d/40network/dhclient.conf +++ /dev/null @@ -1,3 +0,0 @@ -request subnet-mask, broadcast-address, time-offset, routers, - domain-name, domain-name-servers, domain-search, host-name, - root-path, interface-mtu; diff --git a/modules.d/40network/ifup.sh b/modules.d/40network/ifup.sh index 31a04bf..92e4b38 100755 --- a/modules.d/40network/ifup.sh +++ b/modules.d/40network/ifup.sh @@ -87,6 +87,70 @@ else [ -e /tmp/net.$(cat /sys/class/net/$netif/address).did-setup ] && exit 0 fi +dhcp_apply() { + if [ -f /tmp/leaseinfo.${netif}.dhcp.ipv${1:1:1} ]; then + . /tmp/leaseinfo.${netif}.dhcp.ipv${1:1:1} + else + warn "DHCP failed"; + return 1 + fi + + if [ -z "${IPADDR}" ] || [ -z "${INTERFACE}" ]; then + warn "Missing crucial DHCP variables" + return 1 + fi + + # Assign IP address + ip $1 addr add "$IPADDR" ${BROADCAST:+broadcast $BROADCAST} dev "$INTERFACE" + + # Assign network route the interface is attached to + if [ -n "${NETWORK}" ]; then + ip $1 route add "$NETWORK"/"$PREFIXLEN" dev "$INTERFACE" + fi + + # Assign provided routes + local r route=() + if [ -n "${ROUTES}" ]; then + for r in ${ROUTES}; do + route=(${r//,/ }) + ip $1 route add "$route[0]"/"$route[1]" via "$route[2]" dev "$INTERFACE" + done + fi + + # Assign provided routers + local g + if [ -n "${GATEWAYS}" ]; then + for g in ${GATEWAYS}; do + ip $1 route add default via "$g" dev "$INTERFACE" && break + done + fi + + # Setup hostname + [ -n "${HOSTNAME}" ] && hostname "$HOSTNAME" + + # If nameserver= has not been specified, use what dhcp provides + if [ ! -s /tmp/net.$netif.resolv.conf ]; then + if [ -n "${DNSDOMAIN}" ]; then + echo domain "${DNSDOMAIN}" + fi >> /tmp/net.$netif.resolv.conf + + if [ -n "${DNSSEARCH}" ]; then + echo search "${DNSSEARCH}" + fi >> /tmp/net.$netif.resolv.conf + + if [ -n "${DNSSERVERS}" ] ; then + for s in ${DNSSERVERS}; do + echo nameserver "$s" + done + fi >> /tmp/net.$netif.resolv.conf + fi + [ -e /tmp/net.$netif.resolv.conf ] && \ + cp -f /tmp/net.$netif.resolv.conf /etc/resolv.conf + + info "DHCP is finished successfully" + return 0 +} + # Run dhclient do_dhcp() { # dhclient-script will mark the netif up and generate the online @@ -98,28 +162,35 @@ do_dhcp() { local _DHCPRETRY=$(getargs rd.net.dhcp.retry=) _DHCPRETRY=${_DHCPRETRY:-1} - [ -e /tmp/dhclient.$netif.pid ] && return 0 + [ -f /tmp/leaseinfo.${netif}.dhcp.ipv${1:1:1} ] && return 0 + + info "Preparation for DHCP transaction" + + local dhclient='' + if [ "$1" = "-4" ] ; then + dhclient="wickedd-dhcp4" + elif [ "$1" = "-6" ] ; then + dhclient="wickedd-dhcp6" + fi + + # Address changed + ip $1 addr flush dev "$netif" if ! iface_has_link $netif; then - warn "No carrier detected on interface $netif" - return 1 + warn "No carrier detected" + warn "Trying to set $netif up..." + ip $1 link set dev "$netif" up + if ! iface_has_link $netif; then + warn "Failed..." + return 1 + fi fi - while [ $_COUNT -lt $_DHCPRETRY ]; do - info "Starting dhcp for interface $netif" - dhclient "$@" \ - ${_timeout:+-timeout $_timeout} \ - -q \ - -cf /etc/dhclient.conf \ - -pf /tmp/dhclient.$netif.pid \ - -lf /tmp/dhclient.$netif.lease \ - $netif \ - && return 0 - _COUNT=$(($_COUNT+1)) - [ $_COUNT -lt $_DHCPRETRY ] && sleep 1 - done - warn "dhcp for interface $netif failed" - return 1 + $dhclient --test $netif > /tmp/leaseinfo.${netif}.dhcp.ipv${1:1:1} + dhcp_apply $1 || return $? + + echo $netif > /tmp/setup_net_${netif}.ok + return 0 } load_ipv6() { @@ -262,8 +333,6 @@ if [ -e /tmp/team.info ]; then fi fi -# XXX need error handling like dhclient-script - if [ -e /tmp/bridge.info ]; then . /tmp/bridge.info # start bridge if necessary diff --git a/modules.d/40network/kill-dhclient.sh b/modules.d/40network/kill-dhclient.sh deleted file mode 100755 index 9a17495..0000000 --- a/modules.d/40network/kill-dhclient.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -for f in /tmp/dhclient.*.pid; do - [ -e $f ] || continue - read PID < $f; - kill $PID >/dev/null 2>&1 -done - -sleep 0.1 - -for f in /tmp/dhclient.*.pid; do - [ -e $f ] || continue - read PID < $f; - kill -9 $PID >/dev/null 2>&1 -done diff --git a/modules.d/40network/module-setup.sh b/modules.d/40network/module-setup.sh index 4bf93cc..2252995 100755 --- a/modules.d/40network/module-setup.sh +++ b/modules.d/40network/module-setup.sh @@ -1,10 +1,13 @@ #!/bin/bash +WICKEDD_DHCP_PATH="/usr/lib/wicked/bin" +WICKED_EXT_PATH="/etc/wicked/extensions" + # called by dracut check() { local _program - require_binaries ip arping dhclient || return 1 + require_binaries ip arping $WICKEDD_DHCP_PATH/wickedd-dhcp4 $WICKEDD_DHCP_PATH/wickedd-dhcp6 || return 1 return 255 } @@ -23,17 +26,18 @@ installkernel() { # called by dracut install() { local _arch _i _dir - inst_multiple ip arping dhclient sed + inst_multiple ip arping hostname sed inst_multiple -o ping ping6 inst_multiple -o brctl inst_multiple -o teamd teamdctl teamnl inst_simple /etc/libnl/classid + inst_simple "$WICKEDD_DHCP_PATH/wickedd-dhcp4" "/usr/sbin/wickedd-dhcp4" + inst_simple "$WICKEDD_DHCP_PATH/wickedd-dhcp6" "/usr/sbin/wickedd-dhcp6" + inst_libdir_file "libwicked*.so.*" + inst_libdir_file "libdbus-1.so.*" inst_script "$moddir/ifup.sh" "/sbin/ifup" inst_script "$moddir/netroot.sh" "/sbin/netroot" - inst_script "$moddir/dhclient-script.sh" "/sbin/dhclient-script" inst_simple "$moddir/net-lib.sh" "/lib/net-lib.sh" - inst_simple -H "/etc/dhclient.conf" - cat "$moddir/dhclient.conf" >> "${initdir}/etc/dhclient.conf" inst_hook pre-udev 50 "$moddir/ifname-genrules.sh" inst_hook pre-udev 60 "$moddir/net-genrules.sh" inst_hook cmdline 91 "$moddir/dhcp-root.sh" @@ -44,7 +48,6 @@ install() { inst_hook cmdline 97 "$moddir/parse-bridge.sh" inst_hook cmdline 98 "$moddir/parse-ip-opts.sh" inst_hook cmdline 99 "$moddir/parse-ifname.sh" - inst_hook cleanup 10 "$moddir/kill-dhclient.sh" _arch=$(uname -m) -- 2.6.6
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor