rstp: shift learned MAC addresses to new Root port.

All MAC addresses previously learned on a Root Port can be moved to an
Alternate Port that becomes the new Root Port; i.e., Dynamic Filtering
Entries for those addresses may be modified to show the new Root Port as
their source, reducing the need to flood frames when recovering from
some component failures.

Signed-off-by: Daniele Venturino <daniele.venturino@m3s.it>
Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
rstp: Fix global transitions.

Global transitions are highest priority transitions.  When the
condition associated with a global transition is met, it supersedes
all other exit conditions including UCT.

Extracted from 802.1D-2004 standard (17.16):

A transition that is global in nature (i.e., a transition that occurs
from any of the possible states if the condition attached to the arrow
is met) is denoted by an open arrow, i.e., no specific state is
identified as the origin of the transition.  When the condition
associated with a global transition is met, it supersedes all other
exit conditions including UCT.  The special global condition BEGIN
supersedes all other global conditions, and once asserted remains
asserted until all state blocks have executed to the point that
variable assignments and other consequences of their execution remain
unchanged.

Signed-off-by: Daniele Venturino <daniele.venturino@m3s.it>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
rstp-state-machines: fix proposal reception behaviour.

Other ports should stop forwarding and learning when a port receives a
superior BPDU carrying a Proposal flag.
Without this patch this does not happen and other ports keep executing
the learning and forwarding processes.
This patch contains some fixes reported in the 802.1q-2008 standard.

Signed-off-by: Daniele Venturino <daniele.venturino@m3s.it>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
rstp: refactor RSTP setters.

With this patch setters invoke procedures only if values have changed.
Also rstp_set_bridge_address__() keeps the existing priority in the
bridge_identifier.

Signed-off-by: Daniele Venturino <daniele.venturino@m3s.it>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
ofproto-dpif: fix bundle_move() call in rstp_run().

bundle_move() expects two struct ofbundle pointers as arguments, but
void pointers hide the error.

Signed-off-by: Daniele Venturino <daniele.venturino@m3s.it>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
datapath: compat: Fix build on RHEL 6.6

RHEL 6.6 kernel percpu APIs are broken, so following patch is using OVS
backported version.

Reported-by: Wang Sheng-Hui <shhuiw@gmail.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Fix build break in ofproto/tunnel.c for windows platform.

The breakage was introduced by commit: a36de779
("openvswitch: Userspace tunneling.").

Reported-by: Edwin Chiu <echiu@nicira.com>
Signed-off-by: Saurabh Shah <ssaurabh@vmware.com>
Acked-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
datapath-windows: fixes in OvsGetExtInfoIoctl()

A few fixes around locking.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-by: Ankur Sharma <ankursharma@vmware.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
datapath-windows: add WCHAR version of OvsFindVportByHvName()

In this patch, we rename the existing OvsFindVportByHvName() to
OvsFindVportByHvNameA() to indicate that the input string is an ASCII
string. We also define a OvsFindVportByHvNameW() that takes as input a
WCHAR string.

This will be used later in HvCreatPort() to check for ports with
duplicate names.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-by: Ankur Sharma <ankursharma@vmware.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
datapath-windows: clarify 'portIdHashArray' in the swithc context

In this patch, we update the documentation for 'portIdHashArray' to
indicate that a vport would exist in this hash table if and only if it
also exists on the Hyper-V switch.

This functionality to implement this semantic will follow in subsequent
patches.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
datapath-windows: Changes to OvsRemoveAndDeleteVport()

In this patch, we add changes to OvsRemoveAndDeleteVport() to allow the
caller to specify if a vport is being deleted because it got deleted on
Hyper-V or if it got deleted from OVS userspace.

The reason we need to make the distinction is to be able to delete the
vport from the relevant hash tables.

If a port has been deleted from all the hash tables ie. has been deleted
from Hyper-V as well as OVS userspace, it gets deallocated.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-by: Ankur Sharma <ankursharma@vmware.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
datapath-windows: Changes to InitOvsVportCommon()

If a Hyper-V port (for which there exists an OVS port), gets deleted and
re-added, we'll call into InitOvsVportCommon() for the port to insert
the port into the 'portIdHashArray' as well as do a few other
initialization in the switch ocntext.

We should not be incrementing 'numHvPorts' at this point since this
vport has been counted before when it was first allocated. To account
for this, we add a new parameter to InitOvsVportCommon(). The arguments
passed by some of the callers are not 100% correct, and will be fixed in
future commit in the series.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-by: Ankur Sharma <ankursharma@vmware.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
datapath-windows: Change return type of OvsInitVxlanTunnel()

OvsInitVxlanTunnel() need not return a NL_ERROR. In this patch, we
change it to NTSTATUS, and also update the mapping function that maps a
NTSTATUS to NL_ERROR.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-by: Ankur Sharma <ankursharma@vmware.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
datapath-windows: Fixes in HvCreatePort() to re-add a port

In this patch, we update HvCreatePort() to be able to re-add a Hyper-V
port. Specifically, we handle the case where the port had also been
added by OVS userspace, so that when the port was previously deleted
from Hyper-V, we did not deallocate the port.

The key to a vport is its name. We lookup the list of vports both in the
'portIdHashArray' as well as 'portNoHashArray' to make sure that we
don't have a port with the same name.

Validation:
- deleted an re-added a port with and without the corresponding OVS port
existing
- deleted, changed the name of a port, and re-added it back with and
without the corresponding OVS port existing.
- uninstall was succcessful. No asserts hit.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-by: Ankur Sharma <ankursharma@vmware.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
datapath-windows: Avoid BSOD when switch context is NULL

I came around a BSOD that happened when trying to access pidHashLock
from the gOvsSwitchContext, which was NULL. The stop happened in
OvsAcquirePidHashLock function.

To reproduce this BSOD, make sure the extension is enabled and running,
disable it and, after that, execute 'ovs-dpctl.exe show'. The BSOD is
triggered afterwards.

Signed-off-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>
Reported-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>
Reported-at: https://github.com/openvswitch/ovs-issues/issues/53
Acked-by: Eitan Eliahu <eliahue@vmware.com>
Acked-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
datapath-windows: nuke non-netlink based interface

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
datpath-windows: include/OvsPub.h => ovsext/DpInternal.h

OvsPub.h is not longer the interface file that published the interface
of the kernel datapath to userspace. Nevertheless it is still being used
internal to the kernel datapath.

We rename the file for this reason.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
datapath-windows: cleanup DpInternal.h

Getting rid of unused definitions in DpInternal.h.

This is only the first round. There's scope for more cleanup.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
datpaath-windows: consolidate check for output buffer

Earlier, output buffer was optional in a transaction command. Thus each
command handler, had to check if the output buffer had indeed been
specified by userspace or not.

Now that output buffer is mandatory in transaction command, let's
consolidate the check in one place, and also convert the previous check
to ASSERTs.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
datapath-windows: rename 'hvDeleted' to 'isPresentOnHv'

'hvDeleted' was originally added to track vports that got deleted from
the Hyper-V switch, but which still exists in OVS. Since then, it has
taken a new meaning: eg. it is set to TRUE for VXLAN ports which don't
exist on the Hyper-V switch at all.

Hence renaming it to something more appropriate.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>