5 ip
=$
(ip
-o -f inet addr show
$iface)
10 iface_for_remote_addr
() {
11 set -- $
(ip
-o route get to
$1)
16 local interface
="" mac
="$(echo $1 | tr '[:upper:]' '[:lower:]')"
17 for interface
in /sys
/class
/net
/*; do
18 if [ $
(cat $interface/address
) = "$mac" ]; then
25 local interface
="$1" flags
=""
26 [ -n "$interface" ] ||
return 2
27 interface
="/sys/class/net/$interface"
28 [ -d "$interface" ] ||
return 2
29 flags
=$
(cat $interface/flags
)
30 echo $
(($flags|
0x41)) > $interface/flags
# 0x41: IFF_UP|IFF_RUNNING
31 [ "$(cat $interface/carrier)" = 1 ] ||
return 1
32 # XXX Do we need to reset the flags here? anaconda never bothered..
36 local iface
="" IFACES
=""
37 [ -e "/tmp/net.ifaces" ] && read IFACES
< /tmp
/net.ifaces
38 for iface
in $IFACES; do
39 [ -e /tmp
/net.
$iface.up
] ||
return 1
44 local prefix
="" server
="" rest
=""
45 splitsep
"$1" ":" prefix server rest
47 [0-9]*\.
[0-9]*\.
[0-9]*\.
[0-9]*) echo "$server"; return 0 ;;
53 strstr
"$(ip route get $1 2>/dev/null)" " via "
58 # ip down/flush ensures that routing info goes away as well
59 ip link
set $netif down
60 ip addr flush dev
$netif
61 echo "#empty" > /etc
/resolv.conf
62 # TODO: send "offline" uevent?
66 local netif
="$1" f
="" gw_ip
="" netroot_ip
="" iface
="" IFACES
=""
67 [ -e /tmp
/net.
$netif.up
] ||
return 1
68 [ -e "/tmp/net.ifaces" ] && read IFACES
< /tmp
/net.ifaces
69 [ -z "$IFACES" ] && IFACES
="$netif"
70 for iface
in $IFACES ; do
73 # run the scripts written by ifup
74 [ -e /tmp
/net.
$netif.gw
] && .
/tmp
/net.
$netif.gw
75 [ -e /tmp
/net.
$netif.hostname
] && .
/tmp
/net.
$netif.hostname
76 [ -e /tmp
/net.
$netif.override
] && .
/tmp
/net.
$netif.override
77 [ -e /tmp
/dhclient.
$netif.dhcpopts
] && .
/tmp
/dhclient.
$netif.dhcpopts
79 [ -e /tmp
/net.
$netif.resolv.conf
] && \
80 cp -f /tmp
/net.
$netif.resolv.conf
/etc
/resolv.conf
82 # Handle STP Timeout: arping the default gateway.
83 # (or the root server, if a) it's local or b) there's no gateway.)
84 # Note: This assumes that if no router is present the
85 # root server is on the same subnet.
87 # Get DHCP-provided router IP, or the cmdline-provided "gw=" argument
88 [ -n "$new_routers" ] && gw_ip
=${new_routers%%,*}
89 [ -n "$gw" ] && gw_ip
=$gw
91 # Get the "netroot" IP (if there's an IP address in there)
92 netroot_ip
=$
(get_netroot_ip
$netroot)
94 # try netroot if it's local (or there's no gateway)
95 if ip_is_local
$netroot_ip ||
[ -z "$gw_ip" ]; then
100 if [ -n "$dest" ] && ! arping
-q -f -w 60 -I $netif $dest ; then
101 info
"Resolving $dest via ARP on $netif failed"
106 local name
="$1" mac
="$2" num
=0 n
=""
107 # if it's already set, return the existing name
108 for n
in $
(getargs ifname
=); do
109 strstr
"$n" "$mac" && echo ${n%%:*} && return
111 # otherwise, pick a new name and use that
112 while [ -e /sys
/class
/$name$num ]; do num
=$
(($num+1)); done
113 echo "ifname=$name$num:$mac" >> /etc
/cmdline.d
/45-ifname.conf
118 local iface
="" mac
="" dev
=""
119 local dhcp
="" ip
="" gw
="" mask
="" hostname
=""
120 modprobe
-q iscsi_ibft
122 for iface
in /sys
/firmware
/ibft
/ethernet
*; do
123 [ -e ${iface}/mac
] ||
continue
124 mac
=$
(read a
< ${iface}/mac
; echo $a)
125 [ -z "$ifname_mac" ] && continue
126 dev
=$
(set_ifname ibft
$ifname_mac)
127 dhcp
=$
(read a
< ${iface}/dhcp
; echo $a)
128 if [ -n "$dhcp" ]; then
131 ip
=$
(read a
< ${iface}/ip-addr
; echo $a)
132 gw
=$
(read a
< ${iface}/gateway
; echo $a)
133 mask
=$
(read a
< ${iface}/subnet-mask
; echo $a)
134 hostname
=$
(read a
< ${iface}/hostname
; echo $a)
135 echo "ip=$ip::$gw:$mask:$hostname:$dev:none"
138 ) >> /etc
/cmdline.d
/40-ibft.conf
148 # extract authentication info
153 # allow empty authinfo to allow having an @ in iscsi_target_name like this:
154 # netroot=iscsi:@192.168.1.100::3260::iqn.2009-01.com.example:testdi@sk
155 if [ -n "$authinfo" ]; then
160 if [ $# -gt 4 ]; then
161 warn
"Wrong authentication info in iscsi: parameter!"
166 if [ $# -gt 2 ]; then
177 iscsi_target_ip
=${v#[[]}
178 iscsi_target_ip
=${iscsi_target_ip%%[]]*}
179 v
=${v#[[]$iscsi_target_ip[]]:}
182 iscsi_target_ip
=${v%%[:]*}
183 v
=${v#$iscsi_target_ip:}
187 # extract target name
190 iscsi_target_name
=iqn.
${v##*:iqn.}
194 iscsi_target_name
=iqn.
${v##*:eui.}
198 iscsi_target_name
=iqn.
${v##*:naa.}
202 warn
"Invalid iscii target name, should begin with 'iqn.' or 'eui.' or 'naa.'"
213 iscsi_protocol
=$1; shift # ignored
214 iscsi_target_port
=$1; shift
215 if [ $# -eq 3 ]; then
216 iscsi_iface_name
=$1; shift
218 if [ $# -eq 2 ]; then
219 iscsi_netdev_name
=$1; shift
222 if [ $# -ne 0 ]; then
223 warn
"Invalid parameter in iscsi: parameter!"
232 while [ -n "$v" ]; do
233 if [ "${v#\[*:*:*\]:}" != "$v" ]; then
234 # handle IPv6 address
240 set -- "$@" "${v%%:*}"
245 unset ip srv gw mask hostname dev autoconf macaddr mtu
247 0) autoconf
="error" ;;
249 2) dev
=$1; autoconf
=$2 ;;
250 3) dev
=$1; autoconf
=$2; mtu
=$3 ;;
251 4) dev
=$1; autoconf
=$2; mtu
=$3; macaddr
=$4 ;;
252 *) ip
=$1; srv
=$2; gw
=$3; mask
=$4; hostname
=$5; dev
=$6; autoconf
=$7; mtu
=$8; macaddr
=$9 ;;