[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH 2/2] Replace linuxrc.s390 network configuration code with NetworkManager.



Remove linuxrc.s390's usage of /sbin/ip, /sbin/ifconfig, and /sbin/route
and instead just write the settings to the ifcfg-DEVICE file, set the
device online in sysfs, and start NetworkManager.  This prevents a bug
where linuxrc.s390 was bringing up the interface, then loader would
start, it would launch NM, and immediately the network connection would
come down.  Starting NM earlier prevents this and simplifies
linuxrc.s390 a lot.
---
 loader/linuxrc.s390 |  313 ++++-----------------------------------------------
 1 files changed, 22 insertions(+), 291 deletions(-)

diff --git a/loader/linuxrc.s390 b/loader/linuxrc.s390
index 7a6be69..dfdd8d9 100644
--- a/loader/linuxrc.s390
+++ b/loader/linuxrc.s390
@@ -660,30 +660,6 @@ function set_device_online() {
     fi
 }
 
-# sets device up and blocks until device appears to be up
-function set_device_up() {
-    if [ -z "$DEVICE" ]; then
-        echo $"Could not determine interface name to bring up device $SUBCHANNELS"
-        return 1
-    fi
-    # Device does not come up fast enough to use "ip" to configure, so block.
-    # While OSA come up themselves after setting online,
-    # e.g. HiperSockets won't => set them up explicitly for the following check
-    debug ip link set up $DEVICE
-    local i=1
-    while : ; do
-        local tst=$(ip -o link show up dev $DEVICE)
-        [ -n "$tst" ] && break
-        sleep 1
-        i=$((i+1))
-        if [ "$i" -gt 10 ]; then
-            echo $"Could not bring up device $DEVICE within timeout"
-            return 1
-        fi
-    done
-    return 0
-}
-
 function syntax_check_domainname() {
     # - match against regex adopted from RFC1035,sec.2.3.1 or RFC1034,sec.3.5
     #   (Internationalized Domain Names in Applications (IDNA) [RFC4690]
@@ -730,65 +706,10 @@ function disable_ipv6_autoconf() {
     sysctl -w net.ipv6.conf.default.autoconf=0 > /dev/null
 }
 
-function configure_ipv6_address() {
-    # device needs to be online
-    # arp flag needs to be on for ipv6 over osa because of ndisc.
-    # happens automatically by the driver. do NOT mess with default setting.
-    #NO#debug ip link set dev $DEVICE arp on
-    if ! debug ip -6 address add $IPADDR/$NETMASK dev $DEVICE; then
-        echo $"Could net set IPv6 address $IPADDR/$NETMASK for device $DEVICE"
-        return 1
-    fi
-    # network route has been set by above "ip address add" already
-    # take care of MTU, which is bundled with ifconfig in the other IPv4 cases
-    if [ -n "$MMTU" ]; then
-        if ! debug ip link set $DEVICE $MMTU; then
-            echo $"Could net set maximum transfer unit ($MMTU) for device $DEVICE"
-            return 1
-        fi
-    fi
-    return 0
-}
-
-function configure_ipv4_address() {
-    # it's IPv4 and we can make use of ipcalc for better usability
-    if ipcalc -bmnp $ipcalc_arg > /tmp/ipcalc.$$.out 2> /dev/null; then
-        . /tmp/ipcalc.$$.out
-    else
-        echo $"Could not calculate network address and broadcast address from"
-        echo $" IPv4 address $IPADDR and netmask $NETMASK"
-        return 1
-    fi
-    rm /tmp/ipcalc.$$.out
-    # device needs to be online
-    if ! debug ifconfig $DEVICE $IPADDR $MMTU netmask $NETMASK broadcast $BROADCAST; then
-        echo $"Could not set IPv4 address $IPADDR for device $DEVICE"
-        echo $" with network mask $NETMASK and broadcast address $BROADCAST"
-        [ -n "$MMTU" ] && echo $" and maximum transfer unit: $MMTU"
-        return 1
-    fi
-    # This network route is already there after ifconfig!
-    #if ! debug route add -net $NETWORK netmask $NETMASK dev $DEVICE; then
-    #    echo $"Could not add network route to $NETWORK/$NETMASK on device $DEVICE"
-    #    return 1
-    #fi
-    return 0
-}
-
-function handle_mtu() {
-    # don't ask for MTU, but use it if it has been set in the .parm file
-    # don't overwrite MMTU if it has been set for CTC
-    [ -n "$MTU" -a -z "$MMTU" ] && MMTU="mtu $MTU"
-}
-
 function rollback_config() {
     # each transaction to roll back may fail, if previous setup has not
     # made progress that far to reach a certain transation
     # => error output is misleading and should be avoided
-    [ -n "$DEVICE" ] && tv ip -4 route flush default dev $DEVICE
-    [ -n "$DEVICE" ] && tv ip -6 route flush default dev $DEVICE
-    # address flush seems to be effective for all address families
-    [ -n "$DEVICE" ] && ip address flush dev $DEVICE
     if [ -n "$NETTYPE" ]; then
         if [ -n "$SCH_R_DEVBUSID" ]; then
             local sysnettype
@@ -805,7 +726,6 @@ function rollback_config() {
         fi
     fi
     [ -z "$mtu_was_set" ] && unset MTU
-    [ -z "$mmtu_was_set" ] && unset MMTU
     [ -z "$vswitch_was_set" ] && unset VSWITCH
     # prevent possible reuse of an old DEVICE on restarting dialog
     unset DEVICE
@@ -1632,17 +1552,6 @@ function syntax_check_macaddr() {
     return 1
 }
 
-function handle_macaddr() {
-    # - try to set macaddr right here w/ error handlg.
-    # device needs to be online
-    if debug ifconfig $DEVICE hw ether $MACADDR; then
-        return 0
-    fi
-    echo $"MAC address $MACADDR could not be configured for"
-    echo $" $SUBCHANNELS (network device $DEVICE)"
-    return 1
-}
-
 function question_prefix_macaddr() {
     echo -n $"Unique MAC address"
 }
@@ -1685,7 +1594,7 @@ function do_macaddr() {
     ask MACADDR \
         question_prefix_macaddr question_choices_macaddr \
         -h helptext_macaddr -e exception_macaddr \
-        -s syntax_check_macaddr -c handle_macaddr
+        -s syntax_check_macaddr
 }
 
 ### CTCPROT
@@ -1968,24 +1877,6 @@ function do_netmask() {
     # no handling/configuring of NETMASK yet, since more parameters needed
 }
 
-### NETWORK
-
-function do_network() {
-    echo
-    echo $"The NETWORK parameter isn't used anymore and will be ignored."
-    echo $" It is sufficient to specify IPADDR and NETMASK."
-    echo
-}
-
-### BROADCAST
-
-function do_broadcast() {
-    echo
-    echo $"The BROADCAST parameter isn't used anymore and will be ignored."
-    echo $" It is sufficient to specify IPADDR and NETMASK."
-    echo
-}
-
 ### NETMASK (IPv6)
 
 function syntax_check_prefix_v6() {
@@ -2015,43 +1906,6 @@ function do_netmask_v6() {
 
 ### GATEWAY (IPv4)
 
-function configure_ipv4_gateway() {
-    # FIXME:
-    # - Strictly speaking we should first check reachability of gateway
-    #   and then configure the gateway route.
-    #   This would require a new intermediate workflow_item step
-    #   so that the user might continue despite unreachable gateway.
-    # done: Only adding default route might add multiple undesired default
-    # routes on redoing the parameter item, so delete default route
-    # before adding a new one.
-    ip -4 route del default dev $DEVICE >& /dev/null
-    [ -z "$GATEWAY" ] && return 0
-    if ! tv route add default gw $GATEWAY dev $DEVICE; then
-        echo $"Could net set default route on device $DEVICE via gateway $GATEWAY"
-        return 1
-    fi
-    # BH FIXME: Workaround for manual MACADDR, need ping to update arp table
-    echo $"Trying to reach gateway $GATEWAY..."
-    if [ "$NETTYPE" = "ctc" ]; then
-        # (virtual) CTC(/A) seems to need some time to get functional
-        local i=1
-        while : ; do
-            ping -c 1 $GATEWAY >& /dev/null && break
-            i=$((i+1))
-            if [ "$i" -gt 3 ]; then
-                echo $"Could not reach gateway $GATEWAY within timeout"
-                return 1
-            fi
-        done
-    else
-        if ! ping -c 1 $GATEWAY >& /dev/null; then
-            echo $"Could not reach your default gateway $GATEWAY"
-            return 1
-        fi
-    fi
-    return 0
-}
-
 function hint_ipv4_gateway() {
     # - provide default suggestion based on network,
     #   for a class C network this would be either .1 or .254 at the end
@@ -2090,17 +1944,12 @@ function helptext_gateway() {
     hint_ipv4_gateway
 }
 
-function finish_gateway() {
-    if ! checkipv4 $GATEWAY; then
-        # above checkipv4 is silent, so make up for syntax error
-        echo $"Incorrect format for IPv4 address of gateway (GATEWAY): $GATEWAY"
-        workflow_item_menu
-    fi
-    if configure_ipv4_gateway; then
-        break
-    else
-        workflow_item_menu && break
+function syntax_check_gateway() {
+    if checkipv4 $GATEWAY; then
+        return 0
     fi
+    echo $"Incorrect format for IPv4 address of gateway (GATEWAY): $GATEWAY"
+    return 1
 }
 
 # FIXME: allow empty/no gateway?
@@ -2108,43 +1957,11 @@ function finish_gateway() {
 function do_gateway() {
     ask GATEWAY \
         question_prefix_gateway question_choices_gateway \
-        -h helptext_gateway -f finish_gateway
+        -h helptext_gateway -s syntax_check_gateway
 }
 
 ### GATEWAY (IPv6)
 
-function configure_ipv6_gateway() {
-    # FIXME:
-    # - Strictly speaking we should first check reachability of gateway
-    #   and then configure the gateway route.
-    #   This would require a new intermediate workflow_item step
-    #   so that the user might continue despite unreachable gateway.
-    # done: Only adding default route might add multiple undesired default
-    # routes on redoing the parameter item, so delete default route
-    # before adding a new one.
-    ip -6 route del default dev $DEVICE >& /dev/null
-    [ -z "$GATEWAY" ] && return 0
-    # IPv6 http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/html_single/Linux+IPv6-HOWTO.html#AEN1147
-    #       ip -6 route add ::/0 dev $DEVICE via $GATEWAY
-    # (Could also be learned by autoconfiguration on the link:
-    #  after IP address setup and device up,
-    #   see if default route has been learned
-    #   ip -6 route show | grep ^default
-    #  However, we currently use manual IPv6 configuration only.)
-    if ! debug ip -6 route add ::/0 dev $DEVICE via $GATEWAY; then
-        echo $"Could net set default route on device $DEVICE"
-        echo $" via gateway $GATEWAY"
-        return 1
-    fi
-    # BH FIXME: Workaround for manual MACADDR, need ping to update arp table
-    echo $"Trying to reach gateway $GATEWAY..."
-    if ! ping6 -c 1 $GATEWAY >& /dev/null; then
-        echo $"Could not reach your default gateway $GATEWAY"
-        return 1
-    fi
-    return 0
-}
-
 function question_prefix_gateway_v6() {
     echo -n $"IPv6 address of your default gateway"
 }
@@ -2159,17 +1976,12 @@ function helptext_gateway_v6() {
     echo $"  and choose continue afterwards to go on without gateway."
 }
 
-function finish_gateway_v6() {
-    if ! checkipv6 $GATEWAY; then
-        # above checkipv6 is silent, so make up for syntax error
-        echo $"Incorrect format for IPv6 address of gateway (GATEWAY): $GATEWAY"
-        workflow_item_menu
-    fi
-    if configure_ipv6_gateway; then
-        break
-    else
-        workflow_item_menu && break
+function syntax_check_gateway_v6() {
+    if checkipv6 $GATEWAY; then
+        return 0
     fi
+    echo $"Incorrect format for IPv6 address of gateway (GATEWAY): $GATEWAY"
+    return 1
 }
 
 # FIXME: allow empty/no gateway?
@@ -2177,23 +1989,11 @@ function finish_gateway_v6() {
 function do_gateway_v6() {
     ask GATEWAY \
         question_prefix_gateway_v6 question_choices_gateway_v6 \
-        -h helptext_gateway_v6 -f finish_gateway_v6
+        -h helptext_gateway_v6 -s syntax_check_gateway_v6
 }
 
 ### GATEWAY (IPv4, point-to-point)
 
-function configure_ipv4_ptp() {
-    # device needs to be online
-    if debug ifconfig $DEVICE $IPADDR $MMTU pointopoint $GATEWAY; then
-        configure_ipv4_gateway
-        return $?
-    fi
-    echo $"Could not set IPv4 address $IPADDR for device $DEVICE"
-    echo $" to peer $GATEWAY"
-    [ -n "$MMTU" ] && echo $" and maximum transfer unit: $MMTU"
-    return 1
-}
-
 function question_prefix_ptp_gateway() {
     echo -n $"IPv4 address of your point-to-point partner"
 }
@@ -2261,49 +2061,6 @@ function syntax_check_dns() {
     fi
 }
 
-function handle_dns() {
-    # - foreach DNS try if server is reachable by one ping
-    [ -z "$DNS" ] && return 0
-    local dnsitem
-    local allgood="yes"
-    echo $"Trying to reach DNS servers..."
-    if [ "$ipv6" ]; then
-        while read dnsitem; do
-            if ! ping6 -c 1 $dnsitem >& /dev/null; then
-                echo $"Could not ping DNS server (might still serve DNS requests): $dnsitem"
-                allgood="no"
-                # this should not be a hard failure since some network
-                # environments may prevent pings to DNS servers
-                # => prevent workflow_item_menu in kickstart mode
-            fi
-        done < <(echo $DNS | sed 's/,/\n/g')
-    else
-        while read dnsitem; do
-            # Some network environment may prevent a DNS server from being
-            # reachable by ping, so it would make sense to use nslookup.
-            # However, nslookup fails with "Resolver Error 0 (no error)"
-            # at this stage of the setup progress => not useful
-            if ! ping -c 1 $dnsitem >& /dev/null; then
-                echo $"Could not ping DNS server: $dnsitem"
-#                if nslookup $dnsitem $dnsitem >& /dev/null; then
-#                    echo $" but could resolve DNS server with itself: $dnsitem"
-#                else
-#                    echo $"Could not resolve DNS server with itself: $dnsitem"
-#                    allgood="no"
-#                fi
-#            elif ! nslookup $dnsitem $dnsitem >& /dev/null; then
-#                echo $"Could not resolve DNS server with itself: $dnsitem"
-                allgood="no"
-            fi
-        done < <(echo $DNS | sed 's/:/\n/g')
-    fi
-    if [ "$allgood" = "yes" ]; then
-        return 0
-    else
-        return 1
-    fi
-}
-
 function question_prefix_dns() {
     if [ "$ipv6" ]; then
         echo -n $"IPv6 addresses of DNS servers"
@@ -2340,7 +2097,7 @@ function helptext_dns() {
 function do_dns() {
     ask DNS \
         question_prefix_dns question_choices_dns \
-        -h helptext_dns -s syntax_check_dns -c handle_dns
+        -h helptext_dns -s syntax_check_dns
 }
 
 ### SEARCHDNS
@@ -2674,9 +2431,7 @@ EOF
     [ "$PORTNO" ] && echo "PORTNO=$PORTNO"
     [ "$PEERID" ] && echo "PEERID=$PEERID"
     [ "$CTCPROT" ] && echo "CTCPROT=$CTCPROT"
-    if [ -n "$mmtu_was_set" ]; then
-        echo "MMTU=\"$MMTU\""
-    elif [ -n "$mtu_was_set" ]; then
+    if [ -n "$mtu_was_set" ]; then
         echo "MTU=$MTU"
     fi
     [ "$DNS" ] && echo "DNS=$DNS"
@@ -2786,18 +2541,14 @@ fi
 # Perform a network installation
 
 [ -n "$MTU" ] && mtu_was_set=$MTU
-[ -n "$MMTU" ] && mmtu_was_set=$MMTU
 [ -n "$VSWITCH" ] && vswitch_was_set=$VSWITCH
 
 [ -n "$CHANDEV" ] && do_chandev
-[ -n "$NETWORK" ] && do_network
-[ -n "$BROADCAST" ] && do_broadcast
 
 # [ -z "${cardtype//OSD_*/}" ] can be used to check for real OSA
 
 # Check for missing parameters, prompt for them if necessary
 while : ; do
-
     # do not show list of possible network device configurations, if:
     # - running unattended install with kickstart
     # - relevant parameters have already been specified in parm file
@@ -2854,10 +2605,6 @@ while : ; do
         set_device_online || workflow_item_menu noredo
     fi
 
-    # device needs to be up before configuring with ifconfig/ip in
-    # configure_ipv6_address/configure_ipv4_address/configure_ipv4_address
-    set_device_up || workflow_item_menu noredo
-
     [ "$HOSTNAME" = "(none)" ] && unset HOSTNAME
     do_hostname
 
@@ -2868,8 +2615,6 @@ while : ; do
     if [ "$ipv6" ]; then
         # this branch is all IPv6 and at the same time also NETTYPE==qeth
         do_netmask_v6
-        handle_mtu
-        configure_ipv6_address || workflow_item_menu noredo
         do_gateway_v6
     else
         # Consider IPv4 as default, even for unknown IP versions
@@ -2879,22 +2624,9 @@ while : ; do
         # and jump forward to DNS which is probably not what we want.
         if [ "$NETTYPE" = "qeth" ] || [ "$NETTYPE" = "lcs" ]; then
             do_netmask
-            handle_mtu
-            configure_ipv4_address || workflow_item_menu noredo
             do_gateway
         else  # ctc0
-            if [ -z "$NETMASK" ]; then
-                # If the user did not supply netmask, we add the right one.
-                # Netmask MUST be present,
-                # or pumpSetupInterface() blows routes.
-                NETMASK="255.255.255.255"
-            fi
-            # don't ask for MTU, but use it if set in the parm file
-            # don't overwrite MMTU if it has been set for CTC
-            [ "$NETTYPE" = "ctc" -a -z "$MTU" -a -z "$MMTU" ] && \
-                MMTU="mtu 1500"
             do_ptp_gateway
-            configure_ipv4_ptp || workflow_item_menu noredo
         fi
     fi
 
@@ -2908,7 +2640,6 @@ while : ; do
     final_check && break
     rollback_config
     reenter="yes"
-
 done # outer dialog loop
 
 if [ -z "$testing" ]; then
@@ -2964,9 +2695,7 @@ NETTYPE="$NETTYPE"
 IPADDR="$IPADDR"
 GATEWAY="$GATEWAY"
 MTU="$MTU"
-NETWORK="$NETWORK"
 NETMASK="$NETMASK"
-BROADCAST="$BROADCAST"
 SEARCHDNS="$SEARCHDNS"
 PEERID="$PEERID"
 SUBCHANNELS="$SUBCHANNELS"
@@ -2987,7 +2716,7 @@ fi
 cat >> /tmp/install.cfg << EOF
 export LANG PORTNAME S390ARCH TEXTDOMAIN TEXTDOMAINDIR
 export HOSTNAME DEVICE NETTYPE IPADDR GATEWAY MTU
-export NETWORK NETMASK BROADCAST DNS DNS1 DNS2 SEARCHDNS
+export NETMASK DNS DNS1 DNS2 SEARCHDNS
 export PEERID ONBOOT SUBCHANNELS CTCPROT
 EOF
 # immediately read it in again to export these into the shell below
@@ -3002,7 +2731,7 @@ if [ ! -d "$NETSCRIPTS" ]; then
     mkdir -p $NETSCRIPTS
 fi
 
-# to please NetworkManager on startup in loader before loader reconfigures net
+# nm-system-settings reads the ifcfg-DEVICE files
 cat > /etc/sysconfig/network << EOF
 HOSTNAME=$HOSTNAME
 EOF
@@ -3012,7 +2741,6 @@ DEVICE=$DEVICE
 ONBOOT=yes
 BOOTPROTO=static
 GATEWAY=$GATEWAY
-BROADCAST=$BROADCAST
 MTU=$MTU
 SUBCHANNELS=$SUBCHANNELS
 EOF
@@ -3033,7 +2761,8 @@ EOF
 fi
 [ "$DNS1" != "" ] && echo "DNS1=$DNS1" >> $IFCFGFILE
 [ "$DNS2" != "" ] && echo "DNS2=$DNS2" >> $IFCFGFILE
-# colons in SEARCHDNS already replaced with spaces above for /etc/resolv.conf
+# colons in SEARCHDNS already replaced with spaces above
+# for /etc/resolv.conf
 [ "$SEARCHDNS" != "" ] && echo "DOMAIN=\"$SEARCHDNS\"" >> $IFCFGFILE
 [ "$NETTYPE" != "" ] && echo "NETTYPE=$NETTYPE" >> $IFCFGFILE
 [ "$PEERID" != "" ] && echo "PEERID=$PEERID" >> $IFCFGFILE
@@ -3046,7 +2775,8 @@ for option in LAYER2 PORTNO; do
     [ -n "$optstr" ] && optstr=${optstr}" "
     optstr=${optstr}$(echo ${option} | tr [[:upper:]] [[:lower:]])"="${!option}
 done
-# write single quotes since network.py removes double quotes but we need quotes
+# write single quotes since network.py removes double quotes but we need
+# quotes
 echo "OPTIONS='$optstr'" >> $IFCFGFILE
 unset option
 unset optstr
@@ -3084,6 +2814,7 @@ EOF
     # reboot on SIGUSR2
     trap doreboot SIGUSR2
 
+    /usr/sbin/NetworkManager --pid-file=/var/run/NetworkManager/NetworkManager.pid
     startinetd
 
     if [ -n "$RUNKS" ]; then
-- 
1.6.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]