[SM-Commit] GIT changes to master grimoire by David Brown (a8fa20e62935d646412dc44a2eaaf570c406869f)

David Brown scm at sourcemage.org
Tue Sep 4 22:20:45 EDT 2007


GIT changes to master grimoire by David Brown <dmlb2000 at gmail.com>:

 net/net-tools/HISTORY |    4 ++++
 net/net-tools/ifdown  |   11 +++++++++++
 net/net-tools/ifup    |   18 ++++++++++++++++++
 3 files changed, 33 insertions(+)

New commits:
commit a8fa20e62935d646412dc44a2eaaf570c406869f
Author: David Brown <dmlb2000 at gmail.com>
Commit: David Brown <dmlb2000 at gmail.com>

    net-tools added BRIDGE_PORTS variable so that bridges can be created around interfaces

diff --git a/net/net-tools/HISTORY b/net/net-tools/HISTORY
index e2fd344..e6701ce 100644
--- a/net/net-tools/HISTORY
+++ b/net/net-tools/HISTORY
@@ -1,3 +1,7 @@
+2007-09-04 David Brown <dmlb2000 at gmail.com>
+	* ifup, ifdown: added BRIDGE_PORTS for creating bridges around 
+	  interfaces.
+
 2007-09-01 Jaka Kranjc <lynxlynxlynx at sourcemage.org>
 	* CONFIGURE: fixed typo #13970
 
diff --git a/net/net-tools/ifdown b/net/net-tools/ifdown
index 106e00a..1917cf7 100644
--- a/net/net-tools/ifdown
+++ b/net/net-tools/ifdown
@@ -15,8 +15,18 @@ exists_in_text()
   return 1
 }
 
+_set_bridge()
+{
+  for port in "$@"
+  do
+	  brctl delif $DEV $port
+	  ifconfig $port 0.0.0.0 down
+  done
+}
+
 _do_device_down()
 {
+  [[ -n "$BRIDGE_PORTS" ]] && _set_bridge $BRIDGE_PORTS
   if [[ "$MODE" =~ ^dynamic ]]; then
     echo "Stopping dhcpcd on $DEV ..."
     dhcpcd -k $DEV &&
@@ -24,6 +34,7 @@ _do_device_down()
   fi
   echo "Shutting down network interface $DEV ..."
   ifconfig $DEV 0.0.0.0 down
+  [[ -n "$BRIDGE_PORTS" ]] && brctl delbr $DEV
 }
 
 _do_route_down()
diff --git a/net/net-tools/ifup b/net/net-tools/ifup
index cee462b..fba1147 100644
--- a/net/net-tools/ifup
+++ b/net/net-tools/ifup
@@ -33,6 +33,23 @@ _set_wlan()
   IWC="$IWC $*"
 }
 
+_set_bridge()
+{
+  # if the bridge doesn't exist add it
+  if ! brctl show | grep $DEV
+  then
+    brctl addbr $DEV
+  fi
+  for port in "$@"
+  do
+    if ! brctl show $DEV | grep $port
+    then
+      brctl addif $DEV $port
+    fi &&
+    ifconfig $port 0.0.0.0 promisc up
+  done
+}
+
 _do_device_up()
 {
     # collect settings for iwconfig
@@ -48,6 +65,7 @@ _do_device_up()
     [[ -n "$WIFI_DEFAULTKEY" ]] && _set_wlan key "[$WIFI_DEFAULTKEY]"
     [[ -n "$WIFI_SECMODE" ]] && _set_wlan key $WIFI_SECMODE
     [[ -n "$WIFI_KEY" ]] && _set_wlan key $WIFI_KEY
+    [[ -n "$BRIDGE_PORTS" ]] && _set_bridge $BRIDGE_PORTS
 
     # make sure the wifi settings are applied if any of them are present
     [[ -n "$IWC" ]] && iwconfig $DEV commit && sleep 2



More information about the SM-Commit mailing list