From: Michael Tremer Date: Sat, 21 Feb 2009 22:19:22 +0000 (+0100) Subject: Several networking stuff. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b5238f5767201378b650a7b296cc83358a924db4;p=ipfire-3.x.git Several networking stuff. --- diff --git a/src/firewall/firewall b/src/firewall/firewall index d5197bbae..8d6c905ef 100644 --- a/src/firewall/firewall +++ b/src/firewall/firewall @@ -33,6 +33,8 @@ # # ############################################################################### +PATH=/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin + LIBDIR=/usr/lib/firewall function include() { @@ -92,12 +94,18 @@ while [ "$#" -gt 0 ]; do reload) ;; restart) + # XXX Do restart function here + _stop + _start + _exit $@ ;; start) _start _exit $@ ;; stop) + _stop + _exit $@ ;; *) usage diff --git a/src/firewall/functions b/src/firewall/functions index 91fd21cb7..567973dc2 100644 --- a/src/firewall/functions +++ b/src/firewall/functions @@ -96,4 +96,9 @@ function _start() { # Need to get all zones here iptables_commit + touch /var/lock/subsys/firewall +} + +function _stop() { + rm -f /var/lock/subsys/firewall } diff --git a/src/initscripts/networking/functions b/src/initscripts/networking/functions index 98ecb1c88..ee65e3c63 100644 --- a/src/initscripts/networking/functions +++ b/src/initscripts/networking/functions @@ -19,7 +19,11 @@ # # ############################################################################### -. /etc/sysconfig/network +[ -f "/etc/sysconfig/network" ] && . /etc/sysconfig/network + +function is_mac() { + egrep "^[0-9a-f][0-9a-f]\:[0-9a-f][0-9a-f]\:[0-9a-f][0-9a-f]\:[0-9a-f][0-9a-f]\:[0-9a-f][0-9a-f]\:[0-9a-f][0-9a-f]$" <<<$1 +} function get_device_by_mac() { local mac=$1 @@ -38,3 +42,15 @@ function get_mac_by_device() { fi return 1 } + +function device_exists() { + ip link show ${1} &>/dev/null +} + +function zone_exists() { + [ -e "$CONFIG_ZONES/$1" ] #|| device_exists $@ +} + +function bridge_devices() { + : #TODO +} diff --git a/src/initscripts/networking/net-hotplug b/src/initscripts/networking/net-hotplug index a2d4cd3a4..fd79681e5 100644 --- a/src/initscripts/networking/net-hotplug +++ b/src/initscripts/networking/net-hotplug @@ -27,6 +27,8 @@ fi MAC=$(get_mac_by_device ${INTERFACE}) +logger -t net "Received uevent for $INTERFACE ($ACTION)." + case $ACTION in add|register) # Don't do anything if the network is stopped diff --git a/src/initscripts/networking/services/bridge-slave b/src/initscripts/networking/services/bridge-slave index 3780ba998..16b9eb7e2 100644 --- a/src/initscripts/networking/services/bridge-slave +++ b/src/initscripts/networking/services/bridge-slave @@ -17,20 +17,26 @@ interface=${IFCONFIG##*/} +. /etc/init.d/networking/functions + case "${2}" in up) + if ! device_exists ${BRIDGE}; then + MESSAGE="Bringing up bridge ${BRIDGE}..." + brctl addbr ${BRIDGE} || failed=1 + ip link set ${BRIDGE} up || failed=1 + (exit ${failed}) + evaluate_retval + fi + MESSAGE="Adding slave interface ${interface} to the ${1} interface..." - ip link set ${interface} up || failed=1 - brctl addif ${1} ${interface} || failed=1 - (exit ${failed}) + brctl addif ${1} ${interface} evaluate_retval ;; down) MESSAGE="Removing slave interface ${interface} from the ${1} interface..." - brctl delif ${1} ${interface} || failed=1 - ip link set ${interface} down || failed=1 - (exit ${failed}) + brctl delif ${1} ${interface} evaluate_retval ;;