ofproto-dpif: Eliminate unneeded call to ofproto_dpif_cast().

I noticed this was unneeded while looking over commit 7c33b18807804f
(ofproto-dpif: More efficient implementation of get_odp_port().).

Signed-off-by: Ben Pfaff <blp@nicira.com>
datapath: Change ENOENT return value to ENODEV in lookup_vport().

This reduces the number of valid "no such device" error values that
need special attention by the caller.

Userspace code will need to keep on checking for both ENODEV and
ENOENT as long as older kernel modules are around.

Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
dpif: Document.

Signed-off-by: Ben Pfaff <blp@nicira.com>
ofproto: Fix remaining incorrect users of OVSP_LOCAL.

In the switch to a single datapath, the simple mapping between
OFPP_LOCAL and OVSP_LOCAL was broken.  Unfortunately, a couple of
translations were missed, so this commit fixes them.

Reported-by: Jesse Gross <jesse@nicira.com>
Signed-off-by: Justin Pettit <jpettit@nicira.com>
classifier: Fix theoretical leak in classifier_destroy().

The open-coded version of destroy_table() in classifier_destroy() didn't
free the table's minimatch.  Use destroy_table() to do it properly.

This is only a theoretical leak because all the existing callers actually
remove all the rules from their classifiers before they destroy them
(outside of the tests/ directory, which I didn't examine) and so they don't
ever have anything left to remove in classifier_destroy().

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
tests: Fix memory leaks in test-classifier program.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
Add Openflow 1.3 test for asynchronous message control.

Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
datapath: Use FIELD_SIZEOF() in dp_init().

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: Jesse Gross <jesse@nicira.com>
netdev-vport: Remove useless struct netdev_vport.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
ofproto-dpif: Use proper special value for the reserved PID.

The compose_slow_path() function used UINT16_MAX for
dpif_port_get_pid(), when it should be UINT32_MAX to get the proper
reserved PID.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
dpif-linux: Log the correct port-PID mapping.

When adding a port, the code previously logged the requested port number
(which is generally UINT32_MAX) instead of the assigned port number.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
dpif-linux: Give each port its own userspace-kernel channel.

Userspace-kernel communication is a possible bottleneck when OVS is
receiving a large number of flow set up requests.  To help prevent a bad
actor from consuming too much of this resource, we introduced channels
to segegrate traffic.  Previously, we created 17 channels and
round-robin assigned ports to one of 16 channels (the 17th was reserved
for use by the system).  This meant if there were more than 16 ports,
sharing of channels would occur.

This commit creates a new channel for each port, so that there is no
more sharing and better isolation.  The special system port uses the
"ovs-system"'s channel (port 0), since it is not heavily loaded.

This also fixes an issue introduced in commit acf60855 (ofproto-dpif:
Use a single underlying datapath across multiple bridges.) where ports
that were added at run-time were given the special system channel.

Issue #12073

Signed-off-by: Justin Pettit <jpettit@nicira.com>
vlog: Avoid calling worker_request() reentrantly.

The following call stack was possible:

    vlog
        -> worker_request()
            -> poll_block()
                -> vlog
                     -> worker_request()

which caused problems because worker_request() is not reentrant.  In a
little more detail, the second worker_request() shoves its RPC protocol
data into the middle of the first.  This means that, first, you get
some binary crud in the log (the header for the second RPC).  And,
second, text from the first RPC log message gets treated by the worker
as the subsequent RPC's header.  That, in turn, typically causes the
worker to try to xmalloc() a huge number of bytes (0x20000000 or more,
since "space" has ASCII value 0x20), which causes the worker to die
with "virtual memory exhausted".  The main process then dies because
the worker's death closes the socket it uses to communicate with it
("connection reset").

Bug #14616.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
worker: Do not use poll_block() in worker_send_iovec().

The following call stack was possible:

    poll_block()
        -> vlog
            -> worker_send_iovec()
                -> poll_block()

which caused corruption because poll_block() is not reentrant.

Bug #14616.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
worker: Make worker_request_iovec() verify that it is not being reentered.

This function cannot easily be reentrant because the inner call would
interrupt and corrupt the data being sent by the outer call.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
socket-util: Use CONST_CAST in send_iovec_and_fs().

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
worker: Remove unreachable statement.

Nothing ever breaks out of the loop, so this statement couldn't be reached.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
FAQ: Update question about OpenFlow version support.

We've had a lot of questions about this on the mailing lists recently, and
it would be nice to have an authoritative answer to cut and paste.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
alloc_ofp_port does not allocate the port number correctly

alloc_ofp_port() does not allocate the port number correctly if the port
number passed initially is already in use. The following if block

if (ofp_port >= ofproto->max_ports
            || bitmap_is_set(ofproto->ofp_port_ids, ofp_port)) {

is entered when either of the two conditions is true but the while block
after this is not entered if the second condition above is true and the
first condition is false.

This results in an existing port_number to be re-assigned!

Signed-off-by: Krishna Kondaka <kkondaka@vmware.com>
Signed-off-by: Justin Pettit <jpettit@nicira.com>
netdev-vport: Create new TUNNEL_CLASS macro.

There are a lot of tunnels, and they all use the exact same
functions, so it makes sense to collapse their initialization into
a macro.

Suggested-by: Jesse Gross <jesse@nicira.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>