[ovs-dev] [PATCH v11 2/6] Add set skb_mark, set_priority and tunnel support to execute_set_action
Simon Horman
horms at verge.net.au
Wed May 29 06:06:39 UTC 2013
Add set skb_mark support to execute_set_action.
This also adds support for the user-space datapath
to honour such actions if they occur before recirculation,
which will be added by a subsequent patch.
This is in preparation for using execute_set_action()
to handle recirculation.
Signed-off-by: Simon Horman <horms at verge.net.au>
---
v10
As suggested by Ben Pfaff
- Correct coding style of prototype of tun_key_from_attr
- Remove dubious memset from set_tunnel_action
v9
* Combined the following patches:
- Add set skb_priority support to execute_set_action
- Add set skb_mark support to execute_set_action
- Add set tunnel support to execute_set_action
* As suggested by Jesse Gross
- Reduce the number of new parameters added to functions,
in many cases to zero, by using the skb_priority, skb_mark
and tunnel elements of struct flow.
v7 - v8
* No change
v6
* First post
---
lib/dpif-netdev.c | 21 +++++++++++++--------
lib/odp-execute.c | 23 ++++++++++++++++++++---
lib/odp-util.c | 2 +-
lib/odp-util.h | 2 ++
4 files changed, 36 insertions(+), 12 deletions(-)
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index bd00f18..a2a8ed4 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -159,6 +159,10 @@ static void dp_netdev_execute_actions(struct dp_netdev *,
struct ofpbuf *, struct flow *,
const struct nlattr *actions,
size_t actions_len);
+static void dp_netdev_port_input(struct dp_netdev *dp,
+ struct dp_netdev_port *port,
+ struct ofpbuf *packet, uint32_t skb_priority,
+ uint32_t skb_mark, const struct flow_tnl *tnl);
static struct dpif_netdev *
dpif_netdev_cast(const struct dpif *dpif)
@@ -1032,20 +1036,21 @@ dp_netdev_flow_used(struct dp_netdev_flow *flow, const struct ofpbuf *packet)
static void
dp_netdev_port_input(struct dp_netdev *dp, struct dp_netdev_port *port,
- struct ofpbuf *packet)
+ struct ofpbuf *packet, uint32_t skb_priority,
+ uint32_t skb_mark, const struct flow_tnl *tnl)
{
- struct dp_netdev_flow *flow;
+ struct dp_netdev_flow *dp_flow;
struct flow key;
if (packet->size < ETH_HEADER_LEN) {
return;
}
- flow_extract(packet, 0, 0, NULL, port->port_no, &key);
- flow = dp_netdev_lookup_flow(dp, &key);
- if (flow) {
- dp_netdev_flow_used(flow, packet);
+ flow_extract(packet, skb_priority, skb_mark, tnl, port->port_no, &key);
+ dp_flow = dp_netdev_lookup_flow(dp, &key);
+ if (dp_flow) {
+ dp_netdev_flow_used(dp_flow, packet);
dp_netdev_execute_actions(dp, packet, &key,
- flow->actions, flow->actions_len);
+ dp_flow->actions, dp_flow->actions_len);
dp->n_hit++;
} else {
dp->n_missed++;
@@ -1071,7 +1076,7 @@ dpif_netdev_run(struct dpif *dpif)
error = port->rx ? netdev_rx_recv(port->rx, &packet) : EOPNOTSUPP;
if (!error) {
- dp_netdev_port_input(dp, port, &packet);
+ dp_netdev_port_input(dp, port, &packet, 0, 0, NULL);
} else if (error != EAGAIN && error != EOPNOTSUPP) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
VLOG_ERR_RL(&rl, "error receiving data from %s: %s",
diff --git a/lib/odp-execute.c b/lib/odp-execute.c
index b4a99a6..63403c0 100644
--- a/lib/odp-execute.c
+++ b/lib/odp-execute.c
@@ -23,6 +23,7 @@
#include "netlink.h"
#include "ofpbuf.h"
+#include "odp-util.h"
#include "packets.h"
#include "util.h"
@@ -36,7 +37,17 @@ odp_eth_set_addrs(struct ofpbuf *packet, const struct ovs_key_ethernet *eth_key)
}
static void
-odp_execute_set_action(struct ofpbuf *packet, const struct nlattr *a)
+odp_set_tunnel_action(const struct nlattr *a, struct flow_tnl *tun_key)
+{
+ enum odp_key_fitness fitness;
+
+ fitness = tun_key_from_attr(a, tun_key);
+ ovs_assert(fitness != ODP_FIT_ERROR);
+}
+
+static void
+odp_execute_set_action(struct ofpbuf *packet, const struct nlattr *a,
+ struct flow *flow)
{
enum ovs_key_attr type = nl_attr_type(a);
const struct ovs_key_ipv4 *ipv4_key;
@@ -46,9 +57,15 @@ odp_execute_set_action(struct ofpbuf *packet, const struct nlattr *a)
switch (type) {
case OVS_KEY_ATTR_PRIORITY:
+ flow->skb_priority = nl_attr_get_u32(a);
+ break;
+
case OVS_KEY_ATTR_TUNNEL:
+ odp_set_tunnel_action(a, &flow->tunnel);
+ break;
+
case OVS_KEY_ATTR_SKB_MARK:
- /* not implemented */
+ flow->skb_mark = nl_attr_get_u32(a);
break;
case OVS_KEY_ATTR_ETHERNET:
@@ -185,7 +202,7 @@ odp_execute_actions(void *dp, struct ofpbuf *packet, struct flow *key,
break;
case OVS_ACTION_ATTR_SET:
- odp_execute_set_action(packet, nl_attr_get(a));
+ odp_execute_set_action(packet, nl_attr_get(a), key);
break;
case OVS_ACTION_ATTR_SAMPLE:
diff --git a/lib/odp-util.c b/lib/odp-util.c
index 5bf94fe..9a873bc 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -775,7 +775,7 @@ tunnel_key_attr_len(int type)
return -1;
}
-static enum odp_key_fitness
+enum odp_key_fitness
tun_key_from_attr(const struct nlattr *attr, struct flow_tnl *tun)
{
unsigned int left;
diff --git a/lib/odp-util.h b/lib/odp-util.h
index a981d17..3635591 100644
--- a/lib/odp-util.h
+++ b/lib/odp-util.h
@@ -87,6 +87,8 @@ struct odputil_keybuf {
uint32_t keybuf[DIV_ROUND_UP(ODPUTIL_FLOW_KEY_BYTES, 4)];
};
+enum odp_key_fitness tun_key_from_attr(const struct nlattr *, struct flow_tnl *);
+
void odp_flow_key_format(const struct nlattr *, size_t, struct ds *);
int odp_flow_key_from_string(const char *s, const struct simap *port_names,
struct ofpbuf *);
--
1.7.10.4
More information about the dev
mailing list