diff options
author | Nick Sayer <nsayer@FreeBSD.org> | 2000-12-24 05:20:51 +0000 |
---|---|---|
committer | Nick Sayer <nsayer@FreeBSD.org> | 2000-12-24 05:20:51 +0000 |
commit | 7a7a4930364385cecc134b08110fd860b710eee4 (patch) | |
tree | a4e09ad04cb93e526e439628e69b6b318a148962 /emulators | |
parent | Update to 2.39a (diff) |
Switch the port over to netgraph bridging. This method has a number of
advantages, chief of which is that it doesn't hose over multi-interface
configurations the way the default installation did before. This
mechanism "chains" the guest's interface to an interface specified at
installation-time (it can be changed afterwards by editing the rc.d
script).
Approved by: (maintainer)
Notes
Notes:
svn path=/head/; revision=36295
Diffstat (limited to 'emulators')
-rw-r--r-- | emulators/vmware2/Makefile | 2 | ||||
-rw-r--r-- | emulators/vmware2/files/vmware.sh | 27 | ||||
-rw-r--r-- | emulators/vmware2/scripts/configure | 60 | ||||
-rw-r--r-- | emulators/vmware3/Makefile | 2 | ||||
-rw-r--r-- | emulators/vmware3/files/vmware.sh | 27 | ||||
-rw-r--r-- | emulators/vmware3/scripts/configure | 60 |
6 files changed, 156 insertions, 22 deletions
diff --git a/emulators/vmware2/Makefile b/emulators/vmware2/Makefile index bd0fbe78bb05..e0c4cb0422cc 100644 --- a/emulators/vmware2/Makefile +++ b/emulators/vmware2/Makefile @@ -102,6 +102,8 @@ setoptions: ${SED} -e 's;@@PREFIX@@;${PREFIX};' \ -e 's;@@LINUXBASE@@;${LINUXBASE};' \ -e 's;@@NETWORKING@@;${VMNET_NETWORKING};' \ + -e 's;@@BRIDGED@@;${VMNET_BRIDGED};' \ + -e 's;@@BRIDGE_INTF@@;${VMNET_BRIDGED_INTERFACE};' \ ${FILESDIR}/vmware.sh > ${WRKDIR}/vmware.sh ${SED} -e 's;@@PREFIX@@;${PREFIX};' \ diff --git a/emulators/vmware2/files/vmware.sh b/emulators/vmware2/files/vmware.sh index ee6db6d0d76b..ebd5e68557fa 100644 --- a/emulators/vmware2/files/vmware.sh +++ b/emulators/vmware2/files/vmware.sh @@ -24,6 +24,8 @@ vmware_config() { vmware=`vmware_config vmware.fullpath` vmware_libdir=`vmware_config libdir` networking=@@NETWORKING@@ +bridged=@@BRIDGED@@ +bridge_interface=@@BRIDGE_INTF@@ host_ip=`vmware_config vmnet1.HostOnlyAddress` netmask=`vmware_config vmnet1.HostOnlyNetMask` dev_vmnet1=@@LINUXBASE@@/dev/vmnet1 @@ -45,7 +47,6 @@ case $1 in start) kldload ${vmware_libdir}/modules/vmmon_${suffix}.ko if [ $networking -eq 1 ]; then - sysctl net.link.ether.bridge_refresh && bridge="_bridge" kldload if_tap.ko if [ ! -e $dev_vmnet1 ]; then echo "$dev_vmnet1 does not exist!" >&2 @@ -54,12 +55,21 @@ start) fi echo -n > $dev_vmnet1 ifconfig vmnet1 $host_ip netmask $netmask - if [ _$bridge != _ ]; then - sysctl -w net.link.ether.bridge_refresh=1 - sysctl -w net.link.ether.bridge=1 + if [ X$bridged = XYES ]; then + kldload netgraph.ko + kldload ng_ether.ko + kldload ng_bridge.ko + ngctl mkpeer vmnet1: bridge lower link0 + ngctl name vmnet1:lower vmnet_bridge + ngctl connect vmnet_bridge: ${bridge_interface}: link1 lower + ngctl connect vmnet_bridge: ${bridge_interface}: link2 upper + ngctl msg ${bridge_interface}: setautosrc 0 + ngctl msg ${bridge_interface}: setpromisc 1 + ngctl msg vmnet1: setautosrc 0 + ngctl msg vmnet1: setpromisc 1 fi fi - echo -n " VMware${bridge}" >&2 + echo -n " VMware" >&2 ;; stop) @@ -67,8 +77,11 @@ stop) if [ $networking -eq 1 ]; then ifconfig vmnet1 down ifconfig vmnet1 delete $host_ip - sysctl net.link.ether.bridge_refresh && bridge="_bridge" - [ _$bridge != _ ] && sysctl -w net.link.ether.bridge_refresh=1 + if [ X$bridged = XYES ]; then + ngctl shutdown vmnet_bridge: + ngctl msg ${bridge_interface}: setautosrc 1 + ngctl msg ${bridge_interface}: setpromisc 0 + fi fi ;; diff --git a/emulators/vmware2/scripts/configure b/emulators/vmware2/scripts/configure index bb2150ac04a6..4b00cb17e72e 100644 --- a/emulators/vmware2/scripts/configure +++ b/emulators/vmware2/scripts/configure @@ -8,6 +8,34 @@ netmask=$VMNET_NETMASK title="VMware network options" get_network_settings() { + bridged="NO" + /usr/bin/dialog --title "$title" --clear --yesno \ +"\n"\ +"Do you want to use netgraph bridging?\n"\ + 10 50 + if [ $? -eq 0 ]; then + bridged="YES" + result=`/usr/bin/dialog --title "$title" --clear --inputbox \ +"\n"\ +"To which interface would you\n"\ +"like to tie the bridge?:"\ + 10 50 "" \ + 2>&1 > /dev/tty` + case $? in + 0) + if [ -z "$result" ]; then + return 1 + fi + bdg_interface=$result + ;; + 1) + return 1 + ;; + esac + host_ip=192.168.0.1 + netmask=255.255.255.0 + else + result=`/usr/bin/dialog --title "$title" --clear --inputbox \ "\n"\ "What will be the IP address of your host\n"\ @@ -46,19 +74,31 @@ get_network_settings() { ;; esac return 0; + fi } do_network() { while true; do get_network_settings + if [ "X$bridged" != "XYES" ]; then /usr/bin/dialog --title "Confirmation" --clear --yesno \ "\n"\ "Are the following options correct?\n\n"\ -"IP address: $host_ip\n"\ -"Netmask: $netmask\n"\ +"Configuration: host only\n"\ +"IP address: $host_ip\n"\ +"Netmask: $netmask\n"\ 10 50 [ $? -eq 0 ] && return 0 + else + /usr/bin/dialog --title "Confirmation" --clear --yesno \ +"\n"\ +"Are the following options correct?\n\n"\ +"Configuration: bridged\n"\ +"Interface: $bdg_interface\n"\ + 10 50 + [ $? -eq 0 ] && return 0 + fi /usr/bin/dialog --title "Confirmation" --clear --yesno \ "\n"\ @@ -85,12 +125,22 @@ if [ _$BATCH = _ ]; then if [ $? -eq 0 ]; then networking=1 + if [ X$bridged = XYES ]; then + /usr/bin/dialog --title "$title" --infobox \ +"\n"\ +"The following options will be used.\n\n"\ +"Configuration: bridged\n"\ +"Interface: $bdg_interface\n"\ + 10 50 + else /usr/bin/dialog --title "$title" --infobox \ "\n"\ "The following options will be used.\n\n"\ -"IP address: $host_ip\n"\ -"Netmask: $netmask\n"\ +"Configuration: host only\n"\ +"IP address: $host_ip\n"\ +"Netmask: $netmask\n"\ 10 50 + fi fi else #BATCH [ -f ${WRKDIR}/Makefile.inc.net ] && exit 0 @@ -100,6 +150,8 @@ fi #BATCH exec > ${WRKDIR}/Makefile.inc.net echo '#' `date` +echo VMNET_BRIDGED=$bridged +echo VMNET_BRIDGED_INTERFACE=$bdg_interface echo VMNET_HOST_IP=$host_ip echo VMNET_NETMASK=$netmask echo VMNET_NETWORKING=$networking diff --git a/emulators/vmware3/Makefile b/emulators/vmware3/Makefile index bd0fbe78bb05..e0c4cb0422cc 100644 --- a/emulators/vmware3/Makefile +++ b/emulators/vmware3/Makefile @@ -102,6 +102,8 @@ setoptions: ${SED} -e 's;@@PREFIX@@;${PREFIX};' \ -e 's;@@LINUXBASE@@;${LINUXBASE};' \ -e 's;@@NETWORKING@@;${VMNET_NETWORKING};' \ + -e 's;@@BRIDGED@@;${VMNET_BRIDGED};' \ + -e 's;@@BRIDGE_INTF@@;${VMNET_BRIDGED_INTERFACE};' \ ${FILESDIR}/vmware.sh > ${WRKDIR}/vmware.sh ${SED} -e 's;@@PREFIX@@;${PREFIX};' \ diff --git a/emulators/vmware3/files/vmware.sh b/emulators/vmware3/files/vmware.sh index ee6db6d0d76b..ebd5e68557fa 100644 --- a/emulators/vmware3/files/vmware.sh +++ b/emulators/vmware3/files/vmware.sh @@ -24,6 +24,8 @@ vmware_config() { vmware=`vmware_config vmware.fullpath` vmware_libdir=`vmware_config libdir` networking=@@NETWORKING@@ +bridged=@@BRIDGED@@ +bridge_interface=@@BRIDGE_INTF@@ host_ip=`vmware_config vmnet1.HostOnlyAddress` netmask=`vmware_config vmnet1.HostOnlyNetMask` dev_vmnet1=@@LINUXBASE@@/dev/vmnet1 @@ -45,7 +47,6 @@ case $1 in start) kldload ${vmware_libdir}/modules/vmmon_${suffix}.ko if [ $networking -eq 1 ]; then - sysctl net.link.ether.bridge_refresh && bridge="_bridge" kldload if_tap.ko if [ ! -e $dev_vmnet1 ]; then echo "$dev_vmnet1 does not exist!" >&2 @@ -54,12 +55,21 @@ start) fi echo -n > $dev_vmnet1 ifconfig vmnet1 $host_ip netmask $netmask - if [ _$bridge != _ ]; then - sysctl -w net.link.ether.bridge_refresh=1 - sysctl -w net.link.ether.bridge=1 + if [ X$bridged = XYES ]; then + kldload netgraph.ko + kldload ng_ether.ko + kldload ng_bridge.ko + ngctl mkpeer vmnet1: bridge lower link0 + ngctl name vmnet1:lower vmnet_bridge + ngctl connect vmnet_bridge: ${bridge_interface}: link1 lower + ngctl connect vmnet_bridge: ${bridge_interface}: link2 upper + ngctl msg ${bridge_interface}: setautosrc 0 + ngctl msg ${bridge_interface}: setpromisc 1 + ngctl msg vmnet1: setautosrc 0 + ngctl msg vmnet1: setpromisc 1 fi fi - echo -n " VMware${bridge}" >&2 + echo -n " VMware" >&2 ;; stop) @@ -67,8 +77,11 @@ stop) if [ $networking -eq 1 ]; then ifconfig vmnet1 down ifconfig vmnet1 delete $host_ip - sysctl net.link.ether.bridge_refresh && bridge="_bridge" - [ _$bridge != _ ] && sysctl -w net.link.ether.bridge_refresh=1 + if [ X$bridged = XYES ]; then + ngctl shutdown vmnet_bridge: + ngctl msg ${bridge_interface}: setautosrc 1 + ngctl msg ${bridge_interface}: setpromisc 0 + fi fi ;; diff --git a/emulators/vmware3/scripts/configure b/emulators/vmware3/scripts/configure index bb2150ac04a6..4b00cb17e72e 100644 --- a/emulators/vmware3/scripts/configure +++ b/emulators/vmware3/scripts/configure @@ -8,6 +8,34 @@ netmask=$VMNET_NETMASK title="VMware network options" get_network_settings() { + bridged="NO" + /usr/bin/dialog --title "$title" --clear --yesno \ +"\n"\ +"Do you want to use netgraph bridging?\n"\ + 10 50 + if [ $? -eq 0 ]; then + bridged="YES" + result=`/usr/bin/dialog --title "$title" --clear --inputbox \ +"\n"\ +"To which interface would you\n"\ +"like to tie the bridge?:"\ + 10 50 "" \ + 2>&1 > /dev/tty` + case $? in + 0) + if [ -z "$result" ]; then + return 1 + fi + bdg_interface=$result + ;; + 1) + return 1 + ;; + esac + host_ip=192.168.0.1 + netmask=255.255.255.0 + else + result=`/usr/bin/dialog --title "$title" --clear --inputbox \ "\n"\ "What will be the IP address of your host\n"\ @@ -46,19 +74,31 @@ get_network_settings() { ;; esac return 0; + fi } do_network() { while true; do get_network_settings + if [ "X$bridged" != "XYES" ]; then /usr/bin/dialog --title "Confirmation" --clear --yesno \ "\n"\ "Are the following options correct?\n\n"\ -"IP address: $host_ip\n"\ -"Netmask: $netmask\n"\ +"Configuration: host only\n"\ +"IP address: $host_ip\n"\ +"Netmask: $netmask\n"\ 10 50 [ $? -eq 0 ] && return 0 + else + /usr/bin/dialog --title "Confirmation" --clear --yesno \ +"\n"\ +"Are the following options correct?\n\n"\ +"Configuration: bridged\n"\ +"Interface: $bdg_interface\n"\ + 10 50 + [ $? -eq 0 ] && return 0 + fi /usr/bin/dialog --title "Confirmation" --clear --yesno \ "\n"\ @@ -85,12 +125,22 @@ if [ _$BATCH = _ ]; then if [ $? -eq 0 ]; then networking=1 + if [ X$bridged = XYES ]; then + /usr/bin/dialog --title "$title" --infobox \ +"\n"\ +"The following options will be used.\n\n"\ +"Configuration: bridged\n"\ +"Interface: $bdg_interface\n"\ + 10 50 + else /usr/bin/dialog --title "$title" --infobox \ "\n"\ "The following options will be used.\n\n"\ -"IP address: $host_ip\n"\ -"Netmask: $netmask\n"\ +"Configuration: host only\n"\ +"IP address: $host_ip\n"\ +"Netmask: $netmask\n"\ 10 50 + fi fi else #BATCH [ -f ${WRKDIR}/Makefile.inc.net ] && exit 0 @@ -100,6 +150,8 @@ fi #BATCH exec > ${WRKDIR}/Makefile.inc.net echo '#' `date` +echo VMNET_BRIDGED=$bridged +echo VMNET_BRIDGED_INTERFACE=$bdg_interface echo VMNET_HOST_IP=$host_ip echo VMNET_NETMASK=$netmask echo VMNET_NETWORKING=$networking |