Parcourir la source

openvswitch: initial feed at OpenVSwitch version 2.3

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Alexandru Ardelean il y a 10 ans
Parent
révision
8ecc0fb194

+ 207
- 0
net/openvswitch/Makefile Voir le fichier

@@ -0,0 +1,207 @@
1
+# 
2
+# Copyright (C) 2013 Julius Schulz-Zander <julius@net.t-labs.tu-berlin.de>
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:=1
15
+PKG_VERSION:=2.3.0
16
+PKG_RELEASE=$(PKG_SOURCE_VERSION)
17
+PKG_LICENSE:=Apache-2.0
18
+PKG_LICENSE_FILE:=COPYING
19
+
20
+PKG_SOURCE_PROTO:=git
21
+PKG_SOURCE_URL:=https://github.com/openvswitch/ovs
22
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
23
+PKG_SOURCE_VERSION:=2b70c4b929d18d1f36dcdeb71ea5c383cbb662e9
24
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
25
+
26
+include $(INCLUDE_DIR)/package.mk
27
+include $(INCLUDE_DIR)/kernel.mk
28
+
29
+PKG_FIXUP=libtool
30
+
31
+define Package/openvswitch/Default
32
+  SECTION:=net
33
+  CATEGORY:=Network
34
+  URL:=http://www.openvswitchswitch.org/
35
+  DEPENDS:=+libopenssl +librt +libpcap +libatomic
36
+  MAINTAINER:=Alexandru Ardelean <ardeleanalex@gmail.com>
37
+endef
38
+
39
+define Package/openvswitch/Default/description
40
+  Open vSwitch is a production quality, multilayer, software-based, Ethernet
41
+  virtual switch. It is designed to enable massive network automation through
42
+  programmatic extension, while still supporting standard management interfaces
43
+  and protocols (e.g. NetFlow, sFlow, SPAN, RSPAN, CLI, LACP, 802.1ag). In
44
+  addition, it is designed to support distribution across multiple physical
45
+  servers similar to VMware's vNetwork distributed vswitch or Cisco's Nexus
46
+  1000V.
47
+endef
48
+
49
+define Package/openvswitch-common
50
+  $(call Package/openvswitch/Default)
51
+  TITLE:=Open vSwitch Userspace Package
52
+  DEPENDS:=+libpcap +libopenssl +librt +kmod-openvswitch
53
+endef
54
+
55
+define Package/openvswitch-common/description
56
+  openvswitch-common provides components required by both openvswitch-switch and
57
+  openvswitch-controller.
58
+endef
59
+
60
+define Package/openvswitch-ipsec
61
+  $(call Package/openvswitch/Default)
62
+  TITLE:=Open vSwitch Userspace Package
63
+  DEPENDS:=+openvswitch-common
64
+endef
65
+
66
+define Package/openvswitch-ipsec/description
67
+  The ovs-monitor-ipsec script provides support for encrypting GRE tunnels with 
68
+  IPsec.
69
+endef
70
+
71
+define Package/openvswitch-benchmark
72
+  $(call Package/openvswitch/Default)
73
+  TITLE:=Open vSwitch Userspace Package
74
+  DEPENDS:=+openvswitch-common
75
+endef
76
+
77
+define Package/openvswitch-benchmark/description
78
+  Utility for running OpenVSwitch benchmarking
79
+endef
80
+
81
+define Package/openvswitch-controller
82
+  $(call Package/openvswitch/Default)
83
+  TITLE:=Open vSwitch Userspace Package
84
+  DEPENDS:=+openvswitch-common
85
+endef
86
+
87
+define Package/openvswitch-controller/description
88
+  The Open vSwitch controller enables OpenFlow switches that connect to it to
89
+  act as MAC-learning Ethernet switches.
90
+endef
91
+
92
+define Package/openvswitch-switch
93
+  $(call Package/openvswitch/Default)
94
+  TITLE:=Open vSwitch Userspace Package
95
+  DEPENDS:=+openvswitch-common
96
+endef
97
+
98
+define Package/openvswitch-switch/description
99
+  openvswitch-switch provides the userspace components and utilities for the
100
+  Open vSwitch kernel-based switch.
101
+endef
102
+
103
+define KernelPackage/openvswitch
104
+  SECTION:=kernel
105
+  CATEGORY:=Kernel modules
106
+  SUBMENU:=Network Support
107
+  TITLE:=Open vSwitch Kernel Package
108
+  KCONFIG:=CONFIG_BRIDGE
109
+  DEPENDS:=+kmod-stp +kmod-ipv6 +kmod-gre +kmod-lib-crc32c
110
+  FILES:= \
111
+	$(PKG_BUILD_DIR)/datapath/linux/openvswitch.$(LINUX_KMOD_SUFFIX)
112
+  AUTOLOAD:=$(call AutoLoad,21,openvswitch)
113
+endef
114
+
115
+define KernelPackage/openvswitch/description
116
+  This package contains the Open vSwitch kernel moodule and bridge compat
117
+  module. Furthermore, it supports OpenFlow.
118
+endef
119
+
120
+CONFIGURE_ARGS += --with-linux=$(LINUX_DIR) --with-rundir=/var/run
121
+CONFIGURE_ARGS += --enable-ndebug
122
+CONFIGURE_ARGS += --disable-ssl
123
+CONFIGURE_ARGS += --enable-shared
124
+
125
+TARGET_CFLAGS += -flto
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
+define Build/Compile
135
+	$(MAKE) -C $(PKG_BUILD_DIR) \
136
+		$(TARGET_CONFIGURE_OPTS) \
137
+		CFLAGS="-I$(PKG_BUILD_DIR)/lib $(TARGET_CFLAGS) -std=gnu99" \
138
+		LDFLAGS="-L$(PKG_BUILD_DIR)/lib $(TARGET_LDFLAGS)" \
139
+		LDFLAGS_MODULES="$(TARGET_LDFLAGS) -L$(PKG_BUILD_DIR)/lib" \
140
+		STAGING_DIR="$(STAGING_DIR)" \
141
+		DESTDIR="$(PKG_INSTALL_DIR)/usr" \
142
+		CROSS_COMPILE="$(TARGET_CROSS)" \
143
+		ARCH="$(LINUX_KARCH)" \
144
+		SUBDIRS="$(PKG_BUILD_DIR)/datapath/linux" \
145
+		PATH="$(TARGET_PATH)" \
146
+		KCC="$(KERNEL_CC)"
147
+endef
148
+
149
+define Package/openvswitch-ipsec/install
150
+	$(INSTALL_DIR) $(1)/usr/sbin/
151
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/debian/ovs-monitor-ipsec $(1)/usr/sbin/
152
+endef
153
+
154
+define Package/openvswitch-benchmark/install
155
+	$(INSTALL_DIR) $(1)/usr/bin/
156
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/utilities/.libs/ovs-benchmark $(1)/usr/bin/
157
+endef
158
+
159
+define Package/openvswitch-common/install
160
+	$(INSTALL_DIR) $(1)/etc/openvswitch
161
+
162
+	$(INSTALL_DIR) $(1)/etc/init.d
163
+	$(INSTALL_BIN) ./files/etc/init.d/openvswitch.init $(1)/etc/init.d/openvswitch
164
+
165
+	$(INSTALL_DIR) $(1)/usr/lib/
166
+	$(CP) $(PKG_BUILD_DIR)/lib/.libs/libsflow-$(PKG_VERSION).so  $(1)/usr/lib/
167
+	$(CP) $(PKG_BUILD_DIR)/lib/.libs/libopenvswitch-$(PKG_VERSION).so  $(1)/usr/lib/
168
+	$(CP) $(PKG_BUILD_DIR)/ofproto/.libs/libofproto-$(PKG_VERSION).so  $(1)/usr/lib/
169
+	$(CP) $(PKG_BUILD_DIR)/ovsdb/.libs/libovsdb-$(PKG_VERSION).so  $(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
+endef
176
+
177
+define Package/openvswitch-common/postinst
178
+#!/bin/sh
179
+[ -n "$${IPKG_INSTROOT}" ] || /etc/init.d/openvswitch enable || true
180
+endef
181
+
182
+define Package/openvswitch-controller/install
183
+	$(INSTALL_DIR) $(1)/usr/bin/
184
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/utilities/.libs/ovs-controller $(1)/usr/bin/
185
+endef
186
+
187
+define Package/openvswitch-switch/install
188
+	$(INSTALL_DIR) $(1)/usr/bin/
189
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/utilities/.libs/ovs-dpctl $(1)/usr/bin/
190
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/utilities/.libs/ovs-vsctl $(1)/usr/bin/
191
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/ovsdb/.libs/ovsdb-tool $(1)/usr/bin/
192
+
193
+	$(INSTALL_DIR) $(1)/usr/sbin/
194
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/vswitchd/.libs/ovs-vswitchd $(1)/usr/sbin/
195
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/ovsdb/.libs/ovsdb-server $(1)/usr/sbin/
196
+
197
+	$(INSTALL_DIR) $(1)/usr/share/openvswitch/
198
+	$(INSTALL_CONF) $(PKG_BUILD_DIR)/vswitchd/vswitch.ovsschema $(1)/usr/share/openvswitch/
199
+endef
200
+
201
+$(eval $(call BuildPackage,openvswitch-ipsec))
202
+$(eval $(call BuildPackage,openvswitch-common))
203
+$(eval $(call BuildPackage,openvswitch-controller))
204
+$(eval $(call BuildPackage,openvswitch-switch))
205
+$(eval $(call BuildPackage,openvswitch-benchmark))
206
+$(eval $(call KernelPackage,openvswitch))
207
+

+ 37
- 0
net/openvswitch/files/etc/init.d/openvswitch.init Voir le fichier

@@ -0,0 +1,37 @@
1
+#!/bin/sh /etc/rc.common
2
+# Copyright (C) 2013 Julius Schulz-Zander <julius@net.t-labs.tu-berlin.de>
3
+# Copyright (C) 2014 OpenWrt.org
4
+
5
+START=15
6
+USE_PROCD=1
7
+
8
+start_service() {
9
+	[ -x /var/run/openvswitch ] || mkdir -p /var/run/openvswitch
10
+	[ -e /etc/openvswitch/conf.db ] || {
11
+		/usr/bin/ovsdb-tool create /etc/openvswitch/conf.db /usr/share/openvswitch/vswitch.ovsschema
12
+	}
13
+
14
+	# ovsdb-server
15
+	procd_open_instance
16
+	procd_set_param command /usr/sbin/ovsdb-server
17
+	procd_append_param command --remote=punix:/var/run/db.sock
18
+	procd_append_param command --remote=db:Open_vSwitch,Open_vSwitch,manager_options
19
+	procd_append_param command --pidfile=/var/run/ovsdb-server.pid
20
+	procd_set_param respawn
21
+	procd_append_param respawn 3600
22
+	procd_append_param respawn 5
23
+	procd_append_param respawn -1
24
+	procd_close_instance
25
+
26
+	# ovs-vswitchd
27
+	procd_open_instance
28
+	procd_set_param command /usr/sbin/ovs-vswitchd
29
+	procd_append_param command --pidfile=/var/run/ovs-vswitchd.pid
30
+	procd_set_param respawn
31
+	procd_append_param respawn 3600
32
+	procd_append_param respawn 5
33
+	procd_append_param respawn -1
34
+	procd_close_instance
35
+
36
+}
37
+

+ 41
- 0
net/openvswitch/patches/0001-netdev-linux-Let-interface-flag-survive-internal-por.patch Voir le fichier

@@ -0,0 +1,41 @@
1
+From b9284f535e93c337ab21f330753e60e1038f9a27 Mon Sep 17 00:00:00 2001
2
+From: Helmut Schaa <helmut.schaa@googlemail.com>
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 <helmut.schaa@googlemail.com>
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
+

+ 28
- 0
net/openvswitch/patches/0002-netdev-linux-Use-unsigned-int-for-ifi_flags.patch Voir le fichier

@@ -0,0 +1,28 @@
1
+From 12edcd800d924f69630768eeece842373dee5bb0 Mon Sep 17 00:00:00 2001
2
+From: Helmut Schaa <helmut.schaa@googlemail.com>
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 <helmut.schaa@googlemail.com>
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
+

+ 36
- 0
net/openvswitch/patches/0003-lib-util.h-Disable-ovs_assert-when-build-with-NDEBUG.patch Voir le fichier

@@ -0,0 +1,36 @@
1
+From 34b51e26555d05c00b2320f943a645added5dae4 Mon Sep 17 00:00:00 2001
2
+From: Helmut Schaa <helmut.schaa@googlemail.com>
3
+Date: Mon, 9 Dec 2013 14:15:11 +0100
4
+Subject: [PATCH 5/6] lib/util.h: Disable ovs_assert when build with NDEBUG
5
+
6
+Reduces binary size. Use a static inline function instead of
7
+a macro to not get "unused variable" warning everywhere.
8
+
9
+Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
10
+---
11
+ lib/util.h | 5 +++++
12
+ 1 file changed, 5 insertions(+)
13
+
14
+diff --git a/lib/util.h b/lib/util.h
15
+index 5c23962..9e5866d 100644
16
+--- a/lib/util.h
17
++++ b/lib/util.h
18
+@@ -69,10 +69,15 @@
19
+  *   - Writes the failure message to the log.
20
+  *
21
+  *   - Not affected by NDEBUG. */
22
++#ifndef NDEBUG
23
+ #define ovs_assert(CONDITION)                                           \
24
+     if (!OVS_LIKELY(CONDITION)) {                                       \
25
+         ovs_assert_failure(SOURCE_LOCATOR, __func__, #CONDITION);       \
26
+     }
27
++#else
28
++static inline void ovs_assert(bool cond OVS_UNUSED) {}
29
++#endif
30
++
31
+ void ovs_assert_failure(const char *, const char *, const char *) NO_RETURN;
32
+ 
33
+ /* Casts 'pointer' to 'type' and issues a compiler warning if the cast changes
34
+-- 
35
+1.8.1.4
36
+