My own version of openvswitch derived from
http://openvswitch.org/releases/openvswitch-1.1.0pre2.tar.gz

- LOCAL PORT
The bridge local port represents an entry point to the normal network stack. It
is realized with a tap device. This device is opened by the 'dpif' module and
links all the ports belonging to the bridge with the network stack through the
tap file descriptor.

- TAP DEVICES AS VIRTUAL DEVICES
I've implemented the capability to create and open a tap device specifying it 
in the command line (e.g. in the --ports option of ovs-openflowd). 
Specifying a device with name 'tap:tapN' (e.g. --ports=tap:tap1)the software
attempts to create and open a tap device with name 'tapN'. If the device already
exists it attempts only to open it.
If you don't put the 'tap:' prefix (e.g. --ports=tap1), the software attempts
only to open the device, which must have been previously created (e.g. with
'ifconfig tap1 create').

***********************************
Compilation:
The compilation of the netdev-bsd file requires some additional LDFLAGS.

1. For the time being leaves the Makefile unmodified and run the configure
script as follow:

	bash# export LDFLAGS='-lrt -lpcap -lpthread'
	bash# ./configure

This will include the time and pcap options to the Makefile.

2. Or modify the Makefile LDFAGS with the following line:

<<<<<<< .mine
	LDFLAGS = -lrt -lpcap -lpthread
=======
	LDFLAGS = -lrt -lpcap =lpthread
>>>>>>> .r289

3. The fake generator has the aim to test the openflowd performances 
   avoiding the overhead introduced by the write()/read() functions.
   It can be enabled by the -DFAKE_GEN define and consists in:
   - a fake packet creation;
   - always return the fake packet in netdev_bsd_recv_system();
   - do not wait on the involved interface;
   - always return success for netdev_bsd_send().

   To enable the fake generation you should add a define in the Makefile:
	DEFS= -DFAKE_GEN 
   and configure the openflow with "em0" and "em1":

	./ovs-openflowd netdev@dp0 --ports=em0,em1 tcp:127.0.0.1:6635 --listen=ptcp:6634 --out-of-band
	./ovs-controller -w --max-idle=permanent ptcp:6636

   and insert the forward entry in the flow table by:

	./ovs-ofctl add-flow tcp:127.0.0.1:6634 "in_port=1 idle_timeout=0 priority=65535 actions=output:2"

   this is mandatory because initially the switch does not know where 
   to send the packets (ARP replies are missing for fake packets) and 
   will continuosly flood the packets across the whole network.

4. Commands
	./ovs-ofctl dump-flows tcp:127.0.0.1:6634 
	ovs-openflowd		# The openflows server
	tcp:127.0.0.1:6635 	# socket listening for the controller
	--listen=ptcp:6634 	# socket listening for ofctl
	--out-of-band		# used to avoid error on controller connection

	ovs-ofctl 		# Send commands and querty the server
	add-flow 		# add a flow entry
	dump-flows		# dumps the active flows

	ifconfig dp0 destroy	# to be used when the ovs-server crash and
				# do not reset the interfaces
	arp -d 192.168.1.2	# to be used to forse an arp request/reply
				# useful while running tests with netrate
				# because the flowtable entry is added when
				# a packet has a reply from a port

6. Linux kernel module (ONGOING)
6.1 create the var run directory, only for the first execution
	mkdir -p /usr/local/var/run/openvswitch/
6.2 load the openvswitch module
	insmod datapath/linux-2.6/openvswitch_mod.ko
6.3 start the controller and the server
	./ovs-controller -w --max-idle=permanent ptcp:6636
	./ovs-openflowd system@dp0 --ports=eth2,eth4 tcp:127.0.0.1:6636 --listen=ptcp:6634 --out-of-band

7. Linux kernel user space
7.1 create the var run directory, only for the first execution
	mkdir -p /usr/local/var/run/openvswitch/
7.2 lauch controller, server and test
	./ovs-controller -w --max-idle=permanent ptcp:6636
	./ovs-openflowd netdev@dp0 --ports=eth2,eth4 tcp:127.0.0.1:6636 --listen=ptcp:6634 --out-of-band
	LP MARTA: netsend 33K	PC AMD: ipfw 32900
	LP MARTA: ipfw 32200	PC AMD: netsend 34000
7.3 configure 4 ports and test
	./ovs-openflowd netdev@dp0 --ports=eth2,eth4,eth6,eth7 tcp:127.0.0.1:6636 --listen=ptcp:6634 --out-of-band
	LP MARTA: netsend 33K	PC AMD: ipfw 31700
	LP MARTA: netsend 33K	PC AMD: ipfw 33K
	LP MARTA: netsend 34K	PC AMD: ipfw 30K
	LP MARTA: netsend 33K	PC AMD: ipfw 29K
	LP MARTA: netsend 33K	PC AMD: ipfw 30K
	LP MARTA: netsend 33K	PC AMD: ipfw 30K

	# Errors with the linux device
	May 25 15:53:26|00007|pktbuf|WARN|cookie mismatch: 0000029a != 0000039a
	May 25 15:53:26|00008|pktbuf|WARN|cookie mismatch: 0000029b != 0000039b

8 netmap
The netmap code is enabled wrapping the pcap functions by the changing the
loader search path.
Start the switch with:
(LD_LIBRARY_PATH=. ./ovs-openflowd netdev@dp0 --ports=ix0,ix1 tcp:127.0.0.1:6636 --listen=ptcp:6634 --out-of-band)
and the controller as usual.
./ovs-openflowd netdev@dp0 --ports=ix0,ix1 tcp:127.0.0.1:6636 --listen=ptcp:6634 --out-of-band
Do not forget to disable the checksum on the intefaces:
[root@10Gb1 /home/matteo/workspace/netmap/v2/netmap-v2/examples/pkt-gen]# ifconfig ix0 -rxcsum -txcsum
[root@10Gb1 /home/matteo/workspace/netmap/v2/netmap-v2/examples/pkt-gen]# ifconfig ix1 -rxcsum -txcsum
And to insert the rules into the flowtable:
# ./ovs-ofctl add-flow tcp:127.0.0.1:6634 "in_port=1 idle_timeout=0 priority=65535 actions=output:2"
# ./ovs-ofctl add-flow tcp:127.0.0.1:6634 "in_port=2 idle_timeout=0 priority=65535 actions=output:1"
# ./ovs-ofctl dump-flows tcp:127.0.0.1:6634
