├── .abat-automerge ├── .gitignore ├── .gitmodules ├── .hooks └── pre-commit ├── INTERNALS.md ├── LICENSE ├── Makefile ├── README.md ├── build ├── autobuild.sh ├── build-debian-packages-inner.sh ├── build-debian-packages.sh ├── build-rhel-packages-inner.sh ├── build-rhel-packages.sh ├── files.sh ├── ivs-callgrind.sh ├── ivs-gdb.sh ├── ivs-massif.sh ├── ivs-perf.sh ├── ivs-valgrind.sh ├── ivs.sh ├── oftest.py ├── precheckin.py ├── setup.sh ├── veth_setup.sh └── veth_teardown.sh ├── debian ├── .gitignore ├── README ├── changelog ├── compat ├── control ├── copyright ├── docs ├── init.d ├── ivs.default ├── ivs.manpages ├── ivs.upstart ├── rules └── source │ └── format ├── docker ├── centos7 │ └── Dockerfile └── ubuntu14.04 │ └── Dockerfile ├── init.mk ├── modules ├── .gitignore ├── Manifest.mk ├── OVSDriver │ ├── .gitignore │ ├── Makefile │ ├── OVSDriver.doxy │ ├── README │ ├── module │ │ ├── auto │ │ │ ├── OVSDriver.yml │ │ │ └── make.mk │ │ ├── inc │ │ │ └── OVSDriver │ │ │ │ ├── ovsdriver.h │ │ │ │ ├── ovsdriver.x │ │ │ │ ├── ovsdriver_config.h │ │ │ │ ├── ovsdriver_dox.h │ │ │ │ └── ovsdriver_porting.h │ │ ├── make.mk │ │ └── src │ │ │ ├── Makefile │ │ │ ├── barrier.c │ │ │ ├── dump.c │ │ │ ├── experimenter.c │ │ │ ├── fwd.c │ │ │ ├── hitless.c │ │ │ ├── kflow.c │ │ │ ├── make.mk │ │ │ ├── multicast.c │ │ │ ├── ovs_driver.c │ │ │ ├── ovs_driver_int.h │ │ │ ├── ovsdriver_log.h │ │ │ ├── pipeline.c │ │ │ ├── pktin.c │ │ │ ├── pktin_socket.c │ │ │ ├── pktout.c │ │ │ ├── translate_match.c │ │ │ ├── upcall.c │ │ │ ├── uplink.c │ │ │ ├── util.c │ │ │ ├── vlan_counters.c │ │ │ └── vport.c │ └── utest │ │ ├── _make.mk │ │ └── main.c ├── action │ ├── .gitignore │ └── module │ │ ├── inc │ │ └── action │ │ │ └── action.h │ │ ├── make.mk │ │ └── src │ │ ├── action.c │ │ └── make.mk ├── ivs │ ├── .gitignore │ └── module │ │ ├── inc │ │ └── ivs │ │ │ └── ivs.h │ │ ├── make.mk │ │ └── src │ │ └── make.mk ├── l2table │ ├── .gitignore │ ├── l2table.mk │ ├── module │ │ ├── inc │ │ │ └── l2table │ │ │ │ └── l2table.h │ │ ├── make.mk │ │ └── src │ │ │ ├── l2table.c │ │ │ └── make.mk │ └── utest │ │ ├── _make.mk │ │ └── main.c ├── luajit │ ├── Makefile │ └── luajit.mk ├── packet_trace │ ├── .gitignore │ └── module │ │ ├── inc │ │ └── packet_trace │ │ │ └── packet_trace.h │ │ ├── make.mk │ │ └── src │ │ ├── make.mk │ │ └── packet_trace.c ├── pipeline │ ├── .gitignore │ └── module │ │ ├── inc │ │ └── pipeline │ │ │ └── pipeline.h │ │ ├── make.mk │ │ └── src │ │ ├── make.mk │ │ └── pipeline.c ├── pipeline_lua │ ├── .gitignore │ └── module │ │ ├── make.mk │ │ └── src │ │ ├── actions.lua │ │ ├── allocator.c │ │ ├── base.lua │ │ ├── builtin_lua.c │ │ ├── fields.c │ │ ├── hashtable.lua │ │ ├── log.c │ │ ├── make.mk │ │ ├── murmur.lua │ │ ├── pipeline_lua.c │ │ ├── pipeline_lua_int.h │ │ ├── stats.c │ │ ├── table.c │ │ └── xdr.lua ├── pipeline_reflect │ ├── .gitignore │ └── module │ │ ├── make.mk │ │ └── src │ │ ├── make.mk │ │ └── pipeline_reflect.c ├── pipeline_standard │ ├── .gitignore │ └── module │ │ ├── make.mk │ │ └── src │ │ ├── action.c │ │ ├── action.h │ │ ├── cfr.c │ │ ├── cfr.h │ │ ├── group.c │ │ ├── group.h │ │ ├── make.mk │ │ └── pipeline_standard.c ├── shared_debug_counter │ ├── .gitignore │ └── module │ │ ├── inc │ │ └── shared_debug_counter │ │ │ └── shared_debug_counter.h │ │ ├── make.mk │ │ └── src │ │ ├── link.ld │ │ ├── make.mk │ │ └── shared_debug_counter.c ├── stats │ ├── .gitignore │ └── module │ │ ├── inc │ │ └── stats │ │ │ └── stats.h │ │ ├── make.mk │ │ └── src │ │ ├── make.mk │ │ └── stats.c ├── tcam │ ├── .gitignore │ ├── module │ │ ├── inc │ │ │ └── tcam │ │ │ │ └── tcam.h │ │ ├── make.mk │ │ └── src │ │ │ ├── make.mk │ │ │ ├── tcam.c │ │ │ ├── tcam_log.c │ │ │ └── tcam_log.h │ └── utest │ │ ├── _make.mk │ │ └── main.c └── xbuf │ ├── .gitignore │ ├── module │ ├── inc │ │ └── xbuf │ │ │ └── xbuf.h │ ├── make.mk │ └── src │ │ ├── make.mk │ │ └── xbuf.c │ └── utest │ ├── _make.mk │ └── main.c ├── oftests ├── l2switch.x ├── l2switch_xdr.py ├── lua │ ├── command.lua │ ├── hashtable_benchmark.lua │ ├── hashtable_test.lua │ ├── l2switch.lua │ ├── l2switch_xdr.lua │ ├── pktin.lua │ └── tables.lua ├── lua_basic.py ├── lua_common.py └── lua_l2switch.py ├── openvswitch └── openvswitch.h ├── rhel ├── ivs-7.0.spec ├── ivs.service └── rpm-from-source ├── targets ├── .gitignore ├── ivs-ctl │ ├── Makefile │ ├── ivs-ctl.8 │ └── main.c ├── ivs │ ├── Makefile │ ├── cli.c │ ├── ivs.8 │ ├── main.c │ ├── tests-1.3.txt │ └── tests.txt ├── l2table-benchmark │ ├── Makefile │ └── main.c ├── tcam-benchmark │ ├── Makefile │ └── main.c ├── upcall-latency-benchmark │ ├── Makefile │ ├── plot-latency.gnuplot │ └── upcall-latency.c ├── upcall-throughput-benchmark │ ├── Makefile │ ├── plot-throughput.gnuplot │ └── upcall-throughput.c └── utests │ ├── flowtable │ └── Makefile │ ├── l2table │ └── Makefile │ ├── make │ └── utestmodule.mk │ ├── tcam │ └── Makefile │ └── xbuf │ └── Makefile └── tests └── hitless.py /.abat-automerge: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eux 2 | ################################################################ 3 | # 4 | # Copyright 2013, Big Switch Networks, Inc. 5 | # 6 | # Licensed under the Eclipse Public License, Version 1.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.eclipse.org/legal/epl-v10.html 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 15 | # either express or implied. See the License for the specific 16 | # language governing permissions and limitations under the 17 | # License. 18 | # 19 | ################################################################ 20 | ROOTDIR=$(dirname $(readlink -f $0)) 21 | cd "$ROOTDIR" 22 | 23 | ./build/setup.sh 24 | ./build/precheckin.py 25 | 26 | make -C targets/ivs clean 27 | scan-build --status-bugs make -j8 -C targets/ivs GCC='$(CC)' 28 | 29 | export BUILD_ID=$(date +'%F.%R%z')-$(git rev-parse -q --short HEAD) 30 | 31 | ARCHS="amd64" 32 | SUITES="trusty" 33 | for ARCH in $ARCHS; do 34 | for SUITE in $SUITES; do 35 | ARCH=$ARCH SUITE=$SUITE ./build/build-debian-packages.sh 36 | done 37 | done 38 | 39 | ./build/build-rhel-packages.sh 40 | 41 | # Publish packages from official builds 42 | if [ "${PUBLISH_DIR-}" ]; then 43 | mkdir -p "$PUBLISH_DIR" 44 | rsync -uva pkg/. "$PUBLISH_DIR" 45 | fi 46 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Compiled Dynamic libraries 8 | *.so 9 | 10 | # Compiled Static libraries 11 | *.lai 12 | *.la 13 | *.a 14 | 15 | # Compiled Python 16 | *.pyc 17 | 18 | # Packages # 19 | ############ 20 | # it's better to unpack these files and commit the raw source 21 | # git has its own built in compression methods 22 | *.7z 23 | *.dmg 24 | *.gz 25 | *.iso 26 | *.jar 27 | *.rar 28 | *.tar 29 | *.zip 30 | 31 | # Logs and databases # 32 | ###################### 33 | *.log 34 | *.sql 35 | *.sqlite 36 | *.pcap 37 | 38 | # OS generated files # 39 | ###################### 40 | .DS_Store* 41 | ehthumbs.db 42 | Icon? 43 | Thumbs.db 44 | 45 | export-products 46 | *~ 47 | 48 | # Editor junk 49 | #*# 50 | .*.swp 51 | .*.swo 52 | 53 | # cscope 54 | cscope.files 55 | cscope.out 56 | tags 57 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "submodules/luajit-2.0"] 2 | path = submodules/luajit-2.0 3 | url = git://github.com/floodlight/luajit-2.0.git 4 | [submodule "submodules/infra"] 5 | path = submodules/infra 6 | url = git://github.com/floodlight/infra.git 7 | [submodule "submodules/indigo"] 8 | path = submodules/indigo 9 | url = git://github.com/floodlight/indigo.git 10 | [submodule "submodules/bigcode"] 11 | path = submodules/bigcode 12 | url = git://github.com/floodlight/bigcode.git 13 | [submodule "submodules/loxigen-artifacts"] 14 | path = submodules/loxigen-artifacts 15 | url = git://github.com/floodlight/loxigen-artifacts.git 16 | -------------------------------------------------------------------------------- /.hooks/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # An example hook script to verify what is about to be committed. 4 | # Called by "git commit" with no arguments. The hook should 5 | # exit with non-zero status after issuing an appropriate message if 6 | # it wants to stop the commit. 7 | 8 | echo "Running ${PWD}/$0" 9 | 10 | if git rev-parse --verify HEAD >/dev/null 2>&1 11 | then 12 | against=HEAD 13 | else 14 | # Initial commit: diff against an empty tree object 15 | against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 16 | fi 17 | 18 | # If you want to allow non-ascii filenames set this variable to true. 19 | allownonascii=$(git config hooks.allownonascii) 20 | 21 | # Redirect output to stderr. 22 | exec 1>&2 23 | 24 | # Cross platform projects tend to avoid non-ascii filenames; prevent 25 | # them from being added to the repository. We exploit the fact that the 26 | # printable range starts at the space character and ends with tilde. 27 | if [ "$allownonascii" != "true" ] && 28 | # Note that the use of brackets around a tr range is ok here, (it's 29 | # even required, for portability to Solaris 10's /usr/bin/tr), since 30 | # the square bracket bytes happen to fall in the designated range. 31 | test $(git diff --cached --name-only --diff-filter=A -z $against | 32 | LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 33 | then 34 | echo "Error: Attempt to add a non-ascii file name." 35 | echo 36 | echo "This can cause problems if you want to work" 37 | echo "with people on other platforms." 38 | echo 39 | echo "To be portable it is advisable to rename the file ..." 40 | echo 41 | echo "If you know what you are doing you can disable this" 42 | echo "check using:" 43 | echo 44 | echo " git config hooks.allownonascii true" 45 | echo 46 | exit 1 47 | fi 48 | 49 | if [ ! -e .git/MERGE_MSG ]; then 50 | # If there are whitespace errors, print the offending file names and fail. 51 | git diff-index --check --cached $against -- || exit 1 52 | 53 | # Check for tabs 54 | srcdirs="modules targets" 55 | if find $srcdirs -type f -name '*.[ch]' -a \! -name 'openvswitch.h' -a \! -name 'tunnel.h' | xargs grep -n -P '\t'; then 56 | echo "Tabs found" 57 | exit 1 58 | fi 59 | fi 60 | -------------------------------------------------------------------------------- /INTERNALS.md: -------------------------------------------------------------------------------- 1 | Source Code Layout 2 | ------------------ 3 | 4 | The IVS repository uses the same source code module infrastructure and build 5 | system as the Indigo project (which is included as a submodule under `indigo`). 6 | Here's an (abridged) source code tree: 7 | 8 | - build: Convenience scripts for building and running IVS. 9 | - debian: Debian packaging. 10 | - indigo: Submodule linking to floodlight/indigo. 11 | - modules 12 | - flowtable: Hash-based flowtable implementation. 13 | - OVSDriver: Implementation of Indigo Forwarding/PortManager interfaces 14 | using the openvswitch kernel module. 15 | - module 16 | - inc: OVSDriver public headers. 17 | - src: OVSDriver implementation. 18 | - openvswitch: Header files for the openvswitch netlink interface. 19 | - targets 20 | - ivs: Switch daemon. 21 | - ivs-ctl: Utility to add/remove ports from the switch. 22 | 23 | The OVSDriver module is the main component of the project and has several submodules: 24 | 25 | - bh.c: "Bottom-halves" - queue of requests from upcall threads to the main 26 | thread. 27 | - fwd.c: Implements the Indigo forwarding interface. 28 | - kflow.c: Manages kernel flows (installation, invalidation, expiration). 29 | - ovs_driver.c: Initialization/cleanup. 30 | - translate_actions.c: Translation from OpenFlow matches and actions to 31 | openvswitch actions. 32 | - upcall.c: Handles upcalls from the openvswitch module. 33 | - vport.c: Implements the Indigo port manager interface. 34 | 35 | The ovs_driver_int.h file defines the internal interfaces between these 36 | submodules. 37 | 38 | Upcall Processing 39 | ----------------- 40 | 41 | "Upcalls" are messages from the openvswitch kernel module to userspace sent 42 | when the kernel does not have an exact-match flow for a packet. The main 43 | function of IVS is to handle these upcalls efficiently. 44 | 45 | The IVS daemon spawns several threads (default 4) to handle upcalls. Each 46 | thread is assigned a set of ports. One Netlink socket is used per port for 47 | isolation. An upcall thread spins forever around epoll_wait(), waiting for new 48 | messages from its assigned ports. 49 | 50 | When an upcall thread is woken from epoll_wait() it will read messages from the 51 | kernel in large batches to reduce the number of user/kernel transitions. For 52 | each message, it dispatches to the relevant handler depending on the type of 53 | upcall. For now we'll assume the upcalls are "misses", meaning there was no 54 | matching flow in the kernel flowtable. 55 | 56 | When handling a miss, the upcall thread uses the flow key sent by the kernel to 57 | do a lookup in the userspace flowtable. If no flow was found the thread uses 58 | the BH queue to request a packet-in. Otherwise, it translates the OpenFlow 59 | actions into openvswitch datapath actions and sends the packet up to the 60 | datapath with an "execute" message. 61 | 62 | For long-lived flows we want to avoid repeated round-trips to userspace to make 63 | forwarding decisions. Each upcall thread maintains a Bloom filter which it uses 64 | to (probabilistically) determine if it's seen a given flow key before. If so, 65 | it uses the BH queue to request a new kernel flow from the kflow subsystem. 66 | Installing a kernel flow is a synchronization bottleneck in the openvswitch 67 | kernel module so we want to avoid it for very short flows. This heuristic will 68 | continue to be tuned in the future. 69 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | IVS_BUILD := targets/ivs/build/gcc-local 21 | IVS_CTL_BUILD := targets/ivs-ctl/build/gcc-local 22 | 23 | all: 24 | ${MAKE} -C targets/ivs 25 | ${MAKE} -C targets/ivs-ctl 26 | 27 | install: all 28 | install -D $(IVS_BUILD)/bin/ivs $(DESTDIR)/usr/sbin/ivs 29 | install -D $(IVS_CTL_BUILD)/bin/ivs-ctl $(DESTDIR)/usr/sbin/ivs-ctl 30 | 31 | clean: 32 | ${MAKE} -C targets/ivs clean 33 | ${MAKE} -C targets/ivs-ctl clean 34 | # The build system creates these even during make clean 35 | rm -f modules/OVSDriver/OVSDriver.mk targets/ivs-ctl/IVSCtl.mk targets/ivs/Manifest.mk targets/ivs/IVS.mk targets/ivs/dependmodules.x 36 | (cd indigo; rm -f modules/AIM/AIM.mk modules/BigData/BigList/BigList.mk modules/ELS/ELS.mk modules/FME/FME.mk modules/IOF/IOF.mk modules/IVS/IVS.mk modules/Indigo/OFConnectionManager/OFConnectionManager.mk modules/Indigo/OFStateManager/OFStateManager.mk modules/Indigo/SocketManager/SocketManager.mk modules/Indigo/indigo/indigo.mk modules/NSS/NSS.mk modules/PPE/PPE.mk modules/loci/loci.mk modules/murmur/murmur.mk modules/uCli/uCli.mk) 37 | 38 | deb: 39 | fakeroot ${MAKE} -f debian/rules binary 40 | 41 | rpm: 42 | rhel/rpm-from-source 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Indigo Virtual Switch 2 | ===================== 3 | 4 | Introduction 5 | ------------ 6 | 7 | Indigo Virtual Switch (IVS) is a pure OpenFlow virtual switch designed for high 8 | performance and minimal administration. It is built on the [Indigo 9 | platform][1], which provides a common core for many physical and virtual switches, 10 | 11 | [1]: http://www.projectfloodlight.org/indigo/ 12 | 13 | This README contains documentation to help you get started using IVS. For full 14 | documentation, see the [IVS][2] pages at Project Floodlight. 15 | 16 | [2]: https://docs.projectfloodlight.org/display/indigodocs/Indigo+Virtual+Switch+Documentation 17 | 18 | Building IVS 19 | ------------ 20 | 21 | 1. Install required dependencies: 22 | - Ubuntu 14.04: `sudo apt-get install libnl-3-dev libnl-genl-3-dev libnl-route-3-dev pkg-config python-tz libpcap-dev libcap2-dev` 23 | - CentOS 7: `sudo yum groupinstall 'Development Tools' && sudo yum install libnl3-devel libcap-devel` 24 | 25 | 2. Clone the IVS repository: `git clone --recurse-submodules https://github.com/floodlight/ivs.git` 26 | - NOTE that if you did not use clone with the "--recursive-submodules" option, you can fix this by running 27 | `cd ivs && git submodule update --recursive --init` 28 | 29 | 3. `cd ivs` 30 | 31 | 4. Compile IVS: `make` 32 | 33 | 5. The IVS daemon and ivs-ctl utility will be written to 34 | `targets/ivs/build/gcc-local/bin/ivs` and 35 | `targets/ivs-ctl/build/gcc-local/bin/ivs-ctl` respectively. They can be run 36 | directly from the build directory. 37 | 38 | Building Debian Packages 39 | ------------------------ 40 | 41 | Packaging, including init scripts, is available for Debian-based 42 | distributions in the `debian` directory. If using git we recommend 43 | git-buildpackage. 44 | 45 | The script `build/build-debian-packages.sh` uses Docker to build packages for 46 | Ubuntu 14.04. 47 | 48 | Building CentOS/RHEL packages 49 | ----------------------------- 50 | 51 | Packaging, including init scripts, is available for Red Hat-based 52 | distributions in the `rhel` directory. 53 | 54 | The script `build/build-rhel-packages.sh` uses Docker to build packages for 55 | CentOS 7. 56 | 57 | Usage 58 | ----- 59 | 60 | You'll need an OpenFlow controller to use IVS. We suggest [Floodlight][3], 61 | which should work out of the box. Follow your controller's instructions 62 | to get it running and note down its IP address. 63 | 64 | [3]: http://www.projectfloodlight.org/floodlight/ 65 | 66 | The openvswitch kernel module must be loaded: `modprobe openvswitch`. 67 | 68 | Now you just need to run the IVS daemon. You'll need to tell it the IP address 69 | of the controller (-c) and the initial set of network interfaces to connect (-i). 70 | Here's an example command line: 71 | 72 | ``` 73 | sudo ivs -c 192.168.1.10 -i eth1 -i eth2 74 | ``` 75 | 76 | IVS will immediately begin communicating with the controller and, depending on 77 | your controller's configuration, forwarding traffic between eth1 and eth2. 78 | 79 | `ivs-ctl add-port` and `ivs-ctl del-port` can be used to add and remove ports 80 | at runtime (for example, this is used by hypervisors when a VM is started). See 81 | the `ivs-ctl` man page for more details. 82 | 83 | Contributing 84 | ------------ 85 | 86 | Please fork the repository on GitHub and open a pull request. 87 | 88 | You might be interested in the INTERNALS.md document in this repository which 89 | describes the layout of the source code and includes other details relevant to 90 | developers. 91 | -------------------------------------------------------------------------------- /build/autobuild.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eu 2 | ################################################################ 3 | # 4 | # Copyright 2013, Big Switch Networks, Inc. 5 | # 6 | # Licensed under the Eclipse Public License, Version 1.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.eclipse.org/legal/epl-v10.html 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 15 | # either express or implied. See the License for the specific 16 | # language governing permissions and limitations under the 17 | # License. 18 | # 19 | ################################################################ 20 | 21 | ROOTDIR=$(dirname $(readlink -f $0))/.. 22 | cd "$ROOTDIR" 23 | BSC=../bigswitchcontroller 24 | 25 | # TODO the test db scripts need to be factored out of bigswitchcontroller 26 | if [ ! -d "$BSC" ]; then 27 | echo "missing $BSC" 28 | exit 1 29 | fi 30 | 31 | # TODO report commits to build status page 32 | echo "+++ Last 10 commits:" 33 | git log -n 10 --stat | cat 34 | 35 | echo "+++ Starting build" 36 | [ "${ABAT_TASK-}" ] && "$BSC/build/update-build-info.py" "$ABAT_TASK" "$ABAT_ID" "$ABAT_TIMESTAMP-$ABAT_TASK" 37 | build/setup.sh 38 | build/precheckin.py 39 | 40 | echo "+++ Build finished" 41 | -------------------------------------------------------------------------------- /build/build-debian-packages-inner.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eux 2 | OUTER_UID=$(stat -c '%u' .) 3 | OUTER_GID=$(stat -c '%g' .) 4 | trap "chown -R $OUTER_UID:$OUTER_GID ." EXIT 5 | export PATH=/usr/lib/ccache:$PATH 6 | make deb 7 | -------------------------------------------------------------------------------- /build/build-debian-packages.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eux 2 | ################################################################ 3 | # 4 | # Copyright 2015, Big Switch Networks, Inc. 5 | # 6 | # Licensed under the Eclipse Public License, Version 1.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.eclipse.org/legal/epl-v10.html 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 15 | # either express or implied. See the License for the specific 16 | # language governing permissions and limitations under the 17 | # License. 18 | # 19 | ################################################################ 20 | 21 | ROOTDIR=$(dirname $(readlink -f $0))/.. 22 | cd "$ROOTDIR" 23 | 24 | : Build ID: ${BUILD_ID:=devel} 25 | SUITE=trusty 26 | ARCH=amd64 27 | DOCKER_IMAGE=bigswitch/ivs-builder:ubuntu14.04 28 | BUILD_OS="$SUITE-$ARCH" 29 | 30 | BUILDDIR=$(mktemp -d) 31 | 32 | mkdir -p $BUILDDIR/ivs 33 | 34 | # Copy source code to a volume that will be mounted in the container 35 | #cp build/build-debian-packages-inner.sh $BUILDDIR/build-debian-packages-inner.sh 36 | rsync --files-from <(./build/files.sh) . "$BUILDDIR/ivs" 37 | 38 | docker.io run -e BUILD_ID=$BUILD_ID -e BUILD_OS=$BUILD_OS -v $BUILDDIR:/work -v /tmp/ivs.ccache:/.ccache -w /work/ivs $DOCKER_IMAGE ./build/build-debian-packages-inner.sh 39 | 40 | # Copy built packages to pkg/ 41 | OUTDIR=$(readlink -m "pkg/$BUILD_OS/$BUILD_ID") 42 | rm -rf "$OUTDIR" && mkdir -p "$OUTDIR" 43 | mv $BUILDDIR/*.deb "$OUTDIR" 44 | git log > "$OUTDIR/gitlog.txt" 45 | touch "$OUTDIR/build-$BUILD_ID" 46 | ln -snf $(basename $OUTDIR) $OUTDIR/../latest 47 | 48 | rm -rf "$BUILDDIR" 49 | -------------------------------------------------------------------------------- /build/build-rhel-packages-inner.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eux 2 | SPEC="/rpmbuild/SOURCES/ivs-7.0.spec" 3 | 4 | # RPM runs as root and doesn't like source files owned by a random UID 5 | OUTER_UID=$(stat -c '%u' $SPEC) 6 | OUTER_GID=$(stat -c '%g' $SPEC) 7 | trap "chown -R $OUTER_UID:$OUTER_GID /rpmbuild" EXIT 8 | export PATH=/usr/lib64/ccache:$PATH 9 | chown -R root:root /rpmbuild 10 | 11 | ln -s /rpmbuild /root/rpmbuild 12 | rpmbuild -bb $SPEC 13 | -------------------------------------------------------------------------------- /build/build-rhel-packages.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eux 2 | ################################################################ 3 | # 4 | # Copyright 2015, Big Switch Networks, Inc. 5 | # 6 | # Licensed under the Eclipse Public License, Version 1.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.eclipse.org/legal/epl-v10.html 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 15 | # either express or implied. See the License for the specific 16 | # language governing permissions and limitations under the 17 | # License. 18 | # 19 | ################################################################ 20 | 21 | ROOTDIR=$(dirname $(readlink -f $0))/.. 22 | cd "$ROOTDIR" 23 | 24 | : Build ID: ${BUILD_ID:=devel} 25 | DOCKER_IMAGE=bigswitch/ivs-builder:centos7 26 | BUILD_OS=centos7-x86_64 27 | 28 | BUILDDIR=$(mktemp -d) 29 | 30 | mkdir -p $BUILDDIR/SOURCES $BUILDDIR/RPMS 31 | 32 | # Copy source code to a volume that will be mounted in the container 33 | cp build/build-rhel-packages-inner.sh $BUILDDIR/build-rhel-packages-inner.sh 34 | cp rhel/ivs-7.0.spec $BUILDDIR/SOURCES 35 | tar -T <(./build/files.sh) -c -z -f $BUILDDIR/SOURCES/ivs.tar.gz --transform 's,^,ivs/,' 36 | 37 | docker.io run -e BUILD_ID=$BUILD_ID -e BUILD_OS=$BUILD_OS -v $BUILDDIR:/rpmbuild -v /tmp/ivs.ccache:/.ccache $DOCKER_IMAGE /rpmbuild/build-rhel-packages-inner.sh 38 | 39 | # Copy built RPMs to pkg/ 40 | OUTDIR=$(readlink -m "pkg/$BUILD_OS/$BUILD_ID") 41 | rm -rf "$OUTDIR" && mkdir -p "$OUTDIR" 42 | mv $BUILDDIR/RPMS/x86_64/*.rpm "$OUTDIR" 43 | git log > "$OUTDIR/gitlog.txt" 44 | touch "$OUTDIR/build-$BUILD_ID" 45 | ln -snf $(basename $OUTDIR) $OUTDIR/../latest 46 | 47 | rm -rf "$BUILDDIR" 48 | -------------------------------------------------------------------------------- /build/files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -ex 2 | ################################################################ 3 | # 4 | # Copyright 2013, Big Switch Networks, Inc. 5 | # 6 | # Licensed under the Eclipse Public License, Version 1.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.eclipse.org/legal/epl-v10.html 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 15 | # either express or implied. See the License for the specific 16 | # language governing permissions and limitations under the 17 | # License. 18 | # 19 | ################################################################ 20 | 21 | # List all files in this git repo and submodules 22 | git ls-files 23 | git submodule foreach --recursive --quiet 'git ls-files --with-tree="$sha1" |sed "s#^#$path/#"' 24 | -------------------------------------------------------------------------------- /build/ivs-callgrind.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eu 2 | ################################################################ 3 | # 4 | # Copyright 2013, Big Switch Networks, Inc. 5 | # 6 | # Licensed under the Eclipse Public License, Version 1.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.eclipse.org/legal/epl-v10.html 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 15 | # either express or implied. See the License for the specific 16 | # language governing permissions and limitations under the 17 | # License. 18 | # 19 | ################################################################ 20 | 21 | export VALGRIND_OPTIONS="--tool=callgrind --cache-sim=yes --branch-sim=yes --dump-instr=yes --callgrind-out-file=profile.kcg" 22 | trap "{ sudo chmod a+r profile.kcg; echo Output left in profile.kcg; }" EXIT 23 | $(dirname $(readlink -f $0))/ivs-valgrind.sh "$@" 24 | -------------------------------------------------------------------------------- /build/ivs-gdb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eu 2 | ################################################################ 3 | # 4 | # Copyright 2013, Big Switch Networks, Inc. 5 | # 6 | # Licensed under the Eclipse Public License, Version 1.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.eclipse.org/legal/epl-v10.html 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 15 | # either express or implied. See the License for the specific 16 | # language governing permissions and limitations under the 17 | # License. 18 | # 19 | ################################################################ 20 | 21 | TOOL="gdb --args" $(dirname $(readlink -f $0))/ivs.sh "$@" 22 | -------------------------------------------------------------------------------- /build/ivs-massif.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eu 2 | ################################################################ 3 | # 4 | # Copyright 2013, Big Switch Networks, Inc. 5 | # 6 | # Licensed under the Eclipse Public License, Version 1.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.eclipse.org/legal/epl-v10.html 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 15 | # either express or implied. See the License for the specific 16 | # language governing permissions and limitations under the 17 | # License. 18 | # 19 | ################################################################ 20 | 21 | export VALGRIND_OPTIONS="--tool=massif --alloc-fn=aim_malloc --alloc-fn=aim_zmalloc --alloc-fn=of_object_dup --massif-out-file=massif.out" 22 | trap "{ sudo chmod a+r massif.out; echo Output left in massif.out; }" EXIT 23 | $(dirname $(readlink -f $0))/ivs-valgrind.sh "$@" 24 | -------------------------------------------------------------------------------- /build/ivs-perf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eu 2 | ################################################################ 3 | # 4 | # Copyright 2013, Big Switch Networks, Inc. 5 | # 6 | # Licensed under the Eclipse Public License, Version 1.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.eclipse.org/legal/epl-v10.html 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 15 | # either express or implied. See the License for the specific 16 | # language governing permissions and limitations under the 17 | # License. 18 | # 19 | ################################################################ 20 | 21 | trap "{ sudo chmod a+r perf.data; }" EXIT 22 | TOOL="perf record -g" $(dirname $(readlink -f $0))/ivs.sh "$@" 23 | -------------------------------------------------------------------------------- /build/ivs-valgrind.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eu 2 | ################################################################ 3 | # 4 | # Copyright 2013, Big Switch Networks, Inc. 5 | # 6 | # Licensed under the Eclipse Public License, Version 1.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.eclipse.org/legal/epl-v10.html 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 15 | # either express or implied. See the License for the specific 16 | # language governing permissions and limitations under the 17 | # License. 18 | # 19 | ################################################################ 20 | 21 | TOOL="valgrind ${VALGRIND_OPTIONS:-}" $(dirname $(readlink -f $0))/ivs.sh "$@" 22 | -------------------------------------------------------------------------------- /build/ivs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eu 2 | ################################################################ 3 | # 4 | # Copyright 2013, Big Switch Networks, Inc. 5 | # 6 | # Licensed under the Eclipse Public License, Version 1.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.eclipse.org/legal/epl-v10.html 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 15 | # either express or implied. See the License for the specific 16 | # language governing permissions and limitations under the 17 | # License. 18 | # 19 | ################################################################ 20 | 21 | ROOT=$(dirname $(readlink -f $0))/.. 22 | TOOLCHAIN=${TOOLCHAIN:=gcc-local} 23 | sudo "$ROOT/build/veth_setup.sh" 24 | export INDIGO_BENCHMARK=1 # disable ratelimiters 25 | sudo -E ${TOOL:-} "$ROOT/targets/ivs/build/$TOOLCHAIN/bin/ivs" \ 26 | -i veth0 -i veth2 -i veth4 -i veth6 -i veth8 -i veth10 -i veth12 -i veth14 \ 27 | -c 127.0.0.1 -l 127.0.0.1:6634 "$@" 28 | -------------------------------------------------------------------------------- /build/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ################################################################ 3 | # 4 | # Copyright 2013, Big Switch Networks, Inc. 5 | # 6 | # Licensed under the Eclipse Public License, Version 1.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.eclipse.org/legal/epl-v10.html 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 15 | # either express or implied. See the License for the specific 16 | # language governing permissions and limitations under the 17 | # License. 18 | # 19 | ################################################################ 20 | 21 | # Run this script after git clone or pull. 22 | ROOTDIR=$(dirname $(readlink -f $0))/.. 23 | cd "$ROOTDIR" 24 | 25 | APT_GET="sudo DEBIAN_FRONTEND=noninteractive apt-get -q -y" 26 | 27 | # Run these only if part of git tree 28 | if [ -d ".git" ]; then 29 | git submodule init 30 | git submodule update 31 | 32 | # Show whitespace errors in git diff 33 | git config core.whitespace "trailing-space,space-before-tab" 34 | 35 | # Convert newlines to LF on commit, regardless of OS 36 | # (see http://help.github.com/dealing-with-lineendings/) 37 | git config core.autocrlf input 38 | 39 | # Include original text in conflict markers, as well as theirs and ours 40 | git config merge.conflictstyle diff3 41 | 42 | # Install our hooks 43 | for hook in .hooks/*; do 44 | ln -sf "../../$hook" .git/hooks/ 45 | done 46 | fi 47 | 48 | if ! which pkg-config &> /dev/null; then 49 | echo "Installing pkg-config" 50 | $APT_GET install pkg-config 51 | fi 52 | 53 | if ! which pcap-config &> /dev/null; then 54 | echo "Installing libpcap-dev" 55 | $APT_GET install libpcap-dev 56 | fi 57 | 58 | if ! python -c 'import pcap' &> /dev/null; then 59 | echo "Installing python-pypcap" 60 | $APT_GET install python-pypcap 61 | fi 62 | 63 | # libnl packaging changed between oneiric and precise 64 | if [ $(lsb_release -sc) \< precise ]; then 65 | if ! pkg-config --exists libnl-3.0; then 66 | echo "Installing libnl" 67 | $APT_GET install libnl3-dev 68 | fi 69 | else 70 | if ! pkg-config --exists libnl-3.0 libnl-route-3.0 libnl-genl-3.0; then 71 | echo "Installing libnl" 72 | $APT_GET install libnl-3-dev libnl-route-3-dev libnl-genl-3-dev 73 | fi 74 | fi 75 | -------------------------------------------------------------------------------- /build/veth_setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eu 2 | ################################################################ 3 | # 4 | # Copyright 2013, Big Switch Networks, Inc. 5 | # 6 | # Licensed under the Eclipse Public License, Version 1.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.eclipse.org/legal/epl-v10.html 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 15 | # either express or implied. See the License for the specific 16 | # language governing permissions and limitations under the 17 | # License. 18 | # 19 | ################################################################ 20 | 21 | N=8 22 | for I in `seq 0 $(($N-1))`; do 23 | A="veth$(($I*2))" 24 | B="veth$(($I*2+1))" 25 | if ! ip link show $A &> /dev/null; then 26 | ip link add name $A type veth peer name $B 27 | ip link set dev $A up 28 | ip link set dev $B up 29 | fi 30 | done 31 | -------------------------------------------------------------------------------- /build/veth_teardown.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eu 2 | ################################################################ 3 | # 4 | # Copyright 2013, Big Switch Networks, Inc. 5 | # 6 | # Licensed under the Eclipse Public License, Version 1.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.eclipse.org/legal/epl-v10.html 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 15 | # either express or implied. See the License for the specific 16 | # language governing permissions and limitations under the 17 | # License. 18 | # 19 | ################################################################ 20 | 21 | N=8 22 | for I in `seq 0 $(($N-1))`; do 23 | A="veth$(($I*2))" 24 | if ip link show $A &> /dev/null; then 25 | ip link delete $A type veth 26 | fi 27 | done 28 | -------------------------------------------------------------------------------- /debian/.gitignore: -------------------------------------------------------------------------------- 1 | *.ex 2 | *.EX 3 | *.substvars 4 | files 5 | /ivs 6 | /ivs-dbg 7 | /*.debhelper 8 | -------------------------------------------------------------------------------- /debian/README: -------------------------------------------------------------------------------- 1 | The Debian Package ivs 2 | ---------------------------- 3 | 4 | Comments regarding the Package 5 | 6 | -- Rich Lane Mon, 04 Feb 2013 12:07:19 -0800 7 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | ivs (0.5) unstable; urgency=low 2 | 3 | * New upstream version. 4 | 5 | -- Rich Lane Wed, 09 Jul 2014 23:13:27 -0700 6 | 7 | ivs (0.4) unstable; urgency=low 8 | 9 | * New upstream version. 10 | 11 | -- Rich Lane Fri, 28 Jun 2013 13:58:12 -0700 12 | 13 | ivs (0.3) unstable; urgency=low 14 | 15 | * Changed package name. 16 | 17 | -- Rich Lane Tue, 21 May 2013 11:21:36 -0700 18 | 19 | xenon (0.2) unstable; urgency=low 20 | 21 | * Added parallel HA. 22 | 23 | -- Rich Lane Tue, 09 Apr 2013 14:53:35 -0700 24 | 25 | xenon (0.1) unstable; urgency=low 26 | 27 | * Initial Release. 28 | 29 | -- Rich Lane Mon, 04 Feb 2013 12:07:19 -0800 30 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 8 2 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: ivs 2 | Section: net 3 | Priority: extra 4 | Maintainer: Rich Lane 5 | Build-Depends: debhelper (>= 8.0.0), libnl-3-dev | libnl3-dev, libnl-genl-3-dev | libnl3-dev, libnl-route-3-dev | libnl3-dev, pkg-config, python-tz, libcap-dev 6 | Standards-Version: 3.9.3 7 | Homepage: http://www.openflowhub.org/display/Indigo/Indigo+-+Open+Source+OpenFlow+Switches 8 | Vcs-Git: git://github.com/bigswitch/ivs 9 | Vcs-Browser: https://github.com/bigswitch/ivs 10 | 11 | Package: ivs 12 | Architecture: linux-any 13 | Depends: ${shlibs:Depends}, ${misc:Depends} 14 | Suggests: openvswitch-datapath-module 15 | Description: OpenFlow virtual switch 16 | IVS (Indigo Virtual Switch) is an OpenFlow virtual switch designed for high 17 | performance and minimal administration. It uses the openvswitch kernel module 18 | available in newer kernels or from the openvswitch-datapath-dkms package. 19 | 20 | Package: ivs-dbg 21 | Section: debug 22 | Architecture: linux-any 23 | Depends: ${shlibs:Depends}, ${misc:Depends}, ivs (= ${binary:Version}) 24 | Description: OpenFlow virtual switch (debug symbols) 25 | IVS (Indigo Virtual Switch) is an OpenFlow virtual switch designed for high 26 | performance and minimal administration. It uses the openvswitch kernel module 27 | available in newer kernels or from the openvswitch-datapath-dkms package. 28 | -------------------------------------------------------------------------------- /debian/docs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floodlight/ivs/fa9a580577046191824d450782eaa9047437263a/debian/docs -------------------------------------------------------------------------------- /debian/init.d: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ### BEGIN INIT INFO 19 | # Provides: ivs 20 | # Required-Start: $network $local_fs 21 | # Required-Stop: 22 | # Default-Start: 2 3 4 5 23 | # Default-Stop: 0 1 6 24 | # Short-Description: Indigo Virtual Switch 25 | ### END INIT INFO 26 | 27 | # Author: Rich Lane 28 | 29 | # PATH should only include /usr/* if it runs after the mountnfs.sh script 30 | PATH=/sbin:/usr/sbin:/bin:/usr/bin 31 | DESC=ivs 32 | NAME=ivs 33 | DAEMON=/usr/sbin/ivs 34 | DAEMON_ARGS="" 35 | SCRIPTNAME=/etc/init.d/$NAME 36 | 37 | # Exit if the package is not installed 38 | [ -x $DAEMON ] || exit 0 39 | 40 | # Read configuration variable file if it is present 41 | [ -r /etc/default/$NAME ] && . /etc/default/$NAME 42 | 43 | # Load the VERBOSE setting and other rcS variables 44 | . /lib/init/vars.sh 45 | 46 | # Define LSB log_* functions. 47 | # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. 48 | . /lib/lsb/init-functions 49 | 50 | # 51 | # Function that starts the daemon/service 52 | # 53 | do_start() 54 | { 55 | # Return 56 | # 0 if daemon has been started 57 | # 1 if daemon was already running 58 | # 2 if daemon could not be started 59 | lsmod | grep -q openvswitch || modprobe openvswitch 60 | start-stop-daemon --start --quiet --exec $DAEMON --test > /dev/null \ 61 | || return 1 62 | start-stop-daemon --start --quiet -b --exec $DAEMON -- \ 63 | --syslog $DAEMON_ARGS \ 64 | || return 2 65 | } 66 | 67 | # 68 | # Function that stops the daemon/service 69 | # 70 | do_stop() 71 | { 72 | # Return 73 | # 0 if daemon has been stopped 74 | # 1 if daemon was already stopped 75 | # 2 if daemon could not be stopped 76 | # other if a failure occurred 77 | start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --exec $DAEMON 78 | } 79 | 80 | # 81 | # Function that sends a SIGHUP to the daemon/service 82 | # 83 | do_reload() { 84 | # 85 | # If the daemon can reload its configuration without 86 | # restarting (for example, when it is sent a SIGHUP), 87 | # then implement that here. 88 | # 89 | start-stop-daemon --stop --signal 1 --quiet --exec $DAEMON 90 | return 0 91 | } 92 | 93 | case "$1" in 94 | start) 95 | [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME" 96 | do_start 97 | case "$?" in 98 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 99 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 100 | esac 101 | ;; 102 | stop) 103 | [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" 104 | do_stop 105 | case "$?" in 106 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 107 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 108 | esac 109 | ;; 110 | status) 111 | status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? 112 | ;; 113 | restart|force-reload) 114 | # 115 | # If the "reload" option is implemented then remove the 116 | # 'force-reload' alias 117 | # 118 | log_daemon_msg "Restarting $DESC" "$NAME" 119 | do_stop 120 | case "$?" in 121 | 0|1) 122 | do_start 123 | case "$?" in 124 | 0) log_end_msg 0 ;; 125 | 1) log_end_msg 1 ;; # Old process is still running 126 | *) log_end_msg 1 ;; # Failed to start 127 | esac 128 | ;; 129 | *) 130 | # Failed to stop 131 | log_end_msg 1 132 | ;; 133 | esac 134 | ;; 135 | *) 136 | echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 137 | exit 3 138 | ;; 139 | esac 140 | 141 | : 142 | -------------------------------------------------------------------------------- /debian/ivs.default: -------------------------------------------------------------------------------- 1 | # Default to connecting to a local OpenFlow controller 2 | DAEMON_ARGS="-c 127.0.0.1:6633" 3 | -------------------------------------------------------------------------------- /debian/ivs.manpages: -------------------------------------------------------------------------------- 1 | targets/ivs/ivs.8 2 | targets/ivs-ctl/ivs-ctl.8 3 | -------------------------------------------------------------------------------- /debian/ivs.upstart: -------------------------------------------------------------------------------- 1 | # ivs - An OpenFlow virtual switch 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | 19 | description "Indigo Virtual Switch" 20 | 21 | start on filesystem or runlevel [2345] 22 | stop on runlevel [!2345] 23 | 24 | respawn 25 | 26 | script 27 | DAEMON_ARGS="" 28 | . /etc/default/ivs 29 | lsmod | grep -q openvswitch || modprobe openvswitch 30 | exec ivs --syslog $DAEMON_ARGS 31 | end script 32 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # -*- makefile -*- 3 | # Sample debian/rules that uses debhelper. 4 | # This file was originally written by Joey Hess and Craig Small. 5 | # As a special exception, when this file is copied by dh-make into a 6 | # dh-make output file, you may use that output file without restriction. 7 | # This special exception was added by Craig Small in version 0.37 of dh-make. 8 | 9 | # Uncomment this to turn on verbose mode. 10 | #export DH_VERBOSE=1 11 | 12 | %: 13 | dh $@ 14 | 15 | override_dh_auto_build: 16 | make -j8 RELEASE=1 17 | 18 | override_dh_auto_install: 19 | make install DESTDIR=debian/ivs 20 | 21 | override_dh_strip: 22 | dh_strip --dbg-package=ivs-dbg 23 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (native) 2 | -------------------------------------------------------------------------------- /docker/centos7/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:centos7 2 | MAINTAINER Rich Lane 3 | RUN yum groupinstall -y 'Development Tools' 4 | RUN yum install -y libnl3-devel 5 | RUN yum install -y epel-release 6 | RUN yum install -y ccache 7 | RUN yum install -y libcap-devel 8 | RUN yum install -y libpcap-devel 9 | RUN yum install -y openssl-devel 10 | -------------------------------------------------------------------------------- /docker/ubuntu14.04/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | MAINTAINER Rich Lane 3 | RUN apt-get update && apt-get install -y build-essential pkg-config libnl-3-dev libnl-route-3-dev libnl-genl-3-dev python debhelper ccache 4 | RUN apt-get install -y libcap2-dev 5 | RUN apt-get install -y libpcap0.8-dev 6 | RUN apt-get install -y libssl-dev 7 | -------------------------------------------------------------------------------- /init.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | # 21 | # The root of of our repository is here: 22 | # 23 | ROOT := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) 24 | 25 | # 26 | # Resolve submodule dependencies. 27 | # 28 | ifndef SUBMODULE_INFRA 29 | ifdef SUBMODULES 30 | SUBMODULE_INFRA := $(SUBMODULES)/infra 31 | else 32 | SUBMODULE_INFRA := $(ROOT)/submodules/infra 33 | SUBMODULES_LOCAL += infra 34 | endif 35 | endif 36 | 37 | ifndef SUBMODULE_BIGCODE 38 | ifdef SUBMODULES 39 | SUBMODULE_BIGCODE := $(SUBMODULES)/bigcode 40 | else 41 | SUBMODULE_BIGCODE := $(ROOT)/submodules/bigcode 42 | SUBMODULES_LOCAL += bigcode 43 | endif 44 | endif 45 | 46 | ifndef SUBMODULE_INDIGO 47 | ifdef SUBMODULES 48 | SUBMODULE_INDIGO := $(SUBMODULES)/indigo 49 | else 50 | SUBMODULE_INDIGO := $(ROOT)/submodules/indigo 51 | SUBMODULES_LOCAL += indigo 52 | endif 53 | endif 54 | 55 | ifndef SUBMODULE_LUAJIT2 56 | ifdef SUBMODULES 57 | SUBMODULE_LUAJIT2 := $(SUBMODULES)/luajit-2.0 58 | else 59 | SUBMODULE_LUAJIT2 := $(ROOT)/submodules/luajit-2.0 60 | SUBMODULES_LOCAL += luajit2 61 | endif 62 | endif 63 | 64 | ifndef SUBMODULE_LOXIGEN_ARTIFACTS 65 | ifdef SUBMODULES 66 | SUBMODULE_LOXIGEN_ARTIFACTS := $(SUBMODULES)/loxigen-artifacts 67 | else 68 | SUBMODULE_LOXIGEN_ARTIFACTS := $(ROOT)/submodules/loxigen-artifacts 69 | SUBMODULES_LOCAL += loxigen-artifacts 70 | endif 71 | endif 72 | 73 | export SUBMODULE_INFRA 74 | export SUBMODULE_BIGCODE 75 | export SUBMODULE_INDIGO 76 | export SUBMODULE_LUAJIT2 77 | export BUILDER := $(SUBMODULE_INFRA)/builder/unix 78 | 79 | MODULE_DIRS := $(ROOT)/modules \ 80 | $(SUBMODULE_INFRA)/modules \ 81 | $(SUBMODULE_BIGCODE)/modules \ 82 | $(SUBMODULE_INDIGO)/modules 83 | 84 | .show-submodules: 85 | @echo infra @ $(SUBMODULE_INFRA) 86 | @echo bigcode @ $(SUBMODULE_BIGCODE) 87 | @echo indigo @ $(SUBMODULE_INDIGO) 88 | @echo luajit2 @ $(SUBMODULE_LUAJIT2) 89 | -------------------------------------------------------------------------------- /modules/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | /doc 3 | 4 | -------------------------------------------------------------------------------- /modules/Manifest.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | BASEDIR := $(dir $(lastword $(MAKEFILE_LIST))) 21 | OVSDriver_BASEDIR := $(BASEDIR)/OVSDriver 22 | flowtable_BASEDIR := $(BASEDIR)/flowtable 23 | l2table_BASEDIR := $(BASEDIR)/l2table 24 | luajit_BASEDIR := $(BASEDIR)/luajit 25 | xbuf_BASEDIR := $(BASEDIR)/xbuf 26 | pipeline_BASEDIR := $(BASEDIR)/pipeline 27 | pipeline_lua_BASEDIR := $(BASEDIR)/pipeline_lua 28 | pipeline_standard_BASEDIR := $(BASEDIR)/pipeline_standard 29 | ivs_common_BASEDIR := $(BASEDIR)/ivs 30 | tcam_BASEDIR := $(BASEDIR)/tcam 31 | action_BASEDIR := $(BASEDIR)/action 32 | stats_BASEDIR := $(BASEDIR)/stats 33 | pipeline_reflect_BASEDIR := $(BASEDIR)/pipeline_reflect 34 | shared_debug_counter_BASEDIR := $(BASEDIR)/shared_debug_counter 35 | packet_trace_BASEDIR := $(BASEDIR)/packet_trace 36 | -------------------------------------------------------------------------------- /modules/OVSDriver/.gitignore: -------------------------------------------------------------------------------- 1 | /OVSDriver.mk 2 | -------------------------------------------------------------------------------- /modules/OVSDriver/Makefile: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | ############################################################################### 21 | # 22 | # 23 | # 24 | ############################################################################### 25 | MODULE := OVSDriver 26 | AUTOMODULE := OVSDriver 27 | ifndef BUILDER 28 | $(error "$$BUILDER must be specified.") 29 | endif 30 | include $(BUILDER)/definemodule.mk 31 | -------------------------------------------------------------------------------- /modules/OVSDriver/README: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # 3 | # OVSDriver README 4 | # 5 | ############################################################################### 6 | 7 | -------------------------------------------------------------------------------- /modules/OVSDriver/module/auto/OVSDriver.yml: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # 3 | # OVSDriver Autogeneration Definitions. 4 | # 5 | ############################################################################### 6 | 7 | cdefs: &cdefs 8 | - OVSDRIVER_CONFIG_INCLUDE_LOGGING: 9 | doc: "Include or exclude logging." 10 | default: 1 11 | - OVSDRIVER_CONFIG_LOG_OPTIONS_DEFAULT: 12 | doc: "Default enabled log options." 13 | default: AIM_LOG_OPTIONS_DEFAULT 14 | - OVSDRIVER_CONFIG_LOG_BITS_DEFAULT: 15 | doc: "Default enabled log options." 16 | default: AIM_LOG_BITS_DEFAULT 17 | - OVSDRIVER_CONFIG_LOG_CUSTOM_BITS_DEFAULT: 18 | doc: "Default enabled custom log options." 19 | default: 0 20 | - OVSDRIVER_CONFIG_PORTING_STDLIB: 21 | doc: "Default all porting macros to use the C standard libraries." 22 | default: 1 23 | - OVSDRIVER_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: 24 | doc: "Include standard library headers for stdlib porting macros." 25 | default: OVSDRIVER_CONFIG_PORTING_STDLIB 26 | - OVSDRIVER_CONFIG_INCLUDE_UCLI: 27 | doc: "Include generic uCli support." 28 | default: 0 29 | 30 | 31 | definitions: 32 | cdefs: 33 | OVSDRIVER_CONFIG_HEADER: 34 | defs: *cdefs 35 | basename: ovsdriver_config 36 | 37 | portingmacro: 38 | OVSDRIVER: 39 | macros: 40 | - malloc 41 | - free 42 | - memset 43 | - memcpy 44 | - strncpy 45 | - vsnprintf 46 | - snprintf 47 | - strlen 48 | -------------------------------------------------------------------------------- /modules/OVSDriver/module/auto/make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | ############################################################################### 21 | # 22 | # OVSDriver Autogeneration 23 | # 24 | ############################################################################### 25 | OVSDriver_AUTO_DEFS := module/auto/OVSDriver.yml 26 | OVSDriver_AUTO_DIRS := module/inc/OVSDriver module/src 27 | include $(BUILDER)/auto.mk 28 | 29 | -------------------------------------------------------------------------------- /modules/OVSDriver/module/inc/OVSDriver/ovsdriver.h: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2013, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | #ifndef __OVSDRIVER_H__ 21 | #define __OVSDRIVER_H__ 22 | 23 | struct xbuf; 24 | 25 | indigo_error_t ind_ovs_init(const char *datapath_name, bool hitless); 26 | void ind_ovs_finish(void); 27 | void ind_ovs_enable(void); 28 | 29 | void ind_ovs_uplink_add(const char *name); 30 | indigo_error_t ind_ovs_port_add_internal(const char *port_name); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /modules/OVSDriver/module/inc/OVSDriver/ovsdriver.x: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2013, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | /**************************************************************************//** 21 | * 22 | * 23 | * 24 | *****************************************************************************/ 25 | #include 26 | 27 | 28 | /* <--auto.start.xmacro(ALL).define> */ 29 | /* */ 30 | 31 | /* <--auto.start.xenum(ALL).define> */ 32 | /* */ 33 | 34 | 35 | -------------------------------------------------------------------------------- /modules/OVSDriver/module/inc/OVSDriver/ovsdriver_dox.h: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2013, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | /**************************************************************************//** 21 | * 22 | * OVSDriver Doxygen Header 23 | * 24 | *****************************************************************************/ 25 | #ifndef __OVSDRIVER_DOX_H__ 26 | #define __OVSDRIVER_DOX_H__ 27 | 28 | /** 29 | * @defgroup OVSDriver OVSDriver - OVSDriver Description 30 | * 31 | 32 | The documentation overview for this module should go here. 33 | 34 | * 35 | * @{ 36 | * 37 | * @defgroup ovsdriver-ovsdriver Public Interface 38 | * @defgroup ovsdriver-config Compile Time Configuration 39 | * @defgroup ovsdriver-porting Porting Macros 40 | * 41 | * @} 42 | * 43 | */ 44 | 45 | #endif /* __OVSDRIVER_DOX_H__ */ 46 | -------------------------------------------------------------------------------- /modules/OVSDriver/module/make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | ############################################################################### 21 | # 22 | # 23 | # 24 | ############################################################################### 25 | THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 26 | OVSDriver_INCLUDES := -I $(THIS_DIR)inc 27 | OVSDriver_INTERNAL_INCLUDES := -I $(THIS_DIR)src 28 | OVSDriver_DEPENDMODULE_ENTRIES := init:ovsdriver 29 | 30 | -------------------------------------------------------------------------------- /modules/OVSDriver/module/src/Makefile: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | ############################################################################### 21 | # 22 | # Local source generation targets. 23 | # 24 | ############################################################################### 25 | 26 | ucli: 27 | $(INDIGO)/Tools/uclihandlers.py ovsdriver_ucli.c 28 | 29 | -------------------------------------------------------------------------------- /modules/OVSDriver/module/src/experimenter.c: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2013, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | #include "ovs_driver_int.h" 21 | #include 22 | 23 | indigo_error_t 24 | indigo_fwd_experimenter(of_experimenter_t *experimenter, 25 | indigo_cxn_id_t cxn_id) 26 | { 27 | return INDIGO_ERROR_NOT_SUPPORTED; 28 | } 29 | 30 | indigo_error_t 31 | indigo_port_experimenter(of_experimenter_t *experimenter, 32 | indigo_cxn_id_t cxn_id) 33 | { 34 | return INDIGO_ERROR_NOT_SUPPORTED; 35 | } 36 | -------------------------------------------------------------------------------- /modules/OVSDriver/module/src/fwd.c: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2013, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | #include "ovs_driver_int.h" 21 | 22 | indigo_error_t 23 | indigo_fwd_forwarding_features_get(of_features_reply_t *features) 24 | { 25 | uint32_t capabilities = 0, actions = 0; 26 | 27 | of_features_reply_n_tables_set(features, 1); 28 | 29 | OF_CAPABILITIES_FLAG_FLOW_STATS_SET(capabilities, features->version); 30 | OF_CAPABILITIES_FLAG_TABLE_STATS_SET(capabilities, features->version); 31 | OF_CAPABILITIES_FLAG_PORT_STATS_SET(capabilities, features->version); 32 | OF_CAPABILITIES_FLAG_QUEUE_STATS_SET(capabilities, features->version); 33 | OF_CAPABILITIES_FLAG_ARP_MATCH_IP_SET(capabilities, features->version); 34 | of_features_reply_capabilities_set(features, capabilities); 35 | 36 | if (features->version == OF_VERSION_1_0) { 37 | OF_FLAG_ENUM_SET(actions, 38 | OF_ACTION_TYPE_OUTPUT_BY_VERSION(features->version)); 39 | OF_FLAG_ENUM_SET(actions, 40 | OF_ACTION_TYPE_SET_VLAN_VID_BY_VERSION(features->version)); 41 | OF_FLAG_ENUM_SET(actions, 42 | OF_ACTION_TYPE_SET_VLAN_PCP_BY_VERSION(features->version)); 43 | OF_FLAG_ENUM_SET(actions, 44 | OF_ACTION_TYPE_STRIP_VLAN_BY_VERSION(features->version)); 45 | OF_FLAG_ENUM_SET(actions, 46 | OF_ACTION_TYPE_SET_DL_SRC_BY_VERSION(features->version)); 47 | OF_FLAG_ENUM_SET(actions, 48 | OF_ACTION_TYPE_SET_DL_DST_BY_VERSION(features->version)); 49 | OF_FLAG_ENUM_SET(actions, 50 | OF_ACTION_TYPE_SET_NW_SRC_BY_VERSION(features->version)); 51 | OF_FLAG_ENUM_SET(actions, 52 | OF_ACTION_TYPE_SET_NW_DST_BY_VERSION(features->version)); 53 | OF_FLAG_ENUM_SET(actions, 54 | OF_ACTION_TYPE_SET_NW_TOS_BY_VERSION(features->version)); 55 | OF_FLAG_ENUM_SET(actions, 56 | OF_ACTION_TYPE_SET_TP_SRC_BY_VERSION(features->version)); 57 | OF_FLAG_ENUM_SET(actions, 58 | OF_ACTION_TYPE_SET_TP_DST_BY_VERSION(features->version)); 59 | #if 0 60 | OF_FLAG_ENUM_SET(actions, 61 | OF_ACTION_TYPE_ENQUEUE_BY_VERSION(features->version)); 62 | #endif 63 | of_features_reply_actions_set(features, actions); 64 | } 65 | 66 | return (INDIGO_ERROR_NONE); 67 | } 68 | -------------------------------------------------------------------------------- /modules/OVSDriver/module/src/hitless.c: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2015, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | #include "ovs_driver_int.h" 21 | #include 22 | 23 | /* 24 | * Take over management of the kernel flowtable 25 | * 26 | * If ind_ovs_hitless is true then until this point we have not touched the 27 | * kernel flowtable. Flows that were active when the previous instance of 28 | * IVS died have continued using their kernel flows while this IVS booted 29 | * and was configured by the controller. New flows have been handled by the 30 | * upcall threads and likely dropped. 31 | * 32 | * The controller sends this message to tell us that it has finished pushing 33 | * OpenFlow table entries and we're ready to manage the existing flows. 34 | * 35 | * Currently this just flushes the kernel flowtable and relies on the upcall 36 | * threads to figure out what should go back into the kernel flowtable. 37 | * Future work is to read the flows from the kernel, validate them against the 38 | * new userspace forwarding state, and modify them if necessary. 39 | */ 40 | static void 41 | handle_takeover(indigo_cxn_id_t cxn_id, of_object_t *msg) 42 | { 43 | if (ind_ovs_hitless) { 44 | AIM_LOG_INFO("Received takeover message"); 45 | ind_ovs_kflow_flush(); 46 | ind_ovs_hitless = false; 47 | } else { 48 | AIM_LOG_VERBOSE("Not in hitless restart mode, ignoring takeover message"); 49 | } 50 | } 51 | 52 | static indigo_core_listener_result_t 53 | message_listener(indigo_cxn_id_t cxn_id, of_object_t *msg) 54 | { 55 | switch (msg->object_id) { 56 | case OF_BSN_TAKEOVER: 57 | handle_takeover(cxn_id, msg); 58 | return INDIGO_CORE_LISTENER_RESULT_DROP; 59 | 60 | default: 61 | return INDIGO_CORE_LISTENER_RESULT_PASS; 62 | } 63 | } 64 | 65 | void 66 | ind_ovs_hitless_init(void) 67 | { 68 | indigo_core_message_listener_register(message_listener); 69 | } 70 | -------------------------------------------------------------------------------- /modules/OVSDriver/module/src/make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | ############################################################################### 21 | # 22 | # /module/src/make.mk 23 | # 24 | # OVS Driver Builder Information 25 | # 26 | ############################################################################### 27 | 28 | 29 | LIBRARY := OVSDriver 30 | $(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) 31 | include $(BUILDER)/lib.mk 32 | 33 | -------------------------------------------------------------------------------- /modules/OVSDriver/module/src/ovsdriver_log.h: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2013, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | /**************************************************************************//** 21 | * 22 | * 23 | * 24 | *****************************************************************************/ 25 | #ifndef __OVSDRIVER_LOG_H__ 26 | #define __OVSDRIVER_LOG_H__ 27 | 28 | #define AIM_LOG_MODULE_NAME ovsdriver 29 | #include 30 | 31 | #endif /* __OVSDRIVER_LOG_H__ */ 32 | -------------------------------------------------------------------------------- /modules/OVSDriver/module/src/pipeline.c: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2013, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | #include "ovs_driver_int.h" 21 | #include 22 | 23 | void 24 | indigo_fwd_pipeline_get(of_desc_str_t pipeline) 25 | { 26 | const char *name = pipeline_get(); 27 | memset(pipeline, 0, sizeof(of_desc_str_t)); 28 | strncpy(pipeline, name, sizeof(of_desc_str_t)); 29 | } 30 | 31 | indigo_error_t 32 | indigo_fwd_pipeline_set(of_desc_str_t pipeline) 33 | { 34 | return pipeline_set(pipeline); 35 | } 36 | 37 | void 38 | indigo_fwd_pipeline_stats_get(of_desc_str_t **pipelines, int *num_pipelines) 39 | { 40 | pipeline_list(pipelines, num_pipelines); 41 | } 42 | -------------------------------------------------------------------------------- /modules/OVSDriver/module/src/uplink.c: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2014, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | #include "ovs_driver_int.h" 21 | #include "ovsdriver_log.h" 22 | #include 23 | #include 24 | 25 | /* List of string interface names */ 26 | static biglist_t *uplinks = NULL; 27 | 28 | static of_port_no_t current_uplink = OF_PORT_DEST_NONE; 29 | 30 | void 31 | ind_ovs_uplink_add(const char *name) 32 | { 33 | uplinks = biglist_append(uplinks, strdup(name)); 34 | } 35 | 36 | bool 37 | ind_ovs_uplink_check_by_name(const char *name) 38 | { 39 | biglist_t *element; 40 | char *str; 41 | BIGLIST_FOREACH_DATA(element, uplinks, char *, str) { 42 | if (!strcmp(name, str)) { 43 | return true; 44 | } 45 | } 46 | return false; 47 | } 48 | 49 | bool 50 | ind_ovs_uplink_check(of_port_no_t port_no) 51 | { 52 | struct ind_ovs_port *port = ind_ovs_port_lookup(port_no); 53 | if (port == NULL) { 54 | return false; 55 | } 56 | return port->is_uplink; 57 | } 58 | 59 | of_port_no_t 60 | ind_ovs_uplink_select(void) 61 | { 62 | return current_uplink; 63 | } 64 | 65 | static bool 66 | is_valid_uplink(uint32_t port_no) 67 | { 68 | if (port_no > IND_OVS_MAX_PORTS) { 69 | return false; 70 | } 71 | struct ind_ovs_port *port = ind_ovs_ports[port_no]; 72 | return port && port->is_uplink && port->ifflags & IFF_RUNNING; 73 | } 74 | 75 | /* 76 | * Called whenever an uplink is added, removed, or link status changed. 77 | * May select a new port to be returned by ind_ovs_uplink_select. 78 | */ 79 | void 80 | ind_ovs_uplink_reselect(void) 81 | { 82 | /* Sticky - keep current uplink if it's still good */ 83 | if (is_valid_uplink(current_uplink)) { 84 | AIM_LOG_VERBOSE("Keeping same uplink"); 85 | return; 86 | } 87 | 88 | /* Pick first valid uplink */ 89 | int i; 90 | for (i = 0; i < IND_OVS_MAX_PORTS; i++) { 91 | if (is_valid_uplink(i)) { 92 | current_uplink = i; 93 | AIM_LOG_VERBOSE("Selected uplink %s", ind_ovs_ports[i]->ifname); 94 | return; 95 | } 96 | } 97 | 98 | current_uplink = OF_PORT_DEST_NONE; 99 | AIM_LOG_VERBOSE("No uplinks available"); 100 | } 101 | -------------------------------------------------------------------------------- /modules/OVSDriver/module/src/vlan_counters.c: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2014, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | #include 21 | #include 22 | 23 | struct vlan_counters { 24 | struct stats_handle rx_stats_handle; 25 | struct stats_handle tx_stats_handle; 26 | }; 27 | 28 | static struct vlan_counters vcounters[4096]; 29 | 30 | void 31 | ind_ovs_vlan_stats_init(void) 32 | { 33 | int i; 34 | for (i = 0; i < 4096; i++) { 35 | stats_alloc(&vcounters[i].rx_stats_handle); 36 | stats_alloc(&vcounters[i].tx_stats_handle); 37 | } 38 | } 39 | 40 | void 41 | indigo_fwd_vlan_stats_get(uint16_t vlan_vid, indigo_fi_vlan_stats_t *vlan_stats) 42 | { 43 | if (vlan_vid < 1 || vlan_vid > 4095) return; 44 | 45 | AIM_ASSERT(vlan_stats != NULL); 46 | 47 | struct stats rx_stats, tx_stats; 48 | stats_get(&vcounters[vlan_vid].rx_stats_handle, &rx_stats); 49 | stats_get(&vcounters[vlan_vid].tx_stats_handle, &tx_stats); 50 | 51 | vlan_stats->rx_bytes = rx_stats.bytes; 52 | vlan_stats->rx_packets = rx_stats.packets; 53 | vlan_stats->tx_bytes = tx_stats.bytes; 54 | vlan_stats->tx_packets = tx_stats.packets; 55 | } 56 | 57 | struct stats_handle * 58 | ind_ovs_rx_vlan_stats_select(uint16_t vlan_vid) 59 | { 60 | AIM_ASSERT(vlan_vid > 0 && vlan_vid < 4096); 61 | 62 | return &vcounters[vlan_vid].rx_stats_handle; 63 | } 64 | 65 | struct stats_handle * 66 | ind_ovs_tx_vlan_stats_select(uint16_t vlan_vid) 67 | { 68 | AIM_ASSERT(vlan_vid > 0 && vlan_vid < 4096); 69 | 70 | return &vcounters[vlan_vid].tx_stats_handle; 71 | } 72 | -------------------------------------------------------------------------------- /modules/OVSDriver/utest/_make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | ############################################################################### 21 | # 22 | # OVSDriver Unit Test Makefile. 23 | # 24 | ############################################################################### 25 | UMODULE := OVSDriver 26 | UMODULE_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) 27 | include $(BUILDER)/utest.mk 28 | -------------------------------------------------------------------------------- /modules/OVSDriver/utest/main.c: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2013, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | /**************************************************************************//** 21 | * 22 | * 23 | * 24 | *****************************************************************************/ 25 | #include 26 | 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | int aim_main(int argc, char* argv[]) 34 | { 35 | printf("OVSDriver Utest Is Empty\n"); 36 | ovsdriver_config_show(&aim_pvs_stdout); 37 | return 0; 38 | } 39 | 40 | -------------------------------------------------------------------------------- /modules/action/.gitignore: -------------------------------------------------------------------------------- 1 | /action.mk 2 | -------------------------------------------------------------------------------- /modules/action/module/make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2014, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 21 | action_INCLUDES := -I $(THIS_DIR)inc 22 | action_INTERNAL_INCLUDES := -I $(THIS_DIR)src 23 | -------------------------------------------------------------------------------- /modules/action/module/src/make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2014, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | LIBRARY := action 21 | $(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) 22 | include $(BUILDER)/lib.mk 23 | -------------------------------------------------------------------------------- /modules/ivs/.gitignore: -------------------------------------------------------------------------------- 1 | ivs_common.mk 2 | -------------------------------------------------------------------------------- /modules/ivs/module/make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 21 | ivs_common_INCLUDES := -I $(THIS_DIR)inc 22 | ivs_common_INTERNAL_INCLUDES := -I $(THIS_DIR)src 23 | -------------------------------------------------------------------------------- /modules/ivs/module/src/make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | LIBRARY := ivs_common 21 | $(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) 22 | include $(BUILDER)/lib.mk 23 | -------------------------------------------------------------------------------- /modules/l2table/.gitignore: -------------------------------------------------------------------------------- 1 | flowtable.mk 2 | -------------------------------------------------------------------------------- /modules/l2table/l2table.mk: -------------------------------------------------------------------------------- 1 | 2 | ############################################################################### 3 | # 4 | # Inclusive Makefile for the l2table module. 5 | # 6 | # Autogenerated 2013-06-10 19:59:21.597446 7 | # 8 | ############################################################################### 9 | l2table_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) 10 | include $(l2table_BASEDIR)/module/make.mk 11 | include $(l2table_BASEDIR)/module/src/make.mk 12 | include $(l2table_BASEDIR)/utest/_make.mk 13 | -------------------------------------------------------------------------------- /modules/l2table/module/inc/l2table/l2table.h: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2013, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | /* 21 | * l2table - Efficiently map MAC/VLAN to metadata and out port. 22 | */ 23 | 24 | #ifndef L2TABLE_H 25 | #define L2TABLE_H 26 | 27 | #include 28 | 29 | #define L2TABLE_MAC_LEN 6 30 | 31 | struct l2table; 32 | 33 | /** 34 | * Create a l2table 35 | * 36 | * @param salt Random number used to seed hash function. 37 | */ 38 | struct l2table *l2table_create(uint32_t salt); 39 | 40 | /** 41 | * Destroy a l2table 42 | */ 43 | void l2table_destroy(struct l2table *t); 44 | 45 | /** 46 | * Lookup a MAC/VLAN pair 47 | * 48 | * Returns the associated output port and metadata. 49 | * 50 | * Returns AIM_ERROR_NOT_FOUND if the entry does not exist. 51 | */ 52 | aim_error_t l2table_lookup(struct l2table *t, 53 | const uint8_t mac[L2TABLE_MAC_LEN], 54 | uint16_t vlan_id, 55 | uint32_t *out_port, 56 | uint32_t *metadata); 57 | 58 | /** 59 | * Insert an entry 60 | * 61 | * Returns AIM_ERROR_PARAM if the entry already exists. 62 | */ 63 | aim_error_t l2table_insert(struct l2table *t, 64 | const uint8_t mac[L2TABLE_MAC_LEN], 65 | uint16_t vlan_id, 66 | uint32_t out_port, 67 | uint32_t metadata); 68 | 69 | /** 70 | * Remove an entry 71 | * 72 | * Returns AIM_ERROR_NOT_FOUND if the entry does not exist. 73 | */ 74 | aim_error_t l2table_remove(struct l2table *t, 75 | const uint8_t mac[L2TABLE_MAC_LEN], 76 | uint16_t vlan_id); 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /modules/l2table/module/make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 21 | l2table_INCLUDES := -I $(THIS_DIR)inc 22 | l2table_INTERNAL_INCLUDES := -I $(THIS_DIR)src 23 | -------------------------------------------------------------------------------- /modules/l2table/module/src/make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | LIBRARY := l2table 21 | $(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) 22 | include $(BUILDER)/lib.mk 23 | -------------------------------------------------------------------------------- /modules/l2table/utest/_make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | UMODULE := l2table 21 | UMODULE_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) 22 | include $(BUILDER)/utest.mk 23 | -------------------------------------------------------------------------------- /modules/luajit/Makefile: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | ############################################################################### 21 | # 22 | # Makefile 23 | # 24 | # luajit Makefile 25 | # 26 | ############################################################################### 27 | MODULE := luajit 28 | 29 | ifndef INDIGO 30 | INDIGO:=$(dir $(lastword $(MAKEFILE_LIST)))../../indigo 31 | endif 32 | 33 | # Necessary for our own settings and the Builder itself 34 | ifndef BUILDER 35 | BUILDER:=$(INDIGO)/Builder/unix 36 | endif 37 | 38 | include $(BUILDER)/definemodule.mk 39 | -------------------------------------------------------------------------------- /modules/luajit/luajit.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 21 | LUAJIT := $(THIS_DIR)/../../submodules/luajit-2.0 22 | luajit_INCLUDES := -I $(LUAJIT)/src 23 | 24 | LIBRARY_TARGETS += libluajit.a 25 | 26 | .PHONY: libluajit.a 27 | libluajit.a: 28 | $(VERBOSE) $(MAKE) -C $(LUAJIT)/src libluajit.a LJCORE_O=ljamalg.o BUILDMODE=static CCDEBUG=-g 29 | $(VERBOSE) cp $(LUAJIT)/src/libluajit.a $(LIBRARY_DIR)/libluajit.a 30 | -------------------------------------------------------------------------------- /modules/packet_trace/.gitignore: -------------------------------------------------------------------------------- 1 | /packet_trace.mk 2 | -------------------------------------------------------------------------------- /modules/packet_trace/module/inc/packet_trace/packet_trace.h: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2015, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | /* 21 | * This module allows the user to see logs from the forwarding pipeline for a 22 | * subset of packets. 23 | */ 24 | 25 | #ifndef PACKET_TRACE_H 26 | #define PACKET_TRACE_H 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | void packet_trace_init(const char *name); 34 | 35 | void packet_trace_begin(uint32_t in_port); 36 | void packet_trace_end(void); 37 | void packet_trace_internal(const char *fmt, va_list vargs); 38 | void packet_trace_set_fd_bitmap(aim_bitmap_t *bitmap); 39 | 40 | extern bool packet_trace_enabled; 41 | 42 | static inline void 43 | packet_trace(const char *fmt, ...) 44 | { 45 | if (__builtin_expect(packet_trace_enabled, false)) { 46 | va_list vargs; 47 | va_start(vargs, fmt); 48 | packet_trace_internal(fmt, vargs); 49 | va_end(vargs); 50 | } 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /modules/packet_trace/module/make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2015, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 21 | packet_trace_INCLUDES := -I $(THIS_DIR)inc 22 | packet_trace_INTERNAL_INCLUDES := -I $(THIS_DIR)src 23 | packet_trace_DEPENDMODULE_ENTRIES := init:packet_trace 24 | -------------------------------------------------------------------------------- /modules/packet_trace/module/src/make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2015, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | LIBRARY := packet_trace 21 | $(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) 22 | include $(BUILDER)/lib.mk 23 | -------------------------------------------------------------------------------- /modules/pipeline/.gitignore: -------------------------------------------------------------------------------- 1 | /pipeline.mk 2 | -------------------------------------------------------------------------------- /modules/pipeline/module/inc/pipeline/pipeline.h: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2013, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | /* 21 | * pipeline - Packet processing pipeline 22 | */ 23 | 24 | #ifndef PIPELINE_H 25 | #define PIPELINE_H 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | struct ind_ovs_parsed_key; 34 | 35 | struct pipeline_ops { 36 | void (*init)(const char *name); 37 | void (*finish)(void); 38 | indigo_error_t (*process)( 39 | struct ind_ovs_parsed_key *key, 40 | struct ind_ovs_parsed_key *mask, 41 | struct xbuf *stats, 42 | struct action_context *actx); 43 | }; 44 | 45 | /* 46 | * Register a pipeline implementation 47 | * 48 | * 'name' must be unique. 49 | */ 50 | void pipeline_register(const char *name, const struct pipeline_ops *ops); 51 | 52 | /* 53 | * Choose a pipeline implementation 54 | * 55 | * Returns an error and has no effect if 'name' is not a valid pipeline name. 56 | * 57 | * Cleans up the old pipeline and initializes the new one. This happens even if 58 | * 'name' matches the current pipeline. 59 | * 60 | * Initially no pipeline is current. Attempting to process packets will cause 61 | * an abort until this function is used to choose a pipeline. 62 | * 63 | * If name is NULL then the current pipeline is cleaned up and no new pipeline 64 | * is initialized. 65 | */ 66 | indigo_error_t pipeline_set(const char *name); 67 | 68 | /* 69 | * Get the name of the current pipeline 70 | */ 71 | const char *pipeline_get(void); 72 | 73 | /* 74 | * Get a list of supported pipelines 75 | */ 76 | void pipeline_list(of_desc_str_t **ret_pipelines, int *num_pipelines); 77 | 78 | /* 79 | * Send a packet through the pipeline. 80 | * 81 | * 'key' is the packet key sent by the kernel. 'mask' is the megaflow mask 82 | * that will be installed in the kernel. It should be initialized to zeroes 83 | * and the pipeline implementation will set each bit where it used the 84 | * corresponding key bit in its processing. 85 | * 86 | * 'stats' should be an initialized, empty xbuf. It will be be filled with 87 | * struct stats_handle. These stats objects may belong to flows or tables 88 | * (and in the future meters or groups). For example, every table a packet 89 | * matched in will have its matched_stats added here. 90 | * 91 | * 'actx' should be an initialized action_context. 92 | */ 93 | indigo_error_t 94 | pipeline_process(struct ind_ovs_parsed_key *key, 95 | struct ind_ovs_parsed_key *mask, 96 | struct xbuf *stats, 97 | struct action_context *actx); 98 | 99 | /* 100 | * Convenience function to append a stats handle to an xbuf 101 | * 102 | * This is used by pipeline implementations to fill the stats xbuf passed to 103 | * pipeline_process. 104 | */ 105 | static inline void 106 | pipeline_add_stats(struct xbuf *stats, struct stats_handle *stats_handle) 107 | { 108 | xbuf_append(stats, stats_handle, sizeof(*stats_handle)); 109 | } 110 | 111 | /* 112 | * Set the queue priority for inband control packets. 113 | */ 114 | void pipeline_inband_queue_priority_set(int priority); 115 | 116 | #endif 117 | -------------------------------------------------------------------------------- /modules/pipeline/module/make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 21 | pipeline_INCLUDES := -I $(THIS_DIR)inc 22 | pipeline_INTERNAL_INCLUDES := -I $(THIS_DIR)src 23 | pipeline_DEPENDMODULE_ENTRIES := init:pipeline 24 | -------------------------------------------------------------------------------- /modules/pipeline/module/src/make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | LIBRARY := pipeline 21 | $(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) 22 | include $(BUILDER)/lib.mk 23 | -------------------------------------------------------------------------------- /modules/pipeline_lua/.gitignore: -------------------------------------------------------------------------------- 1 | /pipeline_lua.mk 2 | -------------------------------------------------------------------------------- /modules/pipeline_lua/module/make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2014, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 21 | pipeline_lua_INCLUDES := -I $(THIS_DIR)inc 22 | pipeline_lua_INTERNAL_INCLUDES := -I $(THIS_DIR)src 23 | pipeline_lua_DEPENDMODULE_ENTRIES := init:pipeline_lua 24 | -------------------------------------------------------------------------------- /modules/pipeline_lua/module/src/allocator.c: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2015, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | /* 21 | * Bump allocator 22 | * 23 | * This allocator is used for safety, not speed. We don't want to give 24 | * Lua code pointers to the normal heap because it could save them 25 | * and use them later when they refer to a different object. 26 | * 27 | * Instead, we dedicate memory for communication with Lua. Even if 28 | * Lua code tries to access this memory after it's been freed, it 29 | * won't be able to read or write datastructures that it doesn't 30 | * already own. The corollary is that C code can't trust anything 31 | * it reads from this memory. 32 | * 33 | * The lifetime of these allocations is limited to a single "event", 34 | * whether it's a gentable operation, upcall processing, etc. This 35 | * assumption enables us to reset the heap all at once instead of 36 | * freeing allocations individually. 37 | */ 38 | 39 | #include 40 | #include "pipeline_lua_int.h" 41 | 42 | #define AIM_LOG_MODULE_NAME pipeline_lua 43 | #include 44 | 45 | /* 46 | * We only expect to need 2*64K for the worst case of the 47 | * bsn_lua_command_request message. 48 | */ 49 | #define ALLOCATOR_SIZE (1024*1024) 50 | 51 | static char allocator_heap[ALLOCATOR_SIZE]; 52 | static uint32_t allocator_offset; 53 | 54 | void * 55 | pipeline_lua_allocator_alloc(uint32_t size) 56 | { 57 | if (size > ALLOCATOR_SIZE || allocator_offset + size > ALLOCATOR_SIZE) { 58 | AIM_DIE("Exceeded Lua allocator maximum size"); 59 | } 60 | 61 | void *ptr = allocator_heap + allocator_offset; 62 | allocator_offset += size; 63 | return ptr; 64 | } 65 | 66 | void * 67 | pipeline_lua_allocator_dup(void *src, uint32_t size) 68 | { 69 | void *dst = pipeline_lua_allocator_alloc(size); 70 | memcpy(dst, src, size); 71 | return dst; 72 | } 73 | 74 | void 75 | pipeline_lua_allocator_reset(void) 76 | { 77 | allocator_offset = 0; 78 | } 79 | -------------------------------------------------------------------------------- /modules/pipeline_lua/module/src/builtin_lua.c: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2014, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | #include "pipeline_lua_int.h" 21 | 22 | /* The build system automatically picks up Lua files in this directory, but to 23 | * load them into the VM they need to be specified here */ 24 | #define BUILTIN_LUA \ 25 | X(base) \ 26 | X(actions) \ 27 | X(xdr) \ 28 | X(murmur) \ 29 | X(hashtable) 30 | 31 | #define BUILTIN_LUA_START(name) _binary_ ## name ## _lua_start 32 | #define BUILTIN_LUA_END(name) _binary_ ## name ## _lua_end 33 | 34 | #define X(name) \ 35 | extern const char BUILTIN_LUA_START(name)[]; \ 36 | extern const char BUILTIN_LUA_END(name)[]; 37 | BUILTIN_LUA 38 | #undef X 39 | 40 | const struct builtin_lua pipeline_lua_builtin_lua[] = { 41 | #define X(name) { \ 42 | AIM_STRINGIFY(name) ".lua", \ 43 | BUILTIN_LUA_START(name), \ 44 | BUILTIN_LUA_END(name), \ 45 | }, 46 | BUILTIN_LUA 47 | #undef X 48 | { NULL, NULL, 0 } 49 | }; 50 | -------------------------------------------------------------------------------- /modules/pipeline_lua/module/src/fields.c: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2014, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | #include "pipeline_lua_int.h" 21 | #include 22 | #include 23 | 24 | const char *pipeline_lua_field_names[] = { 25 | #define field(name) AIM_STRINGIFY(name), 26 | FIELDS 27 | #undef field 28 | NULL, 29 | }; 30 | 31 | void 32 | pipeline_lua_fields_from_key(struct ind_ovs_parsed_key *key, 33 | struct fields *fields) 34 | { 35 | memset(fields, 0, sizeof(*fields)); 36 | 37 | fields->in_port = key->in_port; 38 | 39 | { 40 | uint8_t *m = key->ethernet.eth_dst; 41 | fields->eth_dst_lo = (m[2] << 24) | (m[3] << 16) | (m[4] << 8) | m[5]; 42 | fields->eth_dst_hi = (m[0] << 8) | m[1]; 43 | } 44 | 45 | { 46 | uint8_t *m = key->ethernet.eth_src; 47 | fields->eth_src_lo = (m[2] << 24) | (m[3] << 16) | (m[4] << 8) | m[5]; 48 | fields->eth_src_hi = (m[0] << 8) | m[1]; 49 | } 50 | 51 | if (ATTR_BITMAP_TEST(key->populated, OVS_KEY_ATTR_ETHERTYPE)) { 52 | fields->eth_type = ntohs(key->ethertype); 53 | } 54 | 55 | if (ATTR_BITMAP_TEST(key->populated, OVS_KEY_ATTR_VLAN)) { 56 | fields->vlan_vid = VLAN_VID(ntohs(key->vlan)); 57 | fields->vlan_pcp = VLAN_PCP(ntohs(key->vlan)); 58 | } 59 | 60 | if (ATTR_BITMAP_TEST(key->populated, OVS_KEY_ATTR_IPV4)) { 61 | fields->ip_dscp = (key->ipv4.ipv4_tos & IP_DSCP_MASK) >> IP_DSCP_SHIFT; 62 | fields->ip_ecn = key->ipv4.ipv4_tos & IP_ECN_MASK; 63 | fields->ip_proto = key->ipv4.ipv4_proto; 64 | fields->ipv4_src = ntohl(key->ipv4.ipv4_src); 65 | fields->ipv4_dst = ntohl(key->ipv4.ipv4_dst); 66 | } 67 | 68 | if (ATTR_BITMAP_TEST(key->populated, OVS_KEY_ATTR_TCP)) { 69 | fields->tp_src = ntohs(key->tcp.tcp_src); 70 | fields->tp_dst = ntohs(key->tcp.tcp_dst); 71 | } else if (ATTR_BITMAP_TEST(key->populated, OVS_KEY_ATTR_UDP)) { 72 | fields->tp_src = ntohs(key->udp.udp_src); 73 | fields->tp_dst = ntohs(key->udp.udp_dst); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /modules/pipeline_lua/module/src/log.c: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2015, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | #include "pipeline_lua_int.h" 21 | #include 22 | 23 | #define AIM_LOG_MODULE_NAME pipeline_lua 24 | #include 25 | 26 | AIM_LOG_STRUCT_DEFINE(AIM_LOG_OPTIONS_DEFAULT, AIM_LOG_BITS_DEFAULT, NULL, 0); 27 | 28 | void 29 | pipeline_lua_log_verbose(const char *str) 30 | { 31 | AIM_LOG_VERBOSE("%s", str); 32 | } 33 | 34 | void 35 | pipeline_lua_log_info(const char *str) 36 | { 37 | AIM_LOG_INFO("%s", str); 38 | } 39 | 40 | void 41 | pipeline_lua_log_warn(const char *str) 42 | { 43 | AIM_LOG_WARN("%s", str); 44 | } 45 | 46 | void 47 | pipeline_lua_log_error(const char *str) 48 | { 49 | AIM_LOG_ERROR("%s", str); 50 | } 51 | 52 | bool 53 | pipeline_lua_log_verbose_enabled(void) 54 | { 55 | return AIM_LOG_ENABLED_FAST(VERBOSE); 56 | } 57 | 58 | void 59 | pipeline_lua_log_packet_trace(const char *str) 60 | { 61 | packet_trace("%s", str); 62 | } 63 | -------------------------------------------------------------------------------- /modules/pipeline_lua/module/src/make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2014, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | LIBRARY := pipeline_lua 21 | $(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) 22 | 23 | $(LIBRARY)_SRCS := $(wildcard $($(LIBRARY)_SUBDIR)/*.c) \ 24 | $(wildcard $($(LIBRARY)_SUBDIR)/*.lua) 25 | 26 | # Convert base.lua into an object file we can link in 27 | $(OBJECT_DIR)/$($(LIBRARY)_SUBDIR)/%.o: $($(LIBRARY)_SUBDIR)/%.lua 28 | @echo " Embedding$(CINFO): $(LIBRARY)::$(notdir $<)" 29 | $(VERBOSE) cd $(dir $<) && $(LD) -r -b binary -o $(abspath $@) $(notdir $<) 30 | 31 | include $(BUILDER)/lib.mk 32 | -------------------------------------------------------------------------------- /modules/pipeline_lua/module/src/murmur.lua: -------------------------------------------------------------------------------- 1 | -- Copyright 2015, Big Switch Networks, Inc. 2 | -- 3 | -- Licensed under the Eclipse Public License, Version 1.0 (the 4 | -- "License"); you may not use this file except in compliance 5 | -- with the License. You may obtain a copy of the License at 6 | -- 7 | -- http://www.eclipse.org/legal/epl-v10.html 8 | -- 9 | -- Unless required by applicable law or agreed to in writing, 10 | -- software distributed under the License is distributed on an 11 | -- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 12 | -- either express or implied. See the License for the specific 13 | -- language governing permissions and limitations under the 14 | -- License. 15 | 16 | local bit = require("bit") 17 | local bxor, rshift, rol, tobit = bit.bxor, bit.rshift, bit.rol, bit.tobit 18 | 19 | local function mul(x1, x2) 20 | return (tobit(x1*(x2+0LL))) 21 | end 22 | 23 | local function round(state, data) 24 | data = mul(data, -862048943) 25 | data = rol(data, 15) 26 | data = mul(data, 0x1b873593) 27 | 28 | state = bxor(state, data) 29 | state = rol(state, 13) 30 | state = mul(state, 5) - 430675100 31 | 32 | return state 33 | end 34 | 35 | local function finish(h) 36 | h = bxor(h, rshift(h, 16)) 37 | h = mul(h, -2048144789) 38 | h = bxor(h, rshift(h, 13)) 39 | h = mul(h, -1028477387) 40 | h = bxor(h, rshift(h, 16)) 41 | return h 42 | end 43 | 44 | murmur = { round=round, finish=finish } 45 | sandbox.murmur = murmur 46 | -------------------------------------------------------------------------------- /modules/pipeline_lua/module/src/pipeline_lua_int.h: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2014, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | #ifndef PIPELINE_LUA_INT_H 21 | #define PIPELINE_LUA_INT_H 22 | 23 | #include 24 | #include 25 | 26 | #define FIELDS \ 27 | field(in_port) \ 28 | field(eth_dst_lo) \ 29 | field(eth_dst_hi) \ 30 | field(eth_src_lo) \ 31 | field(eth_src_hi) \ 32 | field(eth_type) \ 33 | field(vlan_vid) \ 34 | field(vlan_pcp) \ 35 | field(ip_dscp) \ 36 | field(ip_ecn) \ 37 | field(ip_proto) \ 38 | field(ipv4_src) \ 39 | field(ipv4_dst) \ 40 | field(tp_src) \ 41 | field(tp_dst) 42 | 43 | struct fields { 44 | #define field(name) uint32_t name; 45 | FIELDS 46 | #undef field 47 | }; 48 | 49 | struct builtin_lua { 50 | const char *name; 51 | const char *start; 52 | const char *end; 53 | }; 54 | 55 | void pipeline_lua_fields_from_key(struct ind_ovs_parsed_key *key, struct fields *fields); 56 | 57 | int pipeline_lua_table_register(lua_State *lua); 58 | void pipeline_lua_table_reset(void); 59 | 60 | extern const char *pipeline_lua_field_names[]; 61 | 62 | /* Terminated by name == NULL */ 63 | extern const struct builtin_lua pipeline_lua_builtin_lua[]; 64 | 65 | void *pipeline_lua_allocator_alloc(uint32_t size); 66 | void *pipeline_lua_allocator_dup(void *src, uint32_t size); 67 | void pipeline_lua_allocator_reset(void); 68 | 69 | /* stats.c */ 70 | void pipeline_lua_stats_init(void); 71 | void pipeline_lua_stats_finish(void); 72 | void pipeline_lua_stats_reset(void); 73 | uint32_t pipeline_lua_stats_alloc(void); 74 | void pipeline_lua_stats_free(uint32_t slot); 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /modules/pipeline_lua/module/src/stats.c: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2015, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | /* 21 | * Wrapper around the stats module that keeps track of allocated handles so 22 | * they can be freed when the Lua VM is reset. 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #include "pipeline_lua_int.h" 30 | 31 | #define AIM_LOG_MODULE_NAME pipeline_lua 32 | #include 33 | 34 | #define NUM_STATS 10000 35 | 36 | static struct slot_allocator *stats_allocator; 37 | static struct stats_handle stats[NUM_STATS]; 38 | 39 | void 40 | pipeline_lua_stats_init(void) 41 | { 42 | stats_allocator = slot_allocator_create(NUM_STATS); 43 | int i; 44 | for (i = 0; i < NUM_STATS; i++) { 45 | stats_alloc(&stats[i]); 46 | } 47 | } 48 | 49 | void 50 | pipeline_lua_stats_finish(void) 51 | { 52 | slot_allocator_destroy(stats_allocator); 53 | int i; 54 | for (i = 0; i < NUM_STATS; i++) { 55 | stats_free(&stats[i]); 56 | } 57 | } 58 | 59 | void 60 | pipeline_lua_stats_reset(void) 61 | { 62 | struct slot_allocator_iter iter; 63 | slot_allocator_iter_init(stats_allocator, &iter); 64 | 65 | uint32_t slot; 66 | while ((slot = slot_allocator_iter_next(&iter)) != SLOT_INVALID) { 67 | slot_allocator_free(stats_allocator, slot); 68 | } 69 | } 70 | 71 | /* Will return SLOT_INVALID if allocation fails */ 72 | uint32_t 73 | pipeline_lua_stats_alloc(void) 74 | { 75 | uint32_t slot = slot_allocator_alloc(stats_allocator); 76 | if (slot != SLOT_INVALID) { 77 | stats_clear(&stats[slot]); 78 | } 79 | return slot; 80 | } 81 | 82 | void 83 | pipeline_lua_stats_free(uint32_t slot) 84 | { 85 | if (slot < NUM_STATS) { 86 | slot_allocator_free(stats_allocator, slot); 87 | } 88 | } 89 | 90 | void 91 | pipeline_lua_stats_append(struct xbuf *xbuf, uint32_t slot) 92 | { 93 | if (slot < NUM_STATS && xbuf_length(xbuf) < 128) { 94 | pipeline_add_stats(xbuf, &stats[slot]); 95 | } else { 96 | AIM_LOG_WARN("Failed to append stats"); 97 | } 98 | } 99 | 100 | void 101 | pipeline_lua_stats_get(uint32_t slot, struct stats *result) 102 | { 103 | if (slot < NUM_STATS) { 104 | stats_get(&stats[slot], result); 105 | } else { 106 | memset(result, 0xff, sizeof(*result)); 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /modules/pipeline_lua/module/src/xdr.lua: -------------------------------------------------------------------------------- 1 | -- Copyright 2015, Big Switch Networks, Inc. 2 | -- 3 | -- Licensed under the Eclipse Public License, Version 1.0 (the 4 | -- "License"); you may not use this file except in compliance 5 | -- with the License. You may obtain a copy of the License at 6 | -- 7 | -- http://www.eclipse.org/legal/epl-v10.html 8 | -- 9 | -- Unless required by applicable law or agreed to in writing, 10 | -- software distributed under the License is distributed on an 11 | -- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 12 | -- either express or implied. See the License for the specific 13 | -- language governing permissions and limitations under the 14 | -- License. 15 | 16 | local bit = require("bit") 17 | local ffi = require("ffi") 18 | local band, bnot = bit.band, bit.bnot 19 | local ntohl = ffi.abi("le") and bit.bswap or function(x) return x end 20 | local P8 = ffi.typeof("uint8_t *") 21 | local P32 = ffi.typeof("uint32_t *") 22 | 23 | -- buf is a lightuserdata 24 | -- len is the maximum offset + 1 25 | -- offset is our current position 26 | Reader = {} 27 | Reader.new = function(buf, len, offset) 28 | local self = {} 29 | offset = offset or 0 30 | buf = ffi.cast(P8, buf) 31 | 32 | local function check_length(n) 33 | assert(offset + n <= len) 34 | end 35 | 36 | self.int = function() 37 | check_length(4) 38 | local ptr = ffi.cast(P32, buf+offset) 39 | local ret = ntohl(ptr[0]) 40 | offset = offset + 4 41 | return ret 42 | end 43 | 44 | self.uint = function() 45 | local x = self.int() 46 | -- Converted signed to unsigned 47 | if x < 0 then 48 | return 0x100000000 + x 49 | else 50 | return x 51 | end 52 | end 53 | 54 | self.bool = function() 55 | return self.uint() ~= 0 56 | end 57 | 58 | self.fstring = function(n) 59 | local padded = band(n + 3, bnot(3)) 60 | check_length(padded) 61 | local ret = ffi.string(buf+offset, n) 62 | offset = offset + padded 63 | return ret 64 | end 65 | 66 | self.string = function() 67 | return self.fstring(self.uint()) 68 | end 69 | 70 | return self 71 | end 72 | 73 | Writer = {} 74 | Writer.new = function(buf, len) 75 | local self = {} 76 | local offset = 0 77 | buf = ffi.cast(P8, buf) 78 | 79 | local function check_length(n) 80 | assert(offset + n <= len) 81 | end 82 | 83 | self.uint = function(x) 84 | check_length(4) 85 | local ptr = ffi.cast(P32, buf+offset) 86 | ptr[0] = ntohl(x) 87 | offset = offset + 4 88 | end 89 | 90 | self.int = self.uint 91 | 92 | self.bool = function(x) 93 | self.uint(x and 1 or 0) 94 | end 95 | 96 | self.fstring = function(x) 97 | local n = x:len() 98 | local padded = band(n + 3, bnot(3)) 99 | check_length(padded) 100 | ffi.copy(buf+offset, x, n) 101 | ffi.fill(buf+offset+n, padded-n) 102 | offset = offset + padded 103 | end 104 | 105 | self.string = function(x) 106 | self.uint(x:len()) 107 | self.fstring(x) 108 | end 109 | 110 | self.offset = function() 111 | return offset 112 | end 113 | 114 | return self 115 | end 116 | -------------------------------------------------------------------------------- /modules/pipeline_reflect/.gitignore: -------------------------------------------------------------------------------- 1 | /pipeline_reflect.mk 2 | -------------------------------------------------------------------------------- /modules/pipeline_reflect/module/make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2014, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 21 | pipeline_reflect_INCLUDES := -I $(THIS_DIR)inc 22 | pipeline_reflect_INTERNAL_INCLUDES := -I $(THIS_DIR)src 23 | pipeline_reflect_DEPENDMODULE_ENTRIES := init:pipeline_reflect 24 | -------------------------------------------------------------------------------- /modules/pipeline_reflect/module/src/make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | LIBRARY := pipeline_reflect 21 | $(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) 22 | include $(BUILDER)/lib.mk 23 | -------------------------------------------------------------------------------- /modules/pipeline_reflect/module/src/pipeline_reflect.c: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2014, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | #include 21 | 22 | #define AIM_LOG_MODULE_NAME pipeline_reflect 23 | #include 24 | 25 | AIM_LOG_STRUCT_DEFINE(AIM_LOG_OPTIONS_DEFAULT, AIM_LOG_BITS_DEFAULT, NULL, 0); 26 | 27 | static uint64_t delay_ns; 28 | 29 | static void 30 | pipeline_reflect_init(const char *name) 31 | { 32 | if (getenv("IVS_REFLECT_DELAY")) { 33 | delay_ns = atoi(getenv("IVS_REFLECT_DELAY")); 34 | AIM_LOG_INFO("Adding delay of %"PRIu64" ns"); 35 | } else { 36 | delay_ns = 0; 37 | } 38 | } 39 | 40 | static void 41 | pipeline_reflect_finish(void) 42 | { 43 | } 44 | 45 | static uint64_t 46 | monotonic_ns(void) 47 | { 48 | struct timespec tp; 49 | clock_gettime(CLOCK_MONOTONIC, &tp); 50 | return ((uint64_t)tp.tv_sec * 1000*1000*1000) + tp.tv_nsec; 51 | } 52 | 53 | indigo_error_t 54 | pipeline_reflect_process(struct ind_ovs_parsed_key *key, 55 | struct ind_ovs_parsed_key *mask, 56 | struct xbuf *stats, 57 | struct action_context *actx) 58 | { 59 | if (delay_ns > 0) { 60 | uint64_t end_time = monotonic_ns() + delay_ns; 61 | while (monotonic_ns() <= end_time); 62 | } 63 | 64 | mask->in_port = -1; 65 | 66 | action_output(actx, key->in_port); 67 | return INDIGO_ERROR_NONE; 68 | } 69 | 70 | static struct pipeline_ops pipeline_reflect_ops = { 71 | .init = pipeline_reflect_init, 72 | .finish = pipeline_reflect_finish, 73 | .process = pipeline_reflect_process, 74 | }; 75 | 76 | void 77 | __pipeline_reflect_module_init__(void) 78 | { 79 | AIM_LOG_STRUCT_REGISTER(); 80 | pipeline_register("reflect", &pipeline_reflect_ops); 81 | } 82 | -------------------------------------------------------------------------------- /modules/pipeline_standard/.gitignore: -------------------------------------------------------------------------------- 1 | /pipeline_standard.mk 2 | -------------------------------------------------------------------------------- /modules/pipeline_standard/module/make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2014, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 21 | pipeline_standard_INCLUDES := -I $(THIS_DIR)inc 22 | pipeline_standard_INTERNAL_INCLUDES := -I $(THIS_DIR)src 23 | pipeline_standard_DEPENDMODULE_ENTRIES := init:pipeline_standard 24 | -------------------------------------------------------------------------------- /modules/pipeline_standard/module/src/action.h: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2014, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | #ifndef PIPELINE_STANDARD_ACTION_H 21 | #define PIPELINE_STANDARD_ACTION_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | /* 30 | * IVS actions 31 | * 32 | * These actions are more efficient for the upcall processing code to parse 33 | * than the LOCI of_list_action_t. It also helps to abstract some of the 34 | * differences between OpenFlow 1.0 and 1.3. 35 | */ 36 | 37 | enum { 38 | IND_OVS_ACTION_OUTPUT, /* of_port_no_t */ 39 | IND_OVS_ACTION_CONTROLLER, /* uint64_t userdata (reason in bottom 8 bits, metadata in top 56 bits) */ 40 | IND_OVS_ACTION_LOCAL, 41 | IND_OVS_ACTION_IN_PORT, 42 | IND_OVS_ACTION_SET_ETH_DST, /* of_mac_addr_t */ 43 | IND_OVS_ACTION_SET_ETH_SRC, /* of_mac_addr_t */ 44 | IND_OVS_ACTION_SET_IPV4_DST, /* uint32_t */ 45 | IND_OVS_ACTION_SET_IPV4_SRC, /* uint32_t */ 46 | IND_OVS_ACTION_SET_IP_DSCP, /* uint8_t , Upper 6 bits */ 47 | IND_OVS_ACTION_SET_IP_ECN, /* uint8_t , Lower 2 bits */ 48 | IND_OVS_ACTION_SET_TCP_DST, /* uint16_t */ 49 | IND_OVS_ACTION_SET_TCP_SRC, /* uint16_t */ 50 | IND_OVS_ACTION_SET_UDP_DST, /* uint16_t */ 51 | IND_OVS_ACTION_SET_UDP_SRC, /* uint16_t */ 52 | IND_OVS_ACTION_SET_TP_DST, /* uint16_t */ 53 | IND_OVS_ACTION_SET_TP_SRC, /* uint16_t */ 54 | IND_OVS_ACTION_SET_VLAN_VID, /* uint16_t */ 55 | IND_OVS_ACTION_SET_VLAN_PCP, /* uint8_t */ 56 | IND_OVS_ACTION_POP_VLAN, 57 | IND_OVS_ACTION_PUSH_VLAN, /* uint16_t */ 58 | IND_OVS_ACTION_DEC_NW_TTL, 59 | IND_OVS_ACTION_SET_NW_TTL, /* uint8_t */ 60 | IND_OVS_ACTION_SET_IPV6_DST, /* of_ipv6_t */ 61 | IND_OVS_ACTION_SET_IPV6_SRC, /* of_ipv6_t */ 62 | IND_OVS_ACTION_SET_IPV6_FLABEL, /* uint32_t */ 63 | IND_OVS_ACTION_SET_PRIORITY, /* uint32_t */ 64 | IND_OVS_ACTION_GROUP, /* struct group * */ 65 | }; 66 | 67 | /* Translate OpenFlow actions into IVS actions */ 68 | indigo_error_t pipeline_standard_translate_openflow_actions(of_list_action_t *actions, struct xbuf *xbuf, bool table_miss); 69 | 70 | /* Release resources acquired during OpenFlow action translation */ 71 | void pipeline_standard_cleanup_actions(struct xbuf *actions); 72 | 73 | /* Translate IVS actions into OVS actions */ 74 | void pipeline_standard_translate_actions( 75 | struct action_context *ctx, struct xbuf *actions, 76 | uint32_t hash, struct xbuf *stats); 77 | 78 | /* Netlink socket to be used for receiving pktin's */ 79 | extern struct ind_ovs_pktin_socket pktin_soc; 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /modules/pipeline_standard/module/src/cfr.h: -------------------------------------------------------------------------------- 1 | #ifndef CFR_H 2 | #define CFR_H 3 | 4 | #include 5 | 6 | /* 7 | * Canonical Flow Representation 8 | * Compressed version of the OpenFlow match fields for use in matching. 9 | * Does not contain the non-OpenFlow fields of the flow key. 10 | * Wildcarded fields must be zeroed in the flow entry's CFR. 11 | * sizeof(struct pipeline_standard_cfr) must be a multiple of 8. 12 | * All fields are in network byte order except in_port. 13 | */ 14 | 15 | struct pipeline_standard_cfr { 16 | uint32_t in_port; /* Input switch port. */ 17 | uint8_t dl_dst[6]; /* Ethernet destination address. */ 18 | uint8_t dl_src[6]; /* Ethernet source address. */ 19 | uint16_t dl_type; /* Ethernet frame type. */ 20 | uint16_t dl_vlan; /* VLAN id and priority, same as wire format 21 | plus CFI bit set if tag present. */ 22 | uint8_t nw_tos; /* IPv4 DSCP. */ 23 | uint8_t nw_proto; /* IP protocol. */ 24 | uint16_t pad; 25 | uint32_t nw_src; /* IP source address. */ 26 | uint32_t nw_dst; /* IP destination address. */ 27 | uint16_t tp_src; /* TCP/UDP source port. */ 28 | uint16_t tp_dst; /* TCP/UDP destination port. */ 29 | uint32_t ipv6_src[4]; /* IPv6 source address. */ 30 | uint32_t ipv6_dst[4]; /* IPv6 destination address. */ 31 | uint32_t pad2; 32 | } __attribute__ ((aligned (8))); 33 | 34 | AIM_STATIC_ASSERT(CFR_SIZE, sizeof(struct pipeline_standard_cfr) == 9*8); 35 | 36 | /* Translate an OVS key into a CFR */ 37 | void pipeline_standard_key_to_cfr(const struct ind_ovs_parsed_key *pkey, struct pipeline_standard_cfr *cfr); 38 | 39 | /* Translate an OpenFlow match into a CFR and mask */ 40 | void pipeline_standard_match_to_cfr(const of_match_t *match, struct pipeline_standard_cfr *cfr, struct pipeline_standard_cfr *mask); 41 | 42 | /* Log a readable version of the CFR */ 43 | void pipeline_standard_dump_cfr(const struct pipeline_standard_cfr *cfr); 44 | 45 | /* packet_trace a readable version of the CFR */ 46 | void pipeline_standard_trace_cfr(const struct pipeline_standard_cfr *cfr); 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /modules/pipeline_standard/module/src/group.h: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2014, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | #ifndef PIPELINE_STANDARD_GROUP_H 21 | #define PIPELINE_STANDARD_GROUP_H 22 | 23 | struct group_bucket { 24 | struct xbuf actions; 25 | struct stats_handle stats_handle; 26 | }; 27 | 28 | struct group_value { 29 | uint16_t num_buckets; 30 | struct group_bucket *buckets; 31 | }; 32 | 33 | struct group { 34 | uint32_t id; 35 | uint8_t type; 36 | struct group_value value; 37 | }; 38 | 39 | void pipeline_standard_group_register(void); 40 | void pipeline_standard_group_unregister(void); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /modules/pipeline_standard/module/src/make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | LIBRARY := pipeline_standard 21 | $(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) 22 | include $(BUILDER)/lib.mk 23 | -------------------------------------------------------------------------------- /modules/shared_debug_counter/.gitignore: -------------------------------------------------------------------------------- 1 | /shared_debug_counter.mk 2 | -------------------------------------------------------------------------------- /modules/shared_debug_counter/module/inc/shared_debug_counter/shared_debug_counter.h: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2015, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | /* 21 | * This module is a wrapper around debug counters which places them in shared 22 | * memory. This is necessary for debug counter updates from upcall processes to 23 | * be persistent and visible to the controller. 24 | * 25 | * It's implemented by placing the debug counters in a special section, which 26 | * is aligned and padded to the page size. When shared_debug_counter_init is 27 | * called it replaces these pages (which were private mappings) with a shared 28 | * mapping. When a child process is forked it will be able to write to these 29 | * pages without triggering COW. 30 | * 31 | * One potential downside is that all upcall processes are contending for the 32 | * same cachelines when incrementing debug counters. If we find this is a real 33 | * performance problem then we could allocate a shared memory region per-process 34 | * and periodically synchronize them in the main process. 35 | */ 36 | 37 | #ifndef SHARED_DEBUG_COUNTER_H 38 | #define SHARED_DEBUG_COUNTER_H 39 | 40 | #include 41 | 42 | /* Modified from debug_counter.h */ 43 | #define SHARED_DEBUG_COUNTER(ident, name, description) \ 44 | static __attribute__((section(".shared_debug_counter"))) debug_counter_t ident; \ 45 | static void __attribute__((constructor)) ident ## _constructor(void) \ 46 | { \ 47 | debug_counter_register(&ident, name, description); \ 48 | } 49 | 50 | /* Must be called before any processes are forked */ 51 | void shared_debug_counter_init(void); 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /modules/shared_debug_counter/module/make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2015, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 21 | shared_debug_counter_INCLUDES := -I $(THIS_DIR)inc 22 | shared_debug_counter_INTERNAL_INCLUDES := -I $(THIS_DIR)src 23 | -------------------------------------------------------------------------------- /modules/shared_debug_counter/module/src/link.ld: -------------------------------------------------------------------------------- 1 | /* Align and pad the shared debug counter section to the page size */ 2 | SECTIONS { 3 | . = ALIGN(4096); 4 | shared_debug_counter_start = .; 5 | .shared_debug_counter : { *(.shared_debug_counter) } 6 | shared_debug_counter_end = .; 7 | . = ALIGN(4096); 8 | } 9 | INSERT AFTER .data; 10 | -------------------------------------------------------------------------------- /modules/shared_debug_counter/module/src/make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2015, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | LIBRARY := shared_debug_counter 21 | $(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) 22 | LDFLAGS += -Xlinker -T$(shared_debug_counter_SUBDIR)/link.ld 23 | include $(BUILDER)/lib.mk 24 | -------------------------------------------------------------------------------- /modules/shared_debug_counter/module/src/shared_debug_counter.c: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2015, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #define AIM_LOG_MODULE_NAME shared_debug_counter 27 | #include 28 | 29 | void __attribute__((noinline)) 30 | shared_debug_counter_init(void) 31 | { 32 | extern char shared_debug_counter_start[], shared_debug_counter_end[]; 33 | int len = shared_debug_counter_end - shared_debug_counter_start; 34 | 35 | if (len == 0) { 36 | return; 37 | } 38 | 39 | void *copy = aim_memdup(shared_debug_counter_start, len); 40 | 41 | if (mmap(shared_debug_counter_start, len, PROT_READ|PROT_WRITE, 42 | MAP_SHARED|MAP_ANONYMOUS|MAP_FIXED, -1, 0) == MAP_FAILED) { 43 | AIM_DIE("mmap failed: %s", strerror(errno)); 44 | } 45 | 46 | memcpy(shared_debug_counter_start, copy, len); 47 | aim_free(copy); 48 | } 49 | -------------------------------------------------------------------------------- /modules/stats/.gitignore: -------------------------------------------------------------------------------- 1 | /stats.mk 2 | -------------------------------------------------------------------------------- /modules/stats/module/inc/stats/stats.h: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2014, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | /* 21 | * This module implements lazily aggregated stats. Multiple threads can 22 | * increment stats concurrently without bouncing cache lines between them. 23 | */ 24 | #ifndef STATS_H 25 | #define STATS_H 26 | 27 | #include 28 | 29 | struct stats { 30 | uint64_t packets; 31 | uint64_t bytes; 32 | }; 33 | 34 | /* 35 | * Reference to an allocated stats slot 36 | * 37 | * Treat as private. 38 | */ 39 | struct stats_handle { 40 | uint32_t slot; 41 | }; 42 | 43 | /* 44 | * A stats_writer is used to increment stats. Only a single thread may use a 45 | * particular stats_writer at a time, but multiple stats_writers can 46 | * concurrently increment the same stats slots. 47 | */ 48 | struct stats_writer; 49 | 50 | /* 51 | * Allocate a stats slot 52 | * 53 | * Initializes 'handle'. 54 | */ 55 | void stats_alloc(struct stats_handle *handle); 56 | 57 | /* 58 | * Free a stats slot 59 | */ 60 | void stats_free(struct stats_handle *handle); 61 | 62 | /* 63 | * Increment stats 64 | */ 65 | void stats_inc(const struct stats_writer *stats_writer, 66 | const struct stats_handle *handle, 67 | uint64_t packets, uint64_t bytes); 68 | 69 | /* 70 | * Retrieve stats 71 | * 72 | * Stores the result in 'result'. 73 | */ 74 | void stats_get(const struct stats_handle *handle, struct stats *result); 75 | 76 | /* 77 | * Clear stats 78 | */ 79 | void stats_clear(struct stats_handle *handle); 80 | 81 | /* 82 | * Create a stats_writer 83 | */ 84 | struct stats_writer *stats_writer_create(void); 85 | 86 | /* 87 | * Destroy a stats_writer 88 | */ 89 | void stats_writer_destroy(struct stats_writer *stats_writer); 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /modules/stats/module/make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2014, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 21 | stats_INCLUDES := -I $(THIS_DIR)inc 22 | stats_INTERNAL_INCLUDES := -I $(THIS_DIR)src 23 | stats_DEPENDMODULE_ENTRIES := init:stats 24 | -------------------------------------------------------------------------------- /modules/stats/module/src/make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2014, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | LIBRARY := stats 21 | $(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) 22 | include $(BUILDER)/lib.mk 23 | -------------------------------------------------------------------------------- /modules/tcam/.gitignore: -------------------------------------------------------------------------------- 1 | tcam.mk 2 | -------------------------------------------------------------------------------- /modules/tcam/module/inc/tcam/tcam.h: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2014, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | /* 21 | * Software TCAM 22 | * 23 | * This datastructure supports matching an arbitrarily-sized key against 24 | * a set of keys and masks. Where the corresponding mask bit is zero, 25 | * the key and entry do not need to match. The highest priority matching 26 | * entry will be returned. 27 | * 28 | * Matching performance is proportional to the number of unique masks times 29 | * the size of the key. 30 | */ 31 | 32 | #ifndef TCAM_H 33 | #define TCAM_H 34 | 35 | #include 36 | #include 37 | 38 | struct tcam; 39 | 40 | /* 41 | * An entry in a tcam. 42 | * 43 | * This struct is intended to be embedded in a containing object. 44 | * 45 | * It must not currently be in a tcam when the containing object 46 | * is freed. 47 | * 48 | * It should be treated as opaque. It is initialized by tcam_insert. 49 | */ 50 | struct tcam_entry { 51 | struct tcam_entry *next; 52 | uint32_t hash; 53 | uint16_t priority; 54 | void *key; 55 | void *mask; 56 | }; 57 | 58 | /* 59 | * Create a tcam 60 | * 61 | * @param key_size Size in bytes of the key 62 | * @param salt Random number to prevent hash-collision attacks 63 | */ 64 | struct tcam *tcam_create(uint16_t key_size, uint32_t salt); 65 | 66 | /* 67 | * Destroy a tcam. 68 | * 69 | * All entries should have been removed. 70 | */ 71 | void tcam_destroy(struct tcam *tcam); 72 | 73 | /* 74 | * Insert an entry into a tcam. 75 | * 76 | * @param key Field values. Must be zero where mask is zero (bitwise). 77 | * @param mask Portion of key to match against packet. 78 | * @param priority Higher priority entries match first. 79 | */ 80 | void tcam_insert(struct tcam *tcam, 81 | struct tcam_entry *entry, 82 | const void *key, 83 | const void *mask, 84 | uint16_t priority); 85 | 86 | /* 87 | * Remove an entry from a tcam. 88 | */ 89 | void tcam_remove(struct tcam *tcam, struct tcam_entry *entry); 90 | 91 | /* 92 | * Search for a matching entry in a tcam. 93 | * 94 | * @param key Fields from the packet. 95 | */ 96 | struct tcam_entry *tcam_match(struct tcam *tcam, const void *key); 97 | 98 | /* 99 | * Search for a matching entry in a tcam. 100 | * 101 | * @param key Fields from the packet. 102 | * @param mask Will be ORed with the mask of all entries the key 103 | * was compared to. 104 | */ 105 | struct tcam_entry *tcam_match_and_mask(struct tcam *tcam, const void *key, void *mask); 106 | 107 | #endif 108 | -------------------------------------------------------------------------------- /modules/tcam/module/make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2014, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 21 | tcam_INCLUDES := -I $(THIS_DIR)inc 22 | tcam_INTERNAL_INCLUDES := -I $(THIS_DIR)src 23 | -------------------------------------------------------------------------------- /modules/tcam/module/src/make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2014, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | LIBRARY := tcam 21 | $(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) 22 | include $(BUILDER)/lib.mk 23 | -------------------------------------------------------------------------------- /modules/tcam/module/src/tcam_log.c: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2014, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | #include "tcam_log.h" 21 | 22 | /* 23 | * tcam log struct. 24 | */ 25 | AIM_LOG_STRUCT_DEFINE( 26 | AIM_LOG_OPTIONS_DEFAULT, 27 | AIM_LOG_BITS_DEFAULT, 28 | NULL, /* Custom log map */ 29 | 0 30 | ); 31 | -------------------------------------------------------------------------------- /modules/tcam/module/src/tcam_log.h: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2014, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | #ifndef __TCAM_LOG_H__ 21 | #define __TCAM_LOG_H__ 22 | 23 | #define AIM_LOG_MODULE_NAME tcam 24 | #include 25 | 26 | #endif /* __TCAM_LOG_H__ */ 27 | -------------------------------------------------------------------------------- /modules/tcam/utest/_make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2014, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | UMODULE := tcam 21 | UMODULE_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) 22 | include $(BUILDER)/utest.mk 23 | -------------------------------------------------------------------------------- /modules/xbuf/.gitignore: -------------------------------------------------------------------------------- 1 | xbuf.mk 2 | -------------------------------------------------------------------------------- /modules/xbuf/module/make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) 21 | xbuf_INCLUDES := -I $(THIS_DIR)inc 22 | xbuf_INTERNAL_INCLUDES := -I $(THIS_DIR)src 23 | -------------------------------------------------------------------------------- /modules/xbuf/module/src/make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | LIBRARY := xbuf 21 | $(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) 22 | include $(BUILDER)/lib.mk 23 | -------------------------------------------------------------------------------- /modules/xbuf/module/src/xbuf.c: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2013, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | #include 21 | #include 22 | 23 | #define XBUF_INITIAL_LEN 64 24 | 25 | void 26 | xbuf_init(struct xbuf *xbuf) 27 | { 28 | xbuf->data = NULL; 29 | xbuf->length = 0; 30 | xbuf->allocated = 0; 31 | xbuf_resize(xbuf, XBUF_INITIAL_LEN); 32 | } 33 | 34 | void 35 | xbuf_cleanup(struct xbuf *xbuf) 36 | { 37 | aim_free(xbuf->data); 38 | xbuf->data = NULL; 39 | xbuf->length = 0; 40 | xbuf->allocated = 0; 41 | } 42 | 43 | /* From http://locklessinc.com/articles/next_pow2/ */ 44 | static inline int 45 | next_pow2(uint32_t x) 46 | { 47 | x -= 1; 48 | x |= (x >> 1); 49 | x |= (x >> 2); 50 | x |= (x >> 4); 51 | x |= (x >> 8); 52 | x |= (x >> 16); 53 | return x + 1; 54 | } 55 | 56 | void 57 | xbuf_resize(struct xbuf *xbuf, uint32_t new_len) 58 | { 59 | xbuf->allocated = next_pow2(new_len); 60 | xbuf->data = aim_realloc(xbuf->data, xbuf->allocated); 61 | AIM_TRUE_OR_DIE(xbuf->data != NULL, "failed to allocate xbuf"); 62 | } 63 | 64 | void 65 | xbuf_compact(struct xbuf *xbuf) 66 | { 67 | xbuf->allocated = xbuf->length; 68 | xbuf->data = aim_realloc(xbuf->data, xbuf->allocated); 69 | AIM_TRUE_OR_DIE(xbuf->allocated == 0 || xbuf->data != NULL, "failed to allocate xbuf"); 70 | } 71 | -------------------------------------------------------------------------------- /modules/xbuf/utest/_make.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | UMODULE := xbuf 21 | UMODULE_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) 22 | include $(BUILDER)/utest.mk 23 | -------------------------------------------------------------------------------- /oftests/l2switch.x: -------------------------------------------------------------------------------- 1 | struct endpoint_key { 2 | unsigned int vlan; 3 | unsigned int mac_hi; 4 | unsigned int mac_lo; 5 | }; 6 | 7 | struct endpoint_value { 8 | unsigned int port; 9 | }; 10 | 11 | struct endpoint_stats { 12 | /* TODO use 64-bit integers */ 13 | unsigned int packets; 14 | unsigned int bytes; 15 | }; 16 | -------------------------------------------------------------------------------- /oftests/lua/command.lua: -------------------------------------------------------------------------------- 1 | -- Copyright 2015, Big Switch Networks, Inc. 2 | -- 3 | -- Licensed under the Eclipse Public License, Version 1.0 (the 4 | -- "License"); you may not use this file except in compliance 5 | -- with the License. You may obtain a copy of the License at 6 | -- 7 | -- http://www.eclipse.org/legal/epl-v10.html 8 | -- 9 | -- Unless required by applicable law or agreed to in writing, 10 | -- software distributed under the License is distributed on an 11 | -- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 12 | -- either express or implied. See the License for the specific 13 | -- language governing permissions and limitations under the 14 | -- License. 15 | 16 | -- Command message handler that executes the first string argument as Lua code 17 | -- This is great for testing but a more performant implementation wouldn't 18 | -- parse Lua code for every command. 19 | 20 | function command(reader, writer) 21 | local code = reader.string() 22 | log("Received command: %s", code) 23 | assert(loadstring(code))(reader, writer) 24 | end 25 | -------------------------------------------------------------------------------- /oftests/lua/hashtable_benchmark.lua: -------------------------------------------------------------------------------- 1 | -- Copyright 2015, Big Switch Networks, Inc. 2 | -- 3 | -- Licensed under the Eclipse Public License, Version 1.0 (the 4 | -- "License"); you may not use this file except in compliance 5 | -- with the License. You may obtain a copy of the License at 6 | -- 7 | -- http://www.eclipse.org/legal/epl-v10.html 8 | -- 9 | -- Unless required by applicable law or agreed to in writing, 10 | -- software distributed under the License is distributed on an 11 | -- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 12 | -- either express or implied. See the License for the specific 13 | -- language governing permissions and limitations under the 14 | -- License. 15 | 16 | function hashtable_benchmark() 17 | local num_lookups = 1*1000*1000 18 | local max_table_size = 2^20 19 | 20 | local total_lookups = 0 21 | local total_time = 0 22 | 23 | local ht = hashtable.create({ "x", "y" }, { "a" }) 24 | 25 | local table_size = 16 26 | while table_size <= max_table_size do 27 | local n = math.floor(table_size * 0.8) 28 | 29 | for i = ht:count()+1, n do 30 | ht:insert({ x=i, y=i }, { a=i }) 31 | end 32 | 33 | assert(ht:size() == table_size) 34 | assert(ht:count() == n) 35 | 36 | local start_time = os.clock() 37 | 38 | local key = 1 39 | for i = 1, num_lookups do 40 | local value = ht:lookup({ x=key, y=key }) 41 | if not value then 42 | error("missing value for key " .. key) 43 | end 44 | key = value.a + 1 -- create data dependency 45 | if key > n then 46 | key = 1 47 | end 48 | total_lookups = total_lookups + 1 49 | end 50 | 51 | local elapsed = os.clock() - start_time 52 | total_time = total_time + elapsed 53 | log("size=%u count=%u elapsed=%.3fs avg=%.3fns", 54 | ht:size(), ht:count(), elapsed, elapsed/num_lookups*1e9) 55 | 56 | table_size = table_size * 2 57 | end 58 | 59 | log("total time=%.3fs avg time=%.3fns", total_time, total_time/total_lookups*1e9) 60 | end 61 | -------------------------------------------------------------------------------- /oftests/lua/hashtable_test.lua: -------------------------------------------------------------------------------- 1 | -- Copyright 2015, Big Switch Networks, Inc. 2 | -- 3 | -- Licensed under the Eclipse Public License, Version 1.0 (the 4 | -- "License"); you may not use this file except in compliance 5 | -- with the License. You may obtain a copy of the License at 6 | -- 7 | -- http://www.eclipse.org/legal/epl-v10.html 8 | -- 9 | -- Unless required by applicable law or agreed to in writing, 10 | -- software distributed under the License is distributed on an 11 | -- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 12 | -- either express or implied. See the License for the specific 13 | -- language governing permissions and limitations under the 14 | -- License. 15 | 16 | function hashtable_test() 17 | do 18 | local ht = hashtable.create({ "x", "y" }, { "a" }) 19 | assert(ht:lookup({ x=0, y=1 }) == nil) 20 | ht:insert({ x=0, y=1 }, { a=1000 }) 21 | assert(ht:lookup({ x=0, y=1 }).a == 1000) 22 | ht:remove({ x=0, y=1 }) 23 | assert(ht:lookup({ x=0, y=1 }) == nil) 24 | end 25 | 26 | do 27 | local ht = hashtable.create({ "x", "y" }, { "a" }) 28 | for i = 1, 1000 do 29 | assert(ht:lookup({ x=i, y=i }) == nil) 30 | ht:insert({ x=i, y=i }, { a=i }) 31 | assert(ht:lookup({ x=i, y=i }).a == i) 32 | end 33 | end 34 | 35 | do 36 | local ht = hashtable.create({ "x", "y" }, { "a" }) 37 | local max = 4000*1000*1000 38 | local n = 1639 39 | local seed = 42 40 | 41 | local keys = {} 42 | for i = 1, n do 43 | table.insert(keys, { x=math.random(max), y=math.random(max) }) 44 | end 45 | 46 | for i, key in ipairs(keys) do 47 | assert(ht:lookup(key) == nil) 48 | ht:insert(key, { a=i }) 49 | assert(ht:lookup(key).a == i) 50 | end 51 | 52 | for i, key in ipairs(keys) do 53 | assert(ht:lookup(key).a == i) 54 | assert(ht:lookup(key.x, key.y).a == i) 55 | end 56 | 57 | for i, key in ipairs(keys) do 58 | assert(ht:lookup(key).a == i) 59 | ht:remove(key) 60 | assert(ht:lookup(key) == nil) 61 | end 62 | end 63 | end 64 | -------------------------------------------------------------------------------- /oftests/lua/l2switch_xdr.lua: -------------------------------------------------------------------------------- 1 | local public = {} 2 | 3 | local function read_int(reader) 4 | return reader.int() 5 | end 6 | 7 | local function write_int(writer, x) 8 | writer.int(x) 9 | end 10 | 11 | local function read_uint(reader) 12 | return reader.uint() 13 | end 14 | 15 | local function write_uint(writer, x) 16 | writer.uint(x) 17 | end 18 | 19 | local function read_bool(reader) 20 | return reader.uint() ~= 0 21 | end 22 | 23 | local function write_bool(writer, x) 24 | writer.uint(x and 1 or 0) 25 | end 26 | 27 | local function read_optional(reader, fn) 28 | if read_bool(reader) then 29 | return fn(reader) 30 | else 31 | return nil 32 | end 33 | end 34 | 35 | local function write_optional(writer, x, fn) 36 | if x ~= nil then 37 | writer.int(1) 38 | fn(writer, x) 39 | else 40 | writer.int(0) 41 | end 42 | end 43 | 44 | local function read_array(reader, fn, count) 45 | local t = {} 46 | for i = 1, count do 47 | table.insert(t, fn(reader)) 48 | end 49 | return t 50 | end 51 | 52 | local function write_array(writer, x, fn, count) 53 | assert(#x == count) 54 | for i, v in ipairs(x) do 55 | fn(writer, v) 56 | end 57 | end 58 | 59 | local function read_list(reader, fn, max) 60 | local count = reader.uint() 61 | assert(max == nil or count <= max) 62 | return read_array(reader, fn, count) 63 | end 64 | 65 | local function write_list(writer, x, fn, max) 66 | local count = #x 67 | assert(max == nil or count <= max) 68 | writer.uint(count) 69 | write_array(writer, x, fn, count) 70 | end 71 | 72 | local function read_fstring(reader, count) 73 | return reader.fstring(count) 74 | end 75 | 76 | local function write_fstring(writer, x, count) 77 | assert(#x == count) 78 | writer.fstring(x) 79 | end 80 | 81 | local function read_string(reader, max) 82 | local count = reader.uint() 83 | assert(max == nil or count <= max) 84 | return reader.fstring(count) 85 | end 86 | 87 | local function write_string(writer, x, max) 88 | local count = #x 89 | assert(max == nil or count <= max) 90 | writer.uint(count) 91 | writer.fstring(x) 92 | end 93 | 94 | function public.read_endpoint_key(reader) 95 | local obj = {} 96 | obj.vlan = read_uint(reader) 97 | obj.mac_hi = read_uint(reader) 98 | obj.mac_lo = read_uint(reader) 99 | return obj 100 | end 101 | 102 | function public.write_endpoint_key(writer, obj) 103 | write_uint(writer, obj.vlan) 104 | write_uint(writer, obj.mac_hi) 105 | write_uint(writer, obj.mac_lo) 106 | end 107 | 108 | function public.read_endpoint_value(reader) 109 | local obj = {} 110 | obj.port = read_uint(reader) 111 | return obj 112 | end 113 | 114 | function public.write_endpoint_value(writer, obj) 115 | write_uint(writer, obj.port) 116 | end 117 | 118 | function public.read_endpoint_stats(reader) 119 | local obj = {} 120 | obj.packets = read_uint(reader) 121 | obj.bytes = read_uint(reader) 122 | return obj 123 | end 124 | 125 | function public.write_endpoint_stats(writer, obj) 126 | write_uint(writer, obj.packets) 127 | write_uint(writer, obj.bytes) 128 | end 129 | 130 | return public 131 | -------------------------------------------------------------------------------- /oftests/lua/pktin.lua: -------------------------------------------------------------------------------- 1 | -- Copyright 2015, Big Switch Networks, Inc. 2 | -- 3 | -- Licensed under the Eclipse Public License, Version 1.0 (the 4 | -- "License"); you may not use this file except in compliance 5 | -- with the License. You may obtain a copy of the License at 6 | -- 7 | -- http://www.eclipse.org/legal/epl-v10.html 8 | -- 9 | -- Unless required by applicable law or agreed to in writing, 10 | -- software distributed under the License is distributed on an 11 | -- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 12 | -- either express or implied. See the License for the specific 13 | -- language governing permissions and limitations under the 14 | -- License. 15 | 16 | -- pktin handler that decides if the packet needs to be consumed 17 | -- by the switch or it needs to be sent to the controller 18 | -- Todo: Add packet parsing 19 | 20 | function pktin(reader, reason, metadata) 21 | log("Received pktin with reason: %u, metadata: %u", reason, metadata) 22 | return 1 23 | end 24 | -------------------------------------------------------------------------------- /oftests/lua/tables.lua: -------------------------------------------------------------------------------- 1 | -- Copyright 2015, Big Switch Networks, Inc. 2 | -- 3 | -- Licensed under the Eclipse Public License, Version 1.0 (the 4 | -- "License"); you may not use this file except in compliance 5 | -- with the License. You may obtain a copy of the License at 6 | -- 7 | -- http://www.eclipse.org/legal/epl-v10.html 8 | -- 9 | -- Unless required by applicable law or agreed to in writing, 10 | -- software distributed under the License is distributed on an 11 | -- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 12 | -- either express or implied. See the License for the specific 13 | -- language governing permissions and limitations under the 14 | -- License. 15 | 16 | -- Register a couple of tables for testing with no-op add/remove ops 17 | 18 | local l2_table = hashtable.create({ "vlan", "mac_hi", "mac_lo" }, { "port" }) 19 | 20 | register_table("l2", { 21 | parse_key=function(r) 22 | return { 23 | vlan=r.uint(), 24 | mac_hi=r.uint(), 25 | mac_lo=r.uint(), 26 | } 27 | end, 28 | 29 | parse_value=function(r) 30 | return { 31 | port=r.uint(), 32 | } 33 | end, 34 | 35 | add=function(k, v) 36 | log("l2_add: vlan=%u mac=%04x%08x -> port %u", k.vlan, k.mac_hi, k.mac_lo, v.port) 37 | end, 38 | 39 | modify=function(k, v) 40 | log("l2_modify: vlan=%u mac=%04x%08x -> port %u", k.vlan, k.mac_hi, k.mac_lo, v.port) 41 | end, 42 | 43 | delete=function(k) 44 | log("l2_delete: vlan=%u mac=%04x%08x", k.vlan, k.mac_hi, k.mac_lo) 45 | end, 46 | }) 47 | 48 | local vlan_table = hashtable.create({ "vlan" }, { "port_bitmap" }) 49 | 50 | register_table("vlan", { 51 | parse_key=function(r) 52 | return { 53 | vlan=r.uint(), 54 | } 55 | end, 56 | 57 | parse_value=function(r) 58 | return { 59 | port_bitmap=r.uint(), 60 | } 61 | end, 62 | 63 | add=function(k, v) 64 | log("vlan_add: vlan=%u -> port_bitmap %08x", k.vlan, v.port_bitmap) 65 | end, 66 | 67 | modify=function(k, v) 68 | log("vlan_modify: vlan=%u -> port_bitmap %08x", k.vlan, v.port_bitmap) 69 | end, 70 | 71 | delete=function(k) 72 | log("vlan_delete: vlan=%u", k.vlan) 73 | end, 74 | }) 75 | -------------------------------------------------------------------------------- /oftests/lua_common.py: -------------------------------------------------------------------------------- 1 | # Copyright 2015, Big Switch Networks, Inc. 2 | # 3 | # Licensed under the Eclipse Public License, Version 1.0 (the 4 | # "License"); you may not use this file except in compliance 5 | # with the License. You may obtain a copy of the License at 6 | # 7 | # http://www.eclipse.org/legal/epl-v10.html 8 | # 9 | # Unless required by applicable law or agreed to in writing, 10 | # software distributed under the License is distributed on an 11 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 12 | # either express or implied. See the License for the specific 13 | # language governing permissions and limitations under the 14 | # License. 15 | """ 16 | Common code shared between Lua testcases 17 | """ 18 | 19 | import os 20 | import xdrlib 21 | 22 | import oftest.base_tests as base_tests 23 | import ofp 24 | 25 | from oftest.testutils import * 26 | 27 | class BaseTest(base_tests.SimpleDataPlane): 28 | """ 29 | Base test class which sets up the Lua pipeline 30 | """ 31 | 32 | # Names of Lua files to upload (minus .lua) 33 | # Overriden by each subclass 34 | sources = [] 35 | 36 | def setUp(self): 37 | """ 38 | Setup switch 39 | """ 40 | base_tests.SimpleDataPlane.setUp(self) 41 | self.ports = openflow_ports(6) 42 | 43 | reply, _ = self.controller.transact(ofp.message.bsn_set_switch_pipeline_request(pipeline="lua")) 44 | self.assertEquals(reply.status, 0) 45 | 46 | self.upload(self.sources) 47 | 48 | do_barrier(self.controller) 49 | verify_no_errors(self.controller) 50 | 51 | self.fetch_gentables() 52 | self.clear_gentables() 53 | 54 | self.dataplane.flush() 55 | 56 | def upload(self, sources, force=True): 57 | """ 58 | Upload Lua code 59 | 60 | 'sources' is a list of names of files in oftests/lua, minus the '.lua' extension. 61 | """ 62 | for source in self.sources: 63 | code = file(os.path.join(os.path.dirname(__file__), "lua", source + '.lua')).read() 64 | msg = ofp.message.bsn_lua_upload( 65 | flags=ofp.OFP_BSN_LUA_UPLOAD_MORE, 66 | filename=source, 67 | data=code) 68 | self.controller.message_send(msg) 69 | 70 | # Commit 71 | msg = ofp.message.bsn_lua_upload( 72 | flags=force and ofp.OFP_BSN_LUA_UPLOAD_FORCE or 0, data="") 73 | self.controller.message_send(msg) 74 | 75 | def fetch_gentables(self): 76 | """ 77 | Populates self.gentable_ids with the name -> id mapping 78 | """ 79 | gentables = get_stats(self, ofp.message.bsn_gentable_desc_stats_request()) 80 | self.gentable_ids = { x.name: x.table_id for x in gentables } 81 | 82 | def clear_gentables(self): 83 | """ 84 | Clear gentables with count > 0 85 | """ 86 | gentable_stats = get_stats(self, ofp.message.bsn_gentable_stats_request()) 87 | for stat in gentable_stats: 88 | if stat.entry_count > 0: 89 | request = ofp.message.bsn_gentable_clear_request(table_id=stat.table_id) 90 | self.controller.transact(request) 91 | 92 | def command(self, code): 93 | """ 94 | Send a bsn_lua_command message to the switch 95 | 96 | Compatible with command.lua but doesn't support arguments or 97 | deserializing the result. 98 | """ 99 | packer = xdrlib.Packer() 100 | packer.pack_string(code) 101 | reply, _ = self.controller.transact( 102 | ofp.message.bsn_lua_command_request(data=packer.get_buffer())) 103 | self.assertIsInstance(reply, ofp.message.bsn_lua_command_reply) 104 | return reply.data 105 | -------------------------------------------------------------------------------- /rhel/ivs-7.0.spec: -------------------------------------------------------------------------------- 1 | # Spec file for Indigo Virtual Switch. 2 | # 3 | # Copyright 2014, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | 19 | Name: ivs 20 | Summary: Indigo Virtual Switch 21 | Group: System Environment/Daemons 22 | URL: http://www.bigswitch.com/ 23 | Version: 0.5 24 | Release: 1%{?dist} 25 | 26 | License: EPL-1.0 27 | Source: ivs.tar.gz 28 | 29 | Requires(post): systemd-units 30 | Requires(preun): systemd-units 31 | Requires(postun): systemd-units 32 | 33 | Requires: libnl3, libcap 34 | BuildRequires: bash, python, pkgconfig, libnl3-devel, libcap-devel 35 | 36 | %description 37 | Indigo Virtual Switch (IVS) is a pure OpenFlow virtual switch designed for high 38 | performance and minimal administration. It is built on the [Indigo 39 | platform][1], which provides a common core for many physical and virtual switches, 40 | 41 | [1]: http://www.projectfloodlight.org/indigo/ 42 | 43 | %prep 44 | %setup -q -n ivs 45 | 46 | %build 47 | make -j8 RELEASE=1 48 | 49 | %install 50 | rm -rf $RPM_BUILD_ROOT 51 | make install DESTDIR=$RPM_BUILD_ROOT 52 | install -d -m 755 $RPM_BUILD_ROOT/etc 53 | install -p -D -m 0644 rhel/ivs.service \ 54 | $RPM_BUILD_ROOT%{_unitdir}/ivs.service 55 | install -d -m 755 $RPM_BUILD_ROOT/etc/sysconfig 56 | install -p -D -m 0644 debian/ivs.default \ 57 | $RPM_BUILD_ROOT/etc/sysconfig/ivs 58 | install -p -D -m 0644 targets/ivs/ivs.8 \ 59 | $RPM_BUILD_ROOT/usr/share/man/man8/ivs.8 60 | install -p -D -m 0644 targets/ivs-ctl/ivs-ctl.8 \ 61 | $RPM_BUILD_ROOT/usr/share/man/man8/ivs-ctl.8 62 | 63 | gzip $RPM_BUILD_ROOT/usr/share/man/man8/ivs.8 64 | gzip $RPM_BUILD_ROOT/usr/share/man/man8/ivs-ctl.8 65 | 66 | %clean 67 | rm -rf $RPM_BUILD_ROOT 68 | 69 | %pre 70 | # Perform these actions only on upgrade, not initial installation 71 | if [ "$1" = "2" ]; then 72 | systemctl stop ivs.service 73 | fi 74 | 75 | %preun 76 | # Perform these action only on package removal, not upgrade 77 | if [ $1 = 0 ]; then 78 | systemctl stop ivs.service 79 | systemctl disable ivs.service 80 | fi 81 | 82 | %post 83 | # Initial installation and upgrade 84 | systemctl enable ivs.service 85 | systemctl start ivs.service 86 | 87 | %files 88 | %defattr(-,root,root) 89 | %config /etc/sysconfig/ivs 90 | %{_unitdir}/ivs.service 91 | /usr/sbin/ivs 92 | /usr/sbin/ivs-ctl 93 | %doc /usr/share/man/man8/ivs.8.gz 94 | %doc /usr/share/man/man8/ivs-ctl.8.gz 95 | 96 | %changelog 97 | * Tue Sep 9 2014 Harshmeet Singh 98 | - First build on Centos 7.0 99 | -------------------------------------------------------------------------------- /rhel/ivs.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Indigo Virtual Switch 3 | After=syslog.target network.target 4 | 5 | [Service] 6 | Type=simple 7 | EnvironmentFile=-/etc/sysconfig/ivs 8 | ExecStartPre=/usr/sbin/modprobe -q openvswitch 9 | ExecStart=/usr/sbin/ivs --syslog $DAEMON_ARGS 10 | Restart=always 11 | StartLimitInterval=60s 12 | StartLimitBurst=3 13 | 14 | [Install] 15 | WantedBy=multi-user.target 16 | -------------------------------------------------------------------------------- /rhel/rpm-from-source: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # How to create an RPM from source with spec file 3 | 4 | # This is for Redhat versions of linux. 5 | # 6 | # Final RPM can be found at ~/rpmbuild/RPMS/ 7 | 8 | # Pre-requisites: 9 | # Install rpmbuild - yum install -y rpm-build 10 | 11 | # Step: 1 12 | # Create rpmbuild folders in home directory 13 | 14 | mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} 15 | 16 | # Step: 2 17 | # Create a tar file from the source 18 | # 19 | # Create and move the compressed file to the rpm build SOURCES directory 20 | 21 | tar --transform 's,^\.,ivs,' -cf ~/rpmbuild/SOURCES/ivs.tar.gz . 22 | 23 | # Step: 3 24 | # Build rpm from .spec file depending upon Centos version 25 | # 26 | 27 | if ((`cat /etc/redhat-release | cut -d" " -f4 | cut -d "." -f1` == "7")); then 28 | rpmbuild -bb rhel/ivs-7.0.spec 29 | elif ((`cat /etc/redhat-release | cut -d" " -f3 | cut -d "." -f1` == "6")); then 30 | echo "System is running centos 6"; 31 | exit 1 32 | else 33 | echo "Error: Centos version not supported" 34 | exit 1 35 | fi 36 | -------------------------------------------------------------------------------- /targets/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | *.mk 3 | !utests/make/*.mk 4 | dependmodules.x 5 | git_revision.h 6 | -------------------------------------------------------------------------------- /targets/ivs-ctl/Makefile: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | include ../../init.mk 20 | 21 | ALLOW_DECLARATION_AFTER_STATEMENT = 1 22 | 23 | MODULE := IVSCtl 24 | include $(BUILDER)/standardinit.mk 25 | 26 | LIBRARY := IVSCtlMain 27 | $(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) 28 | include $(BUILDER)/lib.mk 29 | 30 | DEPENDMODULES := 31 | include $(BUILDER)/dependmodules.mk 32 | 33 | BINARY := ivs-ctl 34 | 35 | $(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) 36 | include $(BUILDER)/bin.mk 37 | 38 | include $(BUILDER)/targets.mk 39 | 40 | GLOBAL_CFLAGS += -g 41 | GLOBAL_CFLAGS += -I . 42 | GLOBAL_CFLAGS += -I $(ROOT)/openvswitch 43 | GLOBAL_CFLAGS += -O1 44 | 45 | LIBNL_CFLAGS := $(shell pkg-config --cflags libnl-3.0) 46 | LIBNL_CFLAGS += $(shell pkg-config --cflags --silence-errors libnl-genl-3.0) 47 | LIBNL_LIBS := $(shell pkg-config --libs libnl-3.0) 48 | LIBNL_LIBS += $(shell pkg-config --libs --silence-errors libnl-genl-3.0) 49 | GLOBAL_CFLAGS += $(LIBNL_CFLAGS) 50 | GLOBAL_LINK_LIBS += $(LIBNL_LIBS) 51 | -------------------------------------------------------------------------------- /targets/ivs-ctl/ivs-ctl.8: -------------------------------------------------------------------------------- 1 | .\" Hey, EMACS: -*- nroff -*- 2 | .\" First parameter, NAME, should be all caps 3 | .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection 4 | .\" other parameters are allowed: see man(7), man(1) 5 | .TH IVS-CTL 8 "March 25, 2015" 6 | .\" Please adjust this date whenever revising the manpage. 7 | .\" 8 | .\" Some roff macros, for reference: 9 | .\" .nh disable hyphenation 10 | .\" .hy enable hyphenation 11 | .\" .ad l left justify 12 | .\" .ad b justify to both left and right margins 13 | .\" .nf disable filling 14 | .\" .fi enable filling 15 | .\" .br insert line break 16 | .\" .sp insert n+1 empty lines 17 | .\" for manpage-specific macros, see man(7) 18 | .SH NAME 19 | ivs-ctl \- utility for configuring Indigo Virtual Switch 20 | .SH SYNOPSIS 21 | \fB ivs-ctl help\fR 22 | \fB ivs-ctl show\fR 23 | \fB ivs-ctl add-port\fR \fIINTERFACE\fR 24 | \fB ivs-ctl add-internal-port\fR \fIINTERFACE\fR 25 | \fB ivs-ctl del-port\fR \fIINTERFACE\fR 26 | \fB ivs-ctl dump-flows\fR 27 | \fB ivs-ctl list-ports\fR 28 | \fB ivs-ctl trace\fR 29 | .SH DESCRIPTION 30 | The \fBivs-ctl\fP command can be used to view and modify the \fBivs\fP virtual 31 | switch datapath. 32 | .PP 33 | The \fBshow\fP command outputs information and statistics about the datapath, 34 | including the attached ports. 35 | .PP 36 | The \fBadd-port\fP and \fBdel-port\fR commands modify the attached ports of 37 | the datapath. The \fIINTERFACE\fR argument must be a Linux interface name. 38 | .PP 39 | The \fBadd-internal-port\fP command creates a Linux interface connected to 40 | the datapath. This interface can have an IP address assigned to 41 | it and can generally be used like a normal netdev, but traffic to and from it 42 | will flow through the datapath. 43 | .PP 44 | The \fBdump-flows\fP command shows the contents of the kernel flowtable. 45 | .PP 46 | The \fBlist-ports\fP command shows the names of each attached port, one per line. 47 | .PP 48 | The \fBtrace\fP command explains the forwarding decision for each new flow. 49 | .PP 50 | .SH AUTHOR 51 | ivs was written by the Indigo community . 52 | .PP 53 | This manual page was written by Rich Lane . 54 | -------------------------------------------------------------------------------- /targets/ivs/ivs.8: -------------------------------------------------------------------------------- 1 | .\" Hey, EMACS: -*- nroff -*- 2 | .\" First parameter, NAME, should be all caps 3 | .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection 4 | .\" other parameters are allowed: see man(7), man(1) 5 | .TH IVS 8 "June 16, 2015" 6 | .\" Please adjust this date whenever revising the manpage. 7 | .\" 8 | .\" Some roff macros, for reference: 9 | .\" .nh disable hyphenation 10 | .\" .hy enable hyphenation 11 | .\" .ad l left justify 12 | .\" .ad b justify to both left and right margins 13 | .\" .nf disable filling 14 | .\" .fi enable filling 15 | .\" .br insert line break 16 | .\" .sp insert n+1 empty lines 17 | .\" for manpage-specific macros, see man(7) 18 | .SH NAME 19 | ivs \- OpenFlow virtual switch 20 | .SH SYNOPSIS 21 | \fB ivs \fR 22 | [\fB-hvt\fR] 23 | [\fB-c\fIhost\fB[:\fIport\fR]]\&... 24 | [\fB-i\fIinterface\fR]\&... 25 | .SH DESCRIPTION 26 | \fBivs\fP (Indigo Virtual Switch) is an OpenFlow virtual switch designed for 27 | high performance and minimal administration. It uses the \fB\%openvswitch\fR 28 | kernel module available in newer kernels or from the \fB\%openvswitch-datapath-dkms\fR 29 | package. 30 | .PP 31 | .SH OPTIONS 32 | .TP 33 | \fB\-h\fR, \fB--help\fR 34 | Show summary of options. 35 | .TP 36 | \fB\-v\fR, \fB--verbose\fR 37 | Enable verbose logging. 38 | .TP 39 | \fB\-t\fR, \fB--trace\fR 40 | Enable trace logging. 41 | .TP 42 | \fB\-i \fIinterface\fR, \fB--interface \fIinterface\fR 43 | Add a network interface. 44 | .TP 45 | \fB\-c \fIhost\fB[:\fIport\fR], \fB--controller \fIhost\fB[:\fIport\fR] 46 | Add a controller connection. \fIport\fR defaults to 6633. 47 | .TP 48 | \fB\-l \fIhost\fB[:\fIport\fR], \fB--listen \fIhost\fB[:\fIport\fR] 49 | Add a listening socket (for dpctl). \fIport\fR defaults to 6634. 50 | .TP 51 | \fB--dpid \fIdpid\fR 52 | Set the datapath ID. \fIdpid\fR should be 16 hex digits. 53 | .TP 54 | \fB--syslog\fR 55 | Write log messages to syslog instead of stderr. 56 | .TP 57 | \fB--internal-port \fIname\fR 58 | Add an internal port. This creates a netdev to which you can assign an IP address. 59 | .TP 60 | \fB--hitless\fR 61 | Enable hitless restart. Requires a compatible controller. 62 | .TP 63 | \fB--help\fR 64 | Print usage information. 65 | .TP 66 | \fB--version\fR 67 | Print version information. 68 | .PP 69 | .SH AUTHOR 70 | ivs was written by the Indigo community . 71 | .PP 72 | This manual page was written by Rich Lane . 73 | -------------------------------------------------------------------------------- /targets/ivs/tests-1.3.txt: -------------------------------------------------------------------------------- 1 | standard 2 | 3 | # Extensions we support 4 | bsn_controller_connections 5 | bsn_flow_checksum 6 | bsn_gentable 7 | 8 | # Async message configuration is not supported 9 | ^basic.AsyncConfigGet 10 | 11 | # Some group features are not supported 12 | ^basic.GroupFeaturesStats 13 | ^groups.GroupAddExisting 14 | ^groups.GroupAddMaxID 15 | ^groups.GroupFlowSelect 16 | ^groups.GroupModifyLoop 17 | 18 | # Meters are not supported 19 | ^basic.MeterConfigStats 20 | ^basic.MeterFeaturesStats 21 | ^basic.MeterStats 22 | 23 | # Not yet passing 24 | ^bsn_flow_checksum.TableChecksumIds 25 | ^groups.GroupAddInvalidAction 26 | ^groups.SelectFwdSpread 27 | ^flow_stats.AllFlowStats 28 | -------------------------------------------------------------------------------- /targets/ivs/tests.txt: -------------------------------------------------------------------------------- 1 | standard 2 | 3 | # Extensions we support 4 | nicira_dec_ttl 5 | 6 | # Indigo respects priority of exact match flows 7 | ^flow_matches.ExactMatchPrio 8 | 9 | # OVS kernel module bug 10 | ^pktact.DirectLlcPackets 11 | 12 | # IVS doesn't support OFPP_FLOOD and OFPP_ALL 13 | ^pktact.AllPlusIngress 14 | ^pktact.Flood 15 | ^pktact.FloodPlusIngress 16 | ^pktact.FloodMinusPort 17 | ^pktact.All 18 | ^actions.ForwardAll 19 | ^actions.ForwardFlood 20 | 21 | # IVS doesn't support matching on output port 22 | ^detailed_contr_sw_messages.Outport1 23 | 24 | # IVS doesn't support overlap checking 25 | ^detailed_contr_sw_messages.OverlapChecking 26 | 27 | # IVS doesn't support OFPPC_NO_FWD 28 | ^message_types.PortModFwd 29 | 30 | # Not yet passing 31 | ^flow_query.Flow_Add_8 32 | ^flow_stats.AggregateStats 33 | ^flow_stats.DeletedFlowStats 34 | ^counters.TxBytPerQueue 35 | ^counters.TxPktPerQueue 36 | ^pktact.DirectPacketQueue 37 | ^nicira_role.AnyReply 38 | -------------------------------------------------------------------------------- /targets/l2table-benchmark/Makefile: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | include ../../init.mk 20 | 21 | ALLOW_DECLARATION_AFTER_STATEMENT = 1 22 | 23 | MODULE := l2table_benchmark 24 | include $(BUILDER)/standardinit.mk 25 | 26 | LIBRARY := l2table_benchmark_main 27 | $(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) 28 | include $(BUILDER)/lib.mk 29 | 30 | DEPENDMODULES := l2table AIM murmur 31 | include $(BUILDER)/dependmodules.mk 32 | 33 | BINARY := l2table-benchmark 34 | 35 | $(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) 36 | include $(BUILDER)/bin.mk 37 | 38 | include $(BUILDER)/targets.mk 39 | 40 | GLOBAL_CFLAGS += -g 41 | GLOBAL_CFLAGS += -O3 42 | GLOBAL_CFLAGS += -fno-omit-frame-pointer 43 | GLOBAL_LINK_LIBS += -lrt 44 | 45 | ifdef USE_CALLGRIND 46 | GLOBAL_CFLAGS += -DUSE_CALLGRIND 47 | endif 48 | -------------------------------------------------------------------------------- /targets/l2table-benchmark/main.c: -------------------------------------------------------------------------------- 1 | /**************************************************************** 2 | * 3 | * Copyright 2013, Big Switch Networks, Inc. 4 | * 5 | * Licensed under the Eclipse Public License, Version 1.0 (the 6 | * "License"); you may not use this file except in compliance 7 | * with the License. You may obtain a copy of the License at 8 | * 9 | * http://www.eclipse.org/legal/epl-v10.html 10 | * 11 | * Unless required by applicable law or agreed to in writing, 12 | * software distributed under the License is distributed on an 13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | * either express or implied. See the License for the specific 15 | * language governing permissions and limitations under the 16 | * License. 17 | * 18 | ****************************************************************/ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #ifdef USE_CALLGRIND 30 | #include 31 | #else 32 | #define CALLGRIND_START_INSTRUMENTATION 33 | #define CALLGRIND_STOP_INSTRUMENTATION 34 | #endif 35 | 36 | const int num_iters = 10; 37 | const int num_flows = 100*1000; 38 | const int num_lookups_per_flow = 5; 39 | 40 | uint64_t total_elapsed = 0; 41 | 42 | struct sample_key { 43 | uint8_t mac[L2TABLE_MAC_LEN]; 44 | uint16_t vlan_id; 45 | }; 46 | 47 | static uint64_t 48 | monotonic_ns(void) 49 | { 50 | struct timespec tp; 51 | clock_gettime(CLOCK_MONOTONIC, &tp); 52 | return ((uint64_t)tp.tv_sec * 1000*1000*1000) + tp.tv_nsec; 53 | } 54 | 55 | static void 56 | make_random_key(struct sample_key *key) 57 | { 58 | int i; 59 | for (i = 0; i < sizeof(key->mac); i++) { 60 | key->mac[i] = random(); 61 | } 62 | 63 | key->vlan_id = random() & 0xffff; 64 | } 65 | 66 | static void 67 | benchmark_iteration(void) 68 | { 69 | int i, j; 70 | 71 | struct sample_key *sample_keys = calloc(num_flows, sizeof(*sample_keys)); 72 | struct l2table *t = l2table_create(random()); 73 | 74 | for (i = 0; i < num_flows; i++) { 75 | make_random_key(&sample_keys[i]); 76 | sample_keys[i].vlan_id &= 0xfff; 77 | if (l2table_insert(t, sample_keys[i].mac, sample_keys[i].vlan_id, i, i) < 0) { 78 | abort(); 79 | } 80 | } 81 | 82 | uint64_t start_time = monotonic_ns(); 83 | 84 | CALLGRIND_START_INSTRUMENTATION; 85 | 86 | for (i = 0; i < num_lookups_per_flow; i++) { 87 | for (j = 0; j < num_flows; j++) { 88 | uint32_t out_port; 89 | uint32_t metadata; 90 | if (l2table_lookup(t, sample_keys[j].mac, sample_keys[j].vlan_id, &out_port, &metadata) < 0) { 91 | abort(); 92 | } 93 | } 94 | } 95 | 96 | uint64_t end_time = monotonic_ns(); 97 | 98 | CALLGRIND_STOP_INSTRUMENTATION; 99 | 100 | for (i = 0; i < num_flows; i++) { 101 | if (l2table_remove(t, sample_keys[i].mac, sample_keys[i].vlan_id) < 0) { 102 | abort(); 103 | } 104 | } 105 | 106 | free(sample_keys); 107 | l2table_destroy(t); 108 | 109 | uint64_t elapsed = end_time - start_time; 110 | total_elapsed += elapsed; 111 | } 112 | 113 | int main(int argc, char* argv[]) 114 | { 115 | (void) argc; 116 | (void) argv; 117 | 118 | CALLGRIND_STOP_INSTRUMENTATION; 119 | 120 | int i; 121 | for (i = 0; i < num_iters; i++) { 122 | benchmark_iteration(); 123 | } 124 | 125 | double avg_time = (total_elapsed*1.0)/(num_flows*num_lookups_per_flow*num_iters); 126 | fprintf(stderr, "average lookup time: %.3f ns\n", avg_time); 127 | 128 | return 0; 129 | } 130 | -------------------------------------------------------------------------------- /targets/tcam-benchmark/Makefile: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | include ../../init.mk 20 | 21 | ALLOW_DECLARATION_AFTER_STATEMENT = 1 22 | 23 | MODULE := tcam_benchmark 24 | include $(BUILDER)/standardinit.mk 25 | 26 | LIBRARY := tcam_benchmark_main 27 | $(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) 28 | include $(BUILDER)/lib.mk 29 | 30 | DEPENDMODULES := tcam AIM murmur BigHash bloom_filter 31 | include $(BUILDER)/dependmodules.mk 32 | 33 | BINARY := tcam-benchmark 34 | 35 | $(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) 36 | include $(BUILDER)/bin.mk 37 | 38 | include $(BUILDER)/targets.mk 39 | 40 | GLOBAL_CFLAGS += -g 41 | GLOBAL_CFLAGS += -O3 42 | GLOBAL_CFLAGS += -fno-omit-frame-pointer 43 | GLOBAL_LINK_LIBS += -lrt 44 | 45 | ifdef USE_CALLGRIND 46 | GLOBAL_CFLAGS += -DUSE_CALLGRIND 47 | endif 48 | -------------------------------------------------------------------------------- /targets/upcall-latency-benchmark/Makefile: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | include ../../init.mk 20 | 21 | ALLOW_DECLARATION_AFTER_STATEMENT = 1 22 | 23 | MODULE := upcall_latency_benchmark 24 | include $(BUILDER)/standardinit.mk 25 | 26 | LIBRARY := upcall_latency_benchmark_main 27 | $(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) 28 | include $(BUILDER)/lib.mk 29 | 30 | DEPENDMODULES := 31 | include $(BUILDER)/dependmodules.mk 32 | 33 | BINARY := upcall-latency-benchmark 34 | 35 | $(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) 36 | include $(BUILDER)/bin.mk 37 | 38 | include $(BUILDER)/targets.mk 39 | 40 | GLOBAL_CFLAGS += -g 41 | GLOBAL_CFLAGS += -O3 42 | GLOBAL_LINK_LIBS += -lrt -lpcap 43 | 44 | ifdef USE_CALLGRIND 45 | GLOBAL_CFLAGS += -DUSE_CALLGRIND 46 | endif 47 | -------------------------------------------------------------------------------- /targets/upcall-latency-benchmark/plot-latency.gnuplot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env gnuplot 2 | ################################################################ 3 | # 4 | # Copyright 2013, Big Switch Networks, Inc. 5 | # 6 | # Licensed under the Eclipse Public License, Version 1.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.eclipse.org/legal/epl-v10.html 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 15 | # either express or implied. See the License for the specific 16 | # language governing permissions and limitations under the 17 | # License. 18 | # 19 | ################################################################ 20 | 21 | # Set OUTPUT_FILENAME=upcall-latency.data when running upcall-latency-benchmark, 22 | # then run this script to plot the latencies as a histogram. Any files matching 23 | # upcall-latency*.data will be graphed. 24 | 25 | # Uncomment these (and comment out the pause at the bottom) to render to a file 26 | #set terminal pngcairo enhanced font "arial,10" size 500, 350 27 | #set output 'upcall-latency-histogram.png' 28 | 29 | set title "Upcall Latency Histogram" 30 | set xlabel "Latency (nanoseconds, bucket size 500ns)" 31 | set ylabel "#" 32 | 33 | set style histogram clustered gap 5 34 | set style fill solid 1 35 | set xrange[10000:30000] 36 | set boxwidth 249 37 | 38 | binwidth=500 39 | bin(x,width)=width*floor(x/width) + binwidth/2.0 40 | 41 | filenames = system("echo upcall-latency*.data") 42 | plot for [filename in filenames] filename using (bin($1,binwidth)+(binwidth/2)):(1.0) smooth freq with boxes title filename 43 | pause -1 44 | -------------------------------------------------------------------------------- /targets/upcall-throughput-benchmark/Makefile: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | include ../../init.mk 20 | 21 | ALLOW_DECLARATION_AFTER_STATEMENT = 1 22 | 23 | MODULE := upcall_throughput_benchmark 24 | include $(BUILDER)/standardinit.mk 25 | 26 | LIBRARY := upcall_throughput_benchmark_main 27 | $(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) 28 | include $(BUILDER)/lib.mk 29 | 30 | DEPENDMODULES := 31 | include $(BUILDER)/dependmodules.mk 32 | 33 | BINARY := upcall-throughput-benchmark 34 | 35 | $(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) 36 | include $(BUILDER)/bin.mk 37 | 38 | include $(BUILDER)/targets.mk 39 | 40 | GLOBAL_CFLAGS += -g 41 | GLOBAL_CFLAGS += -O3 42 | GLOBAL_LINK_LIBS += -lrt -lpcap -lpthread 43 | 44 | LIBNL_CFLAGS := $(shell pkg-config --cflags libnl-3.0) 45 | LIBNL_CFLAGS += $(shell pkg-config --cflags --silence-errors libnl-route-3.0) 46 | LIBNL_LIBS := $(shell pkg-config --libs libnl-3.0) 47 | LIBNL_LIBS += $(shell pkg-config --libs --silence-errors libnl-route-3.0) 48 | 49 | GLOBAL_CFLAGS += $(LIBNL_CFLAGS) 50 | GLOBAL_LINK_LIBS += $(LIBNL_LIBS) 51 | 52 | ifdef USE_CALLGRIND 53 | GLOBAL_CFLAGS += -DUSE_CALLGRIND 54 | endif 55 | -------------------------------------------------------------------------------- /targets/upcall-throughput-benchmark/plot-throughput.gnuplot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env gnuplot 2 | ################################################################ 3 | # 4 | # Copyright 2013, Big Switch Networks, Inc. 5 | # 6 | # Licensed under the Eclipse Public License, Version 1.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # with the License. You may obtain a copy of the License at 9 | # 10 | # http://www.eclipse.org/legal/epl-v10.html 11 | # 12 | # Unless required by applicable law or agreed to in writing, 13 | # software distributed under the License is distributed on an 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 15 | # either express or implied. See the License for the specific 16 | # language governing permissions and limitations under the 17 | # License. 18 | # 19 | ################################################################ 20 | 21 | # Set OUTPUT_FILENAME=upcall-throughput.data when running upcall-throughput-benchmark, 22 | # then run this script to plot the throughput over time. Any files matching 23 | # upcall-throughput*.data will be graphed. 24 | 25 | # Uncomment these (and comment out the pause at the bottom) to render to a file 26 | #set terminal pngcairo enhanced font "arial,10" size 500, 350 27 | #set output 'upcall-throughtput.png' 28 | 29 | set title "Upcall Throughput" 30 | set xlabel "Time (s)" 31 | set ylabel "upcall/s" 32 | 33 | set yrange[0:] 34 | 35 | filenames = system("echo upcall-throughput*.data") 36 | plot for [filename in filenames] filename title filename with lines 37 | pause -1 38 | -------------------------------------------------------------------------------- /targets/utests/flowtable/Makefile: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | ############################################################################### 21 | # 22 | # flowtable Unit Testing Module Makefile 23 | # 24 | # 25 | # 26 | ############################################################################### 27 | MODULE := flowtable_utest 28 | NOMODULEMAKE := 1 29 | TEST_MODULE := flowtable 30 | DEPENDMODULES := AIM murmur 31 | GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_POSIX=1 32 | GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 33 | OS_MAKE_CONFIG_AUTOSELECT := 1 34 | PEDANTIC := 1 35 | include ../make/utestmodule.mk 36 | -------------------------------------------------------------------------------- /targets/utests/l2table/Makefile: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | ############################################################################### 21 | # 22 | # l2table Unit Testing Module Makefile 23 | # 24 | # 25 | # 26 | ############################################################################### 27 | MODULE := l2table_utest 28 | NOMODULEMAKE := 1 29 | TEST_MODULE := l2table 30 | DEPENDMODULES := AIM murmur 31 | GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_POSIX=1 32 | GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 33 | OS_MAKE_CONFIG_AUTOSELECT := 1 34 | PEDANTIC := 1 35 | include ../make/utestmodule.mk 36 | -------------------------------------------------------------------------------- /targets/utests/make/utestmodule.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | ############################################################################### 21 | # 22 | # Generic Unit Testing Module Makefile 23 | # 24 | ############################################################################### 25 | UCODE_MAKE := $(dir $(lastword $(MAKEFILE_LIST))) 26 | 27 | include ../../../init.mk 28 | 29 | DEBUG := 1 30 | 31 | .DEFAULT_GOAL := tests 32 | 33 | include $(BUILDER)/standardinit.mk 34 | 35 | # The Module we are building 36 | ifndef TEST_MODULE 37 | $(error $$(TEST_MODULE) is not defined. Please define relative to BigCode) 38 | endif 39 | 40 | ifndef MODULE 41 | $(error Need to define $$MODULE) 42 | endif 43 | 44 | # At the very least we need the test module 45 | DEPENDMODULES += $(TEST_MODULE) 46 | 47 | # Pull in the utest library for the TEST_MODULE 48 | INCLUDE_$(TEST_MODULE)_UTEST := 1 49 | 50 | # Pull in external module dependencies 51 | include $(BUILDER)/dependmodules.mk 52 | 53 | include $(BUILDER)/targets.mk 54 | 55 | ifdef VALGRIND 56 | HARNESS:=valgrind --leak-check=full --show-reachable=yes --suppressions=$(INDIGO)/Tools/valgrind.suppressions 57 | endif 58 | 59 | GLOBAL_CFLAGS += -DOF_WIRE_BUFFER_DEBUG 60 | 61 | 62 | # By Convention 63 | ifdef $(TEST_MODULE)UtestBinary 64 | # There is only one unit test - default unit testing 65 | UTEST_BINARY := $(BINARY_DIR)/$($(TEST_MODULE)UtestBinary) 66 | tests: $(UTEST_BINARY) $($(TEST_MODULE)_UNIT_TESTS) 67 | @echo "" 68 | @echo "** Starting Unit Test: $(UTEST_BINARY)" 69 | @$(SUDO) $(HARNESS) $(UTEST_BINARY) 70 | @echo "** Finished Unit Test: $(UTEST_BINARY)" 71 | @echo "" 72 | 73 | endif 74 | 75 | ifdef $(TEST_MODULE)UtestBinaries 76 | # Multiple unit tests -- you have to specify your own targets 77 | tests: $($(TEST_MODULE)UtestBinaries) $($(TEST_MODULE)_UNIT_TESTS) 78 | endif 79 | 80 | 81 | 82 | alltests: 83 | $(MAKE) alltc MAKETARGET=tests 84 | 85 | 86 | # 87 | # Convenience: remake autogen in the test module directory 88 | # 89 | autogen: 90 | $(MAKE) -C $($(TEST_MODULE)_BASEDIR) autogen 91 | -------------------------------------------------------------------------------- /targets/utests/tcam/Makefile: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | ############################################################################### 21 | # 22 | # tcam Unit Testing Module Makefile 23 | # 24 | # 25 | # 26 | ############################################################################### 27 | MODULE := tcam_utest 28 | NOMODULEMAKE := 1 29 | TEST_MODULE := tcam 30 | DEPENDMODULES := AIM murmur BigHash bloom_filter 31 | GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_POSIX=1 32 | GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 33 | OS_MAKE_CONFIG_AUTOSELECT := 1 34 | PEDANTIC := 1 35 | include ../make/utestmodule.mk 36 | -------------------------------------------------------------------------------- /targets/utests/xbuf/Makefile: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # 3 | # Copyright 2013, Big Switch Networks, Inc. 4 | # 5 | # Licensed under the Eclipse Public License, Version 1.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.eclipse.org/legal/epl-v10.html 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 14 | # either express or implied. See the License for the specific 15 | # language governing permissions and limitations under the 16 | # License. 17 | # 18 | ################################################################ 19 | 20 | ############################################################################### 21 | # 22 | # xbuf Unit Testing Module Makefile 23 | # 24 | # 25 | # 26 | ############################################################################### 27 | MODULE := xbuf_utest 28 | NOMODULEMAKE := 1 29 | TEST_MODULE := xbuf 30 | DEPENDMODULES := AIM 31 | GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_POSIX=1 32 | GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 33 | OS_MAKE_CONFIG_AUTOSELECT := 1 34 | PEDANTIC := 1 35 | include ../make/utestmodule.mk 36 | -------------------------------------------------------------------------------- /tests/hitless.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """ 3 | This test verifies that an IVS started with the --hitless flag waits until it 4 | receives a bsn_takeover message before revalidating the kernel flowtable. 5 | """ 6 | import subprocess 7 | import logging 8 | import time 9 | import os 10 | import signal 11 | import sys 12 | 13 | sys.path.insert(1, "submodules/loxigen-artifacts/pyloxi") 14 | import loxi.of14 as ofp 15 | import loxi.connection 16 | from loxi.pp import pp 17 | 18 | IVS = "./targets/ivs/build/gcc-local/bin/ivs" 19 | 20 | logging.basicConfig(level=logging.INFO) 21 | 22 | logfile = file("ivs.log", "w") 23 | ivs = None 24 | 25 | def start_ivs(): 26 | global ivs 27 | logging.info("Starting IVS") 28 | ivs = subprocess.Popen( 29 | [IVS, '-v', '-l', '127.0.0.1:6634', '--hitless', '-V', '1.3'], 30 | stdout=logfile, stderr=logfile) 31 | 32 | def insert_flows(): 33 | logging.info("Inserting flows") 34 | cxn = loxi.connection.connect("127.0.0.1", port=6634) 35 | port_descs = cxn.transact_multipart(ofp.message.port_desc_stats_request()) 36 | port_numbers = { x.name: x.port_no for x in port_descs } 37 | 38 | cxn.send(ofp.message.flow_add( 39 | match=ofp.match([ 40 | ofp.oxm.in_port(port_numbers["test1"])]), 41 | instructions=[ 42 | ofp.instruction.apply_actions([ 43 | ofp.action.output(port_numbers["test2"])])])) 44 | cxn.send(ofp.message.flow_add( 45 | match=ofp.match([ 46 | ofp.oxm.in_port(port_numbers["test2"])]), 47 | instructions=[ 48 | ofp.instruction.apply_actions([ 49 | ofp.action.output(port_numbers["test1"])])])) 50 | cxn.send(ofp.message.bsn_takeover()) 51 | cxn.transact(ofp.message.barrier_request()) 52 | 53 | def cmd(*args): 54 | logging.debug("Running %s", ' '.join(args)) 55 | subprocess.check_call(args) 56 | 57 | 58 | subprocess.call(["ivs-ctl", "del-dp"]) 59 | 60 | try: 61 | if os.path.exists("/var/run/netns/test1"): 62 | cmd("ip", "netns", "delete", "test1") 63 | 64 | if os.path.exists("/var/run/netns/test2"): 65 | cmd("ip", "netns", "delete", "test2") 66 | 67 | start_ivs() 68 | 69 | cmd("ip", "netns", "add", "test1") 70 | cmd("ip", "netns", "add", "test2") 71 | 72 | cmd("ip", "link", "add", "name", "test1", "type", "veth", "peer", "name", "test1-peer") 73 | cmd("ip", "link", "set", "test1-peer", "up", "netns", "test1", "name", "eth0") 74 | cmd("ip", "netns", "exec", "test1", "ip", "addr", "add", "dev", "eth0", "192.168.248.1/24") 75 | 76 | cmd("ip", "link", "add", "name", "test2", "type", "veth", "peer", "name", "test2-peer") 77 | cmd("ip", "link", "set", "test2-peer", "up", "netns", "test2", "name", "eth0") 78 | cmd("ip", "netns", "exec", "test2", "ip", "addr", "add", "dev", "eth0", "192.168.248.2/24") 79 | 80 | cmd("ivs-ctl", "add-port", "test1") 81 | cmd("ivs-ctl", "add-port", "test2") 82 | 83 | insert_flows() 84 | 85 | logging.info("Normal ping") 86 | cmd("ip", "netns", "exec", "test1", "ping", "-c", "10", "-i", "0.1", "192.168.248.2") 87 | ivs.kill() 88 | 89 | logging.info("Pinging while IVS is dead") 90 | cmd("ip", "netns", "exec", "test1", "ping", "-c", "10", "-i", "0.1", "192.168.248.2") 91 | 92 | start_ivs() 93 | 94 | logging.info("Pinging after IVS has restarted but before takeover") 95 | cmd("ip", "netns", "exec", "test1", "ping", "-c", "10", "-i", "0.1", "192.168.248.2") 96 | 97 | insert_flows() 98 | 99 | logging.info("Pinging after takeover") 100 | cmd("ip", "netns", "exec", "test1", "ping", "-c", "10", "-i", "0.1", "192.168.248.2") 101 | finally: 102 | if ivs: 103 | ivs.kill() 104 | 105 | if os.path.exists("/var/run/netns/test1"): 106 | cmd("ip", "netns", "delete", "test1") 107 | 108 | if os.path.exists("/var/run/netns/test2"): 109 | cmd("ip", "netns", "delete", "test2") 110 | --------------------------------------------------------------------------------