Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Dec 2000 14:44:32 -0800 (PST)
From:      Nick Sayer <nsayer@freebsd.org>
To:        freebsd-emulation@freebsd.org
Subject:   Suggestet patch to vmware2 port: netgraph bridging
Message-ID:  <Pine.BSF.4.21.0012141441480.93965-200000@medusa.kfu.com>

index | next in thread | raw e-mail

[-- Attachment #1 --]
I've been using netgraph bridging for quite some time now and it works
remarkably well. One of the big advantages of it is that it is far less
likely to gum up multi-interface configurations, since you pick which
interface you want to "chain" the guest to at install-time.

I usually dummy up the vmware.sh script by hand, so this patch is not
thoroughly tested, but I think it would be a good replacement for the
bridge functionality we have in the vmware2 port now. If nothing else, it
means you can run vmware without having to recompile the kernel!


[-- Attachment #2 --]
Index: Makefile
===================================================================
RCS file: /home/ncvs/ports/emulators/vmware2/Makefile,v
retrieving revision 1.29
diff -u -r1.29 Makefile
--- Makefile	2000/11/07 14:40:23	1.29
+++ Makefile	2000/12/14 22:41:33
@@ -102,6 +102,8 @@
 	${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};' \
Index: files/config
===================================================================
RCS file: /home/ncvs/ports/emulators/vmware2/files/config,v
retrieving revision 1.2
diff -u -r1.2 config
--- files/config	2000/01/28 06:22:55	1.2
+++ files/config	2000/12/14 22:41:33
@@ -5,3 +5,4 @@
 libdir = "@@PREFIX@@/lib/vmware/lib"
 vmnet1.HostOnlyAddress = "@@HOST_IP@@"
 vmnet1.HostOnlyNetMask = "@@NETMASK@@"
+vmnet1.NGBridge = "@@BRIDGE@@"
Index: files/vmware.sh
===================================================================
RCS file: /home/ncvs/ports/emulators/vmware2/files/vmware.sh,v
retrieving revision 1.9
diff -u -r1.9 vmware.sh
--- files/vmware.sh	2000/11/02 12:20:26	1.9
+++ files/vmware.sh	2000/12/14 22:41:33
@@ -24,6 +24,8 @@
 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 @@
 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 @@
 	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 @@
     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
     ;;
 
Index: scripts/configure
===================================================================
RCS file: /home/ncvs/ports/emulators/vmware2/scripts/configure,v
retrieving revision 1.5
diff -u -r1.5 configure
--- scripts/configure	2000/09/10 15:03:00	1.5
+++ scripts/configure	2000/12/14 22:41:33
@@ -8,6 +8,34 @@
 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 xl0 \
+	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 @@
 	;;
     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 [ $? -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 @@
 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
help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0012141441480.93965-200000>