aboutsummaryrefslogtreecommitdiff
path: root/lib/dpif-netdev.c
AgeCommit message (Collapse)Author
2013-10-09odp-execute: Refine signatures for odp_execute_actions() callbacks.Ben Pfaff
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-09-07dpif-netdev: Do not allow adding loopback devicesAlexandru Copot
Signed-off-by: Alexandru Copot <alex.mihai.c@gmail.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-08-23dpif: Change get_max_ports() to return uint32_t.Alex Wang
The declaration of 'get_max_ports()' to return odp_port_t adds unwanted complexity to coding. This commit changes it back to return uint32_t type. Signed-off-by: Alex Wang <alexw@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-08-13flow: Rename skb_mark to pkt_mark.Jesse Gross
The skb_mark field is currently only available with the Linux datapath and is only used internally. However, it is desirable to expose this through OpenFlow and when it is exposed ideally it would not be system- specific. In preparation for this, skb_mark is rename to pkt_mark in internal data structures for consistency. This does not rename the Linux interfaces because doing so would break the API. It would not necessarily be desirable to do anyways since in Linux-specific code it is clearer to use the actual name rather than a generic one. This can lead to confusion in some places, however, because we do not always strictly separate generic and platform dependent code (one example is actions). This seems inevitable though at this point if the lower and upper layers have different names (as they must given the above requirements). Signed-off-by: Jesse Gross <jesse@nicira.com> Acked-by: Andy Zhou <azhou@nicira.com>
2013-08-10dpif-netdev: Avoid races on queue and port changes using seq objects.Ben Pfaff
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-07-30clang: Add annotations for thread safety check.Ethan Jackson
This commit adds annotations for thread safety check. And the check can be conducted by using -Wthread-safety flag in clang. Co-authored-by: Alex Wang <alexw@nicira.com> Signed-off-by: Alex Wang <alexw@nicira.com> Signed-off-by: Ethan Jackson <ethan@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-07-29ofproto-dpif: Tolerate spontaneous changes in datapath port numbers.Ben Pfaff
This can happen on ESX. Also adds a test to make sure this works. Bug #17634. Signed-off-by: Ben Pfaff <blp@nicira.com> Tested-by: Guolin Yang <gyang@vmware.com>
2013-07-25dpif-netdev: Make internally thread-safe by introducing a global mutex.Ben Pfaff
This can be improved later but it is the simple thing to do for now. I marked a couple of races with XXX. I don't have a really good solution for these, but I hope to find one. They may be harmless in practice. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
2013-07-22dpif-netdev: Make 'max_mtu' a per-dp feature, for thread safety.Ben Pfaff
This ensures that an external lock around a dpif_netdev will allow thread-safe access to it. Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-07-11dpif-netdev: Make "packet-out" with in_port=OFPP_CONTROLLER work again.Ben Pfaff
Commit 4e022ec09e14 (Create specific types for ofp and odp port) broke OpenFlow OFPP_PACKET_OUT requests that use in_port=OFPP_CONTROLLER. This commit fixes the problem and adds a regression test. CC: Alex Wang <alexw@nicira.com> Reported-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-28Replace all uses of strerror() by ovs_strerror(), for thread safety.Ben Pfaff
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-20Create specific types for ofp and odp portAlex Wang
Until now, datapath ports and openflow ports were both represented by unsigned integers of various sizes. With implicit conversions, etc., it is easy to mix them up and use one where the other is expected. This commit creates two typedefs, ofp_port_t and odp_port_t. Both of these two types are marked by "__attribute__((bitwise))" so that sparse can be used to detect any misuse. Signed-off-by: Alex Wang <alexw@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-20ovs-dpctl: Add mega flow supportAndy Zhou
Added support to allow mega flow specified and displayed. ovs-dpctl tool is mainly used as debugging tool. This patch also implements the low level user space routines to send and receive mega flow netlink messages. Those netlink suppor routines are required for forthcoming user space mega flow patches. Added a unit test to test parsing and display of mega flows. Ethan contributed the ovs-dpctl mega flow output function. Co-authored-by: Ethan Jackson <ethan@nicira.com> Signed-off-by: Ethan Jackson <ethan@nicira.com> Signed-off-by: Andy Zhou <azhou@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-06netdev-vport: Don't return static data in netdev_vport_get_dpif_port().Ben Pfaff
Returning a static data buffer makes code more brittle and definitely not thread-safe, so this commit switches to using a caller-provided buffer instead. Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-06-06dpif-netdev: Don't run port names through netdev_vport_get_dpif_port().Ben Pfaff
The ports that exist within a dpif have already been translated through netdev_vport_get_dpif_port(), so there is no value to translating them again in the interfaces that query or dump ports (and possibly a drawback if somehow the translation could change). After this change, dpif-netdev translates port names in just one place, the port_add path, which makes dpif-netdev act the same way as dpif-linux in this respect. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
2013-06-05odp-execute: Add set skb_mark, set_priority, tunnel support.Simon Horman
The motivation for this is to allow such actions to be honoured if they are encountered; by the user-space datapath before recirculation; or by internal processing of actions by ovs-vswitchd before recirculation. Recirculation will be added by a subsequent patch. Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-05-29odp-execute: New module for executing datapath actions.Simon Horman
This moves generic action execution code out of lib/dpif-netedev.c and into a new file, lib/odp-execute.c. This is in preparation for using odp_execute_actions() in lib/odp-util.c to handle recirculation/ Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-05-23dpif-netdev: Move decoding of data out of dp_netdev_output_userspace()Simon Horman
This is in preparation for making dp_netdev_action_userspace() more generic and passing dp_netdev_output_userspace() as a callback. In this case it makes sense to decode userdata in generic code. Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-05-23dpif-netdev: Constify key parameter of dp_netdev_action_userspace()Simon Horman
Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-05-10netdev: Add new "struct netdev_rx" for capturing packets from a netdev.Ben Pfaff
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>
2013-05-10netdev: Factor restoring flags into new "struct netdev_saved_flags".Ben Pfaff
This gets rid of the only per-instance data in "struct netdev", which will make it possible to merge "struct netdev_dev" into "struct netdev" in a later commit. Ed Maste wrote the netdev-bsd changes in this commit. Signed-off-by: Ben Pfaff <blp@nicira.com> Co-authored-by: Ed Maste <emaste@freebsd.org> Signed-off-by: Ed Maste <emaste@freebsd.org> Tested-by: Ed Maste <emaste@freebsd.org>
2013-04-30dpif-netdev: Shorten delay loops.Ben Pfaff
Um, I mean, remove useless code. Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-04-29dpif-netdev: Update max_mtu correctly.Ben Pfaff
What a dumb bug. Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-03-04Tunnel: Cleanup old tunnel infrastructure.Pravin B Shelar
Since userspace flow based tunneling code is checked in, the kernel port based tunneling code can be removed. Patch removes following components: - tunnel ports hash table and moved tunnel ports list to individual vports. - Cleaned per tnl-port config. - OVS_KEY_ATTR_TUN_ID action is removed. Signed-off-by: Pravin B Shelar <pshelar@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com> Bug #15078
2013-02-15Allow OVS_USERSPACE_ATTR_USERDATA to be variable length.Ben Pfaff
Until now, the optional OVS_USERSPACE_ATTR_USERDATA attribute had to be exactly 64 bits long, if it was present. However, 64 bits is not enough space to associate as much information with a flow as would be convenient for some userspace features now under development. This commit generalizes the attribute, allowing it to be any length. This generalization is backward-compatible: if userspace only uses 64-bit attributes, then it will not see any change in behavior. CC: Romain Lenglet <rlenglet@vmware.com> Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com>
2013-02-05User-Space MPLS actions and matchesSimon Horman
This patch implements use-space datapath and non-datapath code to match and use the datapath API set out in Leo Alterman's patch "user-space datapath: Add basic MPLS support to kernel". The resulting MPLS implementation supports: * Pushing a single MPLS label * Poping a single MPLS label * Modifying an MPLS lable using set-field or load actions that act on the label value, tc and bos bit. * There is no support for manipulating the TTL this is considered future work. The single-level push pop limitation is implemented by processing push, pop and set-field/load actions in order and discarding information that would require multiple levels of push/pop to be supported. e.g. push,push -> the first push is discarded pop,pop -> the first pop is discarded This patch is based heavily on work by Ravi K. Cc: Ravi K <rkerur@gmail.com> Reviewed-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-01-28netdev: New function netdev_get_dpif_port().Ethan Jackson
In future patches, a netdev's datapath port name may not necessarily be the same as its device name. This patch prepares for this by making the distinction in the netdev and dpif layers. Signed-off-by: Ethan Jackson <ethan@nicira.com>
2013-01-28dpif-netdev: Allow stub interfaces on the dummy datapath.Ethan Jackson
Future patches will need to add netdevs to the dummy datapath which can't actually send or receive packets. Signed-off-by: Ethan Jackson <ethan@nicira.com>
2013-01-18datapath: More flexible kernel/userspace tunneling attribute.Pravin B Shelar
Following patch breaks down single ipv4_tunnel netlink attribute into individual member attributes. It will help when we extend tunneling parameters in future. Signed-off-by: Pravin B Shelar <pshelar@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com> Bug #14611
2013-01-17dpif-netdev: Limit scope of vlan in dp_netdev_execute_actionsSimon Horman
This is to make the code consistent with the proposed MPLS changes and avoid cluttering the top of the NL_ATTR_FOR_EACH_UNSAFE loop. Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-01-16Replace most uses of assert by ovs_assert.Ben Pfaff
This is a straight search-and-replace, except that I also removed #include <assert.h> from each file where there were no assert calls left. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
2012-11-21datapath: add skb mark matching and set actionAnsis Atteka
This patch adds support for skb mark matching and set action. Acked-by: Jesse Gross <jesse@nicira.com> Signed-off-by: Ansis Atteka <aatteka@nicira.com>
2012-11-20dpif-netdev: Make odp_flow_key_to_flow() check more explicit.Ben Pfaff
ODP_FIT_PERFECT has value 0 but this 'if' statement doesn't make much sense unless you happen to know that. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Kyle Mestery <kmestery@cisco.com>
2012-11-16Add functions to determine how port should be opened based on type.Justin Pettit
Depending on the port and type of datapath, a port may need to be opened as a different type of device than it's configured. For example, an "internal" port on a "dummy" datapath should opened as a "dummy" port. This commit adds the ability for a dpif to provide this information to a caller. It will be used in a future commit. Signed-off-by: Justin Pettit <jpettit@nicira.com>
2012-11-16dpif-netdev: Don't special-case "br" bridges in create_dp_netdev().Justin Pettit
With a single datapath, we no longer need to special case bridges beginning with "br*" for testing, since all netdev-based bridges are named "ovs-netdev". This removes that unnecessary code. Signed-off-by: Justin Pettit <jpettit@nicira.com>
2012-11-13datapath: add ipv6 'set' actionAnsis Atteka
This patch adds ipv6 set action functionality. It allows to change traffic class, flow label, hop-limit, ipv6 source and destination address fields. Acked-by: Jesse Gross <jesse@nicira.com> Signed-off-by: Ansis Atteka <aatteka@nicira.com>
2012-11-01dpif: Add new dpif_port_exists() function.Justin Pettit
Provide the ability to determine whether a port exists in a datapath without having to deal with a "dpif_port" structure as with dpif_port_query_by_name(). A future patch will use this function. Signed-off-by: Justin Pettit <jpettit@nicira.com>
2012-11-01tests: Rewrite unit tests to not expect bridge with odp zero.Justin Pettit
A future commit will make all bridges of a particular type share a single backing datapath. That backing datapath will have a datapath port number of zero and bridges will be assigned other numbers. This commit modifies the tests so that they don't expect port zero. It adopts the convention that bridges of type "dummy" with a name of the form "br<n>" will be assigned a port number of 100+<n>. Signed-off-by: Justin Pettit <jpettit@nicira.com>
2012-11-01Use ODP ports in dpif layer and below.Justin Pettit
The current code has a simple mapping between datapath and OpenFlow port numbers (the port numbers were the same other than OFPP_LOCAL which maps to datapath port 0). Since the translation was know at compile time, this allowed different layers to easily translate between the two, so the translation often occurred late. A future commit will break this simple mapping, so this commit draws a line between where datapath and OpenFlow port numbers are used. The ofproto-dpif layer will be responsible for the translations. Callers above will use OpenFlow port numbers. Providers below will use datapath port numbers. Signed-off-by: Justin Pettit <jpettit@nicira.com>
2012-11-01Always treat datapath ports as 32 bits.Justin Pettit
Most of the code referred to datapath ports as 32-bit values, but a few places still used 16-bit references. Signed-off-by: Justin Pettit <jpettit@nicira.com>
2012-10-20datapath: Add support for tun_key to Open vSwitch datapathKyle Mestery
This is a first pass at providing a tun_key which can be used as the basis for flow-based tunnelling. The tun_key includes and replaces the tun_id in both struct ovs_skb_cb and struct sw_tun_key. This patch allows all existing tun_id behaviour to still work. Existing users of tun_id are redirected to tun_key->tun_id to retain compatibility. However, when the userspace code is updated to make use of the new tun_key, the old behaviour will be deprecated and removed. NOTE: With these changes, the tunneling code no longer assumes input and output keys are symmetric. If they are not, PMTUD needs to be disabled for tunneling to work. Signed-off-by: Kyle Mestery <kmestery@cisco.com> Signed-off-by: Pravin B Shelar <pshelar@nicira.com> Reviewed-by: Jesse Gross <jesse@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
2012-10-03flow: Extend struct flow to contain tunnel outer header.Jesse Gross
Soon the kernel will begin supplying the information about the outer IP header for tunneled packets and userspace will need to be able to track it as part of the flow. For the time being this is only used internally by OVS and not exposed outwards to OpenFlow. As a result, this threads the information throughout userspace but simply stores the existing tun_id in it. Signed-off-by: Jesse Gross <jesse@nicira.com>
2012-09-26dpif-netdev: Remove unneeded 'key' parameter from dp_netdev_flow_used().Ben Pfaff
The 'key' passed to dp_netdev_flow_used() is the same as the 'key' member in the struct dp_netdev_flow also passed to the function. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
2012-08-16dpif-netdev: Eliminate two malloc() calls per packet sent to "userspace".Ben Pfaff
This is easy enough, so it seems worthwhile now that FreeBSD is starting to make more use of the "userspace switch". CC: Ed Maste <emaste@freebsd.org> Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-08-16dpif-netdev: Fix memory leak.Ben Pfaff
upcall->packet is allocated with malloc(), via ofpbuf_new(), but nothing ever frees it. Found by valgrind. CC: Ed Maste <emaste@freebsd.org> Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-08-15netdev: Map to OpenFlow port for flow lookupEd Maste
In the flow hash special ports are stored using OpenFlow constants. For example the "local port" is stored as 0xfffe (OFPP_LOCAL). Signed-off-by: Ed Maste <emaste@freebsd.org> Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-07-30dpif: Allow the port number to be requested when adding an interface.Justin Pettit
The datapath allows requesting a specific port number for a port, but the dpif interface didn't expose it. This commit adds that support. Signed-off-by: Justin Pettit <jpettit@nicira.com>
2012-07-09Rename static functions to increase uniqueness.Arun Sharma
Rename do_* in ovs-dpctl and ovs-ofctl command with "dpctl_" or "ofctl_" prefix. Rename add_flow with dp_netdev_flow_add in lib/dpif-netdev.c. Signed-off-by: Arun Sharma <arun.sharma@calsoftinc.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-06-09dpif-netdev: Fix use-after-free in dpif_netdev_recv.Ben Pfaff
Found by valgrind. Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-05-16dpif-netdev: allow for proper destruction of netdev datapathsGiuseppe Lettieri
Until now, bridges with datapath_type=netdev did not destroy the datapath when deleted. In particular, the tap device implementing the internal interface was not close()d, and therefore the tap persists until ovs-vswitchd exit()s. This behaviour was caused by the missing callback for 'enumerate' in the dpif-netdev class. Without this callback 'bridge_reconfigure' failed to realize that there are datapaths with no bridge, and thus cannot destroy them. Providing an 'enumerate' callback fixes this. Signed-off-by: Giuseppe Lettieri <g.lettieri@iet.unipi.it> Signed-off-by: Ben Pfaff <blp@nicira.com>