[ovs-dev] [pkt_key v2] datapath: Make OVS_ACTION_ATTR_USERSPACE action to send packet key

Andy Zhou azhou at nicira.com
Tue Jun 25 16:21:16 UTC 2013


OVS_ACTION_ATTR_USERSPACE action was sending the key from the matching
flow. This works for exact match flows because flow keys are the
same as packet keys. However, it does not work with wildcarded flows as
the packet keys may be different than the flow keys. This patch uses
the packet keys carried in OVS_CB(skb) when calling output_userspace().

Bug #18163

Signed-off-by: Andy Zhou <azhou at nicira.com>
---
 datapath/actions.c  |    6 ++++--
 datapath/datapath.c |    2 ++
 datapath/datapath.h |    2 ++
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/datapath/actions.c b/datapath/actions.c
index 09d0c3f..0a2def6 100644
--- a/datapath/actions.c
+++ b/datapath/actions.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007-2012 Nicira, Inc.
+ * Copyright (c) 2007-2013 Nicira, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of version 2 of the GNU General Public
@@ -384,8 +384,10 @@ static int output_userspace(struct datapath *dp, struct sk_buff *skb,
 	const struct nlattr *a;
 	int rem;
 
+	BUG_ON(!OVS_CB(skb)->pkt_key);
+
 	upcall.cmd = OVS_PACKET_CMD_ACTION;
-	upcall.key = &OVS_CB(skb)->flow->key;
+	upcall.key = OVS_CB(skb)->pkt_key;
 	upcall.userdata = NULL;
 	upcall.portid = 0;
 
diff --git a/datapath/datapath.c b/datapath/datapath.c
index a514e74..3680391 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -260,6 +260,7 @@ void ovs_dp_process_received_packet(struct vport *p, struct sk_buff *skb)
 	}
 
 	OVS_CB(skb)->flow = flow;
+	OVS_CB(skb)->pkt_key = &key;
 
 	stats_counter = &stats->n_hit;
 	ovs_flow_used(OVS_CB(skb)->flow, skb);
@@ -923,6 +924,7 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info)
 		goto err_flow_free;
 
 	OVS_CB(packet)->flow = flow;
+	OVS_CB(packet)->pkt_key = &flow->key;
 	packet->priority = flow->key.phy.priority;
 	skb_set_mark(packet, flow->key.phy.skb_mark);
 
diff --git a/datapath/datapath.h b/datapath/datapath.h
index ad59a3a..e64dbb3 100644
--- a/datapath/datapath.h
+++ b/datapath/datapath.h
@@ -92,6 +92,7 @@ struct datapath {
 /**
  * struct ovs_skb_cb - OVS data in skb CB
  * @flow: The flow associated with this packet.  May be %NULL if no flow.
+ * @pkt_key: The flow information extracted from thepacket.  Must be nonnull.
  * @tun_key: Key for the tunnel that encapsulated this packet. NULL if the
  * packet is not being tunneled.
  * @ip_summed: Consistently stores L4 checksumming status across different
@@ -104,6 +105,7 @@ struct datapath {
  */
 struct ovs_skb_cb {
 	struct sw_flow		*flow;
+	struct sw_flow_key	*pkt_key;
 	struct ovs_key_ipv4_tunnel  *tun_key;
 #ifdef NEED_CSUM_NORMALIZE
 	enum csum_type		ip_summed;
-- 
1.7.9.5




More information about the dev mailing list