├── debian ├── compat ├── dirs ├── source │ └── format ├── openvswitch-common.dirs ├── openvswitch-ipsec.dirs ├── openvswitch-controller.dirs ├── openvswitch-controller.install ├── ovsdbmonitor.manpages ├── openvswitch-brcompat.manpages ├── openvswitch-controller.manpages ├── openvswitch-brcompat.install ├── openvswitch-datapath-source.dirs ├── openvswitch-ipsec.install ├── ovsdbmonitor.install ├── python-openvswitch.dirs ├── openvswitch-switch.dirs ├── python-openvswitch.install ├── openvswitch-switch.manpages ├── openvswitch-common.install ├── openvswitch-common.manpages ├── openvswitch-controller.README.Debian ├── openvswitch-switch.template ├── openvswitch-datapath-dkms.prerm ├── openvswitch-datapath-source.install ├── openvswitch-switch.install ├── openvswitch-datapath-source.copyright ├── dkms.conf.in ├── openvswitch-brcompat.postinst ├── .gitignore ├── openvswitch-switch.logrotate ├── openvswitch-datapath-dkms.postinst ├── openvswitch-datapath-module-_KVERS_.postinst.modules.in ├── openvswitch-switch.README.Debian ├── control.modules.in ├── openvswitch-datapath-source.README.Debian ├── openvswitch-controller.default ├── openvswitch-pki.postinst ├── rules.modules ├── openvswitch-switch.postrm └── openvswitch-controller.postinst ├── utilities ├── bugtool │ ├── .gitignore │ ├── ovs-bugtool-ovsdb-dump │ ├── plugins │ │ ├── kernel-info │ │ │ └── openvswitch.xml │ │ ├── system-configuration │ │ │ └── openvswitch.xml │ │ ├── system-logs │ │ │ └── openvswitch.xml │ │ ├── network-status │ │ │ └── openvswitch.xml │ │ └── system-configuration.xml │ ├── ovs-bugtool-tc-class-show │ └── ovs-bugtool.8 ├── .gitignore ├── ovs-pcap.1.in ├── ovs-vlan-bugs.man ├── ovs-tcpundump.1.in ├── ovs-parse-leaks.8 └── ovs-pki-cgi.in ├── include ├── .gitignore ├── openflow │ ├── .gitignore │ └── automake.mk ├── automake.mk ├── openvswitch │ └── automake.mk └── sparse │ ├── automake.mk │ ├── arpa │ └── inet.h │ ├── assert.h │ └── sys │ └── wait.h ├── ofproto ├── .gitignore ├── automake.mk ├── collectors.h ├── pktbuf.h ├── names.c ├── pinsched.h ├── in-band.h ├── fail-open.h └── ofproto-dpif-sflow.h ├── ovsdb ├── ovsdbmonitor │ ├── .gitignore │ ├── COPYING │ ├── ovsdbmonitor.1 │ ├── ovsdbmonitor.in │ ├── OVEStandard.py │ └── OVELogger.py ├── .gitignore ├── remote-active.man ├── remote-passive.man └── query.h ├── third-party ├── .gitignore ├── automake.mk └── README ├── boot.sh ├── python └── ovs │ ├── __init__.py │ ├── db │ ├── __init__.py │ └── error.py │ ├── dirs.py │ ├── timeval.py │ ├── automake.mk │ ├── process.py │ └── util.py ├── lib ├── ssl-bootstrap-syn.man ├── unixctl-syn.man ├── .gitignore ├── common-syn.man ├── daemon-syn.man ├── common.man ├── ssl-syn.man ├── vlog-syn.man ├── dh1024.pem ├── unixctl.man ├── vconn-active.man ├── dh2048.pem ├── leak-checker.man ├── ssl-peer-ca-cert.man ├── vconn-passive.man ├── entropy.h ├── dhparams.h ├── valgrind.h ├── string.c ├── sort.h ├── dummy.h ├── lockfile.h ├── backtrace.h ├── pcap.h ├── random.h ├── dh4096.pem ├── dirs.h ├── ssl-bootstrap.man ├── route-table.h ├── dummy.c ├── ofp-errors.h ├── netdev-linux.h ├── signals.h ├── autopath.h ├── csum.h ├── netdev-vport.h ├── ssl.man ├── aes128.h ├── learn.h ├── stream-fd.h ├── multipath.h ├── command-line.h ├── timer.c ├── string.h ├── sat-math.h ├── compiler.h ├── vlan-bitmap.h ├── fatal-signal.h ├── type-props.h ├── ofp-print.h ├── leak-checker.h ├── ofp-parse.h └── vlog-unixctl.man ├── rhel ├── .gitignore ├── etc_logrotate.d_openvswitch ├── usr_share_openvswitch_scripts_sysconfig.template └── automake.mk ├── datapath ├── .gitignore ├── linux │ ├── compat │ │ ├── genetlink-openvswitch.c │ │ ├── reciprocal_div.c │ │ ├── include │ │ │ ├── linux │ │ │ │ ├── compiler.h │ │ │ │ ├── compiler-gcc.h │ │ │ │ ├── poison.h │ │ │ │ ├── stddef.h │ │ │ │ ├── ipv6.h │ │ │ │ ├── icmp.h │ │ │ │ ├── icmpv6.h │ │ │ │ ├── cpumask.h │ │ │ │ ├── types.h │ │ │ │ ├── udp.h │ │ │ │ ├── inetdevice.h │ │ │ │ ├── if_arp.h │ │ │ │ ├── log2.h │ │ │ │ ├── genetlink.h │ │ │ │ ├── tcp.h │ │ │ │ ├── ip.h │ │ │ │ ├── rcupdate.h │ │ │ │ ├── if.h │ │ │ │ ├── netfilter_ipv4.h │ │ │ │ ├── if_ether.h │ │ │ │ ├── err.h │ │ │ │ ├── netfilter_bridge.h │ │ │ │ ├── bottom_half.h │ │ │ │ ├── rculist.h │ │ │ │ ├── slab.h │ │ │ │ ├── kobject.h │ │ │ │ ├── jiffies.h │ │ │ │ ├── in.h │ │ │ │ ├── netlink.h │ │ │ │ ├── reciprocal_div.h │ │ │ │ ├── workqueue.h │ │ │ │ └── mutex.h │ │ │ ├── net │ │ │ │ ├── dst.h │ │ │ │ ├── ip.h │ │ │ │ ├── protocol.h │ │ │ │ ├── net_namespace.h │ │ │ │ ├── route.h │ │ │ │ └── checksum.h │ │ │ └── asm-generic │ │ │ │ └── bug.h │ │ ├── skbuff-openvswitch.c │ │ ├── kmemdup.c │ │ ├── genetlink-brcompat.c │ │ ├── ip_output-openvswitch.c │ │ ├── dev-openvswitch.c │ │ └── time.c │ ├── Makefile.in │ ├── .gitignore │ └── Kbuild.in ├── vport-generic.h ├── vport-internal_dev.h ├── dp_sysfs.h ├── actions.h ├── Makefile.am ├── loop_counter.h ├── compat.h ├── vport-generic.c ├── vlan.c ├── vport-netdev.h ├── Modules.mk └── dp_notify.c ├── tests ├── openssl.supp ├── atlocal.in ├── idltest.ann ├── classifier.at ├── ovsdb-macros.at ├── ovsdb-column.at ├── .gitignore ├── vconn.at ├── lockfile.at ├── timeval.at ├── uuidfilt.pl ├── ofproto-macros.at ├── valgrind-wrapper.in ├── file_name.at ├── check-structs.at ├── test-file_name.c ├── autopath.at ├── test-uuid.c ├── ovsdb-monitor-sort.pl └── test-strtok_r.c ├── vswitchd ├── .gitignore ├── vswitch-idl.ann ├── xenserver.h ├── system-stats.h ├── bridge.h ├── vswitch.gv └── ovs-brcompatd.8.in ├── NOTICE ├── .gitignore ├── xenserver ├── etc_logrotate.d_openvswitch ├── usr_share_openvswitch_scripts_sysconfig.template ├── automake.mk └── etc_profile.d_openvswitch.sh ├── README-gcov ├── COPYING └── soexpand.pl /debian/compat: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /debian/dirs: -------------------------------------------------------------------------------- 1 | usr/bin 2 | usr/sbin 3 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /utilities/bugtool/.gitignore: -------------------------------------------------------------------------------- 1 | /ovs-bugtool 2 | -------------------------------------------------------------------------------- /include/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /Makefile.in 3 | -------------------------------------------------------------------------------- /ofproto/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /Makefile.in 3 | -------------------------------------------------------------------------------- /ovsdb/ovsdbmonitor/.gitignore: -------------------------------------------------------------------------------- 1 | /ovsdbmonitor.py 2 | -------------------------------------------------------------------------------- /third-party/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /Makefile.in 3 | -------------------------------------------------------------------------------- /boot.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | autoreconf --install --force 3 | -------------------------------------------------------------------------------- /debian/openvswitch-common.dirs: -------------------------------------------------------------------------------- 1 | var/log/openvswitch 2 | -------------------------------------------------------------------------------- /debian/openvswitch-ipsec.dirs: -------------------------------------------------------------------------------- 1 | usr/share/openvswitch/scripts 2 | -------------------------------------------------------------------------------- /debian/openvswitch-controller.dirs: -------------------------------------------------------------------------------- 1 | etc/openvswitch-controller 2 | -------------------------------------------------------------------------------- /debian/openvswitch-controller.install: -------------------------------------------------------------------------------- 1 | usr/bin/ovs-controller 2 | -------------------------------------------------------------------------------- /debian/ovsdbmonitor.manpages: -------------------------------------------------------------------------------- 1 | ovsdb/ovsdbmonitor/ovsdbmonitor.1 2 | -------------------------------------------------------------------------------- /python/ovs/__init__.py: -------------------------------------------------------------------------------- 1 | # This file intentionally left blank. 2 | -------------------------------------------------------------------------------- /python/ovs/db/__init__.py: -------------------------------------------------------------------------------- 1 | # This file intentionally left blank. 2 | -------------------------------------------------------------------------------- /debian/openvswitch-brcompat.manpages: -------------------------------------------------------------------------------- 1 | _debian/vswitchd/ovs-brcompatd.8 2 | -------------------------------------------------------------------------------- /include/openflow/.gitignore: -------------------------------------------------------------------------------- 1 | /nicira-ext.h.stamp 2 | /openflow.h.stamp 3 | -------------------------------------------------------------------------------- /debian/openvswitch-controller.manpages: -------------------------------------------------------------------------------- 1 | _debian/utilities/ovs-controller.8 2 | -------------------------------------------------------------------------------- /debian/openvswitch-brcompat.install: -------------------------------------------------------------------------------- 1 | _debian/vswitchd/ovs-brcompatd usr/sbin 2 | -------------------------------------------------------------------------------- /lib/ssl-bootstrap-syn.man: -------------------------------------------------------------------------------- 1 | .br 2 | [\fB\-\-bootstrap\-ca\-cert=\fIcacert.pem] 3 | -------------------------------------------------------------------------------- /debian/openvswitch-datapath-source.dirs: -------------------------------------------------------------------------------- 1 | usr/src/modules/openvswitch-datapath/debian 2 | -------------------------------------------------------------------------------- /debian/openvswitch-ipsec.install: -------------------------------------------------------------------------------- 1 | debian/ovs-monitor-ipsec usr/share/openvswitch/scripts 2 | -------------------------------------------------------------------------------- /debian/ovsdbmonitor.install: -------------------------------------------------------------------------------- 1 | usr/bin/ovsdbmonitor 2 | usr/share/openvswitch/ovsdbmonitor 3 | -------------------------------------------------------------------------------- /debian/python-openvswitch.dirs: -------------------------------------------------------------------------------- 1 | usr/share/pyshared/ovs/ 2 | usr/share/pyshared/ovs/db/ 3 | -------------------------------------------------------------------------------- /lib/unixctl-syn.man: -------------------------------------------------------------------------------- 1 | .IP "Runtime management options:" 2 | \fB\-\-unixctl=\fIsocket\fR 3 | -------------------------------------------------------------------------------- /rhel/.gitignore: -------------------------------------------------------------------------------- 1 | openvswitch-kmod-rhel5.spec 2 | openvswitch-kmod-rhel6.spec 3 | openvswitch.spec 4 | -------------------------------------------------------------------------------- /third-party/automake.mk: -------------------------------------------------------------------------------- 1 | EXTRA_DIST += \ 2 | third-party/README \ 3 | third-party/ofp-tcpdump.patch 4 | -------------------------------------------------------------------------------- /debian/openvswitch-switch.dirs: -------------------------------------------------------------------------------- 1 | /etc/openvswitch 2 | /etc/openvswitch-switch 3 | /usr/share/openvswitch/switch 4 | -------------------------------------------------------------------------------- /datapath/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /Makefile.in 3 | *.cmd 4 | *.ko 5 | *.mod.c 6 | Module.symvers 7 | /distfiles 8 | -------------------------------------------------------------------------------- /lib/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /Makefile.in 3 | /dhparams.c 4 | /dirs.c 5 | /coverage-counters.c 6 | /ofp-errors.c 7 | -------------------------------------------------------------------------------- /lib/common-syn.man: -------------------------------------------------------------------------------- 1 | .IP "Common options:" 2 | [\fB\-h\fR | \fB\-\-help\fR] 3 | [\fB\-V\fR | \fB\-\-version\fR] 4 | 5 | -------------------------------------------------------------------------------- /debian/python-openvswitch.install: -------------------------------------------------------------------------------- 1 | python/ovs/*.py usr/share/pyshared/ovs/ 2 | python/ovs/db/*.py usr/share/pyshared/ovs/db/ 3 | -------------------------------------------------------------------------------- /include/automake.mk: -------------------------------------------------------------------------------- 1 | include include/openflow/automake.mk 2 | include include/openvswitch/automake.mk 3 | include include/sparse/automake.mk 4 | -------------------------------------------------------------------------------- /datapath/linux/compat/genetlink-openvswitch.c: -------------------------------------------------------------------------------- 1 | #define GENL_FIRST_MCGROUP 16 2 | #define GENL_LAST_MCGROUP 31 3 | 4 | #include "genetlink.inc" 5 | -------------------------------------------------------------------------------- /lib/daemon-syn.man: -------------------------------------------------------------------------------- 1 | .IP "Daemon options:" 2 | [\fB\-\-pidfile\fR[\fB=\fIpidfile\fR]] 3 | [\fB\-\-overwrite\-pidfile\fR] 4 | [\fB\-\-detach\fR] 5 | [\fB\-\-no\-chdir\fR] 6 | -------------------------------------------------------------------------------- /ovsdb/.gitignore: -------------------------------------------------------------------------------- 1 | /ovsdb-client 2 | /ovsdb-client.1 3 | /ovsdb-doc 4 | /ovsdb-dot 5 | /ovsdb-idlc 6 | /ovsdb-server 7 | /ovsdb-server.1 8 | /ovsdb-tool 9 | /ovsdb-tool.1 10 | -------------------------------------------------------------------------------- /lib/common.man: -------------------------------------------------------------------------------- 1 | .TP 2 | \fB\-h\fR, \fB\-\-help\fR 3 | Prints a brief help message to the console. 4 | . 5 | .TP 6 | \fB\-V\fR, \fB\-\-version\fR 7 | Prints version information to the console. 8 | -------------------------------------------------------------------------------- /lib/ssl-syn.man: -------------------------------------------------------------------------------- 1 | .IP "Public key infrastructure options:" 2 | [\fB\-\-private\-key=\fIprivkey.pem\fR] 3 | .br 4 | [\fB\-\-certificate=\fIcert.pem\fR] 5 | .br 6 | [\fB\-\-ca\-cert=\fIcacert.pem\fR] 7 | -------------------------------------------------------------------------------- /include/openvswitch/automake.mk: -------------------------------------------------------------------------------- 1 | noinst_HEADERS += \ 2 | include/openvswitch/brcompat-netlink.h \ 3 | include/openvswitch/datapath-protocol.h \ 4 | include/openvswitch/tunnel.h \ 5 | include/openvswitch/types.h 6 | 7 | -------------------------------------------------------------------------------- /tests/openssl.supp: -------------------------------------------------------------------------------- 1 | # suppress OpenSSL errors from valgrind 2 | 3 | { 4 | BN_mod_inverse 5 | Memcheck:Cond 6 | fun:BN_mod_inverse 7 | } 8 | 9 | { 10 | BN_div 11 | Memcheck:Cond 12 | fun:BN_div 13 | } 14 | -------------------------------------------------------------------------------- /datapath/linux/compat/reciprocal_div.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | u32 reciprocal_value(u32 k) 5 | { 6 | u64 val = (1LL << 32) + (k - 1); 7 | do_div(val, k); 8 | return (u32)val; 9 | } 10 | -------------------------------------------------------------------------------- /lib/vlog-syn.man: -------------------------------------------------------------------------------- 1 | .IP "Logging options:" 2 | [\fB\-v\fR[\fImodule\fR[\fB:\fIfacility\fR[\fB:\fIlevel\fR]]]]\&... 3 | .br 4 | [\fB\-\-verbose[=\fImodule\fR[\fB:\fIfacility\fR[\fB:\fIlevel\fR]]]]\&... 5 | .br 6 | [\fB\-\-log\-file\fR[\fB=\fIfile\fR]] 7 | -------------------------------------------------------------------------------- /vswitchd/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /Makefile.in 3 | /ovs-brcompatd 4 | /ovs-brcompatd.8 5 | /ovs-vswitchd 6 | /ovs-vswitchd.8 7 | /ovs-vswitchd.conf.db.5 8 | /vswitch.ovsschema.stamp 9 | /vswitch-idl.c 10 | /vswitch-idl.h 11 | /vswitch-idl.ovsidl 12 | -------------------------------------------------------------------------------- /datapath/linux/Makefile.in: -------------------------------------------------------------------------------- 1 | ifeq ($(KERNELRELEASE),) 2 | # We're being called directly by running make in this directory. 3 | include Makefile.main 4 | else 5 | # We're being included by the Linux kernel build system 6 | include Kbuild 7 | endif 8 | 9 | 10 | -------------------------------------------------------------------------------- /debian/openvswitch-switch.manpages: -------------------------------------------------------------------------------- 1 | _debian/ovsdb/ovsdb-server.1 2 | _debian/utilities/ovs-dpctl.8 3 | _debian/utilities/ovs-pcap.1 4 | _debian/utilities/ovs-tcpundump.1 5 | _debian/utilities/ovs-vlan-test.8 6 | _debian/utilities/ovs-vsctl.8 7 | _debian/vswitchd/ovs-vswitchd.8 8 | -------------------------------------------------------------------------------- /tests/atlocal.in: -------------------------------------------------------------------------------- 1 | # -*- shell-script -*- 2 | HAVE_OPENSSL='@HAVE_OPENSSL@' 3 | HAVE_PYTHON='@HAVE_PYTHON@' 4 | PERL='@PERL@' 5 | PYTHON='@PYTHON@' 6 | 7 | PYTHONPATH=$PYTHONPATH:$abs_top_srcdir/python 8 | export PYTHONPATH 9 | 10 | PYTHONIOENCODING=utf_8 11 | export PYTHONIOENCODING 12 | -------------------------------------------------------------------------------- /debian/openvswitch-common.install: -------------------------------------------------------------------------------- 1 | etc/openvswitch/bugtool-plugins 2 | usr/bin/ovs-appctl 3 | usr/bin/ovs-benchmark 4 | usr/bin/ovs-ofctl 5 | usr/bin/ovs-parse-leaks 6 | usr/bin/ovs-pki 7 | usr/bin/ovsdb-client 8 | usr/sbin/ovs-bugtool 9 | usr/share/openvswitch/scripts/ovs-bugtool-tc-class-show 10 | -------------------------------------------------------------------------------- /debian/openvswitch-common.manpages: -------------------------------------------------------------------------------- 1 | _debian/ovsdb/ovsdb-client.1 2 | _debian/ovsdb/ovsdb-tool.1 3 | _debian/utilities/ovs-appctl.8 4 | _debian/utilities/ovs-benchmark.1 5 | _debian/utilities/ovs-ofctl.8 6 | _debian/utilities/ovs-pki.8 7 | utilities/bugtool/ovs-bugtool.8 8 | utilities/ovs-parse-leaks.8 9 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/compiler.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_COMPILER_WRAPPER_H 2 | #define __LINUX_COMPILER_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #ifndef __percpu 7 | #define __percpu 8 | #endif 9 | 10 | #ifndef __rcu 11 | #define __rcu 12 | #endif 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/compiler-gcc.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_COMPILER_H 2 | #error "Please don't include directly, include instead." 3 | #endif 4 | 5 | #include_next 6 | 7 | #ifndef __packed 8 | #define __packed __attribute__((packed)) 9 | #endif 10 | -------------------------------------------------------------------------------- /include/sparse/automake.mk: -------------------------------------------------------------------------------- 1 | noinst_HEADERS += \ 2 | include/sparse/arpa/inet.h \ 3 | include/sparse/assert.h \ 4 | include/sparse/math.h \ 5 | include/sparse/netinet/in.h \ 6 | include/sparse/netinet/ip6.h \ 7 | include/sparse/sys/socket.h \ 8 | include/sparse/sys/wait.h 9 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/poison.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_POISON_WRAPPER_H 2 | #define __LINUX_POISON_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #ifndef FLEX_ARRAY_FREE 7 | /********** lib/flex_array.c **********/ 8 | #define FLEX_ARRAY_FREE 0x6c /* for use-after-free poisoning */ 9 | #endif 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /debian/openvswitch-controller.README.Debian: -------------------------------------------------------------------------------- 1 | README.Debian for openvswitch-controller 2 | ------------------------------------- 3 | 4 | * To (re)configure the controller, edit /etc/default/openvswitch-controller 5 | and run "/etc/init.d/openvswitch-controller restart". 6 | 7 | -- Ben Pfaff , Fri, 4 Mar 2011 14:28:53 -0800 8 | -------------------------------------------------------------------------------- /debian/openvswitch-switch.template: -------------------------------------------------------------------------------- 1 | # This is a POSIX shell fragment -*- sh -*- 2 | 3 | # FORCE_COREFILES: If 'yes' then core files will be enabled. 4 | # FORCE_COREFILES=yes 5 | 6 | # BRCOMPAT: If 'yes' and the openvswitch-brcompat package is installed, then 7 | # Linux bridge compatibility will be enabled. 8 | # BRCOMPAT=no 9 | -------------------------------------------------------------------------------- /debian/openvswitch-datapath-dkms.prerm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | package=openvswitch-datapath-dkms 6 | name=openvswitch 7 | 8 | version=`dpkg-query -W -f='${Version}' "$package" \ 9 | |rev|cut -d- -f2-|rev|cut -d':' -f2|tr -d "\n"` 10 | 11 | dkms remove -m "$name" -v "$version" --all || true 12 | 13 | #DEBHELPER# 14 | 15 | exit 0 16 | -------------------------------------------------------------------------------- /debian/openvswitch-datapath-source.install: -------------------------------------------------------------------------------- 1 | debian/changelog usr/src/modules/openvswitch-datapath/debian 2 | debian/control usr/src/modules/openvswitch-datapath/debian 3 | debian/compat usr/src/modules/openvswitch-datapath/debian 4 | debian/*.modules.in usr/src/modules/openvswitch-datapath/debian 5 | _debian/openvswitch.tar.gz usr/src/modules/openvswitch-datapath 6 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/stddef.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_STDDEF_WRAPPER_H 2 | #define __LINUX_STDDEF_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #ifdef __KERNEL__ 7 | 8 | #ifndef HAVE_BOOL_TYPE 9 | enum { 10 | false = 0, 11 | true = 1 12 | }; 13 | #endif /* !HAVE_BOOL_TYPE */ 14 | 15 | #endif /* __KERNEL__ */ 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/ipv6.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_IPV6_WRAPPER_H 2 | #define __LINUX_IPV6_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #ifndef HAVE_SKBUFF_HEADER_HELPERS 7 | static inline struct ipv6hdr *ipv6_hdr(const struct sk_buff *skb) 8 | { 9 | return (struct ipv6hdr *)skb_network_header(skb); 10 | } 11 | #endif 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/icmp.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_ICMP_WRAPPER_H 2 | #define __LINUX_ICMP_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #ifndef HAVE_SKBUFF_HEADER_HELPERS 7 | static inline struct icmphdr *icmp_hdr(const struct sk_buff *skb) 8 | { 9 | return (struct icmphdr *)skb_transport_header(skb); 10 | } 11 | #endif 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/icmpv6.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_ICMPV6_WRAPPER_H 2 | #define __LINUX_ICMPV6_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #ifndef HAVE_ICMP6_HDR 7 | static inline struct icmp6hdr *icmp6_hdr(const struct sk_buff *skb) 8 | { 9 | return (struct icmp6hdr *)skb_transport_header(skb); 10 | } 11 | #endif 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/net/dst.h: -------------------------------------------------------------------------------- 1 | #ifndef __NET_DST_WRAPPER_H 2 | #define __NET_DST_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #ifndef HAVE_SKB_DST_ACCESSOR_FUNCS 7 | 8 | static inline void skb_dst_drop(struct sk_buff *skb) 9 | { 10 | if (skb->dst) 11 | dst_release(skb_dst(skb)); 12 | skb->dst = NULL; 13 | } 14 | 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/cpumask.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_CPUMASK_WRAPPER_H 2 | #define __LINUX_CPUMASK_WRAPPER_H 3 | 4 | #include_next 5 | 6 | /* for_each_cpu was renamed for_each_possible_cpu in 2.6.18. */ 7 | #ifndef for_each_possible_cpu 8 | #define for_each_possible_cpu for_each_cpu 9 | #endif 10 | 11 | #endif /* linux/cpumask.h wrapper */ 12 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/types.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_TYPES_WRAPPER_H 2 | #define __LINUX_TYPES_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #ifndef HAVE_CSUM_TYPES 7 | typedef __u16 __bitwise __sum16; 8 | typedef __u32 __bitwise __wsum; 9 | #endif 10 | 11 | #ifndef HAVE_BOOL_TYPE 12 | typedef _Bool bool; 13 | #endif /* !HAVE_BOOL_TYPE */ 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/udp.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_UDP_WRAPPER_H 2 | #define __LINUX_UDP_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #ifndef HAVE_SKBUFF_HEADER_HELPERS 7 | static inline struct udphdr *udp_hdr(const struct sk_buff *skb) 8 | { 9 | return (struct udphdr *)skb_transport_header(skb); 10 | } 11 | #endif /* HAVE_SKBUFF_HEADER_HELPERS */ 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/net/ip.h: -------------------------------------------------------------------------------- 1 | #ifndef __NET_IP_WRAPPER_H 2 | #define __NET_IP_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #include 7 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) 8 | 9 | extern int __ip_local_out(struct sk_buff *skb); 10 | extern int ip_local_out(struct sk_buff *skb); 11 | 12 | #endif /* linux kernel < 2.6.25 */ 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /debian/openvswitch-switch.install: -------------------------------------------------------------------------------- 1 | usr/bin/ovs-dpctl 2 | usr/bin/ovs-pcap 3 | usr/bin/ovs-tcpundump 4 | usr/bin/ovs-vlan-test 5 | usr/bin/ovs-vsctl 6 | usr/bin/ovsdb-tool 7 | usr/sbin/ovs-vswitchd 8 | usr/sbin/ovsdb-server 9 | usr/share/openvswitch/scripts/ovs-ctl 10 | usr/share/openvswitch/scripts/ovs-lib.sh 11 | usr/share/openvswitch/scripts/ovs-save 12 | usr/share/openvswitch/vswitch.ovsschema 13 | -------------------------------------------------------------------------------- /python/ovs/dirs.py: -------------------------------------------------------------------------------- 1 | # These are the default directories. They will be replaced by the 2 | # configured directories at install time. 3 | 4 | import os 5 | PKGDATADIR = os.environ.get("OVS_PKGDATADIR", "/usr/local/share/openvswitch") 6 | RUNDIR = os.environ.get("OVS_RUNDIR", "/var/run") 7 | LOGDIR = os.environ.get("OVS_LOGDIR", "/usr/local/var/log") 8 | BINDIR = os.environ.get("OVS_BINDIR", "/usr/local/bin") 9 | -------------------------------------------------------------------------------- /tests/idltest.ann: -------------------------------------------------------------------------------- 1 | # -*- python -*- 2 | 3 | # This code, when invoked by "ovsdb-idlc annotate" (by the build 4 | # process), annotates idltest.ovsschema with additional data that give 5 | # the ovsdb-idl engine information about the types involved, so that 6 | # it can generate more programmer-friendly data structures. 7 | 8 | s["idlPrefix"] = "idltest_" 9 | s["idlHeader"] = "\"tests/idltest.h\"" 10 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/inetdevice.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_INETDEVICE_WRAPPER_H 2 | #define __LINUX_INETDEVICE_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #include 7 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) 8 | 9 | #define inetdev_by_index(net, ifindex) \ 10 | inetdev_by_index((ifindex)) 11 | 12 | #endif /* linux kernel < 2.6.25 */ 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /vswitchd/vswitch-idl.ann: -------------------------------------------------------------------------------- 1 | # -*- python -*- 2 | 3 | # This code, when invoked by "ovsdb-idlc annotate" (by the build 4 | # process), annotates vswitch.ovsschema with additional data that give 5 | # the ovsdb-idl engine information about the types involved, so that 6 | # it can generate more programmer-friendly data structures. 7 | 8 | s["idlPrefix"] = "ovsrec_" 9 | s["idlHeader"] = "\"vswitchd/vswitch-idl.h\"" 10 | -------------------------------------------------------------------------------- /datapath/linux/compat/skbuff-openvswitch.c: -------------------------------------------------------------------------------- 1 | #if !defined(HAVE_SKB_WARN_LRO) && defined(NETIF_F_LRO) 2 | 3 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 4 | 5 | #include 6 | 7 | void __skb_warn_lro_forwarding(const struct sk_buff *skb) 8 | { 9 | if (net_ratelimit()) 10 | pr_warn("%s: received packets cannot be forwarded while LRO is enabled\n", 11 | skb->dev->name); 12 | } 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/if_arp.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_IF_ARP_WRAPPER_H 2 | #define __LINUX_IF_ARP_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #ifndef HAVE_SKBUFF_HEADER_HELPERS 7 | #include 8 | 9 | static inline struct arphdr *arp_hdr(const struct sk_buff *skb) 10 | { 11 | return (struct arphdr *)skb_network_header(skb); 12 | } 13 | #endif /* !HAVE_SKBUFF_HEADER_HELPERS */ 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /debian/openvswitch-datapath-source.copyright: -------------------------------------------------------------------------------- 1 | Upstream Authors: 2 | 3 | Nicira Networks 4 | 5 | Copyright: 6 | 7 | Copyright (C) 2008 Nicira Networks 8 | 9 | License: 10 | 11 | Files in the datapath/ and its sub-directories are covered under the GNU 12 | General Public License Version 2. 13 | 14 | On Debian systems, the complete text of the GNU General 15 | Public License can be found in `/usr/share/common-licenses/GPL'. 16 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/net/protocol.h: -------------------------------------------------------------------------------- 1 | #ifndef __NET_PROTOCOL_WRAPPER_H 2 | #define __NET_PROTOCOL_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #include 7 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32) 8 | #define inet_add_protocol(prot, num) inet_add_protocol((struct net_protocol *)(prot), num) 9 | #define inet_del_protocol(prot, num) inet_del_protocol((struct net_protocol *)(prot), num) 10 | #endif 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/log2.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_LOG2_WRAPPER 2 | #define __LINUX_LOG2_WRAPPER 3 | 4 | #ifdef HAVE_LOG2_H 5 | #include_next 6 | #else 7 | /* This is very stripped down because log2.h has far too many dependencies. */ 8 | 9 | extern __attribute__((const, noreturn)) 10 | int ____ilog2_NaN(void); 11 | 12 | #define ilog2(n) ((n) == 4 ? 2 : \ 13 | (n) == 8 ? 3 : \ 14 | ____ilog2_NaN()) 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /debian/dkms.conf.in: -------------------------------------------------------------------------------- 1 | PACKAGE_NAME="openvswitch" 2 | PACKAGE_VERSION="__VERSION__" 3 | MAKE="./configure --with-linux=/usr/src/linux-headers-`uname -r` ; make -C datapath/linux" 4 | BUILT_MODULE_NAME[0]=openvswitch_mod 5 | BUILT_MODULE_NAME[1]=brcompat_mod 6 | BUILT_MODULE_LOCATION[0]=datapath/linux/ 7 | BUILT_MODULE_LOCATION[1]=datapath/linux/ 8 | DEST_MODULE_LOCATION[0]=/kernel/drivers/net/openvswitch/ 9 | DEST_MODULE_LOCATION[1]=/kernel/drivers/net/openvswitch/ 10 | -------------------------------------------------------------------------------- /debian/openvswitch-brcompat.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | # If openvswitch-switch is installed, and then later openvswitch-brcompat is 6 | # installed, make sure that ovs-brcompatd starts. 7 | if test X"$1" = Xconfigure && \ 8 | test -x /etc/init.d/openvswitch-switch && \ 9 | test -e /var/run/openvswitch/ovs-vswitchd.pid; then 10 | invoke-rc.d openvswitch-switch start || exit $? 11 | fi 12 | 13 | #DEBHELPER# 14 | 15 | exit 0 16 | 17 | 18 | -------------------------------------------------------------------------------- /tests/classifier.at: -------------------------------------------------------------------------------- 1 | AT_BANNER([flow classifier unit tests]) 2 | m4_foreach( 3 | [testname], 4 | [[empty], 5 | [destroy-null], 6 | [single-rule], 7 | [rule-replacement], 8 | [many-rules-in-one-list], 9 | [many-rules-in-one-table], 10 | [many-rules-in-two-tables], 11 | [many-rules-in-five-tables]], 12 | [AT_SETUP([flow classifier - m4_bpatsubst(testname, [-], [ ])]) 13 | AT_CHECK([test-classifier testname], [0], [], []) 14 | AT_CLEANUP])]) 15 | -------------------------------------------------------------------------------- /tests/ovsdb-macros.at: -------------------------------------------------------------------------------- 1 | dnl OVSDB_INIT([$1]) 2 | dnl 3 | dnl Creates an empty database named $1. 4 | m4_define([OVSDB_INIT], 5 | [AT_CHECK( 6 | [ovsdb-tool create $1 $abs_top_srcdir/vswitchd/vswitch.ovsschema], 7 | [0], [stdout], [ignore]) 8 | AT_CHECK( 9 | [[ovsdb-tool transact $1 \ 10 | '["Open_vSwitch", 11 | {"op": "insert", 12 | "table": "Open_vSwitch", 13 | "row": {}}]']], 14 | [0], [ignore], [ignore])]) 15 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/genetlink.h: -------------------------------------------------------------------------------- 1 | #ifndef __GENETLINK_WRAPPER_H 2 | #define __GENETLINK_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #ifdef CONFIG_PROVE_LOCKING 7 | /* No version of the kernel has this function, but our locking scheme depends 8 | * on genl_mutex so for clarity we use it where appropriate. */ 9 | static inline int lockdep_genl_is_held(void) 10 | { 11 | return 1; 12 | } 13 | #endif 14 | 15 | #endif /* linux/genetlink.h wrapper */ 16 | -------------------------------------------------------------------------------- /datapath/linux/compat/kmemdup.c: -------------------------------------------------------------------------------- 1 | #ifndef HAVE_KMEMDUP 2 | 3 | #include 4 | #include 5 | 6 | /** 7 | * kmemdup - duplicate region of memory 8 | * 9 | * @src: memory region to duplicate 10 | * @len: memory region length 11 | * @gfp: GFP mask to use 12 | */ 13 | void *kmemdup(const void *src, size_t len, gfp_t gfp) 14 | { 15 | void *p; 16 | 17 | p = kmalloc(len, gfp); 18 | if (p) 19 | memcpy(p, src, len); 20 | return p; 21 | } 22 | #endif 23 | -------------------------------------------------------------------------------- /debian/.gitignore: -------------------------------------------------------------------------------- 1 | *.debhelper 2 | *.debhelper.log 3 | *.substvars 4 | /control 5 | /copyright 6 | /files 7 | /nicira-switch 8 | /openvswitch 9 | /openvswitch-brcompat 10 | /openvswitch-common 11 | /openvswitch-common.copyright 12 | /openvswitch-controller 13 | /openvswitch-datapath-source 14 | /openvswitch-datapath-dkms 15 | /openvswitch-dbg 16 | /openvswitch-ipsec 17 | /openvswitch-pki 18 | /openvswitch-switch 19 | /openvswitch-switch.copyright 20 | /ovsdbmonitor 21 | /python-openvswitch 22 | /tmp 23 | -------------------------------------------------------------------------------- /datapath/linux/compat/genetlink-brcompat.c: -------------------------------------------------------------------------------- 1 | /* We fix grp->id to 32 so that it doesn't collide with any of the multicast 2 | * groups selected by openvswitch_mod, which uses groups 16 through 31. 3 | * Collision isn't fatal--multicast listeners should check that the family is 4 | * the one that they want and discard others--but it wastes time and memory to 5 | * receive unwanted messages. */ 6 | 7 | #define GENL_FIRST_MCGROUP 32 8 | #define GENL_LAST_MCGROUP 32 9 | 10 | #include "genetlink.inc" 11 | -------------------------------------------------------------------------------- /ovsdb/remote-active.man: -------------------------------------------------------------------------------- 1 | .IP "\fBssl:\fIip\fB:\fIport\fR" 2 | The specified SSL \fIport\fR on the host at the given \fIip\fR, which 3 | must be expressed as an IP address (not a DNS name). The 4 | \fB\-\-private\-key\fR, \fB\-\-certificate\fR, and \fB\-\-ca\-cert\fR 5 | options are mandatory when this form is used. 6 | . 7 | .IP "\fBtcp:\fIip\fB:\fIport\fR" 8 | Connect to the given TCP \fIport\fR on \fIip\fR. 9 | . 10 | .IP "\fBunix:\fIfile\fR" 11 | Connect to the Unix domain server socket named \fIfile\fR. 12 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/tcp.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_TCP_WRAPPER_H 2 | #define __LINUX_TCP_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #ifndef HAVE_SKBUFF_HEADER_HELPERS 7 | static inline struct tcphdr *tcp_hdr(const struct sk_buff *skb) 8 | { 9 | return (struct tcphdr *)skb_transport_header(skb); 10 | } 11 | 12 | static inline unsigned int tcp_hdrlen(const struct sk_buff *skb) 13 | { 14 | return tcp_hdr(skb)->doff * 4; 15 | } 16 | #endif /* !HAVE_SKBUFF_HEADER_HELPERS */ 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /tests/ovsdb-column.at: -------------------------------------------------------------------------------- 1 | AT_BANNER([OVSDB -- columns]) 2 | 3 | OVSDB_CHECK_POSITIVE_CPY([ordinary column], 4 | [[parse-column mycol '{"type": "integer"}']], 5 | [[{"type":"integer"}]]) 6 | 7 | OVSDB_CHECK_POSITIVE_CPY([immutable column], 8 | [[parse-column mycol '{"type": "real", "mutable": false}']], 9 | [[{"mutable":false,"type":"real"}]]) 10 | 11 | OVSDB_CHECK_POSITIVE_CPY([ephemeral column], 12 | [[parse-column mycol '{"type": "uuid", "ephemeral": true}']], 13 | [[{"ephemeral":true,"type":"uuid"}]]) 14 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/asm-generic/bug.h: -------------------------------------------------------------------------------- 1 | #ifndef __ASM_GENERIC_BUG_WRAPPER_H 2 | #define __ASM_GENERIC_BUG_WRAPPER_H 3 | 4 | #include_next 5 | 6 | #ifndef WARN_ON_ONCE 7 | #define WARN_ON_ONCE(condition) ({ \ 8 | static int __warned; \ 9 | int __ret_warn_once = !!(condition); \ 10 | \ 11 | if (unlikely(__ret_warn_once) && !__warned) { \ 12 | WARN_ON(1); \ 13 | __warned = 1; \ 14 | } \ 15 | unlikely(__ret_warn_once); \ 16 | }) 17 | #endif 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/net/net_namespace.h: -------------------------------------------------------------------------------- 1 | #ifndef __NET_NET_NAMESPACE_WRAPPER_H 2 | #define __NET_NET_NAMESPACE_WRAPPER_H 1 3 | 4 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) 5 | /* exists, go ahead and include it. */ 6 | #include_next 7 | #endif 8 | 9 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32) 10 | #define INIT_NET_GENL_SOCK init_net.genl_sock 11 | #else 12 | #define INIT_NET_GENL_SOCK genl_sock 13 | #endif 14 | 15 | #endif /* net/net_namespace.h wrapper */ 16 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/ip.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_IP_WRAPPER_H 2 | #define __LINUX_IP_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #ifndef HAVE_SKBUFF_HEADER_HELPERS 7 | #include 8 | static inline struct iphdr *ip_hdr(const struct sk_buff *skb) 9 | { 10 | return (struct iphdr *)skb_network_header(skb); 11 | } 12 | 13 | static inline unsigned int ip_hdrlen(const struct sk_buff *skb) 14 | { 15 | return ip_hdr(skb)->ihl * 4; 16 | } 17 | #endif /* !HAVE_SKBUFF_HEADER_HELPERS */ 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /debian/openvswitch-switch.logrotate: -------------------------------------------------------------------------------- 1 | /var/log/openvswitch/*.log { 2 | daily 3 | compress 4 | create 640 root adm 5 | delaycompress 6 | missingok 7 | rotate 30 8 | postrotate 9 | # Tell Open vSwitch daemons to reopen their log files 10 | if [ -e /var/run/openvswitch/ovs-vswitchd.pid ]; then 11 | ovs-appctl --t ovs-vswitchd vlog/reopen 12 | fi 13 | if [ -e /var/run/openvswitch/ovsdb-server.pid ]; then 14 | ovs-appctl --t ovsdb-server vlog/reopen 15 | fi 16 | endscript 17 | } 18 | -------------------------------------------------------------------------------- /lib/dh1024.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN DH PARAMETERS----- 2 | MIGHAoGBAPSI/VhOSdvNILSd5JEHNmszbDgNRR0PfIizHHxbLY7288kjwEPwpVsY 3 | jY67VYy4XTjTNP18F1dDox0YbN4zISy1Kv884bEpQBgRjXyEpwpy1obEAxnIByl6 4 | ypUM2Zafq9AKUJsCRtMIPWakXUGfnHy9iUsiGSa6q6Jew1XpL3jHAgEC 5 | -----END DH PARAMETERS----- 6 | 7 | These are the 1024 bit DH parameters from "Assigned Number for SKIP Protocols" 8 | (http://www.skip-vpn.org/spec/numbers.html). 9 | See there for how they were generated. 10 | Note that g is not a generator, but this is not a problem since p is a safe prime. 11 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/rcupdate.h: -------------------------------------------------------------------------------- 1 | #ifndef __RCUPDATE_WRAPPER_H 2 | #define __RCUPDATE_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #ifndef rcu_dereference_check 7 | #define rcu_dereference_check(p, c) rcu_dereference(p) 8 | #endif 9 | 10 | #ifndef rcu_dereference_protected 11 | #define rcu_dereference_protected(p, c) (p) 12 | #endif 13 | 14 | #ifndef HAVE_RCU_READ_LOCK_HELD 15 | static inline int rcu_read_lock_held(void) 16 | { 17 | return 1; 18 | } 19 | #endif 20 | 21 | #endif /* linux/rcupdate.h wrapper */ 22 | -------------------------------------------------------------------------------- /lib/unixctl.man: -------------------------------------------------------------------------------- 1 | .IP "\fB\-\-unixctl=\fIsocket\fR" 2 | Sets the name of the control socket on which \fB\*(PN\fR listens for 3 | runtime management commands (see \fBRUNTIME MANAGEMENT COMMANDS\fR, 4 | below). If \fIsocket\fR does not begin with \fB/\fR, it is 5 | interpreted as relative to \fB@RUNDIR@\fR. If \fB\-\-unixctl\fR is 6 | not used at all, the default socket is 7 | \fB@RUNDIR@/\*(PN.\fIpid\fB.ctl\fR, where \fIpid\fR is \fB\*(PN\fR's 8 | process ID. 9 | Specifying \fBnone\fR for \fIsocket\fR disables the control socket 10 | feature. 11 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/if.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_IF_WRAPPER_H 2 | #define __LINUX_IF_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #include 7 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31) 8 | 9 | #define IFF_XMIT_DST_RELEASE 0 10 | 11 | #endif /* linux kernel < 2.6.31 */ 12 | 13 | #if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,36) 14 | #define IFF_OVS_DATAPATH IFF_BRIDGE_PORT 15 | #elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36) 16 | #define IFF_OVS_DATAPATH 0 /* no-op flag */ 17 | #endif 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/netfilter_ipv4.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_NETFILTER_IPV4_WRAPPER_H 2 | #define __LINUX_NETFILTER_IPV4_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #include 7 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) 8 | 9 | #ifdef __KERNEL__ 10 | 11 | #define NF_INET_PRE_ROUTING NF_IP_PRE_ROUTING 12 | #define NF_INET_POST_ROUTING NF_IP_POST_ROUTING 13 | #define NF_INET_FORWARD NF_IP_FORWARD 14 | 15 | #endif /* __KERNEL__ */ 16 | 17 | #endif /* linux kernel < 2.6.25 */ 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /debian/openvswitch-datapath-dkms.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | package=openvswitch-datapath-dkms 6 | name=openvswitch 7 | 8 | version=`dpkg-query -W -f='${Version}' "$package" \ 9 | |rev|cut -d- -f2-|rev|cut -d':' -f2|tr -d "\n"` 10 | 11 | isadded=`dkms status -m "$name" -v "$version"` 12 | 13 | if [ "x${isadded}" = "x" ] ; then 14 | dkms add -m "$name" -v "$version" 15 | fi 16 | 17 | if [ "$1" = 'configure' ] ; then 18 | dkms build -m "$name" -v "$version" && dkms install -m "$name" -v "$version" || true 19 | fi 20 | 21 | #DEBHELPER# 22 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | This file is included in compliance with the Apache 2.0 license, 2 | available at http://www.apache.org/licenses/LICENSE-2.0.html 3 | 4 | Open vSwitch 5 | Copyright (c) 2007, 2008, 2009 Nicira Networks. 6 | 7 | Apache Portable Runtime 8 | Copyright 2008 The Apache Software Foundation. 9 | 10 | This product includes software developed by 11 | The Apache Software Foundation (http://www.apache.org/). 12 | 13 | Portions of this software were developed at the National Center 14 | for Supercomputing Applications (NCSA) at the University of 15 | Illinois at Urbana-Champaign. 16 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/if_ether.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_IF_ETHER_WRAPPER_H 2 | #define __LINUX_IF_ETHER_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #include 7 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) 8 | 9 | #define ETH_P_TEB 0x6558 /* Trans Ether Bridging */ 10 | 11 | #endif /* linux kernel < 2.6.28 */ 12 | 13 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) 14 | 15 | #define ETH_P_FCOE 0x8906 /* Fibre Channel over Ethernet */ 16 | 17 | #endif /* linux kernel < 2.6.30 */ 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/net/route.h: -------------------------------------------------------------------------------- 1 | #ifndef __NET_ROUTE_WRAPPER_H 2 | #define __NET_ROUTE_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #include 7 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) 8 | 9 | #define ip_route_output_key(net, rp, flp) \ 10 | ip_route_output_key((rp), (flp)) 11 | 12 | #endif /* linux kernel < 2.6.25 */ 13 | 14 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38) 15 | static inline int ip4_dst_hoplimit(const struct dst_entry *dst) 16 | { 17 | return dst_metric(dst, RTAX_HOPLIMIT); 18 | } 19 | #endif 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /utilities/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /Makefile.in 3 | /nlmon 4 | /ovs-appctl 5 | /ovs-appctl.8 6 | /ovs-benchmark 7 | /ovs-benchmark.1 8 | /ovs-cfg-mod 9 | /ovs-cfg-mod.8 10 | /ovs-controller 11 | /ovs-controller.8 12 | /ovs-ctl 13 | /ovs-dpctl 14 | /ovs-dpctl.8 15 | /ovs-lib.sh 16 | /ovs-ofctl 17 | /ovs-ofctl.8 18 | /ovs-parse-leaks 19 | /ovs-pcap 20 | /ovs-pcap.1 21 | /ovs-pki 22 | /ovs-pki-cgi 23 | /ovs-pki.8 24 | /ovs-tcpundump 25 | /ovs-tcpundump.1 26 | /ovs-vlan-bug-workaround 27 | /ovs-vlan-bug-workaround.8 28 | /ovs-vlan-test 29 | /ovs-vlan-test.8 30 | /ovs-vsctl 31 | /ovs-vsctl.8 32 | -------------------------------------------------------------------------------- /lib/vconn-active.man: -------------------------------------------------------------------------------- 1 | .IP "\fBssl:\fIip\fR[\fB:\fIport\fR]" 2 | The specified SSL \fIport\fR (default: 6633) on the host at the given 3 | \fIip\fR, which must be expressed as an IP address (not a DNS name). 4 | The \fB\-\-private\-key\fR, \fB\-\-certificate\fR, and 5 | \fB\-\-ca\-cert\fR options are mandatory when this form is used. 6 | . 7 | .IP "\fBtcp:\fIip\fR[\fB:\fIport\fR]" 8 | The specified TCP \fIport\fR (default: 6633) on the host at the given 9 | \fIip\fR, which must be expressed as an IP address (not a DNS name). 10 | . 11 | .TP 12 | \fBunix:\fIfile\fR 13 | The Unix domain server socket named \fIfile\fR. 14 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/err.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_ERR_WRAPPER_H 2 | #define __LINUX_ERR_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #ifndef HAVE_ERR_CAST 7 | /** 8 | * ERR_CAST - Explicitly cast an error-valued pointer to another pointer type 9 | * @ptr: The pointer to cast. 10 | * 11 | * Explicitly cast an error-valued pointer to another pointer type in such a 12 | * way as to make it clear that's what's going on. 13 | */ 14 | static inline void *ERR_CAST(const void *ptr) 15 | { 16 | /* cast away the const */ 17 | return (void *) ptr; 18 | } 19 | #endif /* HAVE_ERR_CAST */ 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /datapath/vport-generic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Nicira Networks. 3 | * Distributed under the terms of the GNU GPL version 2. 4 | * 5 | * Significant portions of this file may be copied from parts of the Linux 6 | * kernel, by Linus Torvalds and others. 7 | */ 8 | 9 | #ifndef VPORT_GENERIC_H 10 | #define VPORT_GENERIC_H 1 11 | 12 | #include "vport.h" 13 | 14 | void vport_gen_rand_ether_addr(u8 *addr); 15 | unsigned vport_gen_get_dev_flags(const struct vport *); 16 | int vport_gen_is_running(const struct vport *); 17 | unsigned char vport_gen_get_operstate(const struct vport *); 18 | 19 | #endif /* vport-generic.h */ 20 | -------------------------------------------------------------------------------- /datapath/vport-internal_dev.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2010 Nicira Networks. 3 | * Distributed under the terms of the GNU GPL version 2. 4 | * 5 | * Significant portions of this file may be copied from parts of the Linux 6 | * kernel, by Linus Torvalds and others. 7 | */ 8 | 9 | #ifndef VPORT_INTERNAL_DEV_H 10 | #define VPORT_INTERNAL_DEV_H 1 11 | 12 | #include "datapath.h" 13 | #include "vport.h" 14 | 15 | int is_internal_vport(const struct vport *); 16 | 17 | int is_internal_dev(const struct net_device *); 18 | struct vport *internal_dev_get_vport(struct net_device *); 19 | 20 | #endif /* vport-internal_dev.h */ 21 | -------------------------------------------------------------------------------- /ovsdb/ovsdbmonitor/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010 Citrix Systems, Inc. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at: 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /lib/dh2048.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN DH PARAMETERS----- 2 | MIIBCAKCAQEA9kJXtwh/CBdyorrWqULzBej5UxE5T7bxbrlLOCDaAadWoxTpj0BV 3 | 89AHxstDqZSt90xkhkn4DIO9ZekX1KHTUPj1WV/cdlJPPT2N286Z4VeSWc39uK50 4 | T8X8dryDxUcwYc58yWb/Ffm7/ZFexwGq01uejaClcjrUGvC/RgBYK+X0iP1YTknb 5 | zSC0neSRBzZrM2w4DUUdD3yIsxx8Wy2O9vPJI8BD8KVbGI2Ou1WMuF040zT9fBdX 6 | Q6MdGGzeMyEstSr/POGxKUAYEY18hKcKctaGxAMZyAcpesqVDNmWn6vQClCbAkbT 7 | CD1mpF1Bn5x8vYlLIhkmuquiXsNV6TILOwIBAg== 8 | -----END DH PARAMETERS----- 9 | 10 | These are the 2048 bit DH parameters from "Assigned Number for SKIP Protocols" 11 | (http://www.skip-vpn.org/spec/numbers.html). 12 | See there for how they were generated. 13 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/netfilter_bridge.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_NETFILTER_BRIDGE_WRAPPER_H 2 | #define __LINUX_NETFILTER_BRIDGE_WRAPPER_H 3 | 4 | #include_next 5 | 6 | #include 7 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) 8 | 9 | #include 10 | #include 11 | 12 | static inline unsigned int nf_bridge_encap_header_len(const struct sk_buff *skb) 13 | { 14 | switch (skb->protocol) { 15 | case __constant_htons(ETH_P_8021Q): 16 | return VLAN_HLEN; 17 | default: 18 | return 0; 19 | } 20 | } 21 | 22 | #endif /* linux version < 2.6.22 */ 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /debian/openvswitch-datapath-module-_KVERS_.postinst.modules.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # postinst script for #PACKAGE# 3 | # 4 | # see: dh_installdeb(1) 5 | 6 | set -e 7 | 8 | #DEBHELPER# 9 | 10 | # If the switch is running, restart it. This ensures that we are using the 11 | # latest kernel module, because the init script will unload and reload the 12 | # module. 13 | # 14 | # (Ideally we'd only want to do this if this package corresponds to the 15 | # running kernel, but I don't know a reliable way to check.) 16 | INIT=/etc/init.d/openvswitch-switch 17 | if test -x $INIT && $INIT status; then 18 | $INIT restart || true 19 | fi 20 | 21 | exit 0 22 | 23 | 24 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/bottom_half.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_BH_WRAPPER_H 2 | #define __LINUX_BH_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | /* This is not, strictly speaking, compatibility code in the sense that it is 7 | * not needed by older kernels. However, it is used on kernels with the 8 | * realtime patchset applied to create an environment more similar to what we 9 | * would see on normal kernels. 10 | */ 11 | 12 | #ifdef CONFIG_PREEMPT_HARDIRQS 13 | #undef local_bh_disable 14 | #define local_bh_disable preempt_disable 15 | #undef local_bh_enable 16 | #define local_bh_enable preempt_enable 17 | #endif 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/rculist.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_RCULIST_WRAPPER_H 2 | #define __LINUX_RCULIST_WRAPPER_H 3 | 4 | #include 5 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26) 6 | #include_next 7 | #else 8 | /* Prior to 2.6.26, the contents of rculist.h were part of list.h. */ 9 | #include 10 | #endif 11 | 12 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) 13 | #define hlist_del_init_rcu rpl_hlist_del_init_rcu 14 | static inline void hlist_del_init_rcu(struct hlist_node *n) 15 | { 16 | if (!hlist_unhashed(n)) { 17 | __hlist_del(n); 18 | n->pprev = NULL; 19 | } 20 | } 21 | #endif 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /lib/leak-checker.man: -------------------------------------------------------------------------------- 1 | .TP 2 | \fB\-\-check\-leaks=\fIfile\fR 3 | . 4 | Logs information about memory allocation and deallocation to 5 | \fIfile\fR, to allow for debugging memory leaks in \fB\*(PN\fR. This 6 | option slows down \fB\*(PN\fR considerably, so it should only be used 7 | when a memory leak is suspected. Use the \fBovs\-parse\-leaks\fR script 8 | to interpret the leak file. 9 | .TP 10 | \fB\-\-leak\-limit=\fIsize\fR 11 | . 12 | Limits size of the leak file as specified by \fB\-\-check\-leaks\fR to 13 | \fIsize\fR bytes. Finding leaks sometimes requires allowing the leak 14 | file to grow very large, up to 1GB. By default, files are limited 15 | to 10MB. 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #*# 2 | *.a 3 | *.d 4 | *.ko 5 | *.la 6 | *.lo 7 | *.loT 8 | *.mod.c 9 | *.o 10 | *.o 11 | *.pyc 12 | *.so 13 | *~ 14 | .#* 15 | .*.cmd 16 | .*.swp 17 | .deps 18 | .dirstamp 19 | .libs 20 | .tmp_versions 21 | /Makefile 22 | /Makefile.in 23 | /aclocal.m4 24 | /all-distfiles 25 | /all-gitfiles 26 | /autom4te.cache 27 | /build-arch-stamp 28 | /build-indep-stamp 29 | /compile 30 | /config.guess 31 | /config.h 32 | /config.h.in 33 | /config.log 34 | /config.status 35 | /config.sub 36 | /configure 37 | /configure-stamp 38 | /depcomp 39 | /distfiles 40 | /install-sh 41 | /manpage-check 42 | /missing 43 | /missing-distfiles 44 | /package.m4 45 | /stamp-h1 46 | Module.symvers 47 | TAGS 48 | cscope.* 49 | tags 50 | -------------------------------------------------------------------------------- /ovsdb/ovsdbmonitor/ovsdbmonitor.1: -------------------------------------------------------------------------------- 1 | .\" -*- nroff -*- 2 | .TH ovsdbmonitor 1 "May 2011" "Open vSwitch" "Open vSwitch Manual" 3 | . 4 | .SH NAME 5 | ovsdbmonitor \- GUI tool for monitoring Open vSwitch installations 6 | . 7 | .SH SYNOPSIS 8 | \fBovsdbmonitor\fR 9 | . 10 | .SH DESCRIPTION 11 | The \fBovsdbmonitor\fR program is a Qt-based GUI tool for monitoring 12 | and troubleshooting Open vSwitch. It presents GUI tables that 13 | graphically represent an Open vSwitch kernel flow table (similar to 14 | \fBovs\-dpctl dump\-flows\fR) and Open vSwitch database contents 15 | (similar to \fBovs\-vsctl list \fItable\fR). 16 | .SH "SEE ALSO" 17 | . 18 | \fBovsdb\-server\fR(1), 19 | \fBovsdb\-client\fR(1), 20 | and the OVSDB specification. 21 | -------------------------------------------------------------------------------- /datapath/dp_sysfs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2010 Nicira Networks. 3 | * Distributed under the terms of the GNU GPL version 2. 4 | * 5 | * Significant portions of this file may be copied from parts of the Linux 6 | * kernel, by Linus Torvalds and others. 7 | */ 8 | 9 | #ifndef DP_SYSFS_H 10 | #define DP_SYSFS_H 1 11 | 12 | struct datapath; 13 | struct vport; 14 | 15 | /* dp_sysfs_dp.c */ 16 | int dp_sysfs_add_dp(struct datapath *dp); 17 | int dp_sysfs_del_dp(struct datapath *dp); 18 | 19 | /* dp_sysfs_if.c */ 20 | int dp_sysfs_add_if(struct vport *p); 21 | int dp_sysfs_del_if(struct vport *p); 22 | 23 | #ifdef CONFIG_SYSFS 24 | extern struct sysfs_ops brport_sysfs_ops; 25 | #endif 26 | 27 | #endif /* dp_sysfs.h */ 28 | 29 | -------------------------------------------------------------------------------- /datapath/actions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2010, 2011 Nicira Networks. 3 | * Distributed under the terms of the GNU GPL version 2. 4 | * 5 | * Significant portions of this file may be copied from parts of the Linux 6 | * kernel, by Linus Torvalds and others. 7 | */ 8 | 9 | #ifndef ACTIONS_H 10 | #define ACTIONS_H 1 11 | 12 | #include 13 | #include 14 | 15 | struct datapath; 16 | struct sk_buff; 17 | struct sw_flow_key; 18 | 19 | int execute_actions(struct datapath *dp, struct sk_buff *skb); 20 | 21 | static inline void skb_clear_rxhash(struct sk_buff *skb) 22 | { 23 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35) 24 | skb->rxhash = 0; 25 | #endif 26 | } 27 | 28 | #endif /* actions.h */ 29 | -------------------------------------------------------------------------------- /utilities/ovs-pcap.1.in: -------------------------------------------------------------------------------- 1 | .TH ovs\-pcap 1 "December 2010" "Open vSwitch" "Open vSwitch Manual" 2 | . 3 | .SH NAME 4 | ovs\-pcap \- print packets from a pcap file as hex 5 | . 6 | .SH SYNOPSIS 7 | \fBovs\-pcap\fR \fIfile\fR 8 | .so lib/common-syn.man 9 | . 10 | .SH DESCRIPTION 11 | The \fBovs\-pcap\fR program reads the pcap \fIfile\fR named on the 12 | command line and prints each packet's contents as a sequence of hex 13 | digits on a line of its own. This format is suitable for use with the 14 | \fBofproto/trace\fR command supported by \fBovs\-vswitchd\fR(8). 15 | . 16 | .SH "OPTIONS" 17 | .so lib/common.man 18 | . 19 | .SH "SEE ALSO" 20 | . 21 | .BR ovs\-vswitchd (8), 22 | .BR ovs\-tcpundump (1), 23 | .BR tcpdump (8), 24 | .BR wireshark (8). 25 | -------------------------------------------------------------------------------- /tests/.gitignore: -------------------------------------------------------------------------------- 1 | *.pem 2 | /Makefile 3 | /Makefile.in 4 | /atconfig 5 | /atlocal 6 | /idltest.c 7 | /idltest.h 8 | /idltest.ovsidl 9 | /ovs-pki.log 10 | /pki/ 11 | /test-aes128 12 | /test-bundle 13 | /test-byte-order 14 | /test-classifier 15 | /test-csum 16 | /test-file_name 17 | /test-flows 18 | /test-hash 19 | /test-hmap 20 | /test-json 21 | /test-jsonrpc 22 | /test-list 23 | /test-lockfile 24 | /test-multipath 25 | /test-odp 26 | /test-openflowd 27 | /test-openflowd.8 28 | /test-ovsdb 29 | /test-packets 30 | /test-random 31 | /test-reconnect 32 | /test-strtok_r 33 | /test-timeval 34 | /test-sha1 35 | /test-type-props 36 | /test-unix-socket 37 | /test-util 38 | /test-uuid 39 | /test-vconn 40 | /testsuite 41 | /testsuite.dir/ 42 | /testsuite.log 43 | -------------------------------------------------------------------------------- /rhel/etc_logrotate.d_openvswitch: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2009, 2010, 2011 Nicira Networks, Inc. 2 | # 3 | # Copying and distribution of this file, with or without modification, 4 | # are permitted in any medium without royalty provided the copyright 5 | # notice and this notice are preserved. This file is offered as-is, 6 | # without warranty of any kind. 7 | 8 | /var/log/openvswitch/*.log { 9 | sharedscripts 10 | missingok 11 | postrotate 12 | # Tell Open vSwitch daemons to reopen their log files 13 | if [ -e /var/run/openvswitch/ovs-vswitchd.pid ]; then 14 | /usr/bin/ovs-appctl -t ovs-vswitchd vlog/reopen 15 | fi 16 | if [ -e /var/run/openvswitch/ovsdb-server.pid ]; then 17 | /usr/bin/ovs-appctl -t ovsdb-server vlog/reopen 18 | fi 19 | endscript 20 | } 21 | -------------------------------------------------------------------------------- /xenserver/etc_logrotate.d_openvswitch: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2009, 2010, 2011 Nicira Networks, Inc. 2 | # 3 | # Copying and distribution of this file, with or without modification, 4 | # are permitted in any medium without royalty provided the copyright 5 | # notice and this notice are preserved. This file is offered as-is, 6 | # without warranty of any kind. 7 | 8 | /var/log/openvswitch/*.log { 9 | sharedscripts 10 | missingok 11 | postrotate 12 | # Tell Open vSwitch daemons to reopen their log files 13 | if [ -e /var/run/openvswitch/ovs-vswitchd.pid ]; then 14 | /usr/bin/ovs-appctl -t ovs-vswitchd vlog/reopen 15 | fi 16 | if [ -e /var/run/openvswitch/ovsdb-server.pid ]; then 17 | /usr/bin/ovs-appctl -t ovsdb-server vlog/reopen 18 | fi 19 | endscript 20 | } 21 | -------------------------------------------------------------------------------- /tests/vconn.at: -------------------------------------------------------------------------------- 1 | m4_define([TEST_VCONN_CLASS], 2 | [AT_BANNER([vconn library -- $1 class]) 3 | m4_foreach( 4 | [testname], 5 | [[refuse-connection], 6 | [accept-then-close], 7 | [read-hello], 8 | [send-plain-hello], 9 | [send-long-hello], 10 | [send-echo-hello], 11 | [send-short-hello], 12 | [send-invalid-version-hello]], 13 | [AT_SETUP([$1 vconn - m4_bpatsubst(testname, [-], [ ])]) 14 | m4_if([$1], [ssl], [ 15 | AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) 16 | AT_CHECK([cp $abs_top_builddir/tests/testpki*.pem .])]) 17 | AT_CHECK([test-vconn testname $1], [0], [], [ignore]) 18 | AT_CLEANUP])]) 19 | 20 | TEST_VCONN_CLASS([unix]) 21 | TEST_VCONN_CLASS([tcp]) 22 | TEST_VCONN_CLASS([ssl]) 23 | -------------------------------------------------------------------------------- /debian/openvswitch-switch.README.Debian: -------------------------------------------------------------------------------- 1 | README.Debian for openvswitch-switch 2 | --------------------------------- 3 | 4 | * The switch must be configured before it can be used. Edit 5 | /etc/default/openvswitch-switch, then start the switch manually with 6 | "/etc/init.d/openvswitch-switch start". 7 | 8 | * To use the Linux kernel-based switch implementation, you will need 9 | to build and install the Open vSwitch kernel module. To do so, install 10 | the openvswitch-datapath-source package, then follow the instructions 11 | given in /usr/share/doc/openvswitch-datapath-source/README.Debian 12 | 13 | * This package does not yet support the userspace datapath-based 14 | switch implementation. 15 | 16 | -- Ben Pfaff , Mon, 30 Aug 2010 09:51:19 -0700 17 | -------------------------------------------------------------------------------- /datapath/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = 2 | if LINUX_ENABLED 3 | SUBDIRS += linux 4 | endif 5 | 6 | EXTRA_DIST = $(dist_headers) $(dist_sources) $(dist_extras) 7 | 8 | # Suppress warnings about GNU extensions in Modules.mk files. 9 | AUTOMAKE_OPTIONS = -Wno-portability 10 | 11 | include Modules.mk 12 | include linux/Modules.mk 13 | 14 | # The following is based on commands for the Automake "distdir" target. 15 | distfiles: Makefile 16 | @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 17 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 18 | list='$(DISTFILES)'; \ 19 | for file in $$list; do echo $$file; done | \ 20 | sed -e "s|^$$srcdirstrip/||;t" \ 21 | -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t" | sort -u > $@ 22 | CLEANFILES = distfiles 23 | -------------------------------------------------------------------------------- /datapath/linux/.gitignore: -------------------------------------------------------------------------------- 1 | /Kbuild 2 | /Makefile 3 | /Makefile.main 4 | /Module.markers 5 | /actions.c 6 | /addrconf_core-openvswitch.c 7 | /brc_sysfs_dp.c 8 | /brc_sysfs_if.c 9 | /brcompat.c 10 | /checksum.c 11 | /dev-openvswitch.c 12 | /dp_sysfs_dp.c 13 | /dp_sysfs_if.c 14 | /datapath.c 15 | /dp_dev.c 16 | /dp_notify.c 17 | /flex_array.c 18 | /flow.c 19 | /genetlink-brcompat.c 20 | /genetlink-openvswitch.c 21 | /ip_output-openvswitch.c 22 | /kcompat.h 23 | /kmemdup.c 24 | /loop_counter.c 25 | /modules.order 26 | /netdevice.c 27 | /random32.c 28 | /reciprocal_div.c 29 | /skbuff-openvswitch.c 30 | /table.c 31 | /time.c 32 | /tmp 33 | /tunnel.c 34 | /vlan.c 35 | /vport-capwap.c 36 | /vport-generic.c 37 | /vport-gre.c 38 | /vport-internal_dev.c 39 | /vport-netdev.c 40 | /vport-patch.c 41 | /vport.c 42 | -------------------------------------------------------------------------------- /lib/ssl-peer-ca-cert.man: -------------------------------------------------------------------------------- 1 | .IP "\fB\-\-peer\-ca\-cert=\fIpeer-cacert.pem\fR" 2 | Specifies a PEM file that contains one or more additional certificates 3 | to send to SSL peers. \fIpeer-cacert.pem\fR should be the CA 4 | certificate used to sign \fB\*(PN\fR's own certificate, that is, the 5 | certificate specified on \fB\-c\fR or \fB\-\-certificate\fR. If 6 | \fB\*(PN\fR's certificate is self-signed, then \fB\-\-certificate\fR 7 | and \fB\-\-peer\-ca\-cert\fR should specify the same file. 8 | .IP 9 | This option is not useful in normal operation, because the SSL peer 10 | must already have the CA certificate for the peer to have any 11 | confidence in \fB\*(PN\fR's identity. However, this offers a way for 12 | a new installation to bootstrap the CA certificate on its first SSL 13 | connection. 14 | -------------------------------------------------------------------------------- /ovsdb/remote-passive.man: -------------------------------------------------------------------------------- 1 | .IP "\fBpssl:\fIport\fR[\fB:\fIip\fR]" 2 | Listen on the given SSL \fIport\fR for a connection. By default, 3 | \fB\*(PN\fR listens for connections to any local IP address, but 4 | specifying \fIip\fR limits connections to those from the given 5 | \fIip\fR. The \fB\-\-private\-key\fR, \fB\-\-certificate\fR, and 6 | \fB\-\-ca\-cert\fR options are mandatory when this form is used. 7 | . 8 | .IP "\fBptcp:\fIport\fR[\fB:\fIip\fR]" 9 | Listen on the given TCP \fIport\fR for a connection. By default, 10 | \fB\*(PN\fR listens for connections to any local IP address, but 11 | \fIip\fR may be specified to listen only for connections to the given 12 | \fIip\fR. 13 | . 14 | .IP "\fBpunix:\fIfile\fR" 15 | Listen on the Unix domain server socket named \fIfile\fR for a 16 | connection. 17 | -------------------------------------------------------------------------------- /README-gcov: -------------------------------------------------------------------------------- 1 | Building with gcov support 2 | ========================== 3 | 4 | The Open vSwitch "configure" script supports the following 5 | code-coverage related options: 6 | 7 | --disable-coverage 8 | --enable-coverage=no 9 | 10 | Do not build with gcov code coverage support. 11 | 12 | This is the default if no coverage option is passed to 13 | "configure". 14 | 15 | --enable-coverage 16 | --enable-coverage=yes 17 | 18 | Build with gcov code coverage support. 19 | 20 | If you enable coverage and you have the "lcov" and "genhtml" 21 | programs in PATH, then you may run "make check-lcov" to produce a 22 | directory "tests/coverage.html" in the build directory with an 23 | analysis of the test suite's coverage. lcov is available at 24 | http://ltp.sourceforge.net/coverage/lcov.php 25 | -------------------------------------------------------------------------------- /tests/lockfile.at: -------------------------------------------------------------------------------- 1 | AT_BANNER([lockfile unit tests]) 2 | 3 | m4_define([CHECK_LOCKFILE], 4 | [AT_SETUP([m4_translit([$1], [_], [ ])]) 5 | AT_KEYWORDS([lockfile]) 6 | AT_CHECK([test-lockfile $1], [0], [$1: success (m4_if( 7 | [$2], [1], [$2 child], [$2 children])) 8 | ]) 9 | AT_CLEANUP]) 10 | 11 | CHECK_LOCKFILE([lock_and_unlock], [0]) 12 | CHECK_LOCKFILE([lock_and_unlock_twice], [0]) 13 | CHECK_LOCKFILE([lock_blocks_same_process], [0]) 14 | CHECK_LOCKFILE([lock_blocks_same_process_twice], [0]) 15 | CHECK_LOCKFILE([lock_blocks_other_process], [1]) 16 | CHECK_LOCKFILE([lock_twice_blocks_other_process], [1]) 17 | CHECK_LOCKFILE([lock_and_unlock_allows_other_process], [1]) 18 | CHECK_LOCKFILE([lock_timeout_gets_the_lock], [1]) 19 | CHECK_LOCKFILE([lock_timeout_runs_out], [1]) 20 | CHECK_LOCKFILE([lock_multiple], [0]) 21 | -------------------------------------------------------------------------------- /vswitchd/xenserver.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009 Nicira Networks 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #ifndef VSWITCHD_XENSERVER_H 17 | #define VSWITCHD_XENSERVER_H 1 18 | 19 | const char *xenserver_get_host_uuid(void); 20 | 21 | #endif /* xenserver.h */ 22 | -------------------------------------------------------------------------------- /include/sparse/arpa/inet.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CHECKER__ 18 | #error "Use this header only with sparse. It is not a correct implementation." 19 | #endif 20 | 21 | #include 22 | -------------------------------------------------------------------------------- /vswitchd/system-stats.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010 Nicira Networks 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #ifndef VSWITCHD_SYSTEM_STATS 17 | #define VSWITCHD_SYSTEM_STATS 1 18 | 19 | void get_system_stats(struct shash *); 20 | 21 | #endif /* vswitchd/system-stats.h */ 22 | -------------------------------------------------------------------------------- /lib/vconn-passive.man: -------------------------------------------------------------------------------- 1 | .IP "\fBpssl:\fR[\fIport\fR][\fB:\fIip\fR]" 2 | Listens for OpenFlow SSL connections on \fIport\fR (default: 6633). 3 | The \fB\-\-private\-key\fR, \fB\-\-certificate\fR, and 4 | \fB\-\-ca\-cert\fR options are mandatory when this form is used. By 5 | default, \fB\*(PN\fR listens for connections to any local IP address, 6 | but \fIip\fR may be specified to listen only for connections to the 7 | given \fIip\fR. 8 | . 9 | .IP "\fBptcp:\fR[\fIport\fR][\fB:\fIip\fR]" 10 | Listens for OpenFlow TCP connections on \fIport\fR (default: 6633). 11 | By default, \fB\*(PN\fR listens for connections to any local IP 12 | address, but \fIip\fR may be specified to listen only for connections 13 | to the given \fIip\fR. 14 | . 15 | .IP "\fBpunix:\fIfile\fR" 16 | Listens for OpenFlow connections on the Unix domain server socket 17 | named \fIfile\fR. 18 | -------------------------------------------------------------------------------- /debian/control.modules.in: -------------------------------------------------------------------------------- 1 | Source: openvswitch 2 | Section: net 3 | Priority: extra 4 | Maintainer: Open vSwitch developers 5 | Build-Depends: debhelper (>= 5.0.37) 6 | Standards-Version: 3.7.3 7 | 8 | Package: openvswitch-datapath-module-_KVERS_ 9 | Architecture: any 10 | Recommends: kernel-image-_KVERS_, openvswitch-switch 11 | Provides: openvswitch-datapath-module 12 | Description: Open vSwitch Linux datapath kernel module 13 | This package contains the Open vSwitch loadable datapath kernel modules for 14 | the kernel-image-_KVERS_ package. 15 | . 16 | If you compiled a custom kernel, you will most likely need to compile 17 | a custom version of this module as well. The 18 | openvswitch-datapath-source package has been provided for this 19 | purpose. Refer to README.Debian provided in that package for further 20 | instructions. 21 | -------------------------------------------------------------------------------- /rhel/usr_share_openvswitch_scripts_sysconfig.template: -------------------------------------------------------------------------------- 1 | ### Configuration options for openvswitch 2 | 3 | # Copyright (C) 2009, 2010, 2011 Nicira Networks, Inc. 4 | 5 | # FORCE_COREFILES: If 'yes' then core files will be enabled. 6 | # FORCE_COREFILES=yes 7 | 8 | # OVSDB_SERVER_PRIORITY: "nice" priority at which to run ovsdb-server. 9 | # 10 | # OVSDB_SERVER_PRIORITY=-10 11 | 12 | # VSWITCHD_PRIORITY: "nice" priority at which to run ovs-vswitchd. 13 | # VSWITCHD_PRIORITY=-10 14 | 15 | # VSWITCHD_MLOCKALL: Whether to pass ovs-vswitchd the --mlockall option. 16 | # This option should be set to "yes" or "no". The default is "yes". 17 | # Enabling this option can avoid networking interruptions due to 18 | # system memory pressure in extraordinary situations, such as multiple 19 | # concurrent VM import operations. 20 | # VSWITCHD_MLOCKALL=yes 21 | -------------------------------------------------------------------------------- /tests/timeval.at: -------------------------------------------------------------------------------- 1 | AT_BANNER([timeval unit tests]) 2 | 3 | AT_SETUP([check that time advances]) 4 | AT_KEYWORDS([timeval]) 5 | AT_CHECK([test-timeval plain], [0]) 6 | AT_CLEANUP 7 | 8 | AT_SETUP([check that time advances after daemonize()]) 9 | AT_KEYWORDS([timeval]) 10 | AT_CHECK([test-timeval daemon], [0]) 11 | AT_CHECK( 12 | [# First try a quick sleep, so that the test completes very quickly 13 | # in the normal case. POSIX doesn't require fractional times to 14 | # work, so this might not work. 15 | sleep 0.1; if test -e test-timeval.success; then echo success; exit 0; fi 16 | # Then wait up to 2 seconds. 17 | sleep 1; if test -e test-timeval.success; then echo success; exit 0; fi 18 | sleep 1; if test -e test-timeval.success; then echo success; exit 0; fi 19 | echo failure; exit 1], 20 | [0], [success 21 | ], []) 22 | AT_CLEANUP 23 | -------------------------------------------------------------------------------- /xenserver/usr_share_openvswitch_scripts_sysconfig.template: -------------------------------------------------------------------------------- 1 | ### Configuration options for openvswitch 2 | 3 | # Copyright (C) 2009, 2010, 2011 Nicira Networks, Inc. 4 | 5 | # FORCE_COREFILES: If 'yes' then core files will be enabled. 6 | # FORCE_COREFILES=yes 7 | 8 | # OVSDB_SERVER_PRIORITY: "nice" priority at which to run ovsdb-server. 9 | # 10 | # OVSDB_SERVER_PRIORITY=-10 11 | 12 | # VSWITCHD_PRIORITY: "nice" priority at which to run ovs-vswitchd. 13 | # VSWITCHD_PRIORITY=-10 14 | 15 | # VSWITCHD_MLOCKALL: Whether to pass ovs-vswitchd the --mlockall option. 16 | # This option should be set to "yes" or "no". The default is "yes". 17 | # Enabling this option can avoid networking interruptions due to 18 | # system memory pressure in extraordinary situations, such as multiple 19 | # concurrent VM import operations. 20 | # VSWITCHD_MLOCKALL=yes 21 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/slab.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_SLAB_WRAPPER_H 2 | #define __LINUX_SLAB_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #ifndef HAVE_KMEMDUP 7 | extern void *kmemdup(const void *src, size_t len, gfp_t gfp); 8 | #endif 9 | 10 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23) 11 | #define kmem_cache_create(n, s, a, f, c) kmem_cache_create(n, s, a, f, c, NULL) 12 | #endif 13 | 14 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23) 15 | static inline void *rpl_kzalloc(size_t size, gfp_t flags) 16 | { 17 | return kzalloc(size, flags & ~__GFP_ZERO); 18 | } 19 | #define kzalloc rpl_kzalloc 20 | 21 | static inline void *rpl_kmalloc(size_t size, gfp_t flags) 22 | { 23 | if (flags & __GFP_ZERO) 24 | return kzalloc(size, flags); 25 | 26 | return kmalloc(size, flags); 27 | } 28 | #define kmalloc rpl_kmalloc 29 | #endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /lib/entropy.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010 Nicira Networks 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #ifndef ENTROPY_H 17 | #define ENTROPY_H 1 18 | 19 | #include 20 | 21 | int get_entropy(void *, size_t); 22 | void get_entropy_or_die(void *, size_t); 23 | 24 | #endif /* entropy.h */ 25 | -------------------------------------------------------------------------------- /lib/dhparams.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef DHPARAMS_H 18 | #define DHPARAMS_H 1 19 | 20 | #include 21 | 22 | DH *get_dh1024(void); 23 | DH *get_dh2048(void); 24 | DH *get_dh4096(void); 25 | 26 | #endif /* dhparams.h */ 27 | -------------------------------------------------------------------------------- /datapath/linux/compat/ip_output-openvswitch.c: -------------------------------------------------------------------------------- 1 | #include 2 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) 3 | 4 | #include 5 | #include 6 | 7 | int __ip_local_out(struct sk_buff *skb) 8 | { 9 | struct iphdr *iph = ip_hdr(skb); 10 | 11 | iph->tot_len = htons(skb->len); 12 | ip_send_check(iph); 13 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) 14 | return nf_hook(PF_INET, NF_IP_LOCAL_OUT, &skb, NULL, skb->dst->dev, 15 | dst_output); 16 | #else 17 | return nf_hook(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, skb->dst->dev, 18 | dst_output); 19 | #endif /* kernel < 2.6.24 */ 20 | } 21 | 22 | int ip_local_out(struct sk_buff *skb) 23 | { 24 | int err; 25 | 26 | err = __ip_local_out(skb); 27 | if (likely(err == 1)) 28 | err = dst_output(skb); 29 | 30 | return err; 31 | } 32 | 33 | #endif /* kernel < 2.6.25 */ 34 | -------------------------------------------------------------------------------- /datapath/loop_counter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, 2011 Nicira Networks. 3 | * Distributed under the terms of the GNU GPL version 2. 4 | * 5 | * Significant portions of this file may be copied from parts of the Linux 6 | * kernel, by Linus Torvalds and others. 7 | */ 8 | 9 | #ifndef LOOP_COUNTER_H 10 | #define LOOP_COUNTER_H 1 11 | 12 | #include "datapath.h" 13 | #include "flow.h" 14 | 15 | /* We limit the number of times that we pass into dp_process_received_packet() 16 | * to avoid blowing out the stack in the event that we have a loop. */ 17 | #define MAX_LOOPS 5 18 | 19 | struct loop_counter { 20 | u8 count; /* Count. */ 21 | bool looping; /* Loop detected? */ 22 | }; 23 | 24 | struct loop_counter *loop_get_counter(void); 25 | void loop_put_counter(void); 26 | int loop_suppress(struct datapath *, struct sw_flow_actions *); 27 | 28 | #endif /* loop_counter.h */ 29 | -------------------------------------------------------------------------------- /include/openflow/automake.mk: -------------------------------------------------------------------------------- 1 | noinst_HEADERS += \ 2 | include/openflow/nicira-ext.h \ 3 | include/openflow/openflow.h 4 | 5 | if HAVE_PYTHON 6 | ALL_LOCAL += include/openflow/openflow.h.stamp 7 | include/openflow/openflow.h.stamp: \ 8 | include/openflow/openflow.h build-aux/check-structs 9 | $(PYTHON) $(srcdir)/build-aux/check-structs $(srcdir)/include/openflow/openflow.h 10 | touch $@ 11 | DISTCLEANFILES += include/openflow/openflow.h.stamp 12 | 13 | ALL_LOCAL += include/openflow/nicira-ext.h.stamp 14 | include/openflow/nicira-ext.h.stamp: include/openflow/openflow.h include/openflow/nicira-ext.h build-aux/check-structs 15 | $(PYTHON) $(srcdir)/build-aux/check-structs $(srcdir)/include/openflow/openflow.h $(srcdir)/include/openflow/nicira-ext.h 16 | touch $@ 17 | DISTCLEANFILES += include/openflow/nicira-ext.h.stamp 18 | endif 19 | 20 | EXTRA_DIST += build-aux/check-structs 21 | 22 | -------------------------------------------------------------------------------- /utilities/bugtool/ovs-bugtool-ovsdb-dump: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # This library is free software; you can redistribute it and/or 4 | # modify it under the terms of version 2.1 of the GNU Lesser General 5 | # Public License as published by the Free Software Foundation. 6 | # 7 | # This library is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | # Lesser General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU Lesser General Public 13 | # License along with this library; if not, write to the Free Software 14 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 15 | # USA 16 | # 17 | # Copyright (C) 2011 Nicira Networks. 18 | 19 | ovsdb-client -f csv dump unix:/var/run/openvswitch/db.sock Open_vSwitch 20 | -------------------------------------------------------------------------------- /utilities/bugtool/plugins/kernel-info/openvswitch.xml: -------------------------------------------------------------------------------- 1 | 18 | 19 | 20 | 21 | /proc/slabinfo 22 | 23 | 24 | -------------------------------------------------------------------------------- /utilities/ovs-vlan-bugs.man: -------------------------------------------------------------------------------- 1 | .IP \(bu 2 | When NICs use VLAN stripping on receive they must pass a pointer to a 3 | \fBvlan_group\fR when reporting the stripped tag to the networking 4 | core. If no \fBvlan_group\fR is in use then some drivers just drop 5 | the extracted tag. Drivers are supposed to only enable stripping if a 6 | \fBvlan_group\fR is registered but not all of them do that. 7 | . 8 | .IP \(bu 9 | Some drivers size their receive buffers based on whether a 10 | \fBvlan_group\fR is enabled, meaning that a maximum size packet with a 11 | VLAN tag will not fit if no \fBvlan_group\fR is configured. 12 | . 13 | .IP \(bu 14 | On transmit, some drivers expect that VLAN acceleration will be used 15 | if it is available, which can only be done if a \fBvlan_group\fR is 16 | configured. In these cases, the driver may fail to parse the packet 17 | and correctly setup checksum offloading or TSO. 18 | -------------------------------------------------------------------------------- /datapath/compat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Nicira Networks. 3 | * Distributed under the terms of the GNU GPL version 2. 4 | * 5 | * Significant portions of this file may be copied from parts of the Linux 6 | * kernel, by Linus Torvalds and others. 7 | */ 8 | 9 | #ifndef COMPAT_H 10 | #define COMPAT_H 1 11 | 12 | #include 13 | 14 | #ifndef HAVE_NLA_NUL_STRING 15 | static inline int CHECK_NUL_STRING(struct nlattr *attr, int maxlen) 16 | { 17 | char *s; 18 | int len; 19 | if (!attr) 20 | return 0; 21 | 22 | len = nla_len(attr); 23 | if (len >= maxlen) 24 | return -EINVAL; 25 | 26 | s = nla_data(attr); 27 | if (s[len - 1] != '\0') 28 | return -EINVAL; 29 | 30 | return 0; 31 | } 32 | #else 33 | static inline int CHECK_NUL_STRING(struct nlattr *attr, int maxlen) 34 | { 35 | return 0; 36 | } 37 | #endif /* !HAVE_NLA_NUL_STRING */ 38 | 39 | #endif /* compat.h */ 40 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/kobject.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_KOBJECT_WRAPPER_H 2 | #define __LINUX_KOBJECT_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #include 7 | 8 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) 9 | #define kobject_init(kobj, ktype) rpl_kobject_init(kobj, ktype) 10 | static inline void rpl_kobject_init(struct kobject *kobj, struct kobj_type *ktype) 11 | { 12 | kobj->ktype = ktype; 13 | (kobject_init)(kobj); 14 | } 15 | 16 | #define kobject_add(kobj, parent, name) rpl_kobject_add(kobj, parent, name) 17 | static inline int rpl_kobject_add(struct kobject *kobj, 18 | struct kobject *parent, 19 | const char *name) 20 | { 21 | int err = kobject_set_name(kobj, "%s", name); 22 | if (err) 23 | return err; 24 | kobj->parent = parent; 25 | return (kobject_add)(kobj); 26 | } 27 | #endif 28 | 29 | 30 | #endif /* linux/kobject.h wrapper */ 31 | -------------------------------------------------------------------------------- /include/sparse/assert.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CHECKER__ 18 | #error "Use this header only with sparse. It is not a correct implementation." 19 | #endif 20 | 21 | extern void __ovs_assert(_Bool); 22 | #define assert(EXPRESSION) __ovs_assert(EXPRESSION) 23 | -------------------------------------------------------------------------------- /lib/valgrind.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, 2009 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef VALGRIND_H 18 | #define VALGRIND_H 1 19 | 20 | #ifdef HAVE_VALGRIND_VALGRIND_H 21 | #include 22 | #else 23 | #define RUNNING_ON_VALGRIND 0 24 | #endif 25 | 26 | #endif /* valgrind.h */ 27 | -------------------------------------------------------------------------------- /tests/uuidfilt.pl: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | our %uuids; 7 | our $n_uuids = 0; 8 | sub lookup_uuid { 9 | my ($uuid) = @_; 10 | if (!exists($uuids{$uuid})) { 11 | $uuids{$uuid} = $n_uuids++; 12 | } 13 | return "<$uuids{$uuid}>"; 14 | } 15 | 16 | sub sort_set { 17 | my ($s) = @_; 18 | my (@uuids) = sort { $a <=> $b } (grep(/\d+/, split(/(\d+)/, $s))); 19 | return '["set",[' . join(',', map('["uuid","<' . $_ . '>"]', @uuids)) . ']]'; 20 | } 21 | 22 | my $u = '[0-9a-fA-F]'; 23 | my $uuid_re = "${u}{8}-${u}{4}-${u}{4}-${u}{4}-${u}{12}"; 24 | while (<>) { 25 | s/($uuid_re)/lookup_uuid($1)/eg; 26 | 27 | # Sort sets like this: 28 | # [["uuid","<1>"],["uuid","<0>"]] 29 | # to look like this: 30 | # [["uuid","<0>"],["uuid","<1>"]] 31 | s/(\["set",\[(,?\["uuid","<\d+>"\])+\]\])/sort_set($1)/ge; 32 | print $_; 33 | } 34 | -------------------------------------------------------------------------------- /vswitchd/bridge.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008, 2009, 2010 Nicira Networks 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #ifndef VSWITCHD_BRIDGE_H 17 | #define VSWITCHD_BRIDGE_H 1 18 | 19 | void bridge_init(const char *remote); 20 | void bridge_exit(void); 21 | 22 | void bridge_run(void); 23 | void bridge_wait(void); 24 | 25 | #endif /* bridge.h */ 26 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/jiffies.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_JIFFIES_WRAPPER_H 2 | #define __LINUX_JIFFIES_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #include 7 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) 8 | 9 | /* Same as above, but does so with platform independent 64bit types. 10 | * These must be used when utilizing jiffies_64 (i.e. return value of 11 | * get_jiffies_64() */ 12 | #define time_after64(a,b) \ 13 | (typecheck(__u64, a) && \ 14 | typecheck(__u64, b) && \ 15 | ((__s64)(b) - (__s64)(a) < 0)) 16 | #define time_before64(a,b) time_after64(b,a) 17 | 18 | #define time_after_eq64(a,b) \ 19 | (typecheck(__u64, a) && \ 20 | typecheck(__u64, b) && \ 21 | ((__s64)(a) - (__s64)(b) >= 0)) 22 | #define time_before_eq64(a,b) time_after_eq64(b,a) 23 | 24 | #endif /* linux kernel < 2.6.19 */ 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /python/ovs/timeval.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2009, 2010 Nicira Networks 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at: 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import time 16 | 17 | def msec(): 18 | """Returns the current time, as the amount of time since the epoch, in 19 | milliseconds, as a float.""" 20 | return time.time() * 1000.0 21 | 22 | def postfork(): 23 | # Just a stub for now 24 | pass 25 | -------------------------------------------------------------------------------- /utilities/bugtool/plugins/system-configuration/openvswitch.xml: -------------------------------------------------------------------------------- 1 | 18 | 19 | 20 | date --rfc-3339=seconds 21 | 22 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/in.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_IN_WRAPPER_H 2 | #define __LINUX_IN_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #ifndef HAVE_IPV4_IS_MULTICAST 7 | 8 | static inline bool ipv4_is_loopback(__be32 addr) 9 | { 10 | return (addr & htonl(0xff000000)) == htonl(0x7f000000); 11 | } 12 | 13 | static inline bool ipv4_is_multicast(__be32 addr) 14 | { 15 | return (addr & htonl(0xf0000000)) == htonl(0xe0000000); 16 | } 17 | 18 | static inline bool ipv4_is_local_multicast(__be32 addr) 19 | { 20 | return (addr & htonl(0xffffff00)) == htonl(0xe0000000); 21 | } 22 | 23 | static inline bool ipv4_is_lbcast(__be32 addr) 24 | { 25 | /* limited broadcast */ 26 | return addr == htonl(INADDR_BROADCAST); 27 | } 28 | 29 | static inline bool ipv4_is_zeronet(__be32 addr) 30 | { 31 | return (addr & htonl(0xff000000)) == htonl(0x00000000); 32 | } 33 | 34 | #endif /* !HAVE_IPV4_IS_MULTICAST */ 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /lib/string.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2011 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #include 20 | 21 | #ifndef HAVE_STRNLEN 22 | size_t 23 | strnlen(const char *s, size_t maxlen) 24 | { 25 | const char *end = memchr(s, '\0', maxlen); 26 | return end ? end - s : maxlen; 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /lib/sort.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009 Nicira Networks 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #ifndef SORT_H 17 | #define SORT_H 1 18 | 19 | #include 20 | 21 | void sort(size_t count, 22 | int (*compare)(size_t a, size_t b, void *aux), 23 | void (*swap)(size_t a, size_t b, void *aux), 24 | void *aux); 25 | 26 | #endif /* sort.h */ 27 | -------------------------------------------------------------------------------- /utilities/bugtool/plugins/system-logs/openvswitch.xml: -------------------------------------------------------------------------------- 1 | 18 | 19 | 20 | /etc/openvswitch 21 | 22 | -------------------------------------------------------------------------------- /datapath/vport-generic.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Nicira Networks. 3 | * Distributed under the terms of the GNU GPL version 2. 4 | * 5 | * Significant portions of this file may be copied from parts of the Linux 6 | * kernel, by Linus Torvalds and others. 7 | */ 8 | 9 | #include 10 | 11 | #include "vport-generic.h" 12 | 13 | void vport_gen_rand_ether_addr(u8 *addr) 14 | { 15 | random_ether_addr(addr); 16 | 17 | /* Set the OUI to the Nicira one. */ 18 | addr[0] = 0x00; 19 | addr[1] = 0x23; 20 | addr[2] = 0x20; 21 | 22 | /* Set the top bit to indicate random address. */ 23 | addr[3] |= 0x80; 24 | } 25 | 26 | unsigned vport_gen_get_dev_flags(const struct vport *vport) 27 | { 28 | return IFF_UP | IFF_RUNNING | IFF_LOWER_UP; 29 | } 30 | 31 | int vport_gen_is_running(const struct vport *vport) 32 | { 33 | return 1; 34 | } 35 | 36 | unsigned char vport_gen_get_operstate(const struct vport *vport) 37 | { 38 | return IF_OPER_UP; 39 | } 40 | -------------------------------------------------------------------------------- /lib/dummy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef DUMMY_H 18 | #define DUMMY_H 1 19 | 20 | /* For client programs to call directly to enable dummy support. */ 21 | void dummy_enable(void); 22 | 23 | /* Implementation details. */ 24 | void dpif_dummy_register(void); 25 | void netdev_dummy_register(void); 26 | 27 | #endif /* dummy.h */ 28 | -------------------------------------------------------------------------------- /datapath/linux/compat/dev-openvswitch.c: -------------------------------------------------------------------------------- 1 | #ifndef HAVE_DEV_DISABLE_LRO 2 | 3 | #include 4 | 5 | #ifdef NETIF_F_LRO 6 | #include 7 | 8 | /** 9 | * dev_disable_lro - disable Large Receive Offload on a device 10 | * @dev: device 11 | * 12 | * Disable Large Receive Offload (LRO) on a net device. Must be 13 | * called under RTNL. This is needed if received packets may be 14 | * forwarded to another interface. 15 | */ 16 | void dev_disable_lro(struct net_device *dev) 17 | { 18 | if (dev->ethtool_ops && dev->ethtool_ops->get_flags && 19 | dev->ethtool_ops->set_flags) { 20 | u32 flags = dev->ethtool_ops->get_flags(dev); 21 | if (flags & ETH_FLAG_LRO) { 22 | flags &= ~ETH_FLAG_LRO; 23 | dev->ethtool_ops->set_flags(dev, flags); 24 | } 25 | } 26 | WARN_ON(dev->features & NETIF_F_LRO); 27 | } 28 | #else 29 | void dev_disable_lro(struct net_device *dev) { } 30 | #endif /* NETIF_F_LRO */ 31 | 32 | #endif /* HAVE_DEV_DISABLE_LRO */ 33 | -------------------------------------------------------------------------------- /tests/ofproto-macros.at: -------------------------------------------------------------------------------- 1 | m4_define([STRIP_XIDS], [[sed 's/ (xid=0x[0-9a-fA-F]*)//']]) 2 | m4_define([STRIP_DURATION], [[sed 's/\bduration=[0-9.]*s/duration=?s/']]) 3 | m4_define([TESTABLE_LOG], [-vPATTERN:ANY:'%c|%p|%m']) 4 | 5 | m4_define([OFPROTO_START], 6 | [OVS_RUNDIR=$PWD; export OVS_RUNDIR 7 | OVS_LOGDIR=$PWD; export OVS_LOGDIR 8 | trap 'kill `cat test-openflowd.pid`' 0 9 | AT_CAPTURE_FILE([test-openflowd.log]) 10 | AT_CHECK( 11 | [test-openflowd --detach --pidfile --enable-dummy --log-file --fail=closed dummy@br0 none --datapath-id=fedcba9876543210 $1], 12 | [0], [], [stderr]) 13 | AT_CHECK([[sed < stderr ' 14 | /vlog|INFO|opened log file/d 15 | /openflowd|INFO|Open vSwitch version/d 16 | /openflowd|INFO|OpenFlow protocol version/d 17 | /ofproto|INFO|using datapath ID/d 18 | /ofproto|INFO|datapath ID changed to fedcba9876543210/d']]) 19 | ]) 20 | 21 | m4_define([OFPROTO_STOP], 22 | [AT_CHECK([ovs-appctl -t test-openflowd exit]) 23 | trap '' 0]) 24 | -------------------------------------------------------------------------------- /lib/lockfile.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2008, 2009 Nicira Networks 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #ifndef LOCKFILE_H 17 | #define LOCKFILE_H 1 18 | 19 | struct lockfile; 20 | 21 | char *lockfile_name(const char *file); 22 | int lockfile_lock(const char *file, int timeout, struct lockfile **); 23 | void lockfile_unlock(struct lockfile *); 24 | void lockfile_postfork(void); 25 | 26 | #endif /* lib/lockfile.h */ 27 | -------------------------------------------------------------------------------- /lib/backtrace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef BACKTRACE_H 18 | #define BACKTRACE_H 1 19 | 20 | #include 21 | 22 | #define BACKTRACE_MAX_FRAMES 31 23 | 24 | struct backtrace { 25 | int n_frames; 26 | uintptr_t frames[BACKTRACE_MAX_FRAMES]; 27 | }; 28 | 29 | void backtrace_capture(struct backtrace *); 30 | 31 | #endif /* backtrace.h */ 32 | -------------------------------------------------------------------------------- /tests/valgrind-wrapper.in: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | wrap_program=`basename '@wrap_program@'` 4 | 5 | # Strip the first directory from $PATH that contains $wrap_program, 6 | # so that below we run the real $wrap_program, not ourselves. 7 | not_found=true 8 | new_path= 9 | first=true 10 | save_IFS=$IFS 11 | IFS=: 12 | for dir in $PATH; do 13 | IFS=$save_IFS 14 | if $not_found && test -x "$dir/$wrap_program"; then 15 | not_found=false 16 | else 17 | if $first; then 18 | first=false 19 | new_path=$dir 20 | else 21 | new_path=$new_path:$dir 22 | fi 23 | fi 24 | done 25 | IFS=$save_IFS 26 | if $not_found; then 27 | echo "$0: error: cannot find $wrap_program in \$PATH" >&2 28 | exit 1 29 | fi 30 | PATH=$new_path 31 | export PATH 32 | 33 | : ${VALGRIND:=valgrind -q --log-file=valgrind.%p --leak-check=full} 34 | exec $VALGRIND $wrap_program "$@" 35 | echo "$0: failed to execute $VALGRIND $wrap_program" "$@" >&2 36 | exit 1 37 | -------------------------------------------------------------------------------- /tests/file_name.at: -------------------------------------------------------------------------------- 1 | AT_BANNER([test dir_name and base_name functions]) 2 | 3 | m4_define([CHECK_FILE_NAME], 4 | [AT_SETUP([components of "$1" are "$2", "$3"]) 5 | AT_KEYWORDS([dir_name base_name]) 6 | AT_CHECK([test-file_name "AS_ESCAPE($1)"], [0], [$2 7 | $3 8 | ]) 9 | AT_CLEANUP]) 10 | 11 | # These are the test cases given in POSIX for dirname() and basename(). 12 | CHECK_FILE_NAME([/usr/lib], [/usr], [lib]) 13 | CHECK_FILE_NAME([/usr/], [/], [usr]) 14 | CHECK_FILE_NAME([usr], [.], [usr]) 15 | CHECK_FILE_NAME([/], [/], [/]) 16 | CHECK_FILE_NAME([.], [.], [.]) 17 | CHECK_FILE_NAME([..], [.], [..]) 18 | CHECK_FILE_NAME([//], [//], [//]) # / is also allowed 19 | CHECK_FILE_NAME([//foo], [//], [foo]) # / is also allowed for dirname 20 | CHECK_FILE_NAME([], [.], [.]) 21 | 22 | # Additional test cases. 23 | CHECK_FILE_NAME([dir/file], [dir], [file]) 24 | CHECK_FILE_NAME([dir/file/], [dir], [file]) 25 | CHECK_FILE_NAME([dir/file//], [dir], [file]) 26 | CHECK_FILE_NAME([///foo], [/], [foo]) 27 | -------------------------------------------------------------------------------- /lib/pcap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PCAP_H 18 | #define PCAP_H 1 19 | 20 | #include 21 | 22 | struct ofpbuf; 23 | 24 | FILE *pcap_open(const char *file_name, const char *mode); 25 | int pcap_read_header(FILE *); 26 | void pcap_write_header(FILE *); 27 | int pcap_read(FILE *, struct ofpbuf **); 28 | void pcap_write(FILE *, struct ofpbuf *); 29 | 30 | #endif /* dhcp.h */ 31 | -------------------------------------------------------------------------------- /utilities/ovs-tcpundump.1.in: -------------------------------------------------------------------------------- 1 | .TH ovs\-tcpundump 1 "December 2010" "Open vSwitch" "Open vSwitch Manual" 2 | . 3 | .SH NAME 4 | ovs\-tcpundump \- convert ``tcpdump \-xx'' output to hex strings 5 | . 6 | .SH SYNOPSIS 7 | \fBovs\-tcpundump < \fIfile\fR 8 | .so lib/common-syn.man 9 | . 10 | .SH DESCRIPTION 11 | The \fBovs\-tcpundump\fR program reads \fBtcpdump \-xx\fR output on 12 | stdin, looking for hexadecimal packet data, and dumps each Ethernet as 13 | a single hexadecimal string on stdout. This format is suitable for 14 | use with the \fBofproto/trace\fR command supported by 15 | \fBovs\-vswitchd\fR(8) 16 | via \fBovs\-appctl\fR(8). 17 | .PP 18 | At least two \fB\-x\fR or \fB\-X\fR options must be given, otherwise 19 | the output will omit the Ethernet header, which prevents the output 20 | from being using with \fBofproto/trace\fR. 21 | . 22 | .SH "OPTIONS" 23 | .so lib/common.man 24 | . 25 | .SH "SEE ALSO" 26 | . 27 | .BR ovs\-appctl (8), 28 | .BR ovs\-vswitchd (8), 29 | .BR ovs\-pcap (1), 30 | .BR tcpdump (8), 31 | .BR wireshark (8). 32 | -------------------------------------------------------------------------------- /debian/openvswitch-datapath-source.README.Debian: -------------------------------------------------------------------------------- 1 | Open vSwitch for Debian 2 | ---------------------- 3 | 4 | * How do I build this module the Debian way? 5 | 6 | - Building with module-assistant: 7 | 8 | $ module-assistant auto-install openvswitch-datapath 9 | or 10 | $ m-a a-i openvswitch-datapath 11 | 12 | If kernel source or headers are in a non-standard directory, add 13 | the option -k /path/to/kernel/source with the correct path. 14 | 15 | - Building with make-kpkg 16 | 17 | $ cd /usr/src/ 18 | $ tar jxvf openvswitch.tar.bz2 19 | $ cd /usr/src/kernel-source-2.6.26 20 | $ make-kpkg --added-modules=openvswitch modules 21 | 22 | - Building without make-kpkg 23 | 24 | $ cd /usr/src/ 25 | $ tar jxvf openvswitch.tar.bz2 26 | $ cd modules/openvswitch 27 | $ fakeroot debian/rules kdist_image 28 | 29 | If you run this as root, fakeroot is not needed. 30 | 31 | -- Ben Pfaff , Wed, 22 Jun 2011 09:51:28 -0700 32 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/netlink.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_NETLINK_WRAPPER_H 2 | #define __LINUX_NETLINK_WRAPPER_H 1 3 | 4 | #include 5 | #include_next 6 | 7 | #ifndef NLA_TYPE_MASK 8 | #define NLA_F_NESTED (1 << 15) 9 | #define NLA_F_NET_BYTEORDER (1 << 14) 10 | #define NLA_TYPE_MASK ~(NLA_F_NESTED | NLA_F_NET_BYTEORDER) 11 | #endif 12 | 13 | #include 14 | #include 15 | 16 | #ifndef NLMSG_DEFAULT_SIZE 17 | #define NLMSG_DEFAULT_SIZE (NLMSG_GOODSIZE - NLMSG_HDRLEN) 18 | #endif 19 | 20 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) 21 | #define nlmsg_new(s, f) nlmsg_new_proper((s), (f)) 22 | static inline struct sk_buff *nlmsg_new_proper(int size, gfp_t flags) 23 | { 24 | return alloc_skb(size, flags); 25 | } 26 | #endif /* linux kernel < 2.6.19 */ 27 | 28 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) 29 | static inline struct nlmsghdr *nlmsg_hdr(const struct sk_buff *skb) 30 | { 31 | return (struct nlmsghdr *)skb->data; 32 | } 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /ofproto/automake.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2009, 2010, 2011 Nicira Networks, Inc. 2 | # 3 | # Copying and distribution of this file, with or without modification, 4 | # are permitted in any medium without royalty provided the copyright 5 | # notice and this notice are preserved. This file is offered as-is, 6 | # without warranty of any kind. 7 | 8 | noinst_LIBRARIES += ofproto/libofproto.a 9 | ofproto_libofproto_a_SOURCES = \ 10 | ofproto/collectors.c \ 11 | ofproto/collectors.h \ 12 | ofproto/connmgr.c \ 13 | ofproto/connmgr.h \ 14 | ofproto/fail-open.c \ 15 | ofproto/fail-open.h \ 16 | ofproto/in-band.c \ 17 | ofproto/in-band.h \ 18 | ofproto/names.c \ 19 | ofproto/netflow.c \ 20 | ofproto/netflow.h \ 21 | ofproto/ofproto.c \ 22 | ofproto/ofproto.h \ 23 | ofproto/ofproto-dpif.c \ 24 | ofproto/ofproto-dpif-sflow.c \ 25 | ofproto/ofproto-dpif-sflow.h \ 26 | ofproto/ofproto-provider.h \ 27 | ofproto/pktbuf.c \ 28 | ofproto/pktbuf.h \ 29 | ofproto/pinsched.c \ 30 | ofproto/pinsched.h 31 | 32 | MAN_FRAGMENTS += ofproto/ofproto-unixctl.man 33 | -------------------------------------------------------------------------------- /utilities/bugtool/plugins/network-status/openvswitch.xml: -------------------------------------------------------------------------------- 1 | 18 | 19 | 20 | /usr/share/openvswitch/scripts/ovs-bugtool-tc-class-show 21 | /usr/share/openvswitch/scripts/ovs-bugtool-ovsdb-dump 22 | 23 | -------------------------------------------------------------------------------- /lib/random.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, 2009, 2010 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef RANDOM_H 18 | #define RANDOM_H 1 19 | 20 | #include 21 | #include 22 | 23 | void random_init(void); 24 | void random_set_seed(uint32_t); 25 | 26 | void random_bytes(void *, size_t); 27 | uint8_t random_uint8(void); 28 | uint16_t random_uint16(void); 29 | uint32_t random_uint32(void); 30 | int random_range(int max); 31 | 32 | #endif /* random.h */ 33 | -------------------------------------------------------------------------------- /utilities/bugtool/plugins/system-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 20 | 22 | -------------------------------------------------------------------------------- /lib/dh4096.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN DH PARAMETERS----- 2 | MIICCAKCAgEA+hRyUsFN4VpJ1O8JLcCo/VWr19k3BCgJ4uk+d+KhehjdRqNDNyOQ 3 | l/MOyQNQfWXPeGKmOmIig6Ev/nm6Nf9Z2B1h3R4hExf+zTiHnvVPeRBhjdQi81rt 4 | Xeoh6TNrSBIKIHfUJWBh3va0TxxjQIs6IZOLeVNRLMqzeylWqMf49HsIXqbcokUS 5 | Vt1BkvLdW48j8PPv5DsKRN3tloTxqDJGo9tKvj1Fuk74A+Xda1kNhB7KFlqMyN98 6 | VETEJ6c7KpfOo30mnK30wqw3S8OtaIR/maYX72tGOno2ehFDkq3pnPtEbD2CScxc 7 | alJC+EL7RPk5c/tgeTvCngvc1KZn92Y//EI7G9tPZtylj2b56sHtMftIoYJ9+ODM 8 | sccD5Piz/rejE3Ome8EOOceUSCYAhXn8b3qvxVI1ddd1pED6FHRhFvLrZxFvBEM9 9 | ERRMp5QqOaHJkM+Dxv8Cj6MqrCbfC4u+ZErxodzuusgDgvZiLF22uxMZbobFWyte 10 | OvOzKGtwcTqO/1wV5gKkzu1ZVswVUQd5Gg8lJicwqRWyyNRczDDoG9jVDxmogKTH 11 | AaqLulO7R8Ifa1SwF2DteSGVtgWEN8gDpN3RBmmPTDngyF2DHb5qmpnznwtFKdTL 12 | KWbuHn491xNO25CQWMtem80uKw+pTnisBRF/454n1Jnhub144YRBoN8CAQI= 13 | -----END DH PARAMETERS----- 14 | 15 | These are the 4096 bit DH parameters from "Assigned Number for SKIP Protocols" 16 | (http://www.skip-vpn.org/spec/numbers.html). 17 | See there for how they were generated. 18 | Note that g is not a generator, but this is not a problem since p is a safe prime. 19 | -------------------------------------------------------------------------------- /utilities/bugtool/ovs-bugtool-tc-class-show: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # This library is free software; you can redistribute it and/or 4 | # modify it under the terms of version 2.1 of the GNU Lesser General 5 | # Public License as published by the Free Software Foundation. 6 | # 7 | # This library is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | # Lesser General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU Lesser General Public 13 | # License along with this library; if not, write to the Free Software 14 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 15 | # USA 16 | # 17 | # Copyright (C) 2011 Nicira Networks. 18 | 19 | for iface in $(cd /sys/class/net && echo *); do 20 | if [ -d /sys/class/net/$iface ]; then 21 | echo Interface $iface: 22 | # indent tc output so it's clear which interface it pertains to 23 | /sbin/tc -s -d class show dev $iface | /bin/sed 's/^/ /' 24 | fi 25 | done 26 | -------------------------------------------------------------------------------- /lib/dirs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef DIRS_H 18 | #define DIRS_H 1 19 | 20 | const char *ovs_sysconfdir(void); /* /usr/local/etc */ 21 | const char *ovs_pkgdatadir(void); /* /usr/local/share/openvswitch */ 22 | const char *ovs_rundir(void); /* /usr/local/var/run/openvswitch */ 23 | const char *ovs_logdir(void); /* /usr/local/var/log/openvswitch */ 24 | const char *ovs_bindir(void); /* /usr/local/bin */ 25 | 26 | #endif /* dirs.h */ 27 | -------------------------------------------------------------------------------- /lib/ssl-bootstrap.man: -------------------------------------------------------------------------------- 1 | .IP "\fB\-\-bootstrap\-ca\-cert=\fIcacert.pem\fR" 2 | When \fIcacert.pem\fR exists, this option has the same effect as 3 | \fB\-C\fR or \fB\-\-ca\-cert\fR. If it does not exist, then 4 | \fB\*(PN\fR will attempt to obtain the CA certificate from the 5 | SSL peer on its first SSL connection and save it to the named PEM 6 | file. If it is successful, it will immediately drop the connection 7 | and reconnect, and from then on all SSL connections must be 8 | authenticated by a certificate signed by the CA certificate thus 9 | obtained. 10 | .IP 11 | \fBThis option exposes the SSL connection to a man-in-the-middle 12 | attack obtaining the initial CA certificate\fR, but it may be useful 13 | for bootstrapping. 14 | .IP 15 | This option is only useful if the SSL peer sends its CA certificate as 16 | part of the SSL certificate chain. The SSL protocol does not require 17 | the server to send the CA certificate, but 18 | \fB\*(SN\fR(8) can be configured to do so with the 19 | \fB\-\-peer\-ca\-cert\fR option. 20 | .IP 21 | This option is mutually exclusive with \fB\-C\fR and 22 | \fB\-\-ca\-cert\fR. 23 | -------------------------------------------------------------------------------- /debian/openvswitch-controller.default: -------------------------------------------------------------------------------- 1 | # This is a POSIX shell fragment -*- sh -*- 2 | 3 | # LISTEN: What OpenFlow connection methods should the controller listen on? 4 | # 5 | # This is a space-delimited list of connection methods: 6 | # 7 | # * "pssl:[PORT]": Listen for SSL connections on the specified PORT 8 | # (default: 6633). The private key, certificate, and CA certificate 9 | # must be specified below. 10 | # 11 | # * "pctp:[PORT]": Listen for TCP connections on the specified PORT 12 | # (default: 6633). Not recommended for security reasons. 13 | # 14 | LISTEN="pssl:" 15 | 16 | # PRIVKEY: Name of file containing controller's private key. 17 | # Required if SSL enabled. 18 | PRIVKEY=/etc/openvswitch-controller/privkey.pem 19 | 20 | # CERT: Name of file containing certificate for private key. 21 | # Required if SSL enabled. 22 | CERT=/etc/openvswitch-controller/cert.pem 23 | 24 | # CACERT: Name of file containing switch CA certificate. 25 | # Required if SSL enabled. 26 | CACERT=/etc/openvswitch-controller/cacert.pem 27 | 28 | # Additional options to pass to controller, e.g. "--hub" 29 | DAEMON_OPTS="" 30 | -------------------------------------------------------------------------------- /tests/check-structs.at: -------------------------------------------------------------------------------- 1 | AT_BANNER([struct alignment checker unit tests]) 2 | 3 | m4_define([check_structs], [$top_srcdir/build-aux/check-structs]) 4 | m4_define([RUN_STRUCT_CHECKER], 5 | [AT_SKIP_IF([test $HAVE_PYTHON = no]) 6 | AT_DATA([test.h], [$1 7 | ]) 8 | AT_CHECK_UNQUOTED([$PYTHON check_structs test.h], [$2], [$3], [$4])]) 9 | 10 | AT_SETUP([check struct tail padding]) 11 | RUN_STRUCT_CHECKER( 12 | [struct xyz { 13 | uint16_t x; 14 | };], 15 | [1], [], 16 | [test.h:3: warning: struct xyz needs 2 bytes of tail padding 17 | ]) 18 | AT_CLEANUP 19 | 20 | AT_SETUP([check struct internal alignment]) 21 | RUN_STRUCT_CHECKER( 22 | [struct xyzzy { 23 | uint16_t x; 24 | uint32_t y; 25 | };], 26 | [1], [], 27 | [test.h:3: warning: struct xyzzy member y is 2 bytes short of 4-byte alignment 28 | ]) 29 | AT_CLEANUP 30 | 31 | AT_SETUP([check struct declared size]) 32 | RUN_STRUCT_CHECKER( 33 | [struct wibble { 34 | uint64_t z; 35 | }; 36 | OFP_ASSERT(sizeof(struct wibble) == 12); 37 | ], 38 | [1], [], 39 | [test.h:4: warning: struct wibble is 8 bytes long but declared as 12 40 | ]) 41 | AT_CLEANUP 42 | -------------------------------------------------------------------------------- /tests/test-file_name.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2010 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include "util.h" 19 | #include 20 | 21 | int 22 | main(int argc, char *argv[]) 23 | { 24 | int i; 25 | 26 | for (i = 1; i < argc; i++) { 27 | char *dir, *base; 28 | 29 | dir = dir_name(argv[i]); 30 | puts(dir); 31 | free(dir); 32 | 33 | base = base_name(argv[i]); 34 | puts(base); 35 | free(base); 36 | } 37 | 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /datapath/linux/compat/time.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) 6 | 7 | /* "set_normalized_timespec" is defined but not exported in kernels 8 | * before 2.6.26. */ 9 | 10 | /** 11 | * set_normalized_timespec - set timespec sec and nsec parts and normalize 12 | * 13 | * @ts: pointer to timespec variable to be set 14 | * @sec: seconds to set 15 | * @nsec: nanoseconds to set 16 | * 17 | * Set seconds and nanoseconds field of a timespec variable and 18 | * normalize to the timespec storage format 19 | * 20 | * Note: The tv_nsec part is always in the range of 21 | * 0 <= tv_nsec < NSEC_PER_SEC 22 | * For negative values only the tv_sec field is negative ! 23 | */ 24 | void set_normalized_timespec(struct timespec *ts, 25 | time_t sec, long nsec) 26 | { 27 | while (nsec >= NSEC_PER_SEC) { 28 | nsec -= NSEC_PER_SEC; 29 | ++sec; 30 | } 31 | while (nsec < 0) { 32 | nsec += NSEC_PER_SEC; 33 | --sec; 34 | } 35 | ts->tv_sec = sec; 36 | ts->tv_nsec = nsec; 37 | } 38 | 39 | #endif /* linux kernel < 2.6.26 */ 40 | -------------------------------------------------------------------------------- /include/sparse/sys/wait.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __CHECKER__ 18 | #error "Use this header only with sparse. It is not a correct implementation." 19 | #endif 20 | 21 | #ifndef __SYS_WAIT_SPARSE 22 | #define __SYS_WAIT_SPARSE 1 23 | 24 | #include_next 25 | 26 | #undef wait 27 | #define wait(a) rpl_wait(a) 28 | pid_t rpl_wait(int *); 29 | 30 | #undef waitpid 31 | #define waitpid(a, b, c) rpl_waitpid(a, b, c) 32 | pid_t rpl_waitpid(pid_t, int *, int); 33 | 34 | #endif /* for sparse */ 35 | -------------------------------------------------------------------------------- /datapath/linux/Kbuild.in: -------------------------------------------------------------------------------- 1 | # -*- makefile -*- 2 | export builddir = @abs_builddir@ 3 | export srcdir = @abs_srcdir@ 4 | export top_srcdir = @abs_top_srcdir@ 5 | export VERSION = @VERSION@ 6 | export BUILDNR = @BUILDNR@ 7 | 8 | include $(srcdir)/../Modules.mk 9 | include $(srcdir)/Modules.mk 10 | 11 | EXTRA_CFLAGS := -DVERSION=\"$(VERSION)\" 12 | EXTRA_CFLAGS += -I$(srcdir)/.. 13 | EXTRA_CFLAGS += -I$(builddir)/.. 14 | ifeq '$(BUILDNR)' '0' 15 | EXTRA_CFLAGS += -DBUILDNR=\"\" 16 | else 17 | EXTRA_CFLAGS += -DBUILDNR=\"+build$(BUILDNR)\" 18 | endif 19 | EXTRA_CFLAGS += -g 20 | EXTRA_CFLAGS += -include $(builddir)/kcompat.h 21 | 22 | # These include directories have to go before -I$(KSRC)/include. 23 | # NOSTDINC_FLAGS just happens to be a variable that goes in the 24 | # right place, even though it's conceptually incorrect. 25 | NOSTDINC_FLAGS += -I$(top_srcdir)/include -I$(srcdir)/compat -I$(srcdir)/compat/include 26 | 27 | obj-m := $(patsubst %,%_mod.o,$(build_modules)) 28 | 29 | define module_template 30 | $(1)_mod-y = $$(notdir $$(patsubst %.c,%.o,$($(1)_sources))) 31 | endef 32 | 33 | $(foreach module,$(build_modules),$(eval $(call module_template,$(module)))) 34 | -------------------------------------------------------------------------------- /lib/route-table.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ROUTE_TABLE_H 18 | #define ROUTE_TABLE_H 1 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include "openvswitch/types.h" 25 | 26 | bool route_table_get_ifindex(ovs_be32 ip, int *ifindex); 27 | bool route_table_get_name(ovs_be32 ip, char name[IFNAMSIZ]); 28 | void route_table_register(void); 29 | void route_table_unregister(void); 30 | void route_table_run(void); 31 | void route_table_wait(void); 32 | 33 | #endif /* route-table.h */ 34 | -------------------------------------------------------------------------------- /lib/dummy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #include "dummy.h" 20 | 21 | /* Enables support for "dummy" network devices and dpifs, which are useful for 22 | * testing. A client program might call this function if it is designed 23 | * specifically for testing or the user enables it on the command line. 24 | * 25 | * There is no strong reason why dummy devices shouldn't always be enabled. */ 26 | void 27 | dummy_enable(void) 28 | { 29 | netdev_dummy_register(); 30 | dpif_dummy_register(); 31 | } 32 | -------------------------------------------------------------------------------- /tests/autopath.at: -------------------------------------------------------------------------------- 1 | AT_BANNER([autopath link selection]) 2 | 3 | AT_SETUP([autopath basic]) 4 | AT_CHECK([ovs-ofctl parse-flow 'actions=autopath(1, NXM_NX_REG0[[]])'], [0], 5 | [OFPT_FLOW_MOD (xid=0x1): ADD actions=autopath(1,NXM_NX_REG0[[]]) 6 | ]) 7 | AT_CHECK([ovs-ofctl parse-flow 'actions=autopath(2, NXM_NX_REG0[[2..30]])'], [0], 8 | [OFPT_FLOW_MOD (xid=0x1): ADD actions=autopath(2,NXM_NX_REG0[[2..30]]) 9 | ]) 10 | AT_CLEANUP 11 | 12 | AT_SETUP([autopath action missing argument]) 13 | AT_CHECK([ovs-ofctl parse-flow actions=autopath], [1], [], 14 | [ovs-ofctl: : not enough arguments to autopath action 15 | ]) 16 | AT_CLEANUP 17 | 18 | AT_SETUP([autopath action bad port]) 19 | AT_CHECK([ovs-ofctl parse-flow 'actions=autopath(bad, NXM_NX_REG0[[]])'], [1], [], 20 | [ovs-ofctl: bad, NXM_NX_REG0[[]]: autopath id 0 is not in valid range 1 to 4294967295 21 | ]) 22 | AT_CLEANUP 23 | 24 | AT_SETUP([autopath action destination too narrow]) 25 | AT_CHECK([ovs-ofctl parse-flow 'actions=autopath(1,NXM_NX_REG0[[0..7]])'], [1], [], 26 | [ovs-ofctl: 1,NXM_NX_REG0[[0..7]]: 8-bit destination field has 256 possible values, less than required 65536 27 | ]) 28 | AT_CLEANUP 29 | 30 | -------------------------------------------------------------------------------- /lib/ofp-errors.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, 2009, 2010 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef OFP_ERRORS_H 18 | #define OFP_ERRORS_H 1 19 | 20 | #include 21 | 22 | /* These functions are building blocks for the ofputil_format_error() and 23 | * ofputil_error_to_string() functions declared in ofp-util.h. Those functions 24 | * have friendlier interfaces and should usually be preferred. */ 25 | const char *ofp_error_type_to_string(uint16_t value); 26 | const char *ofp_error_code_to_string(uint16_t type, uint16_t code); 27 | 28 | #endif /* ofp-errors.h */ 29 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/net/checksum.h: -------------------------------------------------------------------------------- 1 | #ifndef __NET_CHECKSUM_WRAPPER_H 2 | #define __NET_CHECKSUM_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #ifndef HAVE_CSUM_UNFOLD 7 | static inline __wsum csum_unfold(__sum16 n) 8 | { 9 | return (__force __wsum)n; 10 | } 11 | #endif /* !HAVE_CSUM_UNFOLD */ 12 | 13 | /* Workaround for debugging included in certain versions of XenServer. It only 14 | * applies to 32-bit x86. 15 | */ 16 | #if defined(HAVE_CSUM_COPY_DBG) && defined(CONFIG_X86_32) 17 | #define csum_and_copy_to_user(src, dst, len, sum, err_ptr) \ 18 | csum_and_copy_to_user(src, dst, len, sum, NULL, err_ptr) 19 | #endif 20 | 21 | #ifndef HAVE_CSUM_REPLACE4 22 | static inline void csum_replace4(__sum16 *sum, __be32 from, __be32 to) 23 | { 24 | __be32 diff[] = { ~from, to }; 25 | 26 | *sum = csum_fold(csum_partial((char *)diff, sizeof(diff), ~csum_unfold(*sum))); 27 | } 28 | #endif 29 | 30 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) 31 | #define inet_proto_csum_replace2(sum, skb, from, to, pseudohdr) \ 32 | inet_proto_csum_replace4(sum, skb, (__force __be32)(from), \ 33 | (__force __be32)(to), pseudohdr) 34 | #endif 35 | 36 | #endif /* checksum.h */ 37 | -------------------------------------------------------------------------------- /vswitchd/vswitch.gv: -------------------------------------------------------------------------------- 1 | digraph Open_vSwitch { 2 | size="6.5,4"; 3 | margin="0"; 4 | node [shape=box]; 5 | edge [dir=none, arrowhead=none, arrowtail=none]; 6 | Bridge []; 7 | Bridge -> sFlow [label="sflow?"]; 8 | Bridge -> Mirror [label="mirrors*"]; 9 | Bridge -> Port [label="ports*"]; 10 | Bridge -> Controller [label="controller*"]; 11 | Bridge -> NetFlow [label="netflow?"]; 12 | QoS [style=bold]; 13 | QoS -> Queue [label="queues value*"]; 14 | sFlow []; 15 | Open_vSwitch [style=bold]; 16 | Open_vSwitch -> Bridge [label="bridges*"]; 17 | Open_vSwitch -> Capability [label="capabilities value*"]; 18 | Open_vSwitch -> SSL [label="ssl?"]; 19 | Open_vSwitch -> Manager [label="manager_options*"]; 20 | Controller []; 21 | Queue [style=bold]; 22 | SSL []; 23 | Manager []; 24 | Capability []; 25 | Mirror []; 26 | Mirror -> Port [style=dotted, constraint=false, label="select_src_port*"]; 27 | Mirror -> Port [style=dotted, constraint=false, label="output_port?"]; 28 | Mirror -> Port [style=dotted, constraint=false, label="select_dst_port*"]; 29 | Interface []; 30 | NetFlow []; 31 | Port []; 32 | Port -> QoS [label="qos?"]; 33 | Port -> Interface [label="interfaces+"]; 34 | } 35 | -------------------------------------------------------------------------------- /ofproto/collectors.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2011 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef COLLECTORS_H 18 | #define COLLECTORS_H 1 19 | 20 | #include 21 | #include 22 | 23 | struct collectors; 24 | struct sset; 25 | 26 | int collectors_create(const struct sset *targets, uint16_t default_port, 27 | struct collectors **); 28 | void collectors_destroy(struct collectors *); 29 | 30 | void collectors_send(const struct collectors *, const void *, size_t); 31 | 32 | int collectors_count(const struct collectors *); 33 | 34 | #endif /* collectors.h */ 35 | -------------------------------------------------------------------------------- /debian/openvswitch-pki.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # postinst script for openvswitch-pki 3 | # 4 | # see: dh_installdeb(1) 5 | 6 | set -e 7 | 8 | # summary of how this script can be called: 9 | # * `configure' 10 | # * `abort-upgrade' 11 | # * `abort-remove' `in-favour' 12 | # 13 | # * `abort-remove' 14 | # * `abort-deconfigure' `in-favour' 15 | # `removing' 16 | # 17 | # for details, see http://www.debian.org/doc/debian-policy/ or 18 | # the debian-policy package 19 | 20 | case "$1" in 21 | configure) 22 | # Create certificate authorities. 23 | if test ! -d /usr/share/openvswitch/pki; then 24 | ovs-pki init 25 | fi 26 | ;; 27 | 28 | abort-upgrade|abort-remove|abort-deconfigure) 29 | ;; 30 | 31 | *) 32 | echo "postinst called with unknown argument \`$1'" >&2 33 | exit 1 34 | ;; 35 | esac 36 | 37 | #DEBHELPER# 38 | 39 | exit 0 40 | 41 | 42 | -------------------------------------------------------------------------------- /debian/rules.modules: -------------------------------------------------------------------------------- 1 | #! /usr/bin/make -f 2 | 3 | PACKAGE=openvswitch-datapath-module 4 | MA_DIR ?= /usr/share/modass 5 | -include $(MA_DIR)/include/generic.make 6 | -include $(MA_DIR)/include/common-rules.make 7 | 8 | DATAPATH_CONFIGURE_OPTS = 9 | 10 | # Official build number. Leave set to 0 if not an official build. 11 | BUILD_NUMBER = 0 12 | 13 | kdist_clean: 14 | dh_testdir 15 | dh_testroot 16 | dh_clean 17 | rm -rf openvswitch 18 | 19 | .PHONY: kdist_config 20 | kdist_config: prep-deb-files 21 | 22 | .PHONY: binary-modules 23 | binary-modules: DSTDIR = $(CURDIR)/debian/$(PKGNAME)/lib/modules/$(KVERS)/kernel 24 | binary-modules: prep-deb-files 25 | dh_testdir 26 | dh_testroot 27 | dh_clean -k 28 | tar xzf openvswitch.tar.gz 29 | cd openvswitch && ./configure --with-linux=$(KSRC) $(DATAPATH_CONFIGURE_OPTS) --with-build-number=$(BUILD_NUMBER) 30 | cd openvswitch && $(MAKE) -C datapath/linux 31 | install -d -m755 $(DSTDIR) 32 | install -m644 openvswitch/datapath/linux/*_mod.ko $(DSTDIR)/ 33 | dh_installmodules 34 | dh_installdocs 35 | dh_installchangelogs 36 | dh_compress 37 | dh_fixperms 38 | dh_installdeb 39 | dh_gencontrol 40 | dh_md5sums 41 | dh_builddeb --destdir=$(DEB_DESTDIR) 42 | 43 | -------------------------------------------------------------------------------- /datapath/vlan.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Nicira Networks. 3 | * Distributed under the terms of the GNU GPL version 2. 4 | * 5 | * Significant portions of this file may be copied from parts of the Linux 6 | * kernel, by Linus Torvalds and others. 7 | */ 8 | 9 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 10 | 11 | #include 12 | #include 13 | 14 | #include "datapath.h" 15 | #include "vlan.h" 16 | 17 | #ifdef NEED_VLAN_FIELD 18 | void vlan_copy_skb_tci(struct sk_buff *skb) 19 | { 20 | OVS_CB(skb)->vlan_tci = 0; 21 | } 22 | 23 | u16 vlan_get_tci(struct sk_buff *skb) 24 | { 25 | return OVS_CB(skb)->vlan_tci; 26 | } 27 | 28 | void vlan_set_tci(struct sk_buff *skb, u16 vlan_tci) 29 | { 30 | OVS_CB(skb)->vlan_tci = vlan_tci; 31 | } 32 | 33 | bool vlan_tx_tag_present(struct sk_buff *skb) 34 | { 35 | return OVS_CB(skb)->vlan_tci & VLAN_TAG_PRESENT; 36 | } 37 | 38 | u16 vlan_tx_tag_get(struct sk_buff *skb) 39 | { 40 | return OVS_CB(skb)->vlan_tci & ~VLAN_TAG_PRESENT; 41 | } 42 | 43 | struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb, u16 vlan_tci) 44 | { 45 | OVS_CB(skb)->vlan_tci = vlan_tci | VLAN_TAG_PRESENT; 46 | return skb; 47 | } 48 | #endif /* NEED_VLAN_FIELD */ 49 | -------------------------------------------------------------------------------- /lib/netdev-linux.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef NETDEV_LINUX_H 18 | #define NETDEV_LINUX_H 1 19 | 20 | #include 21 | #include 22 | #include "openvswitch/datapath-protocol.h" 23 | 24 | /* These functions are Linux specific, so they should be used directly only by 25 | * Linux-specific code. */ 26 | 27 | struct netdev; 28 | struct netdev_stats; 29 | struct rtnl_link_stats; 30 | 31 | int netdev_linux_ethtool_set_flag(struct netdev *netdev, uint32_t flag, 32 | const char *flag_name, bool enable); 33 | 34 | #endif /* netdev-linux.h */ 35 | -------------------------------------------------------------------------------- /lib/signals.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, 2011 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SIGNALS_H 18 | #define SIGNALS_H 1 19 | 20 | #include 21 | #include 22 | 23 | void signal_init(void); 24 | 25 | struct signal *signal_register(int signr); 26 | void signal_unregister(struct signal *); 27 | 28 | bool signal_poll(struct signal *); 29 | void signal_wait(struct signal *); 30 | 31 | const char *signal_name(int signum); 32 | 33 | void xsigaction(int signum, const struct sigaction *, struct sigaction *old); 34 | void xsigprocmask(int how, const sigset_t *, sigset_t *old); 35 | 36 | #endif /* signals.h */ 37 | -------------------------------------------------------------------------------- /tests/test-uuid.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include "uuid.h" 19 | #include 20 | 21 | int 22 | main(int argc, char *argv[]) 23 | { 24 | struct uuid uuid; 25 | 26 | if (argc == 1) { 27 | uuid_generate(&uuid); 28 | } else if (argc == 2) { 29 | if (!uuid_from_string(&uuid, argv[1])) { 30 | ovs_fatal(0, "\"%s\" is not a valid UUID", argv[1]); 31 | } 32 | } else { 33 | ovs_fatal(0, "usage: %s [UUID]", argv[0]); 34 | } 35 | 36 | printf(UUID_FMT"\n", UUID_ARGS(&uuid)); 37 | 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /lib/autopath.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef AUTOPATH_H 18 | #define AUTOPATH_H 1 19 | 20 | #include 21 | 22 | struct flow; 23 | struct nx_action_autopath; 24 | 25 | /* NXAST_AUTOPATH helper functions. 26 | * 27 | * See include/openflow/nicira-ext.h for NXAST_AUTOPATH specification. */ 28 | 29 | void autopath_execute(const struct nx_action_autopath *, struct flow *, 30 | uint16_t ofp_port); 31 | void autopath_parse(struct nx_action_autopath *, const char *); 32 | int autopath_check(const struct nx_action_autopath *, const struct flow *); 33 | 34 | #endif /* autopath.h */ 35 | -------------------------------------------------------------------------------- /tests/ovsdb-monitor-sort.pl: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | # Breaks lines read from into groups using blank lines as 7 | # group separators, then sorts lines within the groups for 8 | # reproducibility. 9 | 10 | sub compare_lines { 11 | my ($a, $b) = @_; 12 | 13 | my $u = '[0-9a-fA-F]'; 14 | my $uuid_re = "${u}{8}-${u}{4}-${u}{4}-${u}{4}-${u}{12}"; 15 | if ($a =~ /^$uuid_re/) { 16 | if ($b =~ /^$uuid_re/) { 17 | return substr($a, 36) cmp substr($b, 36); 18 | } else { 19 | return 1; 20 | } 21 | } elsif ($b =~ /^$uuid_re/) { 22 | return -1; 23 | } else { 24 | return $a cmp $b; 25 | } 26 | } 27 | 28 | sub output_group { 29 | my (@group) = @_; 30 | print "$_\n" foreach sort { compare_lines($a, $b) } @group; 31 | } 32 | 33 | my @group = (); 34 | while () { 35 | chomp; 36 | if ($_ eq '') { 37 | output_group(@group); 38 | @group = (); 39 | print "\n"; 40 | } else { 41 | if (/^,/ && @group) { 42 | $group[$#group] .= "\n" . $_; 43 | } else { 44 | push(@group, $_); 45 | } 46 | } 47 | } 48 | 49 | output_group(@group) if @group; 50 | -------------------------------------------------------------------------------- /ofproto/pktbuf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, 2009 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PKTBUF_H 18 | #define PKTBUF_H 1 19 | 20 | #include 21 | 22 | struct pktbuf; 23 | struct ofpbuf; 24 | 25 | int pktbuf_capacity(void); 26 | 27 | struct pktbuf *pktbuf_create(void); 28 | void pktbuf_destroy(struct pktbuf *); 29 | uint32_t pktbuf_save(struct pktbuf *, struct ofpbuf *buffer, uint16_t in_port); 30 | uint32_t pktbuf_get_null(void); 31 | int pktbuf_retrieve(struct pktbuf *, uint32_t id, struct ofpbuf **bufferp, 32 | uint16_t *in_port); 33 | void pktbuf_discard(struct pktbuf *, uint32_t id); 34 | 35 | #endif /* pktbuf.h */ 36 | -------------------------------------------------------------------------------- /xenserver/automake.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2009, 2010, 2011 Nicira Networks, Inc. 2 | # 3 | # Copying and distribution of this file, with or without modification, 4 | # are permitted in any medium without royalty provided the copyright 5 | # notice and this notice are preserved. This file is offered as-is, 6 | # without warranty of any kind. 7 | 8 | EXTRA_DIST += \ 9 | xenserver/GPLv2 \ 10 | xenserver/LICENSE \ 11 | xenserver/README \ 12 | xenserver/automake.mk \ 13 | xenserver/etc_init.d_openvswitch \ 14 | xenserver/etc_init.d_openvswitch-xapi-update \ 15 | xenserver/etc_logrotate.d_openvswitch \ 16 | xenserver/etc_profile.d_openvswitch.sh \ 17 | xenserver/etc_xapi.d_plugins_openvswitch-cfg-update \ 18 | xenserver/etc_xensource_scripts_vif \ 19 | xenserver/openvswitch-xen.spec \ 20 | xenserver/opt_xensource_libexec_InterfaceReconfigure.py \ 21 | xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py \ 22 | xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py \ 23 | xenserver/opt_xensource_libexec_interface-reconfigure \ 24 | xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py \ 25 | xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync \ 26 | xenserver/usr_share_openvswitch_scripts_sysconfig.template \ 27 | xenserver/uuid.py 28 | -------------------------------------------------------------------------------- /lib/csum.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, 2011 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef CSUM_H 18 | #define CSUM_H 1 19 | 20 | #include 21 | #include 22 | #include "openvswitch/types.h" 23 | 24 | ovs_be16 csum(const void *, size_t); 25 | uint32_t csum_add16(uint32_t partial, ovs_be16); 26 | uint32_t csum_add32(uint32_t partial, ovs_be32); 27 | uint32_t csum_continue(uint32_t partial, const void *, size_t); 28 | ovs_be16 csum_finish(uint32_t partial); 29 | ovs_be16 recalc_csum16(ovs_be16 old_csum, ovs_be16 old_u16, ovs_be16 new_u16); 30 | ovs_be16 recalc_csum32(ovs_be16 old_csum, ovs_be32 old_u32, ovs_be32 new_u32); 31 | 32 | #endif /* csum.h */ 33 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/reciprocal_div.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_RECIPROCAL_DIV_WRAPPER_H 2 | #define __LINUX_RECIPROCAL_DIV_WRAPPER_H 3 | 4 | #include 5 | 6 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 7 | #include_next 8 | #else 9 | 10 | #include 11 | 12 | /* 13 | * This file describes reciprocical division. 14 | * 15 | * This optimizes the (A/B) problem, when A and B are two u32 16 | * and B is a known value (but not known at compile time) 17 | * 18 | * The math principle used is : 19 | * Let RECIPROCAL_VALUE(B) be (((1LL << 32) + (B - 1))/ B) 20 | * Then A / B = (u32)(((u64)(A) * (R)) >> 32) 21 | * 22 | * This replaces a divide by a multiply (and a shift), and 23 | * is generally less expensive in CPU cycles. 24 | */ 25 | 26 | /* 27 | * Computes the reciprocal value (R) for the value B of the divisor. 28 | * Should not be called before each reciprocal_divide(), 29 | * or else the performance is slower than a normal divide. 30 | */ 31 | extern u32 reciprocal_value(u32 B); 32 | 33 | 34 | static inline u32 reciprocal_divide(u32 A, u32 R) 35 | { 36 | return (u32)(((u64)A * R) >> 32); 37 | } 38 | 39 | #endif /* Linux kernel < 2.6.20 */ 40 | #endif /* __LINUX_RECIPROCAL_DIV_WRAPPER_H */ 41 | -------------------------------------------------------------------------------- /datapath/vport-netdev.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Nicira Networks. 3 | * Distributed under the terms of the GNU GPL version 2. 4 | * 5 | * Significant portions of this file may be copied from parts of the Linux 6 | * kernel, by Linus Torvalds and others. 7 | */ 8 | 9 | #ifndef VPORT_NETDEV_H 10 | #define VPORT_NETDEV_H 1 11 | 12 | #include 13 | 14 | #include "vport.h" 15 | 16 | struct vport *netdev_get_vport(struct net_device *dev); 17 | 18 | struct netdev_vport { 19 | struct net_device *dev; 20 | }; 21 | 22 | static inline struct netdev_vport * 23 | netdev_vport_priv(const struct vport *vport) 24 | { 25 | return vport_priv(vport); 26 | } 27 | 28 | int netdev_set_addr(struct vport *, const unsigned char *addr); 29 | const char *netdev_get_name(const struct vport *); 30 | const unsigned char *netdev_get_addr(const struct vport *); 31 | const char *netdev_get_config(const struct vport *); 32 | struct kobject *netdev_get_kobj(const struct vport *); 33 | unsigned netdev_get_dev_flags(const struct vport *); 34 | int netdev_is_running(const struct vport *); 35 | unsigned char netdev_get_operstate(const struct vport *); 36 | int netdev_get_ifindex(const struct vport *); 37 | int netdev_get_mtu(const struct vport *); 38 | 39 | #endif /* vport_netdev.h */ 40 | -------------------------------------------------------------------------------- /ovsdb/ovsdbmonitor/ovsdbmonitor.in: -------------------------------------------------------------------------------- 1 | #! @PYTHON@ 2 | # Copyright (c) 2010 Citrix Systems, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at: 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | # Version 1.51 17 | # 2010-05-07 18 | 19 | import sys 20 | sys.path.insert(0, "@ovsdbmonitordir@") 21 | sys.path.insert(0, "@abs_top_srcdir@/ovsdb/ovsdbmonitor") # NOINSTALL 22 | 23 | import sys, traceback 24 | from pprint import pprint 25 | from OVEApp import * 26 | 27 | app = OVEApp() 28 | try: 29 | retVal = app.enter() 30 | except Exception, e: 31 | print str(e) 32 | try: 33 | trace = traceback.format_tb(sys.exc_info()[2]) 34 | except: 35 | trace = ['Traceback not available'] 36 | print("".join(trace)) 37 | retVal = 1 38 | 39 | sys.exit(retVal) 40 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | This file is a summary of the licensing of files in this distribution. 2 | Some files may be marked specifically with a different license, in 3 | which case that license applies to the file in question. 4 | 5 | Most files are licensed under the Apache License, Version 2.0: 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at: 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | 19 | Files under the datapath directory are licensed under the GNU General 20 | Public License, version 2. 21 | 22 | Files under the xenserver directory are licensed on a file-by-file 23 | basis. Refer to each file for details. 24 | 25 | Files lib/sflow*.[ch] are licensed under the terms of the InMon sFlow 26 | licence that is available at: 27 | http://www.inmon.com/technology/sflowlicense.txt 28 | -------------------------------------------------------------------------------- /lib/netdev-vport.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, 2011 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef NETDEV_VPORT_H 18 | #define NETDEV_VPORT_H 1 19 | 20 | struct dpif_linux_vport; 21 | struct netdev; 22 | struct netdev_stats; 23 | 24 | void netdev_vport_register(void); 25 | 26 | const struct ofpbuf *netdev_vport_get_options(const struct netdev *); 27 | 28 | enum ovs_vport_type netdev_vport_get_vport_type(const struct netdev *); 29 | const char *netdev_vport_get_netdev_type(const struct dpif_linux_vport *); 30 | 31 | int netdev_vport_get_stats(const struct netdev *, struct netdev_stats *); 32 | int netdev_vport_set_stats(struct netdev *, const struct netdev_stats *); 33 | 34 | #endif /* netdev-vport.h */ 35 | -------------------------------------------------------------------------------- /ofproto/names.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #include "ofproto/ofproto.h" 20 | 21 | #include "dpif.h" 22 | 23 | /* This function is in a separate file because it is the only ofproto function 24 | * required by ovs-ofctl, which allows ovs-ofctl to avoid linking in extra 25 | * baggage. */ 26 | 27 | /* Parses 'ofproto_name', which is of the form [type@]name into component 28 | * pieces that are suitable for passing to ofproto_create(). The caller must 29 | * free 'name' and 'type'. */ 30 | void 31 | ofproto_parse_name(const char *ofproto_name, char **name, char **type) 32 | { 33 | dp_parse_name(ofproto_name, name, type); 34 | } 35 | 36 | -------------------------------------------------------------------------------- /python/ovs/db/error.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2009, 2010, 2011 Nicira Networks 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at: 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import ovs.json 16 | 17 | class Error(Exception): 18 | def __init__(self, msg, json=None, tag=None): 19 | self.msg = msg 20 | self.json = json 21 | if tag is None: 22 | if json is None: 23 | self.tag = "ovsdb error" 24 | else: 25 | self.tag = "syntax error" 26 | else: 27 | self.tag = tag 28 | 29 | # Compose message. 30 | syntax = "" 31 | if self.json is not None: 32 | syntax = 'syntax "%s": ' % ovs.json.to_string(self.json) 33 | Exception.__init__(self, "%s%s: %s" % (syntax, self.tag, self.msg)) 34 | -------------------------------------------------------------------------------- /lib/ssl.man: -------------------------------------------------------------------------------- 1 | .de IQ 2 | . br 3 | . ns 4 | . IP "\\$1" 5 | .. 6 | .IP "\fB\-p\fR \fIprivkey.pem\fR" 7 | .IQ "\fB\-\-private\-key=\fIprivkey.pem\fR" 8 | Specifies a PEM file containing the private key used as \fB\*(PN\fR's 9 | identity for outgoing SSL connections. 10 | . 11 | .IP "\fB\-c\fR \fIcert.pem\fR" 12 | .IQ "\fB\-\-certificate=\fIcert.pem\fR" 13 | Specifies a PEM file containing a certificate that certifies the 14 | private key specified on \fB\-p\fR or \fB\-\-private\-key\fR to be 15 | trustworthy. The certificate must be signed by the certificate 16 | authority (CA) that the peer in SSL connections will use to verify it. 17 | . 18 | .IP "\fB\-C\fR \fIcacert.pem\fR" 19 | .IQ "\fB\-\-ca\-cert=\fIcacert.pem\fR" 20 | Specifies a PEM file containing the CA certificate that \fB\*(PN\fR 21 | should use to verify certificates presented to it by SSL peers. (This 22 | may be the same certificate that SSL peers use to verify the 23 | certificate specified on \fB\-c\fR or \fB\-\-certificate\fR, or it may 24 | be a different one, depending on the PKI design in use.) 25 | . 26 | .IP "\fB\-C none\fR" 27 | .IQ "\fB\-\-ca\-cert=none\fR" 28 | Disables verification of certificates presented by SSL peers. This 29 | introduces a security risk, because it means that certificates cannot 30 | be verified to be those of known trusted hosts. 31 | -------------------------------------------------------------------------------- /soexpand.pl: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2008 Nicira Networks. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at: 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | use strict; 16 | use warnings; 17 | use Getopt::Long; 18 | 19 | my ($exit_code) = 0; 20 | my (@include_dirs); 21 | Getopt::Long::Configure ("bundling"); 22 | GetOptions("I|include=s" => \@include_dirs) or exit(1); 23 | @include_dirs = ('.') if !@include_dirs; 24 | OUTER: while () { 25 | if (my ($name) = /^\.so (\S+)$/) { 26 | foreach my $dir (@include_dirs, '.') { 27 | if (open(INNER, "$dir/$name")) { 28 | while () { 29 | print $_; 30 | } 31 | close(INNER); 32 | next OUTER; 33 | } 34 | } 35 | print STDERR "$name not found in: ", join(' ', @include_dirs), "\n"; 36 | $exit_code = 1; 37 | } 38 | print $_; 39 | } 40 | exit $exit_code; 41 | -------------------------------------------------------------------------------- /lib/aes128.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * Based on rijndael.txt by Philip J. Erdelsky, downloaded from 19 | * http://www.efgh.com/software/rijndael.htm on September 24, 2009. The 20 | * license information there is: "Public domain; no restrictions on use." 21 | * The Apache license above applies only to Nicira's modifications to the 22 | * original code. 23 | */ 24 | 25 | #ifndef AES128_H 26 | #define AES128_H 27 | 28 | #include 29 | 30 | struct aes128 { 31 | uint32_t rk[128/8 + 28]; 32 | }; 33 | 34 | void aes128_schedule(struct aes128 *, const uint8_t key[16]); 35 | void aes128_encrypt(const struct aes128 *, const void *, void *); 36 | 37 | #endif /* aes128.h */ 38 | -------------------------------------------------------------------------------- /lib/learn.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef LEARN_H 18 | #define LEARN_H 1 19 | 20 | struct ds; 21 | struct flow; 22 | struct ofpbuf; 23 | struct ofputil_flow_mod; 24 | struct nx_action_learn; 25 | 26 | /* NXAST_LEARN helper functions. 27 | * 28 | * See include/openflow/nicira-ext.h for NXAST_LEARN specification. 29 | */ 30 | 31 | int learn_check(const struct nx_action_learn *, const struct flow *); 32 | void learn_execute(const struct nx_action_learn *, const struct flow *, 33 | struct ofputil_flow_mod *); 34 | 35 | void learn_parse(struct ofpbuf *, char *, const struct flow *); 36 | void learn_format(const struct nx_action_learn *, struct ds *); 37 | 38 | #endif /* learn.h */ 39 | -------------------------------------------------------------------------------- /lib/stream-fd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, 2009 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef STREAM_FD_H 18 | #define STREAM_FD_H 1 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | struct stream; 25 | struct pstream; 26 | struct sockaddr; 27 | 28 | int new_fd_stream(const char *name, int fd, int connect_status, 29 | char *unlink_path, struct stream **streamp); 30 | int new_fd_pstream(const char *name, int fd, 31 | int (*accept_cb)(int fd, const struct sockaddr *, 32 | size_t sa_len, struct stream **), 33 | char *unlink_path, 34 | struct pstream **pstreamp); 35 | 36 | #endif /* stream-fd.h */ 37 | -------------------------------------------------------------------------------- /lib/multipath.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef MULTIPATH_H 18 | #define MULTIPATH_H 1 19 | 20 | #include 21 | 22 | struct ds; 23 | struct flow; 24 | struct nx_action_multipath; 25 | struct nx_action_reg_move; 26 | 27 | /* NXAST_MULTIPATH helper functions. 28 | * 29 | * See include/openflow/nicira-ext.h for NXAST_MULTIPATH specification. 30 | */ 31 | 32 | int multipath_check(const struct nx_action_multipath *, const struct flow *); 33 | void multipath_execute(const struct nx_action_multipath *, struct flow *); 34 | 35 | void multipath_parse(struct nx_action_multipath *, const char *); 36 | void multipath_format(const struct nx_action_multipath *, struct ds *); 37 | 38 | #endif /* multipath.h */ 39 | -------------------------------------------------------------------------------- /lib/command-line.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, 2009, 2010 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef COMMAND_LINE_H 18 | #define COMMAND_LINE_H 1 19 | 20 | /* Utilities for command-line parsing. */ 21 | 22 | #include "compiler.h" 23 | 24 | struct option; 25 | 26 | struct command { 27 | const char *name; 28 | int min_args; 29 | int max_args; 30 | void (*handler)(int argc, char *argv[]); 31 | }; 32 | 33 | char *long_options_to_short_options(const struct option *options); 34 | void run_command(int argc, char *argv[], const struct command[]); 35 | 36 | void proctitle_init(int argc, char **argv); 37 | void proctitle_set(const char *, ...) 38 | PRINTF_FORMAT(1, 2); 39 | void proctitle_restore(void); 40 | 41 | #endif /* command-line.h */ 42 | -------------------------------------------------------------------------------- /debian/openvswitch-switch.postrm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # postrm script for openvswitch-switch 3 | # 4 | # see: dh_installdeb(1) 5 | 6 | set -e 7 | 8 | # summary of how this script can be called: 9 | # * `remove' 10 | # * `purge' 11 | # * `upgrade' 12 | # * `failed-upgrade' 13 | # * `abort-install' 14 | # * `abort-install' 15 | # * `abort-upgrade' 16 | # * `disappear' 17 | # 18 | # for details, see http://www.debian.org/doc/debian-policy/ or 19 | # the debian-policy package 20 | 21 | 22 | case "$1" in 23 | purge) 24 | rm -f /etc/openvswitch/conf.db 25 | rm -f /etc/openvswitch/.conf.db.~lock~ 26 | rm -f /etc/default/openvswitch-switch 27 | rm -f /var/log/openvswitch/* 28 | ;; 29 | 30 | remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) 31 | ;; 32 | 33 | *) 34 | echo "postrm called with unknown argument \`$1'" >&2 35 | exit 1 36 | ;; 37 | esac 38 | 39 | # dh_installdeb will replace this with shell code automatically 40 | # generated by other debhelper scripts. 41 | 42 | #DEBHELPER# 43 | 44 | exit 0 45 | 46 | 47 | -------------------------------------------------------------------------------- /lib/timer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #include "timer.h" 20 | 21 | #include "poll-loop.h" 22 | #include "timeval.h" 23 | 24 | /* Returns the number of milliseconds until 'timer' expires. */ 25 | long long int 26 | timer_msecs_until_expired(const struct timer *timer) 27 | { 28 | switch (timer->t) { 29 | case LLONG_MAX: return LLONG_MAX; 30 | case LLONG_MIN: return 0; 31 | default: return timer->t - time_msec(); 32 | } 33 | } 34 | 35 | /* Causes poll_block() to wake when 'timer' expires. */ 36 | void 37 | (timer_wait)(const struct timer *timer, const char *where) 38 | { 39 | if (timer->t < LLONG_MAX) { 40 | (poll_timer_wait_until)(timer->t, where); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /third-party/README: -------------------------------------------------------------------------------- 1 | This directory contains third-party software that may be useful for 2 | debugging. 3 | 4 | tcpdump 5 | ------- 6 | The "ofp-tcpdump.patch" patch adds the ability to parse OpenFlow 7 | messages to tcpdump. These instructions assume that tcpdump 3.9.8 8 | is going to be used, but it should work with other versions that are not 9 | substantially different. To begin, download tcpdump and apply the 10 | patch: 11 | 12 | wget http://www.tcpdump.org/release/tcpdump-3.9.8.tar.gz 13 | tar xzf tcpdump-3.9.8.tar.gz 14 | ln -s tcpdump-3.9.8 tcpdump 15 | patch -p0 < ofp-tcpdump.patch 16 | 17 | Then build the new version of tcpdump: 18 | 19 | cd tcpdump 20 | ./configure 21 | make 22 | 23 | Clearly, tcpdump can only parse unencrypted packets, so you will need to 24 | connect the controller and datapath using plain TCP. To look at the 25 | traffic, tcpdump will be started in a manner similar to the following: 26 | 27 | sudo ./tcpdump -s0 -i eth0 port 6633 28 | 29 | The "-s0" flag indicates that tcpdump should capture the entire packet. 30 | If the OpenFlow message is not received in its entirety, "[|openflow]" will 31 | be printed instead of the OpenFlow message contents. 32 | 33 | The verbosity of the output may be increased by adding additional "-v" 34 | flags. If "-vvv" is used, the raw OpenFlow data is also printed in 35 | hex and ASCII. 36 | -------------------------------------------------------------------------------- /rhel/automake.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2009, 2010, 2011 Nicira Networks, Inc. 2 | # 3 | # Copying and distribution of this file, with or without modification, 4 | # are permitted in any medium without royalty provided the copyright 5 | # notice and this notice are preserved. This file is offered as-is, 6 | # without warranty of any kind. 7 | 8 | EXTRA_DIST += \ 9 | rhel/automake.mk \ 10 | rhel/etc_init.d_openvswitch \ 11 | rhel/etc_logrotate.d_openvswitch \ 12 | rhel/kmodtool-openvswitch-el5.sh \ 13 | rhel/openvswitch-kmod-rhel5.spec \ 14 | rhel/openvswitch-kmod-rhel5.spec.in \ 15 | rhel/openvswitch-kmod-rhel6.spec \ 16 | rhel/openvswitch-kmod-rhel6.spec.in \ 17 | rhel/openvswitch.spec \ 18 | rhel/openvswitch.spec.in \ 19 | rhel/usr_share_openvswitch_scripts_sysconfig.template 20 | 21 | update_spec = \ 22 | ($(ro_shell) && sed -e 's,[@]VERSION[@],$(VERSION),g') \ 23 | < $(srcdir)/rhel/$(@F).in > $(@F).tmp || exit 1; \ 24 | if cmp -s $(@F).tmp $@; then touch $@; rm $(@F).tmp; else mv $(@F).tmp $@; fi 25 | 26 | $(srcdir)/rhel/openvswitch-kmod-rhel5.spec: rhel/openvswitch-kmod-rhel5.spec.in $(top_builddir)/config.status 27 | $(update_spec) 28 | 29 | $(srcdir)/rhel/openvswitch-kmod-rhel6.spec: rhel/openvswitch-kmod-rhel6.spec.in $(top_builddir)/config.status 30 | $(update_spec) 31 | 32 | $(srcdir)/rhel/openvswitch.spec: rhel/openvswitch.spec.in $(top_builddir)/config.status 33 | $(update_spec) 34 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/workqueue.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_WORKQUEUE_WRAPPER_H 2 | #define __LINUX_WORKQUEUE_WRAPPER_H 1 3 | 4 | #include_next 5 | 6 | #include 7 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23) 8 | 9 | /* Older kernels have an implementation of work queues with some very bad 10 | * characteristics when trying to cancel work (potential deadlocks, use after 11 | * free, etc. Here we directly use timers instead for delayed work. It's not 12 | * optimal but it is better than the alternative. Note that work queues 13 | * normally run in process context but this will cause them to operate in 14 | * softirq context. 15 | */ 16 | 17 | #include 18 | 19 | #undef DECLARE_DELAYED_WORK 20 | #define DECLARE_DELAYED_WORK(n, f) \ 21 | struct timer_list n = TIMER_INITIALIZER((void (*)(unsigned long))f, 0, 0) 22 | 23 | #define schedule_delayed_work rpl_schedule_delayed_work 24 | static inline int schedule_delayed_work(struct timer_list *timer, unsigned long delay) 25 | { 26 | if (timer_pending(timer)) 27 | return 0; 28 | 29 | mod_timer(timer, jiffies + delay); 30 | return 1; 31 | } 32 | 33 | #define cancel_delayed_work_sync rpl_cancel_delayed_work_sync 34 | static inline int cancel_delayed_work_sync(struct timer_list *timer) 35 | { 36 | return del_timer_sync(timer); 37 | } 38 | 39 | #endif /* kernel version < 2.6.23 */ 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /lib/string.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2011 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef STRING_WRAPPER_H 18 | #define STRING_WRAPPER_H 1 19 | 20 | #include_next 21 | 22 | /* Glibc 2.7 has a bug in strtok_r when compiling with optimization that can 23 | * cause segfaults if the delimiters argument is a compile-time constant that 24 | * has exactly 1 character: 25 | * 26 | * http://sources.redhat.com/bugzilla/show_bug.cgi?id=5614 27 | * 28 | * The bug is only present in the inline version of strtok_r(), so force the 29 | * out-of-line version to be used instead. */ 30 | #if HAVE_STRTOK_R_BUG 31 | #undef strtok_r 32 | #endif 33 | 34 | #ifndef HAVE_STRNLEN 35 | #undef strnlen 36 | #define strnlen rpl_strnlen 37 | size_t strnlen(const char *, size_t maxlen); 38 | #endif 39 | 40 | #endif /* string.h wrapper */ 41 | -------------------------------------------------------------------------------- /lib/sat-math.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SAT_MATH_H 18 | #define SAT_MATH_H 1 19 | 20 | #include 21 | #include 22 | 23 | /* Saturating addition: overflow yields UINT_MAX. */ 24 | static inline unsigned int 25 | sat_add(unsigned int x, unsigned int y) 26 | { 27 | return x + y >= x ? x + y : UINT_MAX; 28 | } 29 | 30 | /* Saturating subtraction: underflow yields 0. */ 31 | static inline unsigned int 32 | sat_sub(unsigned int x, unsigned int y) 33 | { 34 | return x >= y ? x - y : 0; 35 | } 36 | 37 | /* Saturating multiplication: overflow yields UINT_MAX. */ 38 | static inline unsigned int 39 | sat_mul(unsigned int x, unsigned int y) 40 | { 41 | return (!y ? 0 42 | : x <= UINT_MAX / y ? x * y 43 | : UINT_MAX); 44 | } 45 | 46 | #endif /* sat-math.h */ 47 | -------------------------------------------------------------------------------- /tests/test-strtok_r.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | /* Some versions of glibc 2.7 has a bug in strtok_r when with optimization that 22 | * can cause segfaults: 23 | * http://sources.redhat.com/bugzilla/show_bug.cgi?id=5614. 24 | * 25 | * Open vSwitch works around this problem by supplying a replacement string.h. 26 | * This test program verifies that the workaround is in place. 27 | */ 28 | int 29 | main(void) 30 | { 31 | char string[] = ":::"; 32 | char *save_ptr = (char *) 0xc0ffee; 33 | char *token1, *token2; 34 | token1 = strtok_r(string, ":", &save_ptr); 35 | token2 = strtok_r(NULL, ":", &save_ptr); 36 | printf ("%s %s\n", token1 ? token1 : "NULL", token2 ? token2 : "NULL"); 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /ofproto/pinsched.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef PINSCHED_H 18 | #define PINSCHED_H_H 1 19 | 20 | #include 21 | 22 | struct ofpbuf; 23 | 24 | typedef void pinsched_tx_cb(struct ofpbuf *, void *aux); 25 | struct pinsched *pinsched_create(int rate_limit, int burst_limit); 26 | void pinsched_get_limits(const struct pinsched *, 27 | int *rate_limit, int *burst_limit); 28 | void pinsched_set_limits(struct pinsched *, int rate_limit, int burst_limit); 29 | void pinsched_destroy(struct pinsched *); 30 | void pinsched_send(struct pinsched *, uint16_t port_no, struct ofpbuf *, 31 | pinsched_tx_cb *, void *aux); 32 | void pinsched_run(struct pinsched *, pinsched_tx_cb *, void *aux); 33 | void pinsched_wait(struct pinsched *); 34 | 35 | #endif /* pinsched.h */ 36 | -------------------------------------------------------------------------------- /xenserver/etc_profile.d_openvswitch.sh: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2009, 2010, 2011 Nicira Networks, Inc. 2 | # 3 | # Copying and distribution of this file, with or without modification, 4 | # are permitted in any medium without royalty provided the copyright 5 | # notice and this notice are preserved. This file is offered as-is, 6 | # without warranty of any kind. 7 | 8 | alias vswitch='service openvswitch' 9 | alias openvswitch='service openvswitch' 10 | 11 | function watchdp { 12 | watch ovs-dpctl show "$@" 13 | } 14 | 15 | function watchdpflows { 16 | local grep="" 17 | local dp=$1 18 | shift 19 | if [ $# -gt 0 ]; then 20 | grep="| grep $@" 21 | fi 22 | watch "ovs-dpctl dump-flows $dp $grep" 23 | } 24 | 25 | function watchflows { 26 | local grep="" 27 | local dp=$1 28 | shift 29 | bridge=$(ovs-dpctl show $dp | grep 'port 0:' | cut -d' ' -f 3) 30 | if [ $# -gt 0 ]; then 31 | grep="| grep $@" 32 | fi 33 | watch "ovs-ofctl dump-flows unix:/var/run/$bridge.mgmt $grep" 34 | } 35 | 36 | function monitorlogs { 37 | local grep="" 38 | if [ $# -gt 0 ]; then 39 | grep="| grep --line-buffered '^==> .* <==$" 40 | for i in "$@"; do 41 | grep="$grep\|$i" 42 | done 43 | grep="$grep'" 44 | fi 45 | cmd="tail -F /var/log/messages /var/log/openvswitch/ovs-vswitchd.log /var/log/openvswitch/ovsdb-server /var/log/xensource.log $grep | tee /var/log/monitorlogs.out" 46 | printf "cmd: $cmd\n" 47 | eval "$cmd" 48 | } 49 | -------------------------------------------------------------------------------- /ovsdb/query.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2009 Nicira Networks 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #ifndef OVSDB_QUERY_H 17 | #define OVSDB_QUERY_H 1 18 | 19 | #include 20 | 21 | struct ovsdb_column_set; 22 | struct ovsdb_condition; 23 | struct ovsdb_row; 24 | struct ovsdb_row_set; 25 | struct ovsdb_table; 26 | struct ovsdb_txn; 27 | 28 | void ovsdb_query(struct ovsdb_table *, const struct ovsdb_condition *, 29 | bool (*output_row)(const struct ovsdb_row *, void *aux), 30 | void *aux); 31 | void ovsdb_query_row_set(struct ovsdb_table *, const struct ovsdb_condition *, 32 | struct ovsdb_row_set *); 33 | void ovsdb_query_distinct(struct ovsdb_table *, const struct ovsdb_condition *, 34 | const struct ovsdb_column_set *, 35 | struct ovsdb_row_set *); 36 | 37 | #endif /* ovsdb/query.h */ 38 | -------------------------------------------------------------------------------- /utilities/bugtool/ovs-bugtool.8: -------------------------------------------------------------------------------- 1 | .\" -*- nroff -*- 2 | .de IQ 3 | . br 4 | . ns 5 | . IP "\\$1" 6 | .. 7 | .TH ovs\-bugtool 8 "June 2011" "Open vSwitch" "Open vSwitch Manual" 8 | .\" This program's name: 9 | .ds PN ovs\-bugtool 10 | . 11 | .SH NAME 12 | ovs\-bugtool \- Open vSwitch bug reporting utility 13 | . 14 | .SH SYNOPSIS 15 | .B ovs\-bugtool 16 | . 17 | .SH DESCRIPTION 18 | Generate a debug bundle with useful information about Open vSwitch on this 19 | system and places it in \fB/var/log/ovs-bugtool\fR. 20 | . 21 | .SH OPTIONS 22 | . 23 | .IP "\fB\-\-all\fR" 24 | Use all available capabilities. 25 | . 26 | .IP "\fB\-\-capabilities\fR" 27 | List \fBovs\-bugtool\fR capabilities. 28 | . 29 | .IP "\fB\-\-debug\fR" 30 | Print verbose debugging output. 31 | . 32 | .IP "\fB\-\-entries=\fIlist\fR" 33 | Use the capabilities specified in a comma-separated list. 34 | . 35 | .IP "\fB\-\-output=\fIfiletype\fR" 36 | Generate a debug bundle with the specified file type. Options include 37 | \fBtar\fR, \fBtar.gz\fR, \fBtar.bz2\fR, and \fBzip\fR. 38 | . 39 | .IP "\fB\-\-silent\fR" 40 | Suppress output. 41 | . 42 | .IP "\fB\-\-unlimited\fR" 43 | Do not exclude files which are too large. 44 | . 45 | .IP "\fB\-\-yestoall\fR" 46 | Answer yes to all prompts. 47 | . 48 | .SH BUGS 49 | \fBovs\-bugtool\fR makes many assumptions about file locations and the 50 | availability of system utilities. It has been tested on Debian and 51 | Red Hat and derived distributions. On other distributions it is 52 | likely to be less useful. 53 | -------------------------------------------------------------------------------- /ovsdb/ovsdbmonitor/OVEStandard.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2011 Nicira Networks. 2 | # Copyright (c) 2010 Citrix Systems, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at: 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | import os, re, struct, sys, time, types, uuid 17 | from copy import deepcopy 18 | from pprint import pprint 19 | 20 | # Set globalForcePySide to True to use PySide instead of PyQt if both are installed 21 | globalForcePySide = False 22 | 23 | try: 24 | import ovs.json 25 | except Exception, e: 26 | print('+++ OVS JSON module is required\n') 27 | raise 28 | 29 | try: 30 | if globalForcePySide: 31 | print('Forcing use of PySide') 32 | raise Exception() 33 | from PyQt4.QtCore import Qt, QVariant 34 | from PyQt4 import QtCore, QtGui 35 | except: 36 | try: 37 | from PySide.QtCore import Qt, QVariant 38 | from PySide import QtCore, QtGui 39 | except Exception, e: 40 | print('+++ This application requires either PyQt4 or PySide\n') 41 | raise 42 | 43 | -------------------------------------------------------------------------------- /lib/compiler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef COMPILER_H 18 | #define COMPILER_H 1 19 | 20 | #if __GNUC__ && !__CHECKER__ 21 | #define NO_RETURN __attribute__((__noreturn__)) 22 | #define OVS_UNUSED __attribute__((__unused__)) 23 | #define PRINTF_FORMAT(FMT, ARG1) __attribute__((__format__(printf, FMT, ARG1))) 24 | #define STRFTIME_FORMAT(FMT) __attribute__((__format__(__strftime__, FMT, 0))) 25 | #define MALLOC_LIKE __attribute__((__malloc__)) 26 | #define ALWAYS_INLINE __attribute__((always_inline)) 27 | #define WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) 28 | #define SENTINEL(N) __attribute__((sentinel(N))) 29 | #else 30 | #define NO_RETURN 31 | #define OVS_UNUSED 32 | #define PRINTF_FORMAT(FMT, ARG1) 33 | #define STRFTIME_FORMAT(FMT) 34 | #define MALLOC_LIKE 35 | #define ALWAYS_INLINE 36 | #define WARN_UNUSED_RESULT 37 | #define SENTINEL(N) 38 | #endif 39 | 40 | #endif /* compiler.h */ 41 | -------------------------------------------------------------------------------- /utilities/ovs-parse-leaks.8: -------------------------------------------------------------------------------- 1 | .TH ovs\-parse\-leaks 8 "August 2010" "Open vSwitch" "Open vSwitch Manual" 2 | . 3 | .SH NAME 4 | ovs\-parse\-leaks \- parses OVS leak checker log files 5 | . 6 | .SH SYNOPSIS 7 | \fBovs\-parse\-leaks\fR [\fIbinary\fR] \fB< \fIlog\fR 8 | . 9 | .SH DESCRIPTION 10 | Many Open vSwitch daemons accept a \fB\-\-check\-leaks\fR option that 11 | writes information about memory allocation and deallocation to a log 12 | file. \fBovs\-parse\-leaks\fR parses log files produced by this 13 | option and prints a summary of the results. The most interesting part 14 | of the output is a list of memory blocks that were allocated but not 15 | freed, which Open vSwitch developers can use to find and fix memory 16 | leaks. 17 | .PP 18 | The log file must be supplied on standard input. The binary that 19 | produced the output should be supplied as the sole non-option 20 | argument. For best results, the binary should have debug symbols. 21 | . 22 | .SH OPTIONS 23 | .TP 24 | \fB\-\-help\fR 25 | Prints a usage message and exits. 26 | .SH BUGS 27 | The output can be hard to interpret, especially for a daemon that does 28 | not exit in normal operation. Using \fBovs\-appctl\fR(8) to invoke 29 | the \fBexit\fR command that some Open vSwitch daemons support 30 | sometimes helps with this. 31 | .PP 32 | \fBovs\-parse\-leaks\fR usually incorrectly reports one or more ``bad 33 | frees of not-allocated address'' errors at the beginning of output. 34 | These reflect frees of data that were allocated before the leak 35 | checker was turned on during program initialization. 36 | -------------------------------------------------------------------------------- /ovsdb/ovsdbmonitor/OVELogger.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 Citrix Systems, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at: 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from OVEStandard import * 16 | 17 | class OVELogger(QtCore.QObject): 18 | instance = None 19 | def __init__(self): 20 | QtCore.QObject.__init__(self) 21 | self.contents = [] 22 | self.loggers = [] 23 | 24 | @classmethod 25 | def Inst(cls): 26 | if cls.instance is None: 27 | cls.instance = OVELogger() 28 | return cls.instance 29 | 30 | def reset(self): 31 | self.contents = [] 32 | self.update() 33 | 34 | def logString(self, message): 35 | self.contents += [str(message)] 36 | if len(self.contents) > 500: 37 | self.contents = ['+++ Log truncated', ''] + self.contents[50:] 38 | self.update() 39 | 40 | def update(self): 41 | self.emit(QtCore.SIGNAL("logUpdated()")) 42 | 43 | def OVELog(message): 44 | OVELogger.Inst().logString(message) 45 | 46 | -------------------------------------------------------------------------------- /datapath/linux/compat/include/linux/mutex.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_MUTEX_WRAPPER_H 2 | #define __LINUX_MUTEX_WRAPPER_H 3 | 4 | 5 | #include 6 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) 7 | 8 | #include 9 | 10 | struct mutex { 11 | struct semaphore sema; 12 | }; 13 | 14 | #define mutex_init(mutex) init_MUTEX(&(mutex)->sema) 15 | #define mutex_destroy(mutex) do { } while (0) 16 | 17 | #define __MUTEX_INITIALIZER(name) \ 18 | __SEMAPHORE_INITIALIZER(name,1) 19 | 20 | #define DEFINE_MUTEX(mutexname) \ 21 | struct mutex mutexname = { __MUTEX_INITIALIZER(mutexname.sema) } 22 | 23 | /* 24 | * See kernel/mutex.c for detailed documentation of these APIs. 25 | * Also see Documentation/mutex-design.txt. 26 | */ 27 | static inline void mutex_lock(struct mutex *lock) 28 | { 29 | down(&lock->sema); 30 | } 31 | 32 | static inline int mutex_lock_interruptible(struct mutex *lock) 33 | { 34 | return down_interruptible(&lock->sema); 35 | } 36 | 37 | #define mutex_lock_nested(lock, subclass) mutex_lock(lock) 38 | #define mutex_lock_interruptible_nested(lock, subclass) mutex_lock_interruptible(lock) 39 | 40 | /* 41 | * NOTE: mutex_trylock() follows the spin_trylock() convention, 42 | * not the down_trylock() convention! 43 | */ 44 | static inline int mutex_trylock(struct mutex *lock) 45 | { 46 | return !down_trylock(&lock->sema); 47 | } 48 | 49 | static inline void mutex_unlock(struct mutex *lock) 50 | { 51 | up(&lock->sema); 52 | } 53 | #else 54 | 55 | #include_next 56 | 57 | #endif /* linux version < 2.6.16 */ 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /lib/vlan-bitmap.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Nicira Networks 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at: 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #ifndef VLAN_BITMAP_H 17 | #define VLAN_BITMAP_H 1 18 | 19 | #include 20 | #include 21 | #include "bitmap.h" 22 | 23 | /* A "VLAN bitmap" is a 4096-bit bitmap that represents a set. A 1-bit 24 | * indicates that the respective VLAN is a member of the set, a 0-bit indicates 25 | * that it is not. There is one wrinkle: NULL is a valid value that indicates 26 | * either that all VLANs are or are not members, depending on the vlan_bitmap. 27 | * 28 | * This is empirically a useful data structure. */ 29 | 30 | unsigned long *vlan_bitmap_from_array(const int64_t *vlans, size_t n_vlans); 31 | bool vlan_bitmap_equal(const unsigned long *a, const unsigned long *b); 32 | 33 | /* Returns a new copy of 'vlans'. */ 34 | static inline unsigned long * 35 | vlan_bitmap_clone(const unsigned long *vlans) 36 | { 37 | return vlans ? bitmap_clone(vlans, 4096) : NULL; 38 | } 39 | 40 | #endif /* lib/vlan-bitmap.h */ 41 | -------------------------------------------------------------------------------- /lib/fatal-signal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, 2009, 2010 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef FATAL_SIGNAL_H 18 | #define FATAL_SIGNAL_H 1 19 | 20 | #include 21 | 22 | /* Basic interface. */ 23 | void fatal_signal_add_hook(void (*hook_cb)(void *aux), 24 | void (*cancel_cb)(void *aux), void *aux, 25 | bool run_at_exit); 26 | void fatal_signal_fork(void); 27 | void fatal_signal_run(void); 28 | void fatal_signal_wait(void); 29 | 30 | /* Convenience functions for unlinking files upon termination. 31 | * 32 | * These functions also unlink the files upon normal process termination via 33 | * exit(). */ 34 | void fatal_signal_add_file_to_unlink(const char *); 35 | void fatal_signal_remove_file_to_unlink(const char *); 36 | int fatal_signal_unlink_file_now(const char *); 37 | 38 | /* Interface for other code that catches one of our signals and needs to pass 39 | * it through. */ 40 | void fatal_signal_handler(int sig_nr); 41 | 42 | #endif /* fatal-signal.h */ 43 | -------------------------------------------------------------------------------- /vswitchd/ovs-brcompatd.8.in: -------------------------------------------------------------------------------- 1 | .TH ovs\-brcompatd 8 "March 2009" "Open vSwitch" "Open vSwitch Manual" 2 | .ds PN ovs\-brcompatd 3 | . 4 | .SH NAME 5 | ovs\-brcompatd \- Bridge compatibility front-end for ovs\-vswitchd 6 | . 7 | .SH SYNOPSIS 8 | .B ovs\-brcompatd 9 | [\fIoptions\fR] 10 | . 11 | .SH DESCRIPTION 12 | A daemon that provides a legacy bridge front-end for \fBovs\-vswitchd\fR. It 13 | does this by listening for bridge ioctl commands (e.g., those generated by 14 | the \fBbrctl\fR program) to add or remove datapaths and the interfaces 15 | that attach to them. 16 | .PP 17 | .SH OPTIONS 18 | .IP "\fB\-\-appctl=\fIprogram\fR" 19 | Sets the name to the program that \fBovs\-brcompatd\fR runs to 20 | communicate with \fBovs\-vswitchd\fR. The default is 21 | \fBovs\-appctl\fR. Unless \fIprogram\fR contains \fB/\fR, 22 | \fBovs\-brcompatd\fR will search the \fBPATH\fR environment variable 23 | to find it. 24 | . 25 | .IP "\fB\-\-vsctl=\fIprogram\fR" 26 | Sets the name to the program that \fBovs\-brcompatd\fR runs to 27 | communicate with \fBovsdb\-server\fR. The default is 28 | \fBovs\-vsctl\fR. Unless \fIprogram\fR contains \fB/\fR, 29 | \fBovs\-brcompatd\fR will search the \fBPATH\fR environment variable 30 | to find it. 31 | . 32 | .ds DD 33 | .so lib/daemon.man 34 | .so lib/vlog.man 35 | .so lib/common.man 36 | .so lib/leak-checker.man 37 | . 38 | .SH NOTES 39 | \fBovs\-brcompatd\fR requires the \fBbrcompat_mod.ko\fR kernel module to be 40 | loaded. 41 | .SH "SEE ALSO" 42 | .BR ovs\-appctl (8), 43 | .BR ovs\-vsctl (8), 44 | .BR ovs\-vswitchd (8), 45 | .BR ovsdb\-server (1), 46 | \fBINSTALL.bridge\fR in the Open vSwitch distribution. 47 | -------------------------------------------------------------------------------- /python/ovs/automake.mk: -------------------------------------------------------------------------------- 1 | run_python = PYTHONPATH=$(top_srcdir)/python:$$PYTHON_PATH $(PYTHON) 2 | 3 | ovs_pyfiles = \ 4 | python/ovs/__init__.py \ 5 | python/ovs/daemon.py \ 6 | python/ovs/db/__init__.py \ 7 | python/ovs/db/data.py \ 8 | python/ovs/db/error.py \ 9 | python/ovs/db/idl.py \ 10 | python/ovs/db/parser.py \ 11 | python/ovs/db/schema.py \ 12 | python/ovs/db/types.py \ 13 | python/ovs/fatal_signal.py \ 14 | python/ovs/json.py \ 15 | python/ovs/jsonrpc.py \ 16 | python/ovs/ovsuuid.py \ 17 | python/ovs/poller.py \ 18 | python/ovs/process.py \ 19 | python/ovs/reconnect.py \ 20 | python/ovs/socket_util.py \ 21 | python/ovs/stream.py \ 22 | python/ovs/timeval.py \ 23 | python/ovs/util.py 24 | EXTRA_DIST += $(ovs_pyfiles) python/ovs/dirs.py 25 | 26 | if HAVE_PYTHON 27 | nobase_pkgdata_DATA = $(ovs_pyfiles) 28 | ovs-install-data-local: 29 | $(MKDIR_P) python/ovs 30 | (echo "import os" && \ 31 | echo 'PKGDATADIR = os.environ.get("OVS_PKGDATADIR", """$(pkgdatadir)""")' && \ 32 | echo 'RUNDIR = os.environ.get("OVS_RUNDIR", """@RUNDIR@""")' && \ 33 | echo 'LOGDIR = os.environ.get("OVS_LOGDIR", """@LOGDIR@""")' && \ 34 | echo 'BINDIR = os.environ.get("OVS_BINDIR", """$(bindir)""")') \ 35 | > python/ovs/dirs.py.tmp 36 | $(MKDIR_P) $(DESTDIR)$(pkgdatadir)/python/ovs 37 | $(INSTALL_DATA) python/ovs/dirs.py.tmp $(DESTDIR)$(pkgdatadir)/python/ovs/dirs.py 38 | rm python/ovs/dirs.py.tmp 39 | else 40 | ovs-install-data-local: 41 | @: 42 | endif 43 | install-data-local: ovs-install-data-local 44 | 45 | UNINSTALL_LOCAL += ovs-uninstall-local 46 | ovs-uninstall-local: 47 | rm -f $(DESTDIR)$(pkgdatadir)/python/ovs/dirs.py 48 | -------------------------------------------------------------------------------- /lib/type-props.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, 2011 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef TYPE_PROPS_H 18 | #define TYPE_PROPS_H 1 19 | 20 | #include 21 | 22 | #define TYPE_IS_INTEGER(TYPE) ((TYPE) 1.5 == (TYPE) 1) 23 | #define TYPE_IS_SIGNED(TYPE) ((TYPE) 1 > (TYPE) -1) 24 | #define TYPE_VALUE_BITS(TYPE) (sizeof(TYPE) * CHAR_BIT - TYPE_IS_SIGNED(TYPE)) 25 | #define TYPE_MINIMUM(TYPE) (TYPE_IS_SIGNED(TYPE) \ 26 | ? ~(TYPE)0 << TYPE_VALUE_BITS(TYPE) \ 27 | : 0) 28 | #define TYPE_MAXIMUM(TYPE) (TYPE_IS_SIGNED(TYPE) \ 29 | ? ~(~(TYPE)0 << TYPE_VALUE_BITS(TYPE)) \ 30 | : (TYPE)-1) 31 | 32 | /* Number of decimal digits required to format an integer of the given TYPE. 33 | * Includes space for a sign, if TYPE is signed, but not for a null 34 | * terminator. 35 | * 36 | * The value is an overestimate. */ 37 | #define INT_STRLEN(TYPE) (TYPE_IS_SIGNED(TYPE) + TYPE_VALUE_BITS(TYPE) / 3 + 1) 38 | 39 | #endif /* type-props.h */ 40 | -------------------------------------------------------------------------------- /python/ovs/process.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010, 2011 Nicira Networks 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at: 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import os 16 | import signal 17 | 18 | def _signal_status_msg(type_, signr): 19 | s = "%s by signal %d" % (type_, signr) 20 | for name in signal.__dict__: 21 | if name.startswith("SIG") and getattr(signal, name) == signr: 22 | return "%s (%s)" % (s, name) 23 | return s 24 | 25 | def status_msg(status): 26 | """Given 'status', which is a process status in the form reported by 27 | waitpid(2) and returned by process_status(), returns a string describing 28 | how the process terminated.""" 29 | if os.WIFEXITED(status): 30 | s = "exit status %d" % os.WEXITSTATUS(status) 31 | elif os.WIFSIGNALED(status): 32 | s = _signal_status_msg("killed", os.WTERMSIG(status)) 33 | elif os.WIFSTOPPED(status): 34 | s = _signal_status_msg("stopped", os.WSTOPSIG(status)) 35 | else: 36 | s = "terminated abnormally (%x)" % status 37 | if os.WCOREDUMP(status): 38 | s += ", core dumped" 39 | return s 40 | -------------------------------------------------------------------------------- /datapath/Modules.mk: -------------------------------------------------------------------------------- 1 | # Some modules should be built and distributed, e.g. openvswitch. 2 | # 3 | # Some modules should be distributed but not built, e.g. we do not build 4 | # veth if the kernel in question already has it. 5 | # 6 | # Some modules should be built but not distributed, e.g. third-party 7 | # hwtable modules. 8 | both_modules = openvswitch 9 | build_modules = $(both_modules) # Modules to build 10 | dist_modules = $(both_modules) # Modules to distribute 11 | 12 | openvswitch_sources = \ 13 | actions.c \ 14 | checksum.c \ 15 | datapath.c \ 16 | dp_notify.c \ 17 | dp_sysfs_dp.c \ 18 | dp_sysfs_if.c \ 19 | flow.c \ 20 | loop_counter.c \ 21 | tunnel.c \ 22 | vlan.c \ 23 | vport.c \ 24 | vport-capwap.c \ 25 | vport-generic.c \ 26 | vport-gre.c \ 27 | vport-internal_dev.c \ 28 | vport-netdev.c \ 29 | vport-patch.c 30 | 31 | openvswitch_headers = \ 32 | actions.h \ 33 | checksum.h \ 34 | compat.h \ 35 | datapath.h \ 36 | dp_sysfs.h \ 37 | flow.h \ 38 | loop_counter.h \ 39 | tunnel.h \ 40 | vlan.h \ 41 | vport.h \ 42 | vport-generic.h \ 43 | vport-internal_dev.h \ 44 | vport-netdev.h 45 | 46 | openvswitch_extras = \ 47 | CAPWAP.txt 48 | 49 | dist_sources = $(foreach module,$(dist_modules),$($(module)_sources)) 50 | dist_headers = $(foreach module,$(dist_modules),$($(module)_headers)) 51 | dist_extras = $(foreach module,$(dist_modules),$($(module)_extras)) 52 | build_sources = $(foreach module,$(build_modules),$($(module)_sources)) 53 | build_headers = $(foreach module,$(build_modules),$($(module)_headers)) 54 | build_links = $(notdir $(build_sources)) 55 | build_objects = $(notdir $(patsubst %.c,%.o,$(build_sources))) 56 | -------------------------------------------------------------------------------- /ofproto/in-band.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef IN_BAND_H 18 | #define IN_BAND_H 1 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | struct flow; 25 | struct in_band; 26 | struct nlattr; 27 | struct ofpbuf; 28 | struct ofproto; 29 | 30 | int in_band_create(struct ofproto *, const char *local_name, 31 | struct in_band **); 32 | void in_band_destroy(struct in_band *); 33 | 34 | void in_band_set_queue(struct in_band *, int queue_id); 35 | void in_band_set_remotes(struct in_band *, 36 | const struct sockaddr_in *, size_t n); 37 | 38 | bool in_band_run(struct in_band *); 39 | void in_band_wait(struct in_band *); 40 | 41 | bool in_band_msg_in_hook(struct in_band *, const struct flow *, 42 | const struct ofpbuf *packet); 43 | bool in_band_rule_check(const struct flow *, 44 | const struct nlattr *odp_actions, size_t actions_len); 45 | 46 | #endif /* in-band.h */ 47 | -------------------------------------------------------------------------------- /debian/openvswitch-controller.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # postinst script for openvswitch-controller 3 | # 4 | # see: dh_installdeb(1) 5 | 6 | set -e 7 | 8 | # summary of how this script can be called: 9 | # * `configure' 10 | # * `abort-upgrade' 11 | # * `abort-remove' `in-favour' 12 | # 13 | # * `abort-remove' 14 | # * `abort-deconfigure' `in-favour' 15 | # `removing' 16 | # 17 | # for details, see http://www.debian.org/doc/debian-policy/ or 18 | # the debian-policy package 19 | 20 | 21 | case "$1" in 22 | configure) 23 | cd /etc/openvswitch-controller 24 | if ! test -e cacert.pem; then 25 | ln -s /usr/share/openvswitch/pki/switchca/cacert.pem cacert.pem 26 | fi 27 | if ! test -e privkey.pem || ! test -e cert.pem; then 28 | oldumask=$(umask) 29 | umask 077 30 | ovs-pki req+sign tmp controller >/dev/null 31 | mv tmp-privkey.pem privkey.pem 32 | mv tmp-cert.pem cert.pem 33 | mv tmp-req.pem req.pem 34 | chmod go+r cert.pem req.pem 35 | umask $oldumask 36 | fi 37 | ;; 38 | 39 | abort-upgrade|abort-remove|abort-deconfigure) 40 | ;; 41 | 42 | *) 43 | echo "postinst called with unknown argument \`$1'" >&2 44 | exit 1 45 | ;; 46 | esac 47 | 48 | #DEBHELPER# 49 | 50 | exit 0 51 | 52 | 53 | -------------------------------------------------------------------------------- /lib/ofp-print.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, 2009, 2011 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* OpenFlow protocol pretty-printer. */ 18 | 19 | #ifndef OFP_PRINT_H 20 | #define OFP_PRINT_H 1 21 | 22 | #include 23 | #include 24 | 25 | struct ofp_flow_mod; 26 | struct ofp_match; 27 | struct ds; 28 | union ofp_action; 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | void ofp_print(FILE *, const void *, size_t, int verbosity); 35 | void ofp_print_packet(FILE *stream, const void *data, size_t len, size_t total_len); 36 | 37 | void ofp_print_actions(struct ds *, const union ofp_action *, size_t); 38 | void ofp_print_match(struct ds *, const struct ofp_match *, int verbosity); 39 | 40 | char *ofp_to_string(const void *, size_t, int verbosity); 41 | char *ofp_match_to_string(const struct ofp_match *, int verbosity); 42 | char *ofp_packet_to_string(const void *data, size_t len, size_t total_len); 43 | char *ofp_message_type_to_string(uint8_t type); 44 | 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif /* ofp-print.h */ 51 | -------------------------------------------------------------------------------- /ofproto/fail-open.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef FAIL_OPEN_H 18 | #define FAIL_OPEN_H 1 19 | 20 | #include 21 | #include 22 | #include "flow.h" 23 | 24 | struct connmgr; 25 | struct fail_open; 26 | struct ofproto; 27 | 28 | /* Priority of the rule added by the fail-open subsystem when a switch enters 29 | * fail-open mode. This priority value uniquely identifies a fail-open flow 30 | * (OpenFlow priorities max out at 65535 and nothing else in Open vSwitch 31 | * creates flows with this priority). And "f0" is mnemonic for "fail open"! */ 32 | #define FAIL_OPEN_PRIORITY 0xf0f0f0 33 | 34 | struct fail_open *fail_open_create(struct ofproto *, struct connmgr *); 35 | void fail_open_destroy(struct fail_open *); 36 | void fail_open_wait(struct fail_open *); 37 | bool fail_open_is_active(const struct fail_open *); 38 | void fail_open_run(struct fail_open *); 39 | void fail_open_maybe_recover(struct fail_open *); 40 | void fail_open_flushed(struct fail_open *); 41 | 42 | #endif /* fail-open.h */ 43 | -------------------------------------------------------------------------------- /python/ovs/util.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010, 2011 Nicira Networks 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at: 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import os 16 | import os.path 17 | import sys 18 | 19 | PROGRAM_NAME = os.path.basename(sys.argv[0]) 20 | 21 | def abs_file_name(dir, file_name): 22 | """If 'file_name' starts with '/', returns a copy of 'file_name'. 23 | Otherwise, returns an absolute path to 'file_name' considering it relative 24 | to 'dir', which itself must be absolute. 'dir' may be None or the empty 25 | string, in which case the current working directory is used. 26 | 27 | Returns None if 'dir' is null and getcwd() fails. 28 | 29 | This differs from os.path.abspath() in that it will never change the 30 | meaning of a file name.""" 31 | if file_name.startswith('/'): 32 | return file_name 33 | else: 34 | if dir is None or dir == "": 35 | try: 36 | dir = os.getcwd() 37 | except OSError: 38 | return None 39 | 40 | if dir.endswith('/'): 41 | return dir + file_name 42 | else: 43 | return "%s/%s" % (dir, file_name) 44 | -------------------------------------------------------------------------------- /lib/leak-checker.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, 2009, 2011 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef LEAK_CHECKER_H 18 | #define LEAK_CHECKER_H 1 19 | 20 | #include 21 | 22 | #define LEAK_CHECKER_OPTION_ENUMS \ 23 | OPT_CHECK_LEAKS, \ 24 | OPT_LEAK_LIMIT 25 | #define LEAK_CHECKER_LONG_OPTIONS \ 26 | {"check-leaks", required_argument, NULL, OPT_CHECK_LEAKS}, \ 27 | {"leak-limit", required_argument, NULL, OPT_LEAK_LIMIT} 28 | #define LEAK_CHECKER_OPTION_HANDLERS \ 29 | case OPT_CHECK_LEAKS: \ 30 | leak_checker_start(optarg); \ 31 | break; \ 32 | case OPT_LEAK_LIMIT: \ 33 | leak_checker_set_limit(atol(optarg)); \ 34 | break; 35 | void leak_checker_start(const char *file_name); 36 | void leak_checker_set_limit(off_t limit); 37 | void leak_checker_stop(void); 38 | void leak_checker_claim(const void *); 39 | void leak_checker_usage(void); 40 | 41 | #endif /* leak-checker.h */ 42 | -------------------------------------------------------------------------------- /lib/ofp-parse.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, 2011 Nicira Networks. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at: 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* OpenFlow protocol string to flow parser. */ 18 | 19 | #ifndef OFP_PARSE_H 20 | #define OFP_PARSE_H 1 21 | 22 | #include 23 | #include 24 | #include 25 | #include "openflow/nicira-ext.h" 26 | 27 | struct list; 28 | struct ofpbuf; 29 | struct ofputil_flow_mod; 30 | struct ofputil_flow_stats_request; 31 | 32 | void parse_ofp_str(struct ofputil_flow_mod *, int command, const char *str_, 33 | bool verbose); 34 | 35 | void parse_ofp_flow_mod_str(struct list *packets, 36 | enum nx_flow_format *cur, bool *flow_mod_table_id, 37 | char *string, uint16_t command, bool verbose); 38 | bool parse_ofp_flow_mod_file(struct list *packets, 39 | enum nx_flow_format *cur, bool *flow_mod_table_id, 40 | FILE *, uint16_t command); 41 | 42 | void parse_ofp_flow_stats_request_str(struct ofputil_flow_stats_request *, 43 | bool aggregate, char *string); 44 | 45 | #endif /* ofp-parse.h */ 46 | -------------------------------------------------------------------------------- /lib/vlog-unixctl.man: -------------------------------------------------------------------------------- 1 | .SS "VLOG COMMANDS" 2 | These commands manage \fB\*(PN\fR's logging settings. 3 | .IP "\fBvlog/set\fR \fImodule\fR[\fB:\fIfacility\fR[\fB:\fIlevel\fR]]" 4 | Sets the logging level for \fImodule\fR in \fIfacility\fR to 5 | \fIlevel\fR: 6 | . 7 | .RS 8 | .IP \(bu 9 | \fImodule\fR may be any valid module name (as displayed by the 10 | \fB\-\-list\fR action on \fBovs\-appctl\fR(8)), or the special name 11 | \fBANY\fR to set the logging levels for all modules. 12 | . 13 | .IP \(bu 14 | \fIfacility\fR may be \fBsyslog\fR, \fBconsole\fR, or \fBfile\fR to 15 | set the levels for logging to the system log, the console, or a file 16 | respectively, or \fBANY\fR to set the logging levels for both 17 | facilities. If it is omitted, \fIfacility\fR defaults to \fBANY\fR. 18 | .IP 19 | The log level for the \fBfile\fR facility has no effect unless 20 | \fB\*(PN\fR was invoked with the \fB\-\-log\-file\fR option. 21 | .IP \(bu 22 | \fIlevel\fR must be one of \fBoff\fR, \fBemer\fR, \fBerr\fR, \fBwarn\fR, 23 | \fBinfo\fR, or 24 | \fBdbg\fR, designating the minimum severity of a message for it to be 25 | logged. If it is omitted, \fIlevel\fR defaults to \fBdbg\fR. 26 | .RE 27 | .IP "\fBvlog/set PATTERN:\fIfacility\fB:\fIpattern\fR" 28 | Sets the log pattern for \fIfacility\fR to \fIpattern\fR. Refer to 29 | \fBovs\-appctl\fR(8) for a description of the valid syntax for \fIpattern\fR. 30 | . 31 | .IP "\fBvlog/list\fR" 32 | Lists the supported logging modules and their current levels. 33 | . 34 | .IP "\fBvlog/reopen\fR" 35 | Causes \fB\*(PN\fR to close and reopen its log file. (This is useful 36 | after rotating log files, to cause a new log file to be used.) 37 | .IP 38 | This has no effect unless \fB\*(PN\fR was invoked with the 39 | \fB\-\-log\-file\fR option. 40 | -------------------------------------------------------------------------------- /datapath/dp_notify.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the terms of the GNU GPL version 2. 3 | * Copyright (c) 2007, 2008, 2009, 2010, 2011 Nicira Networks. 4 | * 5 | * Significant portions of this file may be copied from parts of the Linux 6 | * kernel, by Linus Torvalds and others. 7 | */ 8 | 9 | /* Handle changes to managed devices */ 10 | 11 | #include 12 | #include 13 | 14 | #include "datapath.h" 15 | #include "vport-internal_dev.h" 16 | #include "vport-netdev.h" 17 | 18 | static int dp_device_event(struct notifier_block *unused, unsigned long event, 19 | void *ptr) 20 | { 21 | struct net_device *dev = ptr; 22 | struct vport *vport; 23 | struct datapath *dp; 24 | 25 | if (is_internal_dev(dev)) 26 | vport = internal_dev_get_vport(dev); 27 | else 28 | vport = netdev_get_vport(dev); 29 | 30 | if (!vport) 31 | return NOTIFY_DONE; 32 | 33 | dp = vport->dp; 34 | 35 | switch (event) { 36 | case NETDEV_UNREGISTER: 37 | if (!is_internal_dev(dev)) { 38 | struct sk_buff *reply; 39 | 40 | dp_detach_port(vport); 41 | reply = ovs_vport_cmd_build_info(vport, 0, 0, 42 | OVS_VPORT_CMD_DEL); 43 | if (IS_ERR(reply)) { 44 | netlink_set_err(INIT_NET_GENL_SOCK, 0, 45 | dp_vport_multicast_group.id, 46 | PTR_ERR(reply)); 47 | break; 48 | } 49 | 50 | genl_notify(reply, dev_net(dev), 0, 51 | dp_vport_multicast_group.id, NULL, 52 | GFP_KERNEL); 53 | } 54 | break; 55 | 56 | case NETDEV_CHANGENAME: 57 | if (vport->port_no != OVSP_LOCAL) { 58 | dp_sysfs_del_if(vport); 59 | dp_sysfs_add_if(vport); 60 | } 61 | break; 62 | } 63 | return NOTIFY_DONE; 64 | } 65 | 66 | struct notifier_block dp_device_notifier = { 67 | .notifier_call = dp_device_event 68 | }; 69 | -------------------------------------------------------------------------------- /ofproto/ofproto-dpif-sflow.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, 2010 InMon Corp. 3 | * Copyright (c) 2009 Nicira Networks. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at: 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef OFPROTO_DPIF_SFLOW_H 19 | #define OFPROTO_DPIF_SFLOW_H 1 20 | 21 | #include 22 | #include "svec.h" 23 | 24 | struct dpif; 25 | struct dpif_upcall; 26 | struct flow; 27 | struct ofproto_sflow_options; 28 | 29 | struct dpif_sflow *dpif_sflow_create(struct dpif *); 30 | void dpif_sflow_destroy(struct dpif_sflow *); 31 | void dpif_sflow_set_options(struct dpif_sflow *, 32 | const struct ofproto_sflow_options *); 33 | void dpif_sflow_clear(struct dpif_sflow *); 34 | bool dpif_sflow_is_enabled(const struct dpif_sflow *); 35 | 36 | void dpif_sflow_add_port(struct dpif_sflow *, uint16_t ovs_port, 37 | const char *netdev_name); 38 | void dpif_sflow_del_port(struct dpif_sflow *, uint16_t ovs_port); 39 | 40 | void dpif_sflow_run(struct dpif_sflow *); 41 | void dpif_sflow_wait(struct dpif_sflow *); 42 | 43 | void dpif_sflow_received(struct dpif_sflow *, const struct dpif_upcall *, 44 | const struct flow *); 45 | 46 | #endif /* ofproto/ofproto-dpif-sflow.h */ 47 | -------------------------------------------------------------------------------- /utilities/ovs-pki-cgi.in: -------------------------------------------------------------------------------- 1 | #! @PERL@ 2 | 3 | # Copyright (c) 2008, 2009 Nicira Networks. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at: 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | use CGI; 18 | use Digest::SHA1; 19 | use Fcntl; 20 | 21 | $CGI::POST_MAX = 65536; # Limit POSTs to 64 kB. 22 | 23 | use strict; 24 | use warnings; 25 | 26 | my $pkidir = '@PKIDIR@'; 27 | my $q = new CGI; 28 | 29 | die unless $q->request_method() eq 'POST'; 30 | 31 | my $type = $q->param('type'); 32 | die unless defined $type; 33 | die unless $type eq 'switch' or $type eq 'controller'; 34 | 35 | my $req = $q->param('req'); 36 | die unless defined $req; 37 | die unless $req =~ /^-----BEGIN CERTIFICATE REQUEST-----$/m; 38 | die unless $req =~ /^-----END CERTIFICATE REQUEST-----$/m; 39 | 40 | my $digest = Digest::SHA1::sha1_hex($req); 41 | my $incoming = "$pkidir/${type}ca/incoming"; 42 | my $dst = "$incoming/$digest-req.pem"; 43 | 44 | sysopen(REQUEST, "$dst.tmp", O_RDWR | O_CREAT | O_EXCL, 0600) 45 | or die "sysopen $dst.tmp: $!"; 46 | print REQUEST $req; 47 | close(REQUEST) or die "close $dst.tmp: $!"; 48 | 49 | rename("$dst.tmp", $dst) or die "rename $dst.tmp to $dst: $!"; 50 | 51 | print $q->header('text/html', '204 No response'); 52 | 53 | # Local Variables: 54 | # mode: perl 55 | # End: 56 | --------------------------------------------------------------------------------