summaryrefslogtreecommitdiffstats
path: root/source/n/network-scripts/scripts/rc.inet1
diff options
context:
space:
mode:
author Patrick J Volkerding <volkerdi@slackware.com>2012-09-26 01:10:42 +0000
committer Eric Hameleers <alien@slackware.com>2018-05-31 22:51:55 +0200
commit9664bee729d487bcc0a0bc35859f8e13d5421c75 (patch)
treeb428a16618e36ed864a8d76ea3435e19a452bf90 /source/n/network-scripts/scripts/rc.inet1
parent75a4a592e5ccda30715f93563d741b83e0dcf39e (diff)
downloadcurrent-9664bee729d487bcc0a0bc35859f8e13d5421c75.tar.gz
current-9664bee729d487bcc0a0bc35859f8e13d5421c75.tar.xz
Slackware 14.0slackware-14.0
Wed Sep 26 01:10:42 UTC 2012 Slackware 14.0 x86_64 stable is released! We're perfectionists here at Slackware, so this release has been a long time a-brewing. But we think you'll agree that it was worth the wait. Slackware 14.0 combines modern components, ease of use, and flexible configuration... our "KISS" philosophy demands it. The ISOs are off to be replicated, a 6 CD-ROM 32-bit set and a dual-sided 32-bit/64-bit x86/x86_64 DVD. Please consider supporting the Slackware project by picking up a copy from store.slackware.com. We're taking pre-orders now, and offer a discount if you sign up for a subscription. Thanks to everyone who helped make this happen. The Slackware team, the upstream developers, and (of course) the awesome Slackware user community. Have fun! :-)
Diffstat (limited to 'source/n/network-scripts/scripts/rc.inet1')
-rw-r--r--source/n/network-scripts/scripts/rc.inet132
1 files changed, 31 insertions, 1 deletions
diff --git a/source/n/network-scripts/scripts/rc.inet1 b/source/n/network-scripts/scripts/rc.inet1
index 4e6c7aa00..dc325f477 100644
--- a/source/n/network-scripts/scripts/rc.inet1
+++ b/source/n/network-scripts/scripts/rc.inet1
@@ -72,6 +72,29 @@ lo_down() {
# INTERFACE FUNCTIONS #
#######################
+# Function to assemble a bridge interface.
+br_open() {
+ # argument is 'i' - the position of this interface in the IFNAME array.
+ /sbin/brctl addbr ${IFNAME[$1]}
+ for BRIF in $(echo ${BRNICS[$1]}); do
+ /sbin/ifconfig $BRIF down
+ /sbin/ifconfig $BRIF 0.0.0.0 promisc up
+ /sbin/brctl addif ${IFNAME[$1]} $BRIF
+ done
+}
+
+# Function to disassemble a bridge interface.
+br_close() {
+ # argument is 'i' - the position of this interface in the IFNAME array.
+ #for BRIF in $(echo ${BRNICS[$1]}); do
+ for BRIF in $(ls --indicator-style=none /sys/class/net/${IFNAME[$1]}/brif/)
+ do
+ /sbin/brctl delif ${IFNAME[$1]} $BRIF
+ done
+ /sbin/ifconfig ${IFNAME[$1]} down
+ /sbin/brctl delbr ${IFNAME[$1]}
+}
+
# Function to bring up a network interface. If the interface is
# already up or does not yet exist (perhaps because the kernel driver
# is not loaded yet), do nothing.
@@ -82,6 +105,8 @@ if_up() {
[ "${IFNAME[$i]}" = "${1}" ] && break
i=$(($i+1))
done
+ # If the interface is a bridge, then create it first:
+ [ -n "${BRNICS[$i]}" ] && br_open $i
# If the interface isn't in the kernel yet (but there's an alias for it in
# modules.conf), then it should be loaded first:
if ! grep `echo ${1}: | cut -f 1 -d :`: /proc/net/dev 1> /dev/null ; then # no interface yet
@@ -92,7 +117,7 @@ if_up() {
fi
if grep `echo ${1}: | cut -f 1 -d :`: /proc/net/dev 1> /dev/null ; then # interface exists
if ! /sbin/ifconfig | grep -w "${1}" 1>/dev/null || \
- ! /sbin/ifconfig ${1} | grep "inet addr" 1> /dev/null ; then # interface not up or not configured
+ ! /sbin/ifconfig ${1} | grep -w inet 1> /dev/null ; then # interface not up or not configured
if [ ! "${HWADDR[$i]}" = "" ]; then # Set hardware address _before_ the interface goes up:
echo "/etc/rc.d/rc.inet1: /sbin/ifconfig ${1} hw ether ${HWADDR[$i]}" | $LOGGER
/sbin/ifconfig ${1} hw ether ${HWADDR[$i]}
@@ -105,6 +130,9 @@ if_up() {
. /etc/rc.d/rc.wireless ${1} start # Initialize any wireless parameters
fi
if [ "${USE_DHCP[$i]}" = "yes" ]; then # use DHCP to bring interface up
+ # Clear DHCP_OPTIONS before adding new options to it:
+ unset DHCP_OPTIONS
+ # Set DHCP_OPTIONS for this interface:
[ ${DHCP_HOSTNAME[$i]} ] && DHCP_OPTIONS="-h ${DHCP_HOSTNAME[$i]}"
[ "${DHCP_KEEPRESOLV[$i]}" = "yes" ] && DHCP_OPTIONS="$DHCP_OPTIONS -C resolv.conf"
[ "${DHCP_KEEPNTP[$i]}" = "yes" ] && DHCP_OPTIONS="$DHCP_OPTIONS -C ntp.conf"
@@ -179,6 +207,8 @@ if_down() {
if [ -x /etc/rc.d/rc.wireless ]; then
. /etc/rc.d/rc.wireless ${1} stop # Kill wireless daemons if any.
fi
+ # If the interface is a bridge, then destroy it now:
+ [ -n "${BRNICS[$i]}" ] && br_close $i
fi
}