├── README.md └── openvswitch ├── Makefile ├── files └── etc │ └── init.d │ └── openvswitch.init └── patches ├── 0001-netdev-linux-Let-interface-flag-survive-internal-por.patch ├── 0002-netdev-linux-Use-unsigned-int-for-ifi_flags.patch ├── 0003-fix-macro-miniflow_push_uint8.patch └── 0004-datapath-linux-add-KCFLAGS-var-to-modules-Makefile.m.patch /README.md: -------------------------------------------------------------------------------- 1 | openvswitch 2 | =========== 3 | 4 | UPDATE: Works now with OpenWrt "Barrier Breaker" (Bleeding Edge) 5 | 6 | Open vSwitch 1.9.0 (OvS) package for OpenWrt 7 | 8 | Installation 9 | ------------ 10 | 11 | Install this as a feed! 12 | 13 | ### Installation in OpenWrt 14 | 15 | > cd $TOPDIR 16 | > 17 | > echo 'src-git openvswitch git://github.com/schuza/openvswitch.git' >> feeds.conf 18 | > 19 | > ./scripts/feeds update openvswitch 20 | > 21 | > ./scripts/feeds install -a -p openvswitch 22 | > 23 | > make menuconfig 24 | > 25 | > select Network -> openvswitch-switch, openvswitch-brcompat and openvswitch-controller 26 | > 27 | > echo '# CONFIG_KERNEL_BRIDGE is not set' >> .config 28 | 29 | 30 | 31 | Development 32 | ----------- 33 | 34 | Please fork on github and send pull requests. 35 | -------------------------------------------------------------------------------- /openvswitch/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2013 Julius Schulz-Zander 3 | # Copyright (C) 2014 OpenWrt.org 4 | # 5 | # This is free software, licensed under the GNU General Public License v2. 6 | # See /LICENSE for more information. 7 | # 8 | # $Id: Makefile $ 9 | 10 | include $(TOPDIR)/rules.mk 11 | 12 | PKG_NAME:=openvswitch 13 | 14 | PKG_RELEASE:=conntrack 15 | PKG_VERSION:=2.4.1 16 | PKG_RELEASE=$(PKG_SOURCE_VERSION) 17 | PKG_LICENSE:=Apache-2.0 18 | PKG_LICENSE_FILES:=COPYING 19 | PKG_USE_MIPS16:=0 20 | 21 | PKG_SOURCE_PROTO:=git 22 | PKG_SOURCE_URL:=https://github.com/openvswitch/ovs 23 | PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) 24 | PKG_SOURCE_VERSION:=63b0899453da247bfa23517e62c40b73762fd65e 25 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz 26 | 27 | LIB_VERSION:=1.0.0 28 | 29 | SUPPORTED_KERNELS:=LINUX_3_8||LINUX_3_10||LINUX_3_13||LINUX_3_14||LINUX_3_18||LINUX_4_0 30 | 31 | include $(INCLUDE_DIR)/package.mk 32 | include $(INCLUDE_DIR)/kernel.mk 33 | $(call include_mk, python-package.mk) 34 | 35 | PKG_FIXUP=libtool 36 | PKG_FIXUP:=autoreconf 37 | PKG_FIXUP:=patch-libtool 38 | PKG_FIXUP:=gettext-version 39 | 40 | define Package/openvswitch/Default 41 | SECTION:=net 42 | CATEGORY:=Network 43 | URL:=http://openvswitch.org/ 44 | MAINTAINER:=Alexandru Ardelean 45 | endef 46 | 47 | define Package/openvswitch/Default/description 48 | Open vSwitch is a production quality, multilayer, software-based, Ethernet 49 | virtual switch. It is designed to enable massive network automation through 50 | programmatic extension, while still supporting standard management interfaces 51 | and protocols (e.g. NetFlow, sFlow, SPAN, RSPAN, CLI, LACP, 802.1ag). In 52 | addition, it is designed to support distribution across multiple physical 53 | servers similar to VMware's vNetwork distributed vswitch or Cisco's Nexus 54 | 1000V. 55 | endef 56 | 57 | define Package/openvswitch 58 | $(call Package/openvswitch/Default) 59 | TITLE:=Open vSwitch Userspace Package 60 | DEPENDS:=+libpcap +libopenssl +librt +libatomic +kmod-openvswitch @($(SUPPORTED_KERNELS)) 61 | endef 62 | 63 | define Package/openvswitch/description 64 | Provides the main userspace components required for Open vSwitch to function. 65 | endef 66 | 67 | define Package/openvswitch-python 68 | $(call Package/openvswitch/Default) 69 | TITLE:=Open vSwitch Python Support 70 | DEPENDS:=@PACKAGE_openvswitch +PACKAGE_openvswitch:openvswitch +python 71 | endef 72 | 73 | define Package/openvswitch-python/description 74 | Provides bindings and libraries for using Python to manipulate/work with Open vSwitch. 75 | endef 76 | 77 | define Package/openvswitch-ipsec 78 | $(call Package/openvswitch/Default) 79 | TITLE:=Open vSwitch Userspace Package 80 | DEPENDS:=@PACKAGE_openvswitch +PACKAGE_openvswitch:openvswitch-python 81 | endef 82 | 83 | define Package/openvswitch-ipsec/description 84 | The ovs-monitor-ipsec script provides support for encrypting GRE tunnels with 85 | IPsec. 86 | endef 87 | 88 | define Package/openvswitch-benchmark 89 | $(call Package/openvswitch/Default) 90 | TITLE:=Open vSwitch Userspace Package 91 | DEPENDS:=@PACKAGE_openvswitch +PACKAGE_openvswitch:openvswitch 92 | endef 93 | 94 | define Package/openvswitch-benchmark/description 95 | Utility for running OpenVSwitch benchmarking 96 | endef 97 | 98 | define KernelPackage/openvswitch 99 | SECTION:=kernel 100 | CATEGORY:=Kernel modules 101 | SUBMENU:=Network Support 102 | TITLE:=Open vSwitch Kernel Package 103 | KCONFIG:=CONFIG_BRIDGE 104 | DEPENDS:=+kmod-l2tp +kmod-ipt-conntrack-extra +kmod-nf-conntrack-netlink +kmod-stp \ 105 | +kmod-ipv6 +kmod-gre +kmod-lib-crc32c +kmod-vxlan +kmod-nf-conntrack @($(SUPPORTED_KERNELS)) 106 | FILES:= \ 107 | $(PKG_BUILD_DIR)/datapath/linux/openvswitch.$(LINUX_KMOD_SUFFIX) 108 | AUTOLOAD:=$(call AutoLoad,21,openvswitch) 109 | endef 110 | 111 | define KernelPackage/openvswitch/description 112 | This package contains the Open vSwitch kernel moodule and bridge compat 113 | module. Furthermore, it supports OpenFlow. 114 | endef 115 | 116 | CONFIGURE_ARGS += --with-linux=$(LINUX_DIR) 117 | CONFIGURE_ARGS += --with-rundir=/var/run 118 | CONFIGURE_ARGS += --enable-ndebug 119 | CONFIGURE_ARGS += --disable-ssl 120 | CONFIGURE_ARGS += --enable-shared 121 | CONFIGURE_ARGS += --with-dbdir=/tmp/openvswitch 122 | 123 | TARGET_CFLAGS += -flto 124 | 125 | #PKG_FIXUP:=autoreconf 126 | 127 | define Build/Configure 128 | (cd $(PKG_BUILD_DIR); \ 129 | autoreconf -v --install --force || exit 1 \ 130 | ); 131 | $(call Build/Configure/Default,$(CONFIGURE_ARGS)) 132 | endef 133 | 134 | KCFLAGS= 135 | ifeq ($(CONFIG_GCC_VERSION_4_9),y) 136 | KCFLAGS:=-Wno-error=date-time 137 | endif 138 | 139 | define Build/Compile 140 | $(MAKE) -C $(PKG_BUILD_DIR) \ 141 | $(TARGET_CONFIGURE_OPTS) \ 142 | CFLAGS="-I$(PKG_BUILD_DIR)/lib $(TARGET_CFLAGS) -std=gnu99" \ 143 | LDFLAGS="-L$(PKG_BUILD_DIR)/lib $(TARGET_LDFLAGS)" \ 144 | LDFLAGS_MODULES="$(TARGET_LDFLAGS) -L$(PKG_BUILD_DIR)/lib" \ 145 | STAGING_DIR="$(STAGING_DIR)" \ 146 | DESTDIR="$(PKG_INSTALL_DIR)/usr" \ 147 | CROSS_COMPILE="$(TARGET_CROSS)" \ 148 | ARCH="$(LINUX_KARCH)" \ 149 | SUBDIRS="$(PKG_BUILD_DIR)/datapath/linux" \ 150 | PATH="$(TARGET_PATH)" \ 151 | EXTRA_CFLAGS="$(KCFLAGS)" \ 152 | KCC="$(KERNEL_CC)" 153 | endef 154 | 155 | #define Package/openvswitch/install 156 | # $(INSTALL_DIR) $(1)/etc/openvswitch 157 | define Package/openvswitch/install 158 | $(INSTALL_DIR) $(1)/etc/init.d 159 | $(INSTALL_BIN) ./files/etc/init.d/openvswitch.init $(1)/etc/init.d/openvswitch 160 | 161 | $(INSTALL_DIR) $(1)/usr/lib/ 162 | $(CP) $(PKG_BUILD_DIR)/lib/.libs/libsflow.so.$(LIB_VERSION) $(1)/usr/lib/ 163 | $(CP) $(PKG_BUILD_DIR)/lib/.libs/libopenvswitch.so.$(LIB_VERSION) $(1)/usr/lib/ 164 | $(CP) $(PKG_BUILD_DIR)/ofproto/.libs/libofproto.so.$(LIB_VERSION) $(1)/usr/lib/ 165 | $(CP) $(PKG_BUILD_DIR)/ovsdb/.libs/libovsdb.so.$(LIB_VERSION) $(1)/usr/lib/ 166 | $(CP) $(PKG_BUILD_DIR)/lib/.libs/libsflow.so.1 $(1)/usr/lib/ 167 | $(CP) $(PKG_BUILD_DIR)/lib/.libs/libopenvswitch.so.1 $(1)/usr/lib/ 168 | $(CP) $(PKG_BUILD_DIR)/ofproto/.libs/libofproto.so.1 $(1)/usr/lib/ 169 | $(CP) $(PKG_BUILD_DIR)/ovsdb/.libs/libovsdb.so.1 $(1)/usr/lib/ 170 | 171 | $(INSTALL_DIR) $(1)/usr/bin/ 172 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/utilities/.libs/ovs-appctl $(1)/usr/bin/ 173 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/utilities/.libs/ovs-ofctl $(1)/usr/bin/ 174 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/ovsdb/.libs/ovsdb-client $(1)/usr/bin/ 175 | 176 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/utilities/.libs/ovs-dpctl $(1)/usr/bin/ 177 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/utilities/.libs/ovs-vsctl $(1)/usr/bin/ 178 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/ovsdb/.libs/ovsdb-tool $(1)/usr/bin/ 179 | 180 | $(INSTALL_DIR) $(1)/usr/sbin/ 181 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/vswitchd/.libs/ovs-vswitchd $(1)/usr/sbin/ 182 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/ovsdb/.libs/ovsdb-server $(1)/usr/sbin/ 183 | 184 | $(INSTALL_DIR) $(1)/usr/share/openvswitch/ 185 | $(INSTALL_CONF) $(PKG_BUILD_DIR)/vswitchd/vswitch.ovsschema $(1)/usr/share/openvswitch/ 186 | endef 187 | 188 | define Package/openvswitch-python/install 189 | $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/ 190 | $(CP) $(PKG_BUILD_DIR)/python/ovs/ $(1)/usr/lib/python$(PYTHON_VERSION)/ 191 | endef 192 | 193 | define Package/openvswitch-ipsec/install 194 | $(INSTALL_DIR) $(1)/usr/sbin/ 195 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/debian/ovs-monitor-ipsec $(1)/usr/sbin/ 196 | endef 197 | 198 | define Package/openvswitch-benchmark/install 199 | $(INSTALL_DIR) $(1)/usr/bin/ 200 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/utilities/.libs/ovs-benchmark $(1)/usr/bin/ 201 | endef 202 | 203 | define Package/openvswitch/postinst 204 | #!/bin/sh 205 | [ -n "$${IPKG_INSTROOT}" ] || /etc/init.d/openvswitch enable || true 206 | endef 207 | 208 | $(eval $(call BuildPackage,openvswitch)) 209 | $(eval $(call BuildPackage,openvswitch-python)) 210 | $(eval $(call BuildPackage,openvswitch-ipsec)) 211 | $(eval $(call BuildPackage,openvswitch-benchmark)) 212 | $(eval $(call KernelPackage,openvswitch)) 213 | 214 | -------------------------------------------------------------------------------- /openvswitch/files/etc/init.d/openvswitch.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | # Copyright (C) 2013 Julius Schulz-Zander 3 | # Copyright (C) 2014 OpenWrt.org 4 | 5 | START=35 6 | USE_PROCD=1 7 | 8 | start_service() { 9 | [ -h /etc/openvswitch -a -e /etc/openvswitch ] || { 10 | rm -Rf /etc/openvswitch 11 | ln -s /tmp/openvswitch /etc/openvswitch 12 | } 13 | [ -x /tmp/openvswitch -a -r /tmp/openvswitch ] || { 14 | mkdir -p /tmp/openvswitch 15 | chmod 755 /tmp/openvswitch 16 | } 17 | [ -e /tmp/openvswitch/conf.db ] || { 18 | /usr/bin/ovsdb-tool create /tmp/openvswitch/conf.db /usr/share/openvswitch/vswitch.ovsschema 19 | } 20 | 21 | # ovsdb-server 22 | procd_open_instance 23 | procd_set_param command /usr/sbin/ovsdb-server 24 | procd_append_param command --remote=punix:/var/run/db.sock 25 | procd_append_param command --remote=db:Open_vSwitch,Open_vSwitch,manager_options 26 | procd_append_param command --pidfile=/var/run/ovsdb-server.pid 27 | procd_set_param respawn 28 | procd_append_param respawn 3600 29 | procd_append_param respawn 5 30 | procd_append_param respawn -1 31 | procd_set_param nice 32 | procd_append_param nice -10 33 | procd_close_instance 34 | 35 | # ovs-vswitchd 36 | procd_open_instance 37 | procd_set_param command /usr/sbin/ovs-vswitchd 38 | procd_append_param command --pidfile=/var/run/ovs-vswitchd.pid 39 | procd_set_param respawn 40 | procd_append_param respawn 3600 41 | procd_append_param respawn 5 42 | procd_append_param respawn -1 43 | procd_set_param nice 44 | procd_append_param nice -10 45 | procd_close_instance 46 | 47 | } 48 | 49 | -------------------------------------------------------------------------------- /openvswitch/patches/0001-netdev-linux-Let-interface-flag-survive-internal-por.patch: -------------------------------------------------------------------------------- 1 | From b9284f535e93c337ab21f330753e60e1038f9a27 Mon Sep 17 00:00:00 2001 2 | From: Helmut Schaa 3 | Date: Wed, 8 Jan 2014 13:48:49 +0100 4 | Subject: [PATCH 2/2] netdev-linux: Let interface flag survive internal port 5 | setup 6 | 7 | Due to a race condition when bringing up an internal port on Linux 8 | some interface flags (e.g. IFF_MULTICAST) are falsely reset. This 9 | happens because netlink events may be processed after the according 10 | netdev has been brought up (which sets interface flags). 11 | 12 | Fix this by reading the interface flags just before updating them 13 | if they have not been updated by from the kernel yet. 14 | 15 | Signed-off-by: Helmut Schaa 16 | --- 17 | lib/netdev-linux.c | 8 +++++++- 18 | 1 file changed, 7 insertions(+), 1 deletion(-) 19 | 20 | diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c 21 | index 9eaac33..423e72e 100644 22 | --- a/lib/netdev-linux.c 23 | +++ b/lib/netdev-linux.c 24 | @@ -2569,7 +2569,13 @@ update_flags(struct netdev_linux *netdev, enum netdev_flags off, 25 | unsigned int old_flags, new_flags; 26 | int error = 0; 27 | 28 | - old_flags = netdev->ifi_flags; 29 | + if (!(netdev->cache_valid & VALID_DRVINFO)) { 30 | + /* Most likely the debvice flags are not in sync yet, fetch them now */ 31 | + get_flags(&netdev->up, &old_flags); 32 | + } else { 33 | + old_flags = netdev->ifi_flags; 34 | + } 35 | + 36 | *old_flagsp = iff_to_nd_flags(old_flags); 37 | new_flags = (old_flags & ~nd_to_iff_flags(off)) | nd_to_iff_flags(on); 38 | if (new_flags != old_flags) { 39 | -- 40 | 1.8.1.4 41 | 42 | -------------------------------------------------------------------------------- /openvswitch/patches/0002-netdev-linux-Use-unsigned-int-for-ifi_flags.patch: -------------------------------------------------------------------------------- 1 | From 12edcd800d924f69630768eeece842373dee5bb0 Mon Sep 17 00:00:00 2001 2 | From: Helmut Schaa 3 | Date: Wed, 8 Jan 2014 13:48:33 +0100 4 | Subject: [PATCH 1/2] netdev-linux: Use unsigned int for ifi_flags 5 | 6 | ifi_flags is unsigned, the local equivalents should do the same. 7 | 8 | Signed-off-by: Helmut Schaa 9 | --- 10 | lib/netdev-linux.c | 2 +- 11 | 1 file changed, 1 insertion(+), 1 deletion(-) 12 | 13 | diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c 14 | index 9bdbbdf..9eaac33 100644 15 | --- a/lib/netdev-linux.c 16 | +++ b/lib/netdev-linux.c 17 | @@ -2566,7 +2566,7 @@ update_flags(struct netdev_linux *netdev, enum netdev_flags off, 18 | enum netdev_flags on, enum netdev_flags *old_flagsp) 19 | OVS_REQUIRES(netdev->mutex) 20 | { 21 | - int old_flags, new_flags; 22 | + unsigned int old_flags, new_flags; 23 | int error = 0; 24 | 25 | old_flags = netdev->ifi_flags; 26 | -- 27 | 1.8.1.4 28 | 29 | -------------------------------------------------------------------------------- /openvswitch/patches/0003-fix-macro-miniflow_push_uint8.patch: -------------------------------------------------------------------------------- 1 | Index: openvswitch-2.4.0/lib/flow.c 2 | =================================================================== 3 | --- openvswitch-2.4.0.orig/lib/flow.c 2015-04-09 16:06:51.000000000 +0200 4 | +++ openvswitch-2.4.0/lib/flow.c 2015-04-10 11:43:31.639775926 +0200 5 | @@ -183,7 +183,7 @@ 6 | { \ 7 | MINIFLOW_ASSERT(MF.data < MF.end && \ 8 | ((OFS) % 8 != 0 \ 9 | - || !(MF.map & (UINT64_MAX << (OFS) / 8)))) \ 10 | + || !(MF.map & (UINT64_MAX << (OFS) / 8)))); \ 11 | \ 12 | if ((OFS) % 8 == 0) { \ 13 | *(uint8_t *)MF.data = VALUE; \ 14 | -------------------------------------------------------------------------------- /openvswitch/patches/0004-datapath-linux-add-KCFLAGS-var-to-modules-Makefile.m.patch: -------------------------------------------------------------------------------- 1 | From deb44e6e9d64001562ee9395a2c8525848052394 Mon Sep 17 00:00:00 2001 2 | From: Alexandru Ardelean 3 | Date: Tue, 28 Oct 2014 11:03:53 +0200 4 | Subject: [PATCH] datapath/linux: add KCFLAGS var to modules Makefile.main.in 5 | 6 | This is mostly required because of GCC 4.9 which seems 7 | to error out with: 8 | openvswitch/datapath/linux/datapath.c:2108:10: 9 | error: macro "DATE" might prevent reproducible builds 10 | 11 | We would have wanted to add '-Wno-error=date-time' directly 12 | but that would be too specific, so we decided to add 13 | a generic make flag and configure it with what we need. 14 | 15 | Signed-off-by: Alexandru Ardelean 16 | --- 17 | datapath/linux/Makefile.main.in | 4 ++-- 18 | 1 file changed, 2 insertions(+), 2 deletions(-) 19 | 20 | diff --git a/datapath/linux/Makefile.main.in b/datapath/linux/Makefile.main.in 21 | index 88f144c..0b200b7 100644 22 | --- a/datapath/linux/Makefile.main.in 23 | +++ b/datapath/linux/Makefile.main.in 24 | @@ -67,10 +67,10 @@ ifeq (,$(wildcard $(CONFIG_FILE))) 25 | endif 26 | 27 | default: 28 | - $(MAKE) -C $(KSRC) M=$(builddir) modules 29 | + $(MAKE) -C $(KSRC) M=$(builddir) $(KCFLAGS) modules 30 | 31 | modules_install: 32 | - $(MAKE) -C $(KSRC) M=$(builddir) modules_install 33 | + $(MAKE) -C $(KSRC) M=$(builddir) $(KCFLAGS) modules_install 34 | depmod `sed -n 's/#define UTS_RELEASE "\([^"]*\)"/\1/p' $(KSRC)/include/generated/utsrelease.h` 35 | endif 36 | 37 | -- 38 | 1.8.4.5 39 | 40 | --------------------------------------------------------------------------------