meta-flow: Simplify mf_from_ofp_port_string()

ofputil_port_from_string() does all the work already.

Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
netdev: Add new "struct netdev_rx" for capturing packets from a netdev.

Separating packet capture from "struct netdev" means that there is no
remaining per-"struct netdev" state, which will allow us to get rid of
"struct netdev_dev" (by renaming it "struct netdev").

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
Rename superclass members to 'up'.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
netdev: Get rid of netdev_dev.

The distinction between struct netdev_dev and struct netdev has always
been confusing.  Now that previous commits have eliminated all interesting
state from struct netdev, this commit deletes it and renames struct
netdev_dev to take its place.  Now the situation makes much more sense and
I won't have to continue making embarrassed explanations in the future.

Good riddance.

Signed-off-by: Ben Pfaff <blp@nicira.com>
datapath: Check for positive packet length in vport_send().

When sending a packet, a positive length indicates success and a
negative length indicates failure. However, the check for success
looked for non-zero values which catches both of these cases. This
can result in incorrect stats and leak memory on failure.

Introduced by commit be7cd27e44258bdb3c4e7dd8fd7389b5db56d55a (datapath:
Unify vport error stats handling.).

CC: Pravin B Shelar <pshelar@nicira.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
ofproto-dpif: Make fin_timeout work when governor kicks in.

The xlate_actions() call in handle_flow_miss_without_facet() didn't
implement fin_timeout properly because tcp_flags wasn't getting set.

I have not tested that this fixes the problem, but it seems "obviously
correct".

Bug #16506.
Reported-by: Ying Chen <yingchen@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
datapath: Fix compilation with Linux kernel 3.7.

Definition of __sum16 and __wsum is moved to uapi header.
Following patch adds check in config script for second possible
header.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
netdev-linux: Skip NETDEV_UP test in netdev_linux_set_etheraddr() for taps.

netdev_turn_flags_off() does nothing if the flags that one turns off are
already off.

Reported-by: Ethan Jackson <ethan@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
tests/ovs-vsctl.at: Delete trailing white spaces

Found out there are some trailing white spaces. This patch fixes it.

Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
dynamic-string: Fix style of ds_put_hex_dump().

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
Tested-by: Simon Horman <horms@verge.net.au>
Do not include trailing whitespace in hexdump.

Reported-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Tested-by: Simon Horman <horms@verge.net.au>
netdev: Prevent using reserved names

This commit adds a function to lib/netdev.c to check that the interface name
is not the same as any of the registered vport providers' dpif_port name
(e.g. gre_system) or the datapath's internal port name (e.g. ovs-system).

Bug #15077.
Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/mac-learning.h: Change one variable's type and name

This commit changes variable "int i" of "union port" of "struct mac_entry"
to "uint16_t ofp_port", since it is used to store the OpenFlow port number.

Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
bridge: Fix use of wild pointer in iface_do_create().

'netdev' was not initialized at this point in the function, so the cleanup
at the error label referenced a wild pointer.

Introduced in commit 94a538422d4b (netdev: Prevent using reserved names).

CC: Alex Wang <alexw@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ofp-print: ofp_packet_to_string() Do not emit extra trailing newline

The string produced by ofp_packet_to_string() includes a trailing
newline, so in the case where packet data is formatted by
ofp_print_packet_out() there is already a newline present.

This patch updates ofp_print_packet_out() so that it does not
add a second newline in this case.

It is not necessary to update the case where there is packet data
to ensure that the result it is terminated by a "\n" as the higher-level
ofp_to_string() function will ensure that the result is "\n" terminated.

The test-suite has be updated to exercise output of packet data by
ofp_packet_to_string()

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Allow hexdump of packet data of PACKET_{IN, OUT} messages

If verbosity parameter of ofp_print_packet_{in,out}() is greater than 2
then when formatting packet data include a hex dump as well as the output
of ofp_packet_to_string(), which is already included if verbosity is
greater than 0.

This feature may be accesed in serveral ways including:

* Including the -m parameter in an invoocation of ovs-ofctl monitor.
* Including a verbosity greater than 2 in an invocation of
  ovs-ofctl ofp-print.

This patch includes tests to exercise this feature using ovs-ofctl ofp-print.

The motivation of this is to allow tests to be written that use ovs-ofctl
-m monitor to check packet data which is not output by
ofp_packet_to_string(). Specifically, as the protocol of the inner-packet
is not known by ofp_packet_to_string() it only decodes and stringifies an
MPLS packet up to and including the first MPLS label stack entry. However
it may be useful to create tests which verify the contents of the inner
packet.

One example may be verify the effect of dec_ttl in the following sequence
of actions applied to a packet with a single MPLS label stack entry.

	pop_mpls(0x800),dec_ttl,push_mpls(0x8847)

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
netdev-dummy: Remove FreeBSD dependency.

There's no particular reason that netdev_dummy_register() has to care about
the particular OS, except that the tests like to use the special Linux-only
tunnel vport types.  But that can be done better, I think, by just always
registering them from netdev_dummy_register() and making that function
idempotent, so that calling it twice under Linux has no additional effect.
This commit implements that solution.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ed Maste <emaste@freebsd.org>
ovs-xapi-sync: Handle multiple xs-network-uuids for xs 6.1.

For xenservers with version less than 6.1, interface reconfiguration
happened through interface-reconfigure scripts in this repo. In cases
where there were multiple xs-network-uuids for a single bridge,
interface-reconfigure script would add the network uuid associated
with the non-VLAN network as the first record. ovs-xapi-sync would
just blindly use the first record to create the bridge-id

But it looks like for xenserver 6.1, interface-reconfigure script
is no longer used and xenserver natively writes the xs-network-uuids.
So, in ovs-xapi-sync we no longer can copy the first value in
xs-network-uuids as bridge-id. This commit fetches the PIF record
for each xs-network-uuids and the network that does not have a VLAN
associated with it is copied over to bridge-id.

Bug #17090.
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
ofproto/ofproto-dpif.c: Fix a typo in function header

There is a typo in the "bundle_add_port()" function header.

This patch fixes it.

Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
meta-flow: Add MFF_IN_PORT_OXM, a 32-bit in_port.

This helps get rid of one special case in nx_pull_raw() and allows
loading of 32-bit values from/to OXM_OF_IN_PORT in NXAST_LEARN actions.
Previously the 16-bit limit acted the same on both NXM_OF_IN_PORT and
OXM_OF_IN_PORT, even though OF1.1+ controllers would expect OXM_OF_IN_PORT
to be 32 bits wide.

Signed-off-by: Jarno Rajahalme <jarno.rajahalme@nsn.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>