diff options
author | schweikh <schweikh@FreeBSD.org> | 2006-03-05 15:53:07 +0000 |
---|---|---|
committer | schweikh <schweikh@FreeBSD.org> | 2006-03-05 15:53:07 +0000 |
commit | ffede784aef51020f5d180d32d95d55efa6d351a (patch) | |
tree | a2afb2397fdfa4cfcc805bc8f56048c09ab0d30f /share | |
parent | 00b7acda29699a9f2cfdb9ae73f96c2b54710067 (diff) | |
download | FreeBSD-src-ffede784aef51020f5d180d32d95d55efa6d351a.zip FreeBSD-src-ffede784aef51020f5d180d32d95d55efa6d351a.tar.gz |
- Correct grammos in comments and end them with full stops.
- Use "if !" instead of empty true branches.
- Don't hardcode script name in usage message, use $0 instead.
- Cleanup some whitespace.
Diffstat (limited to 'share')
-rw-r--r-- | share/examples/netgraph/ether.bridge | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/share/examples/netgraph/ether.bridge b/share/examples/netgraph/ether.bridge index 273e4c4..754e760 100644 --- a/share/examples/netgraph/ether.bridge +++ b/share/examples/netgraph/ether.bridge @@ -6,7 +6,7 @@ # # To use this script: # -# 0. Make your own copy of this example script +# 0. Make your own copy of this example script. # # 1. Give your bridging network a name by editing the definition of # ${BRIDGE_NAME} below. It must be a valid netgraph node name. @@ -27,11 +27,11 @@ # # To make a "brouted" network, with IP being routed and other protocols being # bridged, add all the interface in the BRIDGE_IFACES to the LOCAL_IFACES. -# I you just want a normal bridge, just one will surfice. -# in some cases you may want some mixture. -# +# If you just want a normal bridge, just one will be enough. +# In some cases you may want some combination. +# -# Give each bridging network a unique name here +# Give each bridging network a unique name here. BRIDGE_NAME="bnet0" @@ -40,16 +40,16 @@ BRIDGE_NAME="bnet0" # machine as well then set ${LOCAL_IFACES} as well (they may also be # listed in ${BRIDGE_IFACES}). Of course, any ${LOCAL_IFACE} must # be ifconfig(8)ured separately. If you don't want a ${LOCAL_IFACE} -# then leave it defined as the emtpy string. +# then assign it the emtpy string. BRIDGE_IFACES="de0 fxp0 fxp1" LOCAL_IFACES="fxp0 fxp1" -#################################################################### -#### Everything below this point should not need to be modified #### -#################################################################### +##################################################################### +#### Everything below this point should not need to be modified. #### +##################################################################### -# Routine to verify node's existence +# Routine to verify node's existence. bridge_verify() { ngctl info ${BRIDGE_NAME}: >/dev/null 2>&1 if [ $? -ne 0 ]; then @@ -58,7 +58,7 @@ bridge_verify() { fi } -# Routine to get and display link stats +# Routine to get and display link stats. bridge_linkstats() { STATS=`ngctl msg ${BRIDGE_NAME}: getstats $1` if [ $? -ne 0 ]; then @@ -68,38 +68,36 @@ bridge_linkstats() { printf "%20s = %s\n", substr($0, 0, fl - 1), substr($0, fl + 1); }' } -# Start/restart routine +# Start/restart routine. bridge_start() { - # Load netgraph KLD's as necessary + # Load netgraph KLD's as necessary. for KLD in ng_ether ng_bridge; do - if kldstat -v | grep -qw ${KLD}; then - else + if ! kldstat -v | grep -qw ${KLD}; then echo -n "Loading ${KLD}.ko... " kldload ${KLD} || exit 1 echo "done" fi done - # Reset all interfaces + # Reset all interfaces. bridge_stop - # Verify all interfaces exist + # Verify all interfaces exist. for ETHER in ${BRIDGE_IFACES} ${LOCAL_IFACES}; do - if ngctl info ${ETHER}: >/dev/null 2>&1; then - else + if ! ngctl info ${ETHER}: >/dev/null 2>&1; then echo "Error: interface ${ETHER} does not exist" exit 1 fi ifconfig ${ETHER} up || exit 1 done - # Create new ng_bridge(4) node, attached to the first interface + # Create new ng_bridge(4) node, attached to the first interface. FIRSTIF=`echo ${BRIDGE_IFACES} | awk '{ print $1 }'` ngctl mkpeer ${FIRSTIF}: bridge lower link0 || exit 1 ngctl name ${FIRSTIF}:lower ${BRIDGE_NAME} || exit 1 - # Attach other interfaces as well + # Attach other interfaces as well. LINKNUM=0 for ETHER in ${BRIDGE_IFACES}; do if [ ${LINKNUM} != 0 ]; then @@ -109,21 +107,21 @@ bridge_start() { LINKNUM=`expr ${LINKNUM} + 1` done - # Hook up local interface, if any + # Hook up local interface, if any. for LOCAL_IFACE in ${LOCAL_IFACES}; do ngctl connect ${LOCAL_IFACE}: ${BRIDGE_NAME}: \ upper link${LINKNUM} || exit 1 LINKNUM=`expr ${LINKNUM} + 1` done - # Set all interfaces in promiscuous mode and don't overwrite src addr + # Set all interfaces in promiscuous mode and don't overwrite src addr. for ETHER in ${BRIDGE_IFACES}; do ngctl msg ${ETHER}: setpromisc 1 || exit 1 ngctl msg ${ETHER}: setautosrc 0 || exit 1 done } -# Stop routine +# Stop routine. bridge_stop() { ngctl kill ${BRIDGE_NAME}: >/dev/null 2>&1 for ETHER in ${BRIDGE_IFACES} ${LOCAL_IFACES}; do @@ -131,10 +129,10 @@ bridge_stop() { done } -# Stats routine +# Stats routine. bridge_stats() { - # Make sure node exists + # Make sure node exists. bridge_verify echo "" @@ -153,7 +151,7 @@ bridge_stats() { done } -# Main entry point +# Main entry point. case $1 in start) bridge_start @@ -167,7 +165,6 @@ case $1 in bridge_stop ;; *) - echo "usage: ether.bridge [ start | stop | stats ]" + echo "usage: $0 [ start | stop | stats ]" exit 1 esac - |