dpif-netdev: Move 'struct dp_netdev_port' initialization before use.

There is a portion of the 'struct dp_netdev_port' initialization
that is placed after the reload of pmd threads.  This means in
theory, there could be a race where pmd threads access half-
initialized struct.  Although such race has not been seen, it
makes sense to fully initialize the struct before use.

Found by code inspection.

Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
ofproto-dpif-xlate: Allow direct destroy of previous config.

Before this commit, the ofproto-dpif-xlate module uses ovs-rcu to
postpone the destroy of previous configuration.  However, the delayed
close of object like 'struct netdev' could cause failure in immediate
re-add or reconfigure of the same device.

To fix the above issue, this commit makes the ofproto-dpif-xlate
module call ovsrcu_synchronize(), which waits for all threads
to finish the use of reference to previous config.  Then, the
module can just directly destroy the previous config.

Reported-by: Cian Ferriter <cian.ferriter@intel.com>
Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
dpif-netdev: Allow direct destroy of 'struct dp_netdev_port'.

Before this commit, when 'struct dp_netdev_port' is deleted from
'dpif-netdev' datapath, if there is pmd thread, the pmd thread
will release the last reference to the port and ovs-rcu postpone
the destroy.  However, the delayed close of object like 'struct
netdev' could cause failure in immediate re-add or reconfigure of
the same device.

To fix the above issue, this commit uses condition variable and
makes the main thread wait for pmd thread to release the reference
when deleting port.  Then, the main thread can directly destroy the
port.

Reported-by: Cian Ferriter <cian.ferriter@intel.com>
Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>