Split ovs_dp_packet_flow_lookup() into its own API. In preparation for the next patch.
Signed-off-by: Andy Zhou <az...@nicira.com> --- datapath/datapath.c | 31 ++++++++++++++++++++++--------- datapath/datapath.h | 1 + 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/datapath/datapath.c b/datapath/datapath.c index b61e0ae..5bae23e 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -252,13 +252,10 @@ void ovs_dp_detach_port(struct vport *p) } /* Must be called with rcu_read_lock. */ -void ovs_dp_process_packet(struct sk_buff *skb) +struct sw_flow *ovs_dp_packet_flow_lookup(struct datapath *dp, struct sk_buff *skb) { - const struct vport *p = OVS_CB(skb)->input_vport; struct sw_flow_key *pkt_key = OVS_CB(skb)->pkt_key; - struct datapath *dp = p->dp; struct sw_flow *flow; - struct sw_flow_actions *sf_acts; struct dp_stats_percpu *stats; u64 *stats_counter; u32 n_mask_hit; @@ -266,10 +263,11 @@ void ovs_dp_process_packet(struct sk_buff *skb) stats = this_cpu_ptr(dp->stats_percpu); /* Look up flow. */ - flow = ovs_flow_tbl_lookup_stats(&dp->table, pkt_key, skb_get_hash(skb), - &n_mask_hit); + flow = ovs_flow_tbl_lookup_stats(&dp->table, pkt_key, + skb_get_hash(skb), &n_mask_hit); if (unlikely(!flow)) { struct dp_upcall_info upcall; + const struct vport *p = OVS_CB(skb)->input_vport; upcall.cmd = OVS_PACKET_CMD_MISS; upcall.userdata = NULL; @@ -282,9 +280,6 @@ void ovs_dp_process_packet(struct sk_buff *skb) } ovs_flow_stats_update(flow, pkt_key->tp.flags, skb); - - sf_acts = rcu_dereference(flow->sf_acts); - ovs_execute_actions(dp, skb, sf_acts); stats_counter = &stats->n_hit; out: @@ -293,6 +288,24 @@ out: (*stats_counter)++; stats->n_mask_hit += n_mask_hit; u64_stats_update_end(&stats->sync); + + return flow; +} + +/* Must be called with rcu_read_lock. */ +void ovs_dp_process_packet(struct sk_buff *skb) +{ + const struct vport *p = OVS_CB(skb)->input_vport; + struct datapath *dp = p->dp; + struct sw_flow *flow; + + flow =ovs_dp_packet_flow_lookup(dp, skb); + if (flow) { + struct sw_flow_actions *sf_acts; + + sf_acts = rcu_dereference(flow->sf_acts); + ovs_execute_actions(dp, skb, sf_acts); + } } int ovs_dp_upcall(struct datapath *dp, struct sk_buff *skb, diff --git a/datapath/datapath.h b/datapath/datapath.h index dbe58d4..66fa84f 100644 --- a/datapath/datapath.h +++ b/datapath/datapath.h @@ -190,6 +190,7 @@ extern struct genl_family dp_vport_genl_family; extern struct genl_multicast_group ovs_dp_vport_multicast_group; void ovs_dp_process_packet(struct sk_buff *c); +struct sw_flow *ovs_dp_packet_flow_lookup(struct datapath *dp, struct sk_buff *c); void ovs_dp_detach_port(struct vport *); int ovs_dp_upcall(struct datapath *, struct sk_buff *, const struct dp_upcall_info *); -- 1.9.1 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev