diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..559019f --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/openvswitch-2.0.0.tar.gz diff --git a/.openvswitch.metadata b/.openvswitch.metadata new file mode 100644 index 0000000..b820c5e --- /dev/null +++ b/.openvswitch.metadata @@ -0,0 +1 @@ +3ce3f0bb96bfc79fdaf7a325ca1287803324eae7 SOURCES/openvswitch-2.0.0.tar.gz diff --git a/README.md b/README.md deleted file mode 100644 index 98f42b4..0000000 --- a/README.md +++ /dev/null @@ -1,4 +0,0 @@ -The master branch has no content - -Look at the c7 branch if you are working with CentOS-7, or the c4/c5/c6 branch for CentOS-4, 5 or 6 -If you find this file in a distro specific branch, it means that no content has been checked in yet diff --git a/SOURCES/README.RHEL b/SOURCES/README.RHEL new file mode 100644 index 0000000..cb6ab88 --- /dev/null +++ b/SOURCES/README.RHEL @@ -0,0 +1,188 @@ +Red Hat network scripts integration +----------------------------------- + +The RPM packages for Open vSwitch provide some integration with Red +Hat's network scripts. Using this integration is optional. + +To use the integration for a Open vSwitch bridge or interface named +, create or edit /etc/sysconfig/network-scripts/ifcfg-. +This is a shell script that consists of a series of VARIABLE=VALUE +assignments. The following OVS-specific variable names are supported: + + - DEVICETYPE: Always set to "ovs". + + - TYPE: If this is "OVSBridge", then this file represents an OVS + bridge named . Otherwise, it represents a port on an OVS + bridge and TYPE must have one of the following values: + + * "OVSPort", if is a physical port (e.g. eth0) or + virtual port (e.g. vif1.0). + + * "OVSIntPort", if is an internal port (e.g. a tagged + VLAN). + + * "OVSBond", if is an OVS bond. + + * "OVSTunnel", if is an OVS tunnel. + + - OVS_BRIDGE: If TYPE is anything other than "OVSBridge", set to + the name of the OVS bridge to which the port should be attached. + + - OVS_OPTIONS: Optionally, extra options to set in the "Port" + table when adding the port to the bridge, as a sequence of + column[:key]=value options. For example, "tag=100" to make the + port an access port for VLAN 100. See the documentation of + "add-port" in ovs-vsctl(8) for syntax and the section on the + Port table in ovs-vswitchd.conf.db(5) for available options. + + - OVS_EXTRA: Optionally, additional ovs-vsctl commands, separated + by "--" (double dash). + + - BOND_IFACES: For "OVSBond" interfaces, a list of physical + interfaces to bond together. + + - OVS_TUNNEL_TYPE: For "OVSTunnel" interfaces, the type of the tunnel. + For example, "gre", "vxlan", etc. + + - OVS_TUNNEL_OPTIONS: For "OVSTunnel" interfaces, this field should be + used to specify the tunnel options like remote_ip, key, etc. + +Note +---- + +* "ifdown" on a bridge will not bring individual ports on the bridge +down. "ifup" on a bridge will not add ports to the bridge. This +behavior should be compatible with standard bridges (with +TYPE=Bridge). + +* If 'ifup' on an interface is called multiple times, one can see +"RTNETLINK answers: File exists" printed on the console. This comes from +ifup-eth trying to add zeroconf route multiple times and is harmless. + +Examples +-------- + +Standalone bridge: + +==> ifcfg-ovsbridge0 <== +DEVICE=ovsbridge0 +ONBOOT=yes +DEVICETYPE=ovs +TYPE=OVSBridge +BOOTPROTO=static +IPADDR=A.B.C.D +NETMASK=X.Y.Z.0 +HOTPLUG=no + +Enable DHCP on the bridge: +* Needs OVSBOOTPROTO instead of BOOTPROTO. +* All the interfaces that can reach the DHCP server +as a space separated list in OVSDHCPINTERFACES. + +DEVICE=ovsbridge0 +ONBOOT=yes +DEVICETYPE=ovs +TYPE=OVSBridge +OVSBOOTPROTO="dhcp" +OVSDHCPINTERFACES="eth0" +HOTPLUG=no + + +Adding Internal Port to ovsbridge0: + +==> ifcfg-intbr0 <== +DEVICE=intbr0 +ONBOOT=yes +DEVICETYPE=ovs +TYPE=OVSIntPort +OVS_BRIDGE=ovsbridge0 +HOTPLUG=no + + +Internal Port with fixed IP address: + +DEVICE=intbr0 +ONBOOT=yes +DEVICETYPE=ovs +TYPE=OVSIntPort +OVS_BRIDGE=ovsbridge0 +BOOTPROTO=static +IPADDR=A.B.C.D +NETMASK=X.Y.Z.0 +HOTPLUG=no + +Internal Port with DHCP: +* Needs OVSBOOTPROTO or BOOTPROTO. +* All the interfaces that can reach the DHCP server +as a space separated list in OVSDHCPINTERFACES. + +DEVICE=intbr0 +ONBOOT=yes +DEVICETYPE=ovs +TYPE=OVSIntPort +OVS_BRIDGE=ovsbridge0 +OVSBOOTPROTO="dhcp" +OVSDHCPINTERFACES="eth0" +HOTPLUG=no + +Adding physical eth0 to ovsbridge0 described above: + +==> ifcfg-eth0 <== +DEVICE=eth0 +ONBOOT=yes +DEVICETYPE=ovs +TYPE=OVSPort +OVS_BRIDGE=ovsbridge0 +BOOTPROTO=none +HOTPLUG=no + + +Tagged VLAN interface on top of ovsbridge0: + +==> ifcfg-vlan100 <== +DEVICE=vlan100 +ONBOOT=yes +DEVICETYPE=ovs +TYPE=OVSIntPort +BOOTPROTO=static +IPADDR=A.B.C.D +NETMASK=X.Y.Z.0 +OVS_BRIDGE=ovsbridge0 +OVS_OPTIONS="tag=100" +OVS_EXTRA="set Interface $DEVICE external-ids:iface-id=$(hostname -s)-$DEVICE-vif" +HOTPLUG=no + + +Bonding: + +==> ifcfg-bond0 <== +DEVICE=bond0 +ONBOOT=yes +DEVICETYPE=ovs +TYPE=OVSBond +OVS_BRIDGE=ovsbridge0 +BOOTPROTO=none +BOND_IFACES="gige-1b-0 gige-1b-1 gige-21-0 gige-21-1" +OVS_OPTIONS="bond_mode=balance-tcp lacp=active" +HOTPLUG=no + +==> ifcfg-gige-* <== +DEVICE=gige-* +ONBOOT=yes +HOTPLUG=no + +An Open vSwitch Tunnel: + +==> ifcfg-gre0 <== +DEVICE=ovs-gre0 +ONBOOT=yes +DEVICETYPE=ovs +TYPE=OVSTunnel +OVS_BRIDGE=ovsbridge0 +OVS_TUNNEL_TYPE=gre +OVS_TUNNEL_OPTIONS="options:remote_ip=A.B.C.D" + +Reporting Bugs +-------------- + +Please report problems to bugs@openvswitch.org. diff --git a/SOURCES/openvswitch-fedora-package-fix-systemd-ordering-and-deps.patch b/SOURCES/openvswitch-fedora-package-fix-systemd-ordering-and-deps.patch new file mode 100644 index 0000000..ecdf69d --- /dev/null +++ b/SOURCES/openvswitch-fedora-package-fix-systemd-ordering-and-deps.patch @@ -0,0 +1,205 @@ +From f32488ec28a05e26e0298b3e10b3a7fe422fbf88 Mon Sep 17 00:00:00 2001 +From: Flavio Leitner +Date: Thu, 9 Jan 2014 01:04:33 -0200 +Subject: [PATCH] fedora package: fix systemd ordering and deps. + +There is a chicken and egg issue where common OVS +configuration uses a controller which is only accessible +via the network. So starting OVS before network.target +would break those configurations. + +However, the network doesn't come up after boot because +OVS isn't started until after the network scripts tries +to configure the ovs. + +This is partially fixed by commits: + commit: 602453000e28ec1076c0482ce13c284765a84409 + rhel: Automatically start openvswitch service before bringing an ovs interfa + + commit: 3214851c31538e8690e31f95702f8927a8c0838b + rhel: Add OVSREQUIRES to automatically bring up OpenFlow interface dependencies + +But still there is the dependency issue between network.target +and openvswitch which this patch fixes it. It provides two systemd +service units. One to run at any time (openvswitch-nonetwork.service) +which runs 'ovs-ctl start' and the other one (openvswith.service) to +run after network.target which works as a frontend to the admin. + +The openvswitch-nonetwork.service is used internally by the +'ifup-ovs/ifdown-ovs' scripts when adding or removing ports to +the bridge or when the openvswitch.service is enabled by the admin. + +Signed-off-by: Flavio Leitner +Signed-off-by: Gurucharan Shetty +--- + rhel/automake.mk | 4 +++- + rhel/etc_sysconfig_network-scripts_ifdown-ovs | 11 ++++++++++- + rhel/etc_sysconfig_network-scripts_ifup-ovs | 11 ++++++++++- + rhel/openvswitch-fedora.spec.in | 5 ++++- + ...ib_systemd_system_openvswitch-nonetwork.service | 13 ++++++++++++ + rhel/usr_lib_systemd_system_openvswitch.service | 7 ++++--- + ..._openvswitch_scripts_systemd_sysconfig.template | 23 ++++++++++++++++++++++ + 7 files changed, 67 insertions(+), 7 deletions(-) + create mode 100644 rhel/usr_lib_systemd_system_openvswitch-nonetwork.service + create mode 100644 rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template + +diff --git a/rhel/automake.mk b/rhel/automake.mk +index 2911e71..9cd9a41 100644 +--- a/rhel/automake.mk ++++ b/rhel/automake.mk +@@ -22,7 +22,9 @@ EXTRA_DIST += \ + rhel/openvswitch-fedora.spec \ + rhel/openvswitch-fedora.spec.in \ + rhel/usr_share_openvswitch_scripts_sysconfig.template \ +- rhel/usr_lib_systemd_system_openvswitch.service ++ rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template \ ++ rhel/usr_lib_systemd_system_openvswitch.service \ ++ rhel/usr_lib_systemd_system_openvswitch-nonetwork.service + + update_rhel_spec = \ + ($(ro_shell) && sed -e 's,[@]VERSION[@],$(VERSION),g') \ +diff --git a/rhel/etc_sysconfig_network-scripts_ifdown-ovs b/rhel/etc_sysconfig_network-scripts_ifdown-ovs +index d2a2f4b..32fddb5 100755 +--- a/rhel/etc_sysconfig_network-scripts_ifdown-ovs ++++ b/rhel/etc_sysconfig_network-scripts_ifdown-ovs +@@ -34,7 +34,16 @@ if [ ! -x ${OTHERSCRIPT} ]; then + OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-eth" + fi + +-[ -f /var/lock/subsys/openvswitch ] || /sbin/service openvswitch start ++SERVICE_UNIT=/usr/lib/systemd/system/openvswitch-nonetwork.service ++if [ -f $SERVICE_UNIT ] && [ -x /usr/bin/systemctl ]; then ++ if ! systemctl --quiet is-active openvswitch-nonetwork.service; then ++ systemctl start openvswitch-nonetwork.service ++ fi ++else ++ if [ ! -f /var/lock/subsys/openvswitch ]; then ++ /sbin/service openvswitch start ++ fi ++fi + + case "$TYPE" in + OVSBridge) +diff --git a/rhel/etc_sysconfig_network-scripts_ifup-ovs b/rhel/etc_sysconfig_network-scripts_ifup-ovs +index 8904c59..3c6b557 100755 +--- a/rhel/etc_sysconfig_network-scripts_ifup-ovs ++++ b/rhel/etc_sysconfig_network-scripts_ifup-ovs +@@ -60,7 +60,16 @@ fi + fi + done + +-[ -f /var/lock/subsys/openvswitch ] || /sbin/service openvswitch start ++SERVICE_UNIT=/usr/lib/systemd/system/openvswitch-nonetwork.service ++if [ -f $SERVICE_UNIT ] && [ -x /usr/bin/systemctl ]; then ++ if ! systemctl --quiet is-active openvswitch-nonetwork.service; then ++ systemctl start openvswitch-nonetwork.service ++ fi ++else ++ if [ ! -f /var/lock/subsys/openvswitch ]; then ++ /sbin/service openvswitch start ++ fi ++fi + + case "$TYPE" in + OVSBridge) +diff --git a/rhel/openvswitch-fedora.spec.in b/rhel/openvswitch-fedora.spec.in +index 27a3b03..8a5505d 100644 +--- a/rhel/openvswitch-fedora.spec.in ++++ b/rhel/openvswitch-fedora.spec.in +@@ -45,6 +45,8 @@ install -d -m 755 $RPM_BUILD_ROOT/etc + install -d -m 755 $RPM_BUILD_ROOT/etc/openvswitch + install -p -D -m 0644 rhel/usr_lib_systemd_system_openvswitch.service \ + $RPM_BUILD_ROOT%{_unitdir}/openvswitch.service ++install -p -D -m 0644 rhel/usr_lib_systemd_system_openvswitch-nonetwork.service \ ++ $RPM_BUILD_ROOT%{_unitdir}/openvswitch-nonetwork.service + install -m 755 rhel/etc_init.d_openvswitch \ + $RPM_BUILD_ROOT%{_datadir}/openvswitch/scripts/openvswitch.init + install -d -m 755 $RPM_BUILD_ROOT/etc/sysconfig +@@ -60,7 +62,7 @@ install -p -m 0755 rhel/etc_sysconfig_network-scripts_ifdown-ovs \ + $RPM_BUILD_ROOT/etc/sysconfig/network-scripts/ifdown-ovs + install -p -m 0755 rhel/etc_sysconfig_network-scripts_ifup-ovs \ + $RPM_BUILD_ROOT/etc/sysconfig/network-scripts/ifup-ovs +-install -p -D -m 0644 rhel/usr_share_openvswitch_scripts_sysconfig.template \ ++install -p -D -m 0644 rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template \ + $RPM_BUILD_ROOT/etc/sysconfig/openvswitch + install -d -m 755 $RPM_BUILD_ROOT/usr/share/openvswitch/scripts + +@@ -101,6 +103,7 @@ systemctl start openvswitch.service + %config /etc/sysconfig/openvswitch + %config /etc/logrotate.d/openvswitch + %{_unitdir}/openvswitch.service ++%{_unitdir}/openvswitch-nonetwork.service + %{_datadir}/openvswitch/scripts/openvswitch.init + %{_sysconfdir}/sysconfig/network-scripts/ifup-ovs + %{_sysconfdir}/sysconfig/network-scripts/ifdown-ovs +diff --git a/rhel/usr_lib_systemd_system_openvswitch-nonetwork.service b/rhel/usr_lib_systemd_system_openvswitch-nonetwork.service +new file mode 100644 +index 0000000..870b25e +--- /dev/null ++++ b/rhel/usr_lib_systemd_system_openvswitch-nonetwork.service +@@ -0,0 +1,13 @@ ++[Unit] ++Description=Open vSwitch Internal Unit ++After=syslog.target ++PartOf=openvswitch.service ++Wants=openvswitch.service ++ ++[Service] ++Type=oneshot ++RemainAfterExit=yes ++EnvironmentFile=-/etc/sysconfig/openvswitch ++ExecStart=/usr/share/openvswitch/scripts/ovs-ctl start \ ++ --system-id=random $OPTIONS ++ExecStop=/usr/share/openvswitch/scripts/ovs-ctl stop +diff --git a/rhel/usr_lib_systemd_system_openvswitch.service b/rhel/usr_lib_systemd_system_openvswitch.service +index f39d7e6..f0bc16f 100644 +--- a/rhel/usr_lib_systemd_system_openvswitch.service ++++ b/rhel/usr_lib_systemd_system_openvswitch.service +@@ -1,11 +1,12 @@ + [Unit] + Description=Open vSwitch +-After=syslog.target network.target ++After=syslog.target network.target openvswitch-nonetwork.service ++Requires=openvswitch-nonetwork.service + + [Service] + Type=oneshot +-ExecStart=/usr/share/openvswitch/scripts/openvswitch.init start +-ExecStop=/usr/share/openvswitch/scripts/openvswitch.init stop ++ExecStart=/bin/true ++ExecStop=/bin/true + RemainAfterExit=yes + + [Install] +diff --git a/rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template b/rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template +new file mode 100644 +index 0000000..3050a07 +--- /dev/null ++++ b/rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template +@@ -0,0 +1,23 @@ ++### Configuration options for openvswitch ++# ++# Enable core files: ++# --force-corefiles=yes ++# ++# Set "nice" priority at which to run ovsdb-server: ++# --ovsdb-server-priority=-10 ++# ++# Set "nice" priority at which to run ovsdb-vswitchd: ++# --ovs-vswitchd-priority=-10 ++# ++# Pass or not --mlockall option to ovs-vswitchd. ++# This option should be set to "yes" or "no". The default is "yes". ++# Enabling this option can avoid networking interruptions due to ++# system memory pressure in extraordinary situations, such as multiple ++# concurrent VM import operations. ++# --mlockall=yes ++# ++# Use valgrind: ++# --ovs-vswitchd-wrapper=valgrind ++# --ovsdb-server-wrapper=valgrind ++# ++OPTIONS="" +-- +1.8.4.2 + diff --git a/SOURCES/openvswitch-initscripts-add-tunnel-support.patch b/SOURCES/openvswitch-initscripts-add-tunnel-support.patch new file mode 100644 index 0000000..5bd9bc9 --- /dev/null +++ b/SOURCES/openvswitch-initscripts-add-tunnel-support.patch @@ -0,0 +1,29 @@ +diff --git a/rhel/etc_sysconfig_network-scripts_ifdown-ovs b/rhel/etc_sysconfig_network-scripts_ifdown-ovs +index 32fddb5..daa5786 100755 +--- a/rhel/etc_sysconfig_network-scripts_ifdown-ovs ++++ b/rhel/etc_sysconfig_network-scripts_ifdown-ovs +@@ -51,7 +51,7 @@ case "$TYPE" in + retval=$? + ovs-vsctl -t ${TIMEOUT} -- --if-exists del-br "$DEVICE" + ;; +- OVSPort|OVSIntPort|OVSBond) ++ OVSPort|OVSIntPort|OVSBond|OVSTunnel) + ${OTHERSCRIPT} ${CONFIG} $2 + retval=$? + ovs-vsctl -t ${TIMEOUT} -- --if-exists del-port "$OVS_BRIDGE" "$DEVICE" +diff --git a/rhel/etc_sysconfig_network-scripts_ifup-ovs b/rhel/etc_sysconfig_network-scripts_ifup-ovs +index 3c6b557..3f31c30 100755 +--- a/rhel/etc_sysconfig_network-scripts_ifup-ovs ++++ b/rhel/etc_sysconfig_network-scripts_ifup-ovs +@@ -126,6 +126,11 @@ case "$TYPE" in + ${OTHERSCRIPT} ${CONFIG} ${2} + OVSINTF=${DEVICE} /sbin/ifup "$OVS_BRIDGE" + ;; ++ OVSTunnel) ++ ifup_ovs_bridge ++ ovs-vsctl -t ${TIMEOUT} -- --may-exist add-port "$OVS_BRIDGE" "$DEVICE" $OVS_OPTIONS -- set Interface "$DEVICE" type=$OVS_TUNNEL_TYPE $OVS_TUNNEL_OPTIONS ${OVS_EXTRA+-- $OVS_EXTRA} ++ ${OTHERSCRIPT} ${CONFIG} ${2} ++ ;; + *) + echo $"Invalid OVS interface type $TYPE" + exit 1 diff --git a/SOURCES/openvswitch-rhel-Enable-DHCP-support-for-internal-ports.patch b/SOURCES/openvswitch-rhel-Enable-DHCP-support-for-internal-ports.patch new file mode 100644 index 0000000..9280906 --- /dev/null +++ b/SOURCES/openvswitch-rhel-Enable-DHCP-support-for-internal-ports.patch @@ -0,0 +1,90 @@ +From 490db96efaf89c63656b192d5ca287b0908a6c77 Mon Sep 17 00:00:00 2001 +From: Flavio Leitner +Date: Tue, 14 Jan 2014 00:22:07 -0200 +Subject: [PATCH] rhel: Enable DHCP support for internal ports. + +The current initscripts ifup-ovs brings up internal ports as +an ordinary ethernet device, so BOOTPROTO=dhcp|none does not +consider any OVS/bridge detail. + +Since DHCP requires a port in the bridge to reach the server, +bring up the required port before in the same way it does for +OVS bridge. + +Signed-off-by: Flavio Leitner +Signed-off-by: Gurucharan Shetty +--- + rhel/README.RHEL | 38 +++++++++++++++++++++++++++++ + rhel/etc_sysconfig_network-scripts_ifup-ovs | 7 +++++- + 2 files changed, 44 insertions(+), 1 deletion(-) + +diff --git a/rhel/README.RHEL b/rhel/README.RHEL +index 435772f..cb6ab88 100644 +--- a/rhel/README.RHEL ++++ b/rhel/README.RHEL +@@ -87,6 +87,44 @@ OVSBOOTPROTO="dhcp" + OVSDHCPINTERFACES="eth0" + HOTPLUG=no + ++ ++Adding Internal Port to ovsbridge0: ++ ++==> ifcfg-intbr0 <== ++DEVICE=intbr0 ++ONBOOT=yes ++DEVICETYPE=ovs ++TYPE=OVSIntPort ++OVS_BRIDGE=ovsbridge0 ++HOTPLUG=no ++ ++ ++Internal Port with fixed IP address: ++ ++DEVICE=intbr0 ++ONBOOT=yes ++DEVICETYPE=ovs ++TYPE=OVSIntPort ++OVS_BRIDGE=ovsbridge0 ++BOOTPROTO=static ++IPADDR=A.B.C.D ++NETMASK=X.Y.Z.0 ++HOTPLUG=no ++ ++Internal Port with DHCP: ++* Needs OVSBOOTPROTO or BOOTPROTO. ++* All the interfaces that can reach the DHCP server ++as a space separated list in OVSDHCPINTERFACES. ++ ++DEVICE=intbr0 ++ONBOOT=yes ++DEVICETYPE=ovs ++TYPE=OVSIntPort ++OVS_BRIDGE=ovsbridge0 ++OVSBOOTPROTO="dhcp" ++OVSDHCPINTERFACES="eth0" ++HOTPLUG=no ++ + Adding physical eth0 to ovsbridge0 described above: + + ==> ifcfg-eth0 <== +diff --git a/rhel/etc_sysconfig_network-scripts_ifup-ovs b/rhel/etc_sysconfig_network-scripts_ifup-ovs +index 3f31c30..0ee7b21 100755 +--- a/rhel/etc_sysconfig_network-scripts_ifup-ovs ++++ b/rhel/etc_sysconfig_network-scripts_ifup-ovs +@@ -115,7 +115,12 @@ case "$TYPE" in + OVSIntPort) + ifup_ovs_bridge + ovs-vsctl -t ${TIMEOUT} -- --may-exist add-port "$OVS_BRIDGE" "$DEVICE" $OVS_OPTIONS -- set Interface "$DEVICE" type=internal ${OVS_EXTRA+-- $OVS_EXTRA} +- ${OTHERSCRIPT} ${CONFIG} ${2} ++ if [ -n "${OVSDHCPINTERFACES}" ]; then ++ for _iface in ${OVSDHCPINTERFACES}; do ++ /sbin/ifup ${_iface} ++ done ++ fi ++ BOOTPROTO="${OVSBOOTPROTO}" ${OTHERSCRIPT} ${CONFIG} ${2} + ;; + OVSBond) + ifup_ovs_bridge +-- +1.8.4.2 + diff --git a/SOURCES/openvswitch-util-use-gcc-builtins-to-better-check-array-sizes.patch b/SOURCES/openvswitch-util-use-gcc-builtins-to-better-check-array-sizes.patch new file mode 100644 index 0000000..ae9945c --- /dev/null +++ b/SOURCES/openvswitch-util-use-gcc-builtins-to-better-check-array-sizes.patch @@ -0,0 +1,62 @@ +From b86fec9baa9c2ee03b28cfc8dad95c41bf9acaad Mon Sep 17 00:00:00 2001 +From: Flavio Leitner +Date: Wed, 2 Oct 2013 02:40:09 -0300 +Subject: [PATCH] util: use gcc builtins to better check array sizes + +GCC provides two useful builtin functions that can help +to improve array size checking during compilation. + +This patch contains no functional changes, but it makes +it easier to detect mistakes. + +Signed-off-by: Flavio Leitner +Signed-off-by: Ben Pfaff +--- + AUTHORS | 1 + + lib/util.h | 17 ++++++++++++++++- + 2 files changed, 17 insertions(+), 1 deletion(-) + +diff --git a/AUTHORS b/AUTHORS +index af34bfe..7a919a2 100644 +--- a/AUTHORS ++++ b/AUTHORS +@@ -32,6 +32,7 @@ Duffie Cooley dcooley@nicira.com + Ed Maste emaste at freebsd.org + Edward Tomasz NapieraƂa trasz@freebsd.org + Ethan Jackson ethan@nicira.com ++Flavio Leitner fbl@redhat.com + FUJITA Tomonori fujita.tomonori@lab.ntt.co.jp + Gaetano Catalli gaetano.catalli@gmail.com + Giuseppe Lettieri g.lettieri@iet.unipi.it +diff --git a/lib/util.h b/lib/util.h +index 0db41be..a899065 100644 +--- a/lib/util.h ++++ b/lib/util.h +@@ -87,8 +87,23 @@ void ovs_assert_failure(const char *, const char *, const char *) NO_RETURN; + + extern const char *program_name; + ++#define __ARRAY_SIZE_NOCHECK(ARRAY) (sizeof(ARRAY) / sizeof((ARRAY)[0])) ++#ifdef __GNUC__ ++/* return 0 for array types, 1 otherwise */ ++#define __ARRAY_CHECK(ARRAY) \ ++ !__builtin_types_compatible_p(typeof(ARRAY), typeof(&ARRAY[0])) ++ ++/* compile-time fail if not array */ ++#define __ARRAY_FAIL(ARRAY) (sizeof(char[-2*!__ARRAY_CHECK(ARRAY)])) ++#define __ARRAY_SIZE(ARRAY) \ ++ __builtin_choose_expr(__ARRAY_CHECK(ARRAY), \ ++ __ARRAY_SIZE_NOCHECK(ARRAY), __ARRAY_FAIL(ARRAY)) ++#else ++#define __ARRAY_SIZE(ARRAY) __ARRAY_SIZE_NOCHECK(ARRAY) ++#endif ++ + /* Returns the number of elements in ARRAY. */ +-#define ARRAY_SIZE(ARRAY) (sizeof ARRAY / sizeof *ARRAY) ++#define ARRAY_SIZE(ARRAY) __ARRAY_SIZE(ARRAY) + + /* Returns X / Y, rounding up. X must be nonnegative to round correctly. */ + #define DIV_ROUND_UP(X, Y) (((X) + ((Y) - 1)) / (Y)) +-- +1.8.4.2 + diff --git a/SOURCES/openvswitch.logrotate b/SOURCES/openvswitch.logrotate new file mode 100644 index 0000000..46b94b9 --- /dev/null +++ b/SOURCES/openvswitch.logrotate @@ -0,0 +1,17 @@ +# Copyright (C) 2009, 2010, 2011, 2012 Nicira, Inc. +# +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. This file is offered as-is, +# without warranty of any kind. + +/var/log/openvswitch/*.log { + sharedscripts + missingok + postrotate + # Tell Open vSwitch daemons to reopen their log files + for pidfile in `cd /var/run/openvswitch && echo *.pid`; do + ovs-appctl -t "${pidfile%%.pid}" vlog/reopen + done + endscript +} diff --git a/SOURCES/ovsdbmonitor.desktop b/SOURCES/ovsdbmonitor.desktop new file mode 100644 index 0000000..b0f8253 --- /dev/null +++ b/SOURCES/ovsdbmonitor.desktop @@ -0,0 +1,7 @@ +[Desktop Entry] +Name=Open vSwitch DB Monitor +Comment=Monitor and troubleshoot local or remote Open vSwitch instances +Exec=ovsdbmonitor +Terminal=false +Type=Application +Categories=System;Monitor; diff --git a/SPECS/openvswitch.spec b/SPECS/openvswitch.spec new file mode 100644 index 0000000..f92412d --- /dev/null +++ b/SPECS/openvswitch.spec @@ -0,0 +1,427 @@ +%global _hardened_build 1 + + +# This provides a way for distros that doesn't provide +# python-twisted-conch to disable building of ovsdbmonitor +# by default. You can override by passing --with ovsdbmonitor +# or --without ovsdbmonitor while building the RPM. +%define _pkg_ovsdbmonitor 0 + +%if %{?_with_ovsdbmonitor: 1}%{!?_with_ovsdbmonitor: 0} +%define with_ovsdbmonitor 1 +%else +%define with_ovsdbmonitor %{?_without_ovsdbmonitor: 0}%{!?_without_ovsdbmonitor: %{_pkg_ovsdbmonitor}} +%endif + +Name: openvswitch +Version: 2.0.0 +Release: 7%{?dist} +Summary: Open vSwitch daemon/database/utilities + +# Nearly all of openvswitch is ASL 2.0. The bugtool is LGPLv2+, and the +# lib/sflow*.[ch] files are SISSL +# datapath/ is GPLv2 (although not built into any of the binary packages) +# python/compat is Python (although not built into any of the binary packages) +License: ASL 2.0 and LGPLv2+ and SISSL +URL: http://openvswitch.org +Source0: http://openvswitch.org/releases/%{name}-%{version}.tar.gz +Source3: openvswitch.logrotate +Source6: ovsdbmonitor.desktop +Source9: README.RHEL + +Patch1: openvswitch-util-use-gcc-builtins-to-better-check-array-sizes.patch +Patch2: openvswitch-fedora-package-fix-systemd-ordering-and-deps.patch +Patch3: openvswitch-initscripts-add-tunnel-support.patch +Patch4: openvswitch-rhel-Enable-DHCP-support-for-internal-ports.patch + +ExcludeArch: ppc + +BuildRequires: systemd-units openssl openssl-devel +BuildRequires: python python-twisted-core python-zope-interface PyQt4 +BuildRequires: desktop-file-utils +BuildRequires: groff graphviz +%if %{with_ovsdbmonitor} +BuildRequires: python-twisted-conch +%endif + +Requires: openssl iproute module-init-tools + +Requires(post): systemd-units +Requires(preun): systemd-units +Requires(postun): systemd-units + +%description +Open vSwitch provides standard network bridging functions and +support for the OpenFlow protocol for remote per-flow control of +traffic. + +%package -n python-openvswitch +Summary: Open vSwitch python bindings +License: ASL 2.0 +BuildArch: noarch +Requires: python + +%description -n python-openvswitch +Python bindings for the Open vSwitch database + +%if %{with_ovsdbmonitor} +%package -n ovsdbmonitor +Summary: Open vSwitch graphical monitoring tool +License: ASL 2.0 +BuildArch: noarch +Requires: python-openvswitch = %{version}-%{release} +Requires: python python-twisted-core python-twisted-conch python-zope-interface PyQt4 + +%description -n ovsdbmonitor +A GUI tool for monitoring and troubleshooting local or remote Open +vSwitch installations. It presents GUI tables that graphically represent +an Open vSwitch kernel flow table (similar to "ovs-dpctl dump-flows") +and Open vSwitch database contents (similar to "ovs-vsctl list "). +%endif + +%package test +Summary: Open vSwitch testing utilities +License: ASL 2.0 +BuildArch: noarch +Requires: python-openvswitch = %{version}-%{release} +Requires: python python-twisted-core python-twisted-web + +%description test +Utilities that are useful to diagnose performance and connectivity +issues in Open vSwitch setup. + +%package controller +Summary: Open vSwitch OpenFlow controller +License: ASL 2.0 +Requires: openvswitch = %{version}-%{release} + +%description controller +Simple reference implementation of an OpenFlow controller for Open +vSwitch. Manages any number of remote switches over OpenFlow protocol, +causing them to function as L2 MAC-learning switches or hub. + +%prep +%setup -q +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 + +%build +%configure --enable-ssl --with-pkidir=%{_sharedstatedir}/openvswitch/pki +make %{?_smp_mflags} + + +%install +make install DESTDIR=$RPM_BUILD_ROOT + +install -d -m 0755 $RPM_BUILD_ROOT%{_sysconfdir}/openvswitch + +install -p -D -m 0644 \ + rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template \ + $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/openvswitch +install -p -D -m 0644 \ + rhel/usr_lib_systemd_system_openvswitch.service \ + $RPM_BUILD_ROOT%{_unitdir}/openvswitch.service +install -p -D -m 0644 \ + rhel/usr_lib_systemd_system_openvswitch-nonetwork.service \ + $RPM_BUILD_ROOT%{_unitdir}/openvswitch-nonetwork.service + +install -p -D -m 0755 rhel/etc_init.d_openvswitch \ + $RPM_BUILD_ROOT%{_datadir}/openvswitch/scripts/openvswitch.init + +install -p -D -m 0644 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/openvswitch + +install -d -m 0755 $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/network-scripts/ +install -p -m 0755 rhel/etc_sysconfig_network-scripts_ifdown-ovs \ + $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/network-scripts/ifdown-ovs +install -p -m 0755 rhel/etc_sysconfig_network-scripts_ifup-ovs \ + $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/network-scripts/ifup-ovs + +install -d -m 0755 $RPM_BUILD_ROOT/%{_sharedstatedir}/openvswitch + +install -d -m 0755 $RPM_BUILD_ROOT%{python_sitelib} +mv $RPM_BUILD_ROOT/%{_datadir}/openvswitch/python/* $RPM_BUILD_ROOT%{python_sitelib} +rmdir $RPM_BUILD_ROOT/%{_datadir}/openvswitch/python/ + +mkdir -p $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version} +install -p -m 0644 %{SOURCE9} $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version} + +# Get rid of stuff we don't want to make RPM happy. +rm -f \ + $RPM_BUILD_ROOT%{_sbindir}/ovs-vlan-bug-workaround \ + $RPM_BUILD_ROOT%{_mandir}/man8/ovs-vlan-bug-workaround.8 \ + $RPM_BUILD_ROOT%{_sbindir}/ovs-brcompatd \ + $RPM_BUILD_ROOT%{_mandir}/man8/ovs-brcompatd.8 + +desktop-file-install --dir=$RPM_BUILD_ROOT%{_datadir}/applications %{SOURCE6} + +%if ! %{with_ovsdbmonitor} +rm -f $RPM_BUILD_ROOT%{_bindir}/ovsdbmonitor +rm -f $RPM_BUILD_ROOT%{_mandir}/man1/ovsdbmonitor.1* +rm -rf $RPM_BUILD_ROOT%{_datadir}/ovsdbmonitor +rm -f $RPM_BUILD_ROOT%{_datadir}/applications/ovsdbmonitor.desktop +rm -rf $RPM_BUILD_ROOT%{_docdir}/ovsdbmonitor +%endif + + +%post +%if 0%{?systemd_post:1} + %systemd_post %{name}.service +%else + # Package install, not upgrade + if [ $1 -eq 1 ]; then + /bin/systemctl daemon-reload >dev/null || : + fi +%endif + +# Package with native systemd unit file is installed for the first time +%triggerun -- %{name} < 1.9.0-1 +# Save the current service runlevel info +# User must manually run systemd-sysv-convert --apply openvswitch +# to migrate them to systemd targets +/usr/bin/systemd-sysv-convert --save %{name} >/dev/null 2>&1 ||: + +# Run these because the SysV package being removed won't do them +/sbin/chkconfig --del %{name} >/dev/null 2>&1 || : +/bin/systemctl try-restart %{name}.service >/dev/null 2>&1 || : + +%preun +%if 0%{?systemd_preun:1} + %systemd_preun %{name}.service +%else + if [ $1 -eq 0 ] ; then + # Package removal, not upgrade + /bin/systemctl --no-reload disable %{name}.service >/dev/null 2>&1 || : + /bin/systemctl stop %{name}.service >/dev/null 2>&1 || : + fi +%endif + +%postun +%if 0%{?systemd_postun_with_restart:1} + %systemd_postun_with_restart %{name}.service +%else + /bin/systemctl daemon-reload >/dev/null 2>&1 || : + if [ "$1" -ge "1" ] ; then + # Package upgrade, not uninstall + /bin/systemctl try-restart %{name}.service >/dev/null 2>&1 || : + fi +%endif + +%files +%{_sysconfdir}/openvswitch/ +%config(noreplace) %{_sysconfdir}/logrotate.d/openvswitch +%config(noreplace) %{_sysconfdir}/sysconfig/openvswitch +%{_sysconfdir}/sysconfig/network-scripts/ifup-ovs +%{_sysconfdir}/sysconfig/network-scripts/ifdown-ovs +%{_unitdir}/openvswitch.service +%{_unitdir}/openvswitch-nonetwork.service +%{_bindir}/ovs-appctl +%{_bindir}/ovs-benchmark +%{_bindir}/ovs-dpctl +%{_bindir}/ovs-dpctl-top +%{_bindir}/ovs-ofctl +%{_bindir}/ovs-pcap +%{_bindir}/ovs-pki +%{_bindir}/ovs-tcpundump +%{_bindir}/ovs-vsctl +%{_bindir}/ovsdb-client +%{_bindir}/ovsdb-tool +%{_bindir}/ovs-parse-backtrace +# ovs-bugtool is LGPLv2+ +%{_sbindir}/ovs-bugtool +%{_sbindir}/ovs-vswitchd +%{_sbindir}/ovsdb-server +%{_mandir}/man1/ovs-benchmark.1* +%{_mandir}/man1/ovs-pcap.1* +%{_mandir}/man1/ovs-tcpundump.1* +%{_mandir}/man1/ovsdb-client.1* +%{_mandir}/man1/ovsdb-server.1* +%{_mandir}/man1/ovsdb-tool.1* +%{_mandir}/man5/ovs-vswitchd.conf.db.5* +%{_mandir}/man8/ovs-appctl.8* +%{_mandir}/man8/ovs-bugtool.8* +%{_mandir}/man8/ovs-ctl.8* +%{_mandir}/man8/ovs-dpctl.8* +%{_mandir}/man8/ovs-dpctl-top.8* +%{_mandir}/man8/ovs-ofctl.8* +%{_mandir}/man8/ovs-pki.8* +%{_mandir}/man8/ovs-vsctl.8* +%{_mandir}/man8/ovs-vswitchd.8* +%{_mandir}/man8/ovs-parse-backtrace.8* +# /usr/share/openvswitch/bugtool-plugins and +# /usr/share/openvswitch/scripts/ovs-bugtool* are LGPLv2+ +%{_datadir}/openvswitch/ +%{_sharedstatedir}/openvswitch +%{_docdir}/%{name}-%{version}/README.RHEL +# see COPYING for full licensing details +%doc COPYING DESIGN INSTALL.SSL NOTICE README WHY-OVS + +%files -n python-openvswitch +%{python_sitelib}/ovs +%doc COPYING + +%if %{with_ovsdbmonitor} +%files -n ovsdbmonitor +%{_bindir}/ovsdbmonitor +%{_mandir}/man1/ovsdbmonitor.1* +%{_datadir}/ovsdbmonitor +%{_datadir}/applications/ovsdbmonitor.desktop +%doc ovsdb/ovsdbmonitor/COPYING +%endif + +%files test +%{_bindir}/ovs-test +%{_bindir}/ovs-vlan-test +%{_bindir}/ovs-l3ping +%{_mandir}/man8/ovs-test.8* +%{_mandir}/man8/ovs-vlan-test.8* +%{_mandir}/man8/ovs-l3ping.8* +%{python_sitelib}/ovstest + +%files controller +%{_bindir}/ovs-controller +%{_mandir}/man8/ovs-controller.8* + + +%changelog +* Fri Jan 24 2014 Daniel Mach - 2.0.0-7 +- Mass rebuild 2014-01-24 + +* Wed Jan 15 2014 Flavio Leitner - 2.0.0-6 +- Enable DHCP support for internal ports + (upstream commit 490db96efaf89c63656b192d5ca287b0908a6c77) + +* Wed Jan 15 2014 Flavio Leitner - 2.0.0-5 +- disabled ovsdbmonitor packaging + (upstream has removed the component) + +* Wed Jan 15 2014 Flavio Leitner - 2.0.0-4 +- fedora package: fix systemd ordering and deps. + (upstream commit b49c106ef00438b1c59876dad90d00e8d6e7b627) + +* Wed Jan 15 2014 Flavio Leitner - 2.0.0-3 +- util: use gcc builtins to better check array sizes + (upstream commit 878f1972909b33f27b32ad2ded208eb465b98a9b) + +* Fri Dec 27 2013 Daniel Mach - 2.0.0-2 +- Mass rebuild 2013-12-27 + +* Mon Oct 28 2013 Flavio Leitner - 2.0.0-1 +- updated to 2.0.0 (#1023184) + +* Mon Oct 28 2013 Flavio Leitner - 1.11.0-8 +- applied upstream commit 7b75828bf5654c494a53fa57be90713c625085e2 + rhel: Option to create tunnel through ifcfg scripts. + +* Mon Oct 28 2013 Flavio Leitner - 1.11.0-7 +- applied upstream commit 32aa46891af5e173144d672e15fec7c305f9a4f3 + rhel: Set STP of a bridge during bridge creation. + +* Mon Oct 28 2013 Flavio Leitner - 1.11.0-6 +- applied upstream commit 5b56f96aaad4a55a26576e0610fb49bde448dabe + rhel: Prevent duplicate ifup calls. + +* Mon Oct 28 2013 Flavio Leitner - 1.11.0-5 +- applied upstream commit 79416011612541d103a1d396d888bb8c84eb1da4 + rhel: Return an exit value of 0 for ifup-ovs. + +* Mon Oct 28 2013 Flavio Leitner - 1.11.0-4 +- applied upstream commit 2517bad92eec7e5625bc8b248db22fdeaa5fcde9 + Added RHEL ovs-ifup STP option handling + +* Tue Oct 1 2013 Flavio Leitner - 1.11.0-3 +- don't use /var/lock/subsys with systemd (#1006412) + +* Thu Sep 19 2013 Flavio Leitner - 1.11.0-2 +- ovsdbmonitor package is optional + +* Thu Aug 29 2013 Thomas Graf - 1.11.0-1 +- Update to 1.11.0 + +* Tue Aug 13 2013 Flavio Leitner - 1.10.0-7 +- Fixed openvswitch-nonetwork to start openvswitch.service (#996804) + +* Sat Aug 03 2013 Petr Pisar - 1.10.0-6 +- Perl 5.18 rebuild + +* Tue Jul 23 2013 Thomas Graf - 1.10.0-5 +- Typo + +* Tue Jul 23 2013 Thomas Graf - 1.10.0-4 +- Spec file fixes +- Maintain local copy of sysconfig.template + +* Thu Jul 18 2013 Petr Pisar - 1.10.0-3 +- Perl 5.18 rebuild + +* Mon Jul 01 2013 Thomas Graf - 1.10.0-2 +- Enable PIE (#955181) +- Provide native systemd unit files (#818754) + +* Thu May 02 2013 Thomas Graf - 1.10.0-1 +- Update to 1.10.0 (#958814) + +* Thu Feb 28 2013 Thomas Graf - 1.9.0-1 +- Update to 1.9.0 (#916537) + +* Tue Feb 12 2013 Thomas Graf - 1.7.3-8 +- Fix systemd service dependency loop (#818754) + +* Fri Jan 25 2013 Thomas Graf - 1.7.3-7 +- Auto-start openvswitch service on ifup/ifdown (#818754) +- Add OVSREQUIRES to allow defining OpenFlow interface dependencies + +* Thu Jan 24 2013 Thomas Graf - 1.7.3-6 +- Update to Open vSwitch 1.7.3 + +* Tue Nov 20 2012 Thomas Graf - 1.7.1-6 +- Increase max fd limit to support 256 bridges (#873072) + +* Thu Nov 1 2012 Thomas Graf - 1.7.1-5 +- Don't create world writable pki/*/incomming directory (#845351) + +* Thu Oct 25 2012 Thomas Graf - 1.7.1-4 +- Don't add iptables accept rule for -p GRE as GRE tunneling is unsupported + +* Tue Oct 16 2012 Thomas Graf - 1.7.1-3 +- require systemd instead of systemd-units to use macro helpers (#850258) + +* Tue Oct 9 2012 Thomas Graf - 1.7.1-2 +- make ovs-vsctl timeout if daemon is not running (#858722) + +* Mon Sep 10 2012 Thomas Graf - 1.7.1.-1 +- Update to 1.7.1 + +* Fri Sep 7 2012 Thomas Graf - 1.7.0.-3 +- add controller package containing ovs-controller + +* Thu Aug 23 2012 Tomas Hozza - 1.7.0-2 +- fixed SPEC file so it comply with new systemd-rpm macros guidelines (#850258) + +* Fri Aug 17 2012 Tomas Hozza - 1.7.0-1 +- Update to 1.7.0 +- Fixed openvswitch-configure-ovskmod-var-autoconfd.patch because + openvswitch kernel module name changed in 1.7.0 +- Removed Source8: ovsdbmonitor-move-to-its-own-data-directory.patch +- Patches merged: + - ovsdbmonitor-move-to-its-own-data-directory-automaked.patch + - openvswitch-rhel-initscripts-resync.patch + +* Fri Jul 20 2012 Fedora Release Engineering - 1.4.0-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Thu Mar 15 2012 Chris Wright - 1.4.0-5 +- fix ovs network initscripts DHCP address acquisition (#803843) + +* Tue Mar 6 2012 Chris Wright - 1.4.0-4 +- make BuildRequires openssl explicit (needed on f18/rawhide now) + +* Tue Mar 6 2012 Chris Wright - 1.4.0-3 +- use glob to catch compressed manpages + +* Thu Mar 1 2012 Chris Wright - 1.4.0-2 +- Update License comment, use consitent macros as per review comments bz799171 + +* Wed Feb 29 2012 Chris Wright - 1.4.0-1 +- Initial package for Fedora