aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig/network-scripts
diff options
context:
space:
mode:
Diffstat (limited to 'sysconfig/network-scripts')
-rwxr-xr-xsysconfig/network-scripts/ifdown15
-rwxr-xr-xsysconfig/network-scripts/ifdown-eth36
-rwxr-xr-xsysconfig/network-scripts/ifdown-post5
-rwxr-xr-xsysconfig/network-scripts/ifdown-routes2
-rw-r--r--sysconfig/network-scripts/ifdown-sit3
-rwxr-xr-xsysconfig/network-scripts/ifup10
-rwxr-xr-xsysconfig/network-scripts/ifup-aliases130
-rwxr-xr-xsysconfig/network-scripts/ifup-ctc11
-rwxr-xr-xsysconfig/network-scripts/ifup-eth31
-rwxr-xr-xsysconfig/network-scripts/ifup-plip14
-rw-r--r--sysconfig/network-scripts/ifup-plusb10
-rwxr-xr-xsysconfig/network-scripts/ifup-post7
-rw-r--r--sysconfig/network-scripts/ifup-sit8
-rwxr-xr-xsysconfig/network-scripts/net.hotplug60
-rw-r--r--sysconfig/network-scripts/network-functions50
15 files changed, 180 insertions, 212 deletions
diff --git a/sysconfig/network-scripts/ifdown b/sysconfig/network-scripts/ifdown
index 57e56e3f..597802bf 100755
--- a/sysconfig/network-scripts/ifdown
+++ b/sysconfig/network-scripts/ifdown
@@ -41,9 +41,14 @@ then
exit 0
fi
-if [ "$USE_NM" = "true" ]; then
- echo $"$0: interface ${1} is controlled by NetworkManager; skipping." >&2
- exit 0
+if [ "$_use_nm" = "true" ]; then
+ if [ -n "$UUID" -a -z "$DEVICE" ]; then
+ DEVICE=$(nmcli -t --fields uuid,devices con status | awk -F ':' "\$1 == \"$UUID\" { print \$2 }")
+ fi
+ if [ -n "$DEVICE" ] && ! is_nm_device_unmanaged "$DEVICE" ; then
+ nmcli dev disconnect iface "$DEVICE"
+ exit $?
+ fi
fi
if [ -x /sbin/ifdown-pre-local ]; then
@@ -53,6 +58,10 @@ fi
OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-${DEVICETYPE}"
if [ ! -x ${OTHERSCRIPT} ]; then
+ OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-${TYPE}"
+fi
+
+if [ ! -x ${OTHERSCRIPT} ]; then
OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-eth"
fi
diff --git a/sysconfig/network-scripts/ifdown-eth b/sysconfig/network-scripts/ifdown-eth
index 684cef73..56ea2725 100755
--- a/sysconfig/network-scripts/ifdown-eth
+++ b/sysconfig/network-scripts/ifdown-eth
@@ -56,7 +56,7 @@ fi
fi
if is_bonding_device ${DEVICE} ; then
- for device in $(LANG=C egrep -l "^[[:space:]]*MASTER=\"?${DEVICE}\"?" /etc/sysconfig/network-scripts/ifcfg-*) ; do
+ for device in $(LANG=C egrep -l "^[[:space:]]*MASTER=\"?${DEVICE}\"?[[:space:]]*$" /etc/sysconfig/network-scripts/ifcfg-*) ; do
is_ignored_file "$device" && continue
/sbin/ifdown ${device##*/}
done
@@ -88,7 +88,29 @@ if [[ "${DHCPV6C}" = [Yy1]* ]] && [ -f /var/run/dhcp6c_${DEVICE}.pid ]; then
rm -f /var/run/dhcp6c_${DEVICE}.pid;
fi
-# Kill running dhcp client if present
+retcode=0
+[ -n "$(pidof -x dhclient)" ] && {
+ for VER in "" 6 ; do
+ if [ -f "/var/run/dhclient$VER-${DEVICE}.pid" ]; then
+ dhcpid=$(cat /var/run/dhclient$VER-${DEVICE}.pid)
+ generate_lease_file_name $VER
+ if [[ "$DHCPRELEASE" = [yY1]* ]]; then
+ /sbin/dhclient -r -lf ${LEASEFILE} -pf /var/run/dhclient$VER-${DEVICE}.pid ${DEVICE} >/dev/null 2>&1
+ retcode=$?
+ else
+ kill $dhcpid >/dev/null 2>&1
+ retcode=$?
+ reason=STOP$VER interface=${DEVICE} /sbin/dhclient-script
+ fi
+ if [ -f "/var/run/dhclient$VER-${DEVICE}.pid" ]; then
+ rm -f /var/run/dhclient$VER-${DEVICE}.pid
+ kill $dhcpid >/dev/null 2>&1
+ fi
+ fi
+ done
+}
+
+# Kill running dhcp client if present (supports more clients than the above)
dhcp_client_pids() {
CLIENTS='dhcpcd|pump|dhcpxd|dhclient|zcip'
[ -n "${daemon}" -o "$MII_NOT_SUPPORTED" = "yes" ] && CLIENTS="${CLIENTS}|wpa_supplicant"
@@ -100,7 +122,6 @@ if [ -n "${daemon}" -a "$MII_NOT_SUPPORTED" != "yes" ]; then
/sbin/ifplugd -k -W -i ${DEVICE}
fi
-retcode=0
pids=`dhcp_client_pids`
if [ -n "$pids" ]; then
kill $pids
@@ -140,12 +161,12 @@ fi
if [ -n "${BRIDGE}" ] && [ -x /usr/sbin/brctl ]; then
/sbin/ip link set dev ${DEVICE} down
- /usr/sbin/brctl delif ${BRIDGE} ${DEVICE}
+ /usr/sbin/brctl delif -- ${BRIDGE} ${DEVICE}
# Upon removing a device from a bridge,
# it's necessary to make radvd reload its config
[ -r /var/run/radvd/radvd.pid ] && kill -HUP $(cat /var/run/radvd/radvd.pid)
if [ -d /sys/class/net/${BRIDGE}/brif ] && [ $(ls -1 /sys/class/net/${BRIDGE}/brif | wc -l) -eq 0 ]; then
- /usr/sbin/brctl delbr ${BRIDGE}
+ /usr/sbin/brctl delbr -- ${BRIDGE}
fi
fi
@@ -173,11 +194,8 @@ fi
if [ -n "$VLAN" ]; then
# 802.1q VLAN
- if echo ${DEVICE} | LANG=C grep -Ev '(:)' | LANG=C grep -Eq '(eth|bond)[0-9][0-9]*\.[0-9][0-9]?[0-9]?[0-9]?' \
- || echo ${DEVICE} | LANG=C grep -Eq 'vlan[0-9][0-9]?[0-9]?[0-9]?' ; then
- [ -f /proc/net/vlan/${DEVICE} ] && {
+ if [ -f /proc/net/vlan/${DEVICE} ]; then
ip link delete ${DEVICE} type vlan
- }
fi
fi
diff --git a/sysconfig/network-scripts/ifdown-post b/sysconfig/network-scripts/ifdown-post
index 98fe64cc..78fbd8a6 100755
--- a/sysconfig/network-scripts/ifdown-post
+++ b/sysconfig/network-scripts/ifdown-post
@@ -43,6 +43,11 @@ if ! check_default_route ; then
fi
fi
+# Inform firewall
+if [ -x /usr/bin/firewall-cmd -a "${REALDEVICE}" != "lo" ]; then
+ /usr/bin/firewall-cmd --remove --interface="${DEVICE}" > /dev/null 2>&1
+fi
+
# Notify programs that have requested notification
do_netreport
diff --git a/sysconfig/network-scripts/ifdown-routes b/sysconfig/network-scripts/ifdown-routes
index 3c62498a..0109404f 100755
--- a/sysconfig/network-scripts/ifdown-routes
+++ b/sysconfig/network-scripts/ifdown-routes
@@ -2,7 +2,7 @@
#
# Drops static routes which go through device $1
if [ -z "$1" ]; then
- echo $"usage: ifup-routes <net-device> [<nickname>]"
+ echo $"usage: ifdown-routes <net-device> [<nickname>]"
exit 1
fi
diff --git a/sysconfig/network-scripts/ifdown-sit b/sysconfig/network-scripts/ifdown-sit
index 39e9c50f..e4d07345 100644
--- a/sysconfig/network-scripts/ifdown-sit
+++ b/sysconfig/network-scripts/ifdown-sit
@@ -51,5 +51,8 @@ if [ $? != 0 -a $? != 11 ]; then
exit 0
fi
+# Cleanup additional static routes
+/etc/sysconfig/network-scripts/ifdown-routes ${REALDEVICE}
+
# Cleanup and shut down IPv6-in-IPv4 tunnel device
ipv6_del_tunnel_device $DEVICE
diff --git a/sysconfig/network-scripts/ifup b/sysconfig/network-scripts/ifup
index 914309c0..0e69b72a 100755
--- a/sysconfig/network-scripts/ifup
+++ b/sysconfig/network-scripts/ifup
@@ -68,9 +68,9 @@ then
exit 0
fi
-if [ "$USE_NM" = "true" ]; then
- echo $"$0: interface ${1} is controlled by NetworkManager; skipping." >&2
- exit 0
+if [ "$_use_nm" = "true" -a -n "$UUID" ]; then
+ nmcli con up uuid "$UUID"
+ exit $?
fi
# Ethernet 802.1Q VLAN support
@@ -141,6 +141,10 @@ fi
OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-${DEVICETYPE}"
if [ ! -x ${OTHERSCRIPT} ]; then
+ OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-${TYPE}"
+fi
+
+if [ ! -x ${OTHERSCRIPT} ]; then
OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-eth"
fi
diff --git a/sysconfig/network-scripts/ifup-aliases b/sysconfig/network-scripts/ifup-aliases
index fc21c7b6..a647044f 100755
--- a/sysconfig/network-scripts/ifup-aliases
+++ b/sysconfig/network-scripts/ifup-aliases
@@ -74,43 +74,34 @@ parent_device=$device
cd /etc/sysconfig/network-scripts
. ./network-functions
-# Grab the current configuration of any running aliases device info is placed
-# into variables in the form: rdev_$DEVICE_addr, dev_$DEVICE_mb and
-# rdevip_$IPGLOP. A list of all the devices is created in rdev_LIST.
-
-eval $(LC_ALL= LANG= /sbin/ifconfig | LC_ALL=C sed -n '
-# Alias name: store the number in TMP, ignore the following address if the
-# device name does not match. This may leave a hanging ||, so dummy X=x
-# comands are used to ignore a possible previous condition.
-/^[^[:space:]]*:[0-9A-Za-z_]*/ {
- s|^\([^:]*\):\([0-9A-Za-z_]*\).*$|X=x; TMP="\2"; [ "$device" != "\1" ] \|\| |p
- b
-}
-# Non-alias device: always ignore the following address
-/^[^[:space:]]/ {
- s|^.*$|X=x; true \|\| |p
- b
-}
-# Address: Preceded by a device name, which was converted into
-# condition ||
-# So this triggers only for $device.
-# Add a trailing || (which will be swallowed by X=x) to keep the syntax
-# correct.
-/inet addr:[0-9]*\.[0-9]*\.[0-9]*\.[0-9]* *Bcast:[0-9.]* *Mask:[0-9.]*/ {
- s|^.*inet addr:\(\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\) *Bcast:\([0-9.]*\) *Mask:\([0-9.]*\).*$|eval "rdev_${TMP}_addr=\1; rdev_${TMP}_mb=\7_\6; rdevip_\2_\3_\4_\5=${TMP}; rdev_LIST=\\"\\$rdev_LIST \\${TMP}\\"; " \|\| |p
- b
-}') X=x
-
-if [ -z "$rdev_LIST" ]; then
- no_devices_are_up=yes
-fi
-
-##for DEVNUM in $rdev_LIST ; do
-##eval "
-##echo \"rdev_${DEVNUM}_addr = \$rdev_${DEVNUM}_addr\"
-##echo \"rdev_${DEVNUM}_mb = \$rdev_${DEVNUM}_mb\" ";
-##done
-##echo ""; echo "-----"; echo ""
+# Grab the current configuration of any running aliases, place device info
+# into variables of the form:
+# rdev_<index>_addr = <ip address>
+# rdev_<index>_pb = <prefix>_<broadcast>
+# rdevip_<ipaddress> = <index>
+# Example:
+# rdev_0_addr=192.168.1.1
+# rdev_0_pb=24_192.16.1.255
+# rdevip_192_168_1_1=0
+#
+# A list of all the devices is created in rdev_LIST.
+
+eval $( ip addr show $device label $device:* | \
+ awk 'BEGIN { COUNT=0;LAST_DEV="" } /inet / {
+# Split IP address into address/prefix
+ split($2,IPADDR,"/");
+# Create A_B_C_D IP address form
+ IP_ADDR=IPADDR[1];
+ gsub(/\./,"_",IP_ADDR);
+# Split device into device:index
+ split($NF,DEV,":");
+# Update last device
+ LAST_DEV=LAST_DEV " " DEV[2];
+ printf("rdev_%s_addr=%s\nrdevip_%s=%s\nrdev_%s_pb=%s_%s\nrdev_LIST=\"%s\"\n",
+ DEV[2],IPADDR[1],IP_ADDR,DEV[2],DEV[2],IPADDR[2],$4,LAST_DEV);
+ } END {
+ if(LAST_DEV == "") print "no_devices_are_up=yes"
+ }' );
#
# Store configuration of the parent device and network
@@ -130,6 +121,7 @@ eval ` (
}
eval ` (
. ./$PARENTCONFIG;
+ echo default_PREFIX=$PREFIX\;;
echo default_NETMASK=$NETMASK\;;
echo default_BROADCAST=$BROADCAST\;;
echo default_GATEWAY=$GATEWAY\;;
@@ -141,6 +133,7 @@ function ini_env ()
{
DEVICE=""
IPADDR=""
+ PREFIX=$default_PREFIX
NETMASK=$default_NETMASK
BROADCAST=$default_BROADCAST
GATEWAY=$default_GATEWAY
@@ -150,9 +143,8 @@ function ini_env ()
function is_default_gateway ()
{
- LC_ALL=C /sbin/route -n \
- | awk '$1 == "0.0.0.0" && $2 == "'"$1"'" { found = 1; }
- END { exit found == 0; }'
+ LC_ALL=C /sbin/ip route ls default scope global \
+ | awk '$3 == "'"$1"'" { found = 1; } END { exit found == 0; }'
}
#
@@ -193,37 +185,17 @@ function new_interface ()
return 1
fi
- if [ -z "$NETMASK" ]; then
- eval $(/bin/ipcalc --netmask ${IPADDR})
+ if [ -z "$NETMASK" -a -z "$PREFIX" ]; then
+ net_log $"error iN $FILE: didn't specify netmask or prefix"
fi
- if [ -z "$BROADCAST" -o "$BROADCAST" = "$default_BROADCAST" ]; then
- eval $(/bin/ipcalc --broadcast ${IPADDR} ${NETMASK})
- nma=$NETMASK; nmb=${nma#*.}; nmc=${nmb#*.};
- NMGLOP="${nma%%.*}_${nmb%%.*}_${nmc%%.*}_${nmc#*.}";
- if [ ${nma%%.*} -eq 0 ]; then ipnm_a=0; else ipnm_a=${ipa%%.*}; fi
- if [ ${nmb%%.*} -eq 0 ]; then ipnm_b=0; else ipnm_b=${ipb%%.*}; fi
- if [ ${nmc%%.*} -eq 0 ]; then ipnm_c=0; else ipnm_c=${ipc%%.*}; fi
- if [ ${nmc#*.} -eq 0 ]; then ipnm_d=0; else ipnm_d=${ipc#*.}; fi
- CACHENAME="${NMGLOP}_${ipnm_a}_${ipnm_b}_${ipnm_c}_${ipnm_d}"
- eval "
- if [ -z \"\$bcastcache_${CACHENAME}\" ]; then
- eval $(/bin/ipcalc --broadcast $IPADDR $NETMASK)
- bcastcache_${CACHENAME}=\$BROADCAST
- else
- BROADCAST=\$bcastcache_${CACHENAME}
- fi
- ";
+ if [ -z "$PREFIX" ]; then
+ eval $(/bin/ipcalc --prefix ${IPADDR} ${NETMASK})
fi
-##echo "";
-##echo "----------------------------"
-##echo "device = $DEVICE"
-##echo "ipaddr = $IPADDR"
-##echo "netmask = $NETMASK"
-##echo "broadcast = $BROADCAST"
-##echo "devnum = $DEVNUM";
-##echo "";
+ if [ -z "$BROADCAST" -o "$BROADCAST" = "$default_BROADCAST" ]; then
+ eval $(/bin/ipcalc --broadcast ${IPADDR}/${PREFIX})
+ fi
if [ "$no_devices_are_up" = "yes" ]; then
setup_this=yes
@@ -233,7 +205,7 @@ function new_interface ()
eval "
rdev_addr=\$rdev_${DEVNUM}_addr;
- rdev_mb=\$rdev_${DEVNUM}_mb;
+ rdev_pb=\$rdev_${DEVNUM}_pb;
rdev_mark=\$rdev_${DEVNUM}_mark;
rdevip=\$rdevip_${IPGLOP};
";
@@ -241,15 +213,14 @@ function new_interface ()
if [ -n "$rdev_addr" ]; then
if [ "$rdev_addr" = "${IPADDR}" ]; then
newmark=keep
- if [ "$rdev_mb" != "${NETMASK}_${BROADCAST}" ]; then
+ if [ "$rdev_pb" != "${PREFIX}_${BROADCAST}" ]; then
setup_this=freshen
else
setup_this=no
fi
else
if [ "$rdev_mark" != "remove" ]; then
-##echo "removing device $parent_device:${DEVNUM} (devnum conflict)"
- /sbin/ifconfig $parent_device:${DEVNUM} down
+ /sbin/ip addr flush dev $parent_device label $parent_device:${DEVNUM}
do_netreport=yes
fi
newmark=remove
@@ -272,8 +243,7 @@ function new_interface ()
fi
if [ "$mark_remove" != "remove" ]; then
eval " rdev_${rdevip}_mark=remove ";
-##echo "removing device $parent_device:$rdevip (ipaddr conflict)"
- /sbin/ifconfig $parent_device:$rdevip down
+ /sbin/ip addr flush dev $parent_device label $parent_device:$rdevip
do_netreport=yes
fi
fi
@@ -282,15 +252,11 @@ function new_interface ()
if [ "$setup_this" = "freshen" ] ; then
# we can do the freshen stuff right now
-##echo "freshening device $DEVICE"
- /sbin/ifconfig $DEVICE netmask $NETMASK broadcast $BROADCAST;
+ /sbin/ip addr change ${IPADDR}/${PREFIX} brd ${BROADCAST}
fi
if [ "$setup_this" = "yes" ] ; then
-
-##echo "setting up device $DEVICE"
-
- /sbin/ifconfig ${DEVICE} ${IPADDR} netmask ${NETMASK} broadcast ${BROADCAST}
+ /sbin/ip addr add ${IPADDR}/${PREFIX} brd ${BROADCAST} dev ${parent_device} label ${DEVICE}
[ "$IPV6INIT" = "yes" ] && /etc/sysconfig/network-scripts/ifup-ipv6 ${DEVICE}
@@ -302,8 +268,7 @@ function new_interface ()
\( -z "${GATEWAYDEV}" -o "${GATEWAYDEV}" = "${DEVICE}" \) ]; then
# set up default gateway, if it isn't already there
if ! is_default_gateway "$GATEWAY"; then
- route add default gw ${GATEWAY} \
- ${METRIC:+metric $METRIC} ${DEVICE}
+ ip route replace default ${METRIC:+metric $METRIC} via ${GATEWAY} dev ${DEVICE}
fi
fi
@@ -365,8 +330,7 @@ done
for DEVNUM in $rdev_LIST ; do
eval " rdev_mark=\$rdev_${DEVNUM}_mark ";
if [ -z "$rdev_mark" ]; then
- ##echo "removing device $parent_device:${DEVNUM} (lingering)"
- /sbin/ifconfig $parent_device:${DEVNUM} down
+ /sbin/ip addr flush dev $parent_device label $parent_device:${DEVNUM}
do_netreport=yes
fi
done
diff --git a/sysconfig/network-scripts/ifup-ctc b/sysconfig/network-scripts/ifup-ctc
index e268d7cc..39d6a09c 100755
--- a/sysconfig/network-scripts/ifup-ctc
+++ b/sysconfig/network-scripts/ifup-ctc
@@ -23,10 +23,11 @@ if [ "$2" = "boot" -a "${ONBOOT}" = "no" ]
then
exit
fi
-[ -n "${MTU}" ] && opts="${opts} mtu ${MTU}"
-
-ifconfig ${DEVICE} ${IPADDR} ${opts} pointopoint ${GATEWAY} netmask ${NETMASK}
+[ -n "${MTU}" ] && ip link set dev ${DEVICE} mtu ${MTU}
+[ -z "$PREFIX" ] && eval $(/bin/ipcalc --prefix ${IPADDR} ${NETMASK})
+ip addr add ${IPADDR} peer ${GATEWAY}/${PREFIX} dev ${DEVICE}
+ip link set up dev ${DEVICE}
# Wait for the device to come up - the chandev'ified ctc driver can take
# quite a while...
timeout=0
@@ -39,13 +40,13 @@ while ! ping -w 30 -c 1 ${GATEWAY} &>/dev/null; do
done
if [ "${NETWORK}" != "" ] ; then
- route add -host ${GATEWAY} metric 1 ${DEVICE}
+ ip route add to ${GATEWAY} metric 1 dev ${DEVICE}
fi
if [ "${GATEWAY}" != "" ]; then
if [ "${GATEWAYDEV}" = "" -o "${GATEWAYDEV}" = "${DEVICE}" ]; then
# set up default gateway
- route add default gw ${GATEWAY} ${METRIC:+metric $METRIC}
+ ip route replace default ${METRIC:+metric $METRIC} via ${GATEWAY}
fi
fi
diff --git a/sysconfig/network-scripts/ifup-eth b/sysconfig/network-scripts/ifup-eth
index 4db7ba59..e51fdf53 100755
--- a/sysconfig/network-scripts/ifup-eth
+++ b/sysconfig/network-scripts/ifup-eth
@@ -66,10 +66,10 @@ if [ "${TYPE}" = "Bridge" ]; then
exit 1
fi
if [ ! -d /sys/class/net/${DEVICE}/bridge ]; then
- /usr/sbin/brctl addbr ${DEVICE} || exit 1
+ /usr/sbin/brctl addbr -- ${DEVICE} || exit 1
fi
- [ -n "${DELAY}" ] && /usr/sbin/brctl setfd ${DEVICE} ${DELAY}
- [ -n "${STP}" ] && /usr/sbin/brctl stp ${DEVICE} ${STP}
+ [ -n "${DELAY}" ] && /usr/sbin/brctl setfd -- ${DEVICE} ${DELAY}
+ [ -n "${STP}" ] && /usr/sbin/brctl stp -- ${DEVICE} ${STP}
# add the bits to setup driver parameters here
for arg in $BRIDGING_OPTS ; do
key=${arg%%=*};
@@ -212,14 +212,14 @@ if [ "$ISALIAS" = no ] && is_bonding_device ${DEVICE} ; then
if ! grep -q ${value#+} /sys/class/net/${DEVICE}/bonding/$key; then
echo "$value" > /sys/class/net/${DEVICE}/bonding/$key
fi
- else
+ elif [ "${key}" != "primary" ]; then
echo $value > /sys/class/net/${DEVICE}/bonding/$key
fi
done
/sbin/ip link set dev ${DEVICE} up
[ -n "${LINKDELAY}" ] && /bin/sleep ${LINKDELAY}
- for device in $(LANG=C egrep -l "^[[:space:]]*MASTER=\"?${DEVICE}\"?" /etc/sysconfig/network-scripts/ifcfg-*) ; do
+ for device in $(LANG=C egrep -l "^[[:space:]]*MASTER=\"?${DEVICE}\"?[[:space:]]*$" /etc/sysconfig/network-scripts/ifcfg-*) ; do
is_ignored_file "$device" && continue
/sbin/ifup ${device##*/}
done
@@ -237,13 +237,13 @@ fi
# If the device is part of a bridge, add the device to the bridge
if [ -n "${BRIDGE}" ] && [ -x /usr/sbin/brctl ]; then
if [ ! -d /sys/class/net/${BRIDGE}/bridge ]; then
- /usr/sbin/brctl addbr ${BRIDGE} 2>/dev/null
+ /usr/sbin/brctl addbr -- ${BRIDGE} 2>/dev/null
fi
/sbin/ip addr flush dev ${DEVICE} 2>/dev/null
/sbin/ip link set dev ${DEVICE} up
ethtool_set
[ -n "${LINKDELAY}" ] && /bin/sleep ${LINKDELAY}
- /usr/sbin/brctl addif ${BRIDGE} ${DEVICE}
+ /usr/sbin/brctl addif -- ${BRIDGE} ${DEVICE}
# add the bits to setup driver parameters here
for arg in $BRIDGING_OPTS ; do
key=${arg%%=*};
@@ -342,7 +342,9 @@ case $(basename $DHCP_CLIENT) in
else
ONESHOT="-1"
fi
- DHCP_ARGS="$DHCP_ARGS $ONESHOT -q -lf /var/lib/dhcp/dhclient-${DEVICE}.leases -pf /var/run/dhclient-${DEVICE}.pid -cf /etc/dhclient-${DEVICE}.conf $DEVICE"
+ generate_config_file_name
+ generate_lease_file_name
+ DHCP_ARGS="$DHCP_ARGS $ONESHOT -q ${DHCLIENTCONF} -lf ${LEASEFILE} -pf /var/run/dhclient-${DEVICE}.pid $DEVICE"
if [ -n "$DHCP_HOSTNAME" ]; then
if [ ! -e /etc/dhclient-${DEVICE}.conf ] || ! grep -q "[^# ]*send *host-name" /etc/dhclient-${DEVICE}.conf; then
echo "send host-name \"${DHCP_HOSTNAME}\"; $BLURB" >> /etc/dhclient-${DEVICE}.conf
@@ -365,13 +367,6 @@ if [ -w /etc/dhclient-${DEVICE}.conf ] && [ -x /sbin/dhclient ] ; then
fi
if [ -n "${DYNCONFIG}" ]; then
- # copy any lease obtained by the initrd
- for file in /dev/.dhclient-${DEVICE}.leases /dev/.initramfs/net.${DEVICE}.lease /run/initramfs/net.${DEVICE}.lease; do
- if [ -f "${file}" ]; then
- mv -f $file /var/lib/dhclient/dhclient-${DEVICE}.leases
- [ -x /sbin/restorecon ] && restorecon /var/lib/dhclient/dhclient-${DEVICE}.leases > /dev/null 2>&1
- fi
- done
echo
echo -n $"Determining IP information for ${DEVICE}..."
if [[ "${PERSISTENT_DHCLIENT}" != [yY1]* ]] && check_link_down ${DEVICE}; then
@@ -450,7 +445,7 @@ else
fi
if ! LC_ALL=C ip addr ls ${REALDEVICE} | LC_ALL=C grep -q "${ipaddr[$idx]}/${prefix[$idx]}" ; then
- [ "${REALDEVICE}" != "lo" ] && \
+ [ "${REALDEVICE}" != "lo" ] && [ "${arpcheck[$idx]}" != "no" ] && \
if ! /sbin/arping -q -c 2 -w 3 -D -I ${REALDEVICE} ${ipaddr[$idx]} ; then
net_log $"Error, some other host already uses address ${ipaddr[$idx]}."
mdv-network-event connection_failure ${DEVICE}
@@ -507,7 +502,9 @@ fi
# IPv6 initialisation?
/etc/sysconfig/network-scripts/ifup-ipv6 ${CONFIG}
if [[ "${DHCPV6C}" = [Yy1]* ]] && [ -x /sbin/dhclient ]; then
- /sbin/dhclient -6 -1 ${DHCPV6C_OPTIONS} -lf /var/lib/dhclient/dhclient6-${DEVICE}.leases -pf /var/run/dhclient6-${DEVICE}.pid -H ${DHCP_HOSTNAME:-${HOSTNAME%%.*}} ${DEVICE}
+ generate_config_file_name 6
+ generate_lease_file_name 6
+ /sbin/dhclient -6 -1 ${DHCPV6C_OPTIONS} ${DHCLIENTCONF} -lf ${LEASEFILE} -pf /var/run/dhclient6-${DEVICE}.pid -H ${DHCP_HOSTNAME:-${HOSTNAME%%.*}} ${DEVICE}
fi
if [ "${IPX}" = yes ]; then
diff --git a/sysconfig/network-scripts/ifup-plip b/sysconfig/network-scripts/ifup-plip
index 48bcc2ca..c3b9efa1 100755
--- a/sysconfig/network-scripts/ifup-plip
+++ b/sysconfig/network-scripts/ifup-plip
@@ -11,21 +11,17 @@ then
exit
fi
-ifconfig ${DEVICE} ${IPADDR} pointopoint ${REMIP}
-route add -net ${NETWORK} netmask ${NETMASK} ${DEVICE}
-
-# this is broken! it's only here to keep compatibility with old RH systems
-if [ "${GATEWAY}" != "" -a "${GATEWAY}" != "none" ]
-then
- route add default gw ${GATEWAY} metric ${METRIC:-1} ${DEVICE}
-fi
+[ -z "$PREFIX" ] && eval $(/bin/ipcalc --prefix ${IPADDR} ${NETMASK})
+ip addr add ${IPADDR} peer ${REMIP}/${PREFIX} dev ${DEVICE}
+ip link set up dev ${DEVICE}
+ip route add ${NETWORK} dev ${DEVICE}
. /etc/sysconfig/network
if [ "${GATEWAY}" != "" ]; then
if [ "${GATEWAYDEV}" = "" -o "${GATEWAYDEV}" = "${DEVICE}" ]; then
# set up default gateway
- route add default gw ${GATEWAY} ${METRIC:+metric $METRIC}
+ ip route replace default ${METRIC:+metric $METRIC} via ${GATEWAY}
fi
fi
diff --git a/sysconfig/network-scripts/ifup-plusb b/sysconfig/network-scripts/ifup-plusb
index e185e647..ce5a0321 100644
--- a/sysconfig/network-scripts/ifup-plusb
+++ b/sysconfig/network-scripts/ifup-plusb
@@ -22,19 +22,21 @@ then
exit
fi
+[ -z "$PREFIX" ] && eval $(/bin/ipcalc --prefix ${IPADDR} ${NETMASK})
+
if [ ${BROADCAST} != "" ] ; then
- ifconfig ${DEVICE} ${IPADDR} pointopoint ${REMIP} netmask ${NETMASK}
-broadcast ${BROADCAST}
+ ip addr add ${IPADDR} peer ${REMIP}/${PREFIX} broadcast ${BROADCAST} dev ${DEVICE}
else
- ifconfig ${DEVICE} ${IPADDR} pointopoint ${REMIP} netmask ${NETMASK}
+ ip addr add ${IPADDR} peer ${REMIP}/${PREFIX} dev ${DEVICE}
fi
+ip link set up dev ${DEVICE}
. /etc/sysconfig/network
if [ "${GATEWAY}" != "" ]; then
if [ "${GATEWAYDEV}" = "" -o "${GATEWAYDEV}" = "${DEVICE}" ]; then
# set up default gateway
- route add default gw ${GATEWAY} ${METRIC:+metric $METRIC}
+ ip route replace default ${METRIC:+metric $METRIC} via ${GATEWAY}
fi
fi
diff --git a/sysconfig/network-scripts/ifup-post b/sysconfig/network-scripts/ifup-post
index a751bf38..2937bd3d 100755
--- a/sysconfig/network-scripts/ifup-post
+++ b/sysconfig/network-scripts/ifup-post
@@ -1,4 +1,4 @@
-#!/bin/sh
+
cd /etc/sysconfig/network-scripts
. ./network-functions
@@ -97,6 +97,11 @@ if [ "$2" = "boot" -a \
fi
fi
+# Inform firewall which network zone (empty means default) this interface belongs to
+if [ -x /usr/bin/firewall-cmd -a "${REALDEVICE}" != "lo" ]; then
+ /usr/bin/firewall-cmd --zone="${ZONE}" --change --interface="${DEVICE}" > /dev/null 2>&1
+fi
+
# Notify programs that have requested notification
do_netreport
diff --git a/sysconfig/network-scripts/ifup-sit b/sysconfig/network-scripts/ifup-sit
index 9e55146b..1d395e99 100644
--- a/sysconfig/network-scripts/ifup-sit
+++ b/sysconfig/network-scripts/ifup-sit
@@ -107,9 +107,5 @@ if [ -f /etc/sysconfig/static-routes-ipv6 ]; then
done
fi
-# Setup additional static IPv6 routes (newer config style)
-if [ -f "/etc/sysconfig/network-scripts/route6-$REALDEVICE" ]; then
- sed -ne 's/#.*//' -e '/[^[:space:]]/p' "/etc/sysconfig/network-scripts/route6-$REALDEVICE" | while read line; do
- /sbin/ip -6 route add $line
- done
-fi
+# Setup static routes
+/etc/sysconfig/network-scripts/ifup-routes ${REALDEVICE}
diff --git a/sysconfig/network-scripts/net.hotplug b/sysconfig/network-scripts/net.hotplug
deleted file mode 100755
index b10131d1..00000000
--- a/sysconfig/network-scripts/net.hotplug
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/bin/sh
-
-# Don't do anything if the network is stopped
-if [ ! -f /var/lock/subsys/network ]; then
- exit 0
-fi
-if [ -f /dev/.in_sysinit ] ; then
- exit 0
-fi
-
-. /etc/sysconfig/network-scripts/network-functions
-
-if [ "$INTERFACE" = "" ]; then
- exit 1
-fi
-
-[ "$(cat /sys/class/net/$INTERFACE/type)" != "1" ] && exit 0
-
-case $ACTION in
-add|register)
-
- case $INTERFACE in
- # interfaces that are brought up as a part of configuration
- ppp*|ippp*|isdn*|plip*|lo*|irda*|dummy*|ipsec*|tun*|tap*)
- exit 0
- ;;
- # interfaces that are registered then brought up
- *)
- export IN_HOTPLUG=1
- if [ -x /sbin/ifup ]; then
- addr=$(get_hwaddr ${INTERFACE})
- if [ -n "$addr" ]; then
- nconfig=$(get_config_by_hwaddr ${addr})
- [ -n "$nconfig" ] && INTERFACE=$nconfig
- fi
- exec /sbin/ifup $INTERFACE
- fi
- ;;
- esac
- ;;
-
-remove|unregister)
- case $INTERFACE in
- # interfaces that are brought down as part of deconfiguration
- ppp*|ippp*|isdn*|plip*|lo*|irda*|dummy*|ipsec*|tun*|tap*)
- exit 0
- ;;
- *)
- export IN_HOTPLUG=1
- if [ -x /sbin/ifdown ]; then
- exec /sbin/ifdown $INTERFACE
- fi
- ;;
- esac
- ;;
-
-*)
- exit 1 ;;
-
-esac
diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions
index fc61c2b9..dae790ad 100644
--- a/sysconfig/network-scripts/network-functions
+++ b/sysconfig/network-scripts/network-functions
@@ -31,7 +31,7 @@ get_config_by_device ()
get_config_by_hwaddr ()
{
- LANG=C grep -il "^[[:space:]]*HWADDR=${1}\([[:space:]#]\|$\)" /etc/sysconfig/network-scripts/ifcfg-* \
+ LANG=C grep -il "^[[:space:]]*HWADDR=\"\?${1}\"\?\([[:space:]#]\|$\)" /etc/sysconfig/network-scripts/ifcfg-* \
| LC_ALL=C sed -e "$__sed_discard_ignored_files"
}
@@ -56,6 +56,31 @@ get_device_by_hwaddr ()
LANG=C ip -o link | awk -F ': ' -vIGNORECASE=1 '!/link\/ieee802\.11/ && /'"$1"'/ { print $2 }'
}
+get_uuid_by_config ()
+{
+ dbus-send --system --print-reply --dest=com.redhat.ifcfgrh1 /com/redhat/ifcfgrh1 com.redhat.ifcfgrh1.GetIfcfgDetails string:"/etc/sysconfig/network-scripts/$1" 2>/dev/null | awk -F '"' '/string / { print $2 }'
+}
+
+generate_lease_file_name () {
+ local ver=$1
+ LEASEFILE="/var/lib/dhclient/dhclient$ver-${DEVICE}.leases"
+ if [ -f $LEASEFILE ]; then
+ return
+ fi
+ LEASEFILE="/var/lib/dhclient/dhclient$ver-${UUID}-${DEVICE}.lease"
+}
+
+generate_config_file_name () {
+ local ver=$1
+ if [ -s /etc/dhcp/dhclient$ver-${DEVICE}.conf ]; then
+ DHCLIENTCONF="-cf /etc/dhcp/dhclient$ver-${DEVICE}.conf";
+ elif [ -s /etc/dhclient$ver-${DEVICE}.conf ]; then
+ DHCLIENTCONF="-cf /etc/dhclient$ver-${DEVICE}.conf";
+ else
+ DHCLIENTCONF='';
+ fi
+}
+
need_config ()
{
local nconfig
@@ -147,7 +172,10 @@ source_config ()
else
ISALIAS=no
fi
- ! is_false $NM_CONTROLLED && is_nm_running && USE_NM=true
+ ! is_false $NM_CONTROLLED && is_nm_running && _use_nm=true
+ if [ -z "$UUID" -a "$_use_nm" = "true" ]; then
+ UUID=$(get_uuid_by_config $CONFIG)
+ fi
}
ethtool_set()
@@ -178,6 +206,7 @@ expand_config ()
prefix[$i]=$(eval echo '$'PREFIX$idx)
netmask[$i]=$(eval echo '$'NETMASK$idx)
broadcast[$i]=$(eval echo '$'BROADCAST$idx)
+ arpcheck[$i]=$(eval echo '$'ARPCHECK$idx)
if [ "${prefix[$i]}x" != "x" ]; then
val=$(/bin/ipcalc --netmask "${ipaddr[$i]}/${prefix[$i]}")
@@ -198,6 +227,12 @@ expand_config ()
val=$(/bin/ipcalc --broadcast ${ipaddr[$i]} ${netmask[$i]})
broadcast[$i]=${val##BROADCAST=}
fi
+
+ if [ "${arpcheck[$i]}x" != "x" ]; then
+ arpcheck[$i]=${arpcheck[$i]##ARPCHECK=}
+ arpcheck[$i]=${arpcheck[$i],,*}
+ fi
+
i=$((i+1))
done
@@ -329,19 +364,12 @@ set_hostname ()
check_device_down ()
{
- if echo $1 | grep -q ':' ; then
- if LC_ALL=C ifconfig -a 2>/dev/null | grep -q $1 ; then
- return 1
- else
- return 0
- fi
- else
- if LC_ALL=C ip -o link 2>/dev/null | grep -q "$1[:@].*,UP" ; then
+ [ ! -d /sys/class/net/$1 ] && return 0
+ if LC_ALL=C ip -o link show dev $1 2>/dev/null | grep -q ",UP" ; then
return 1
else
return 0
fi
- fi
}
check_link_down ()