Skip to content

Commit

Permalink
datapath: Remove checks for preinitialized flow.
Browse files Browse the repository at this point in the history
Header caching used to store a precomputed flow along with the skb
but no longer exists.  There were a few remaining checks for those
flows, which this removes.  It simplifies the code slightly and brings
us closer to upstream.

Signed-off-by: Jesse Gross <[email protected]>
Acked-by: Pravin B Shelar <[email protected]>
  • Loading branch information
jessegross committed Mar 19, 2013
1 parent 0daa9cf commit 52a23d9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 34 deletions.
50 changes: 23 additions & 27 deletions datapath/datapath.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,41 +201,37 @@ void ovs_dp_process_received_packet(struct vport *p, struct sk_buff *skb)
struct datapath *dp = p->dp;
struct sw_flow *flow;
struct dp_stats_percpu *stats;
struct sw_flow_key key;
u64 *stats_counter;
int error;
int key_len;

stats = this_cpu_ptr(dp->stats_percpu);

if (!OVS_CB(skb)->flow) {
struct sw_flow_key key;
int key_len;

/* Extract flow from 'skb' into 'key'. */
error = ovs_flow_extract(skb, p->port_no, &key, &key_len);
if (unlikely(error)) {
kfree_skb(skb);
return;
}

/* Look up flow. */
flow = ovs_flow_tbl_lookup(rcu_dereference(dp->table),
&key, key_len);
if (unlikely(!flow)) {
struct dp_upcall_info upcall;

upcall.cmd = OVS_PACKET_CMD_MISS;
upcall.key = &key;
upcall.userdata = NULL;
upcall.portid = p->upcall_portid;
ovs_dp_upcall(dp, skb, &upcall);
consume_skb(skb);
stats_counter = &stats->n_missed;
goto out;
}
/* Extract flow from 'skb' into 'key'. */
error = ovs_flow_extract(skb, p->port_no, &key, &key_len);
if (unlikely(error)) {
kfree_skb(skb);
return;
}

OVS_CB(skb)->flow = flow;
/* Look up flow. */
flow = ovs_flow_tbl_lookup(rcu_dereference(dp->table), &key, key_len);
if (unlikely(!flow)) {
struct dp_upcall_info upcall;

upcall.cmd = OVS_PACKET_CMD_MISS;
upcall.key = &key;
upcall.userdata = NULL;
upcall.portid = p->upcall_portid;
ovs_dp_upcall(dp, skb, &upcall);
consume_skb(skb);
stats_counter = &stats->n_missed;
goto out;
}

OVS_CB(skb)->flow = flow;

stats_counter = &stats->n_hit;
ovs_flow_used(OVS_CB(skb)->flow, skb);
ovs_execute_actions(dp, skb);
Expand Down
3 changes: 1 addition & 2 deletions datapath/vport-internal_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ static int internal_dev_xmit(struct sk_buff *skb, struct net_device *netdev)
}

vlan_copy_skb_tci(skb);
OVS_CB(skb)->flow = NULL;

rcu_read_lock();
ovs_vport_receive(internal_dev_priv(netdev)->vport, skb);
Expand Down Expand Up @@ -289,7 +288,7 @@ static int internal_dev_recv(struct vport *vport, struct sk_buff *skb)

const struct vport_ops ovs_internal_vport_ops = {
.type = OVS_VPORT_TYPE_INTERNAL,
.flags = VPORT_F_REQUIRED | VPORT_F_FLOW,
.flags = VPORT_F_REQUIRED,
.create = internal_dev_create,
.destroy = internal_dev_destroy,
.get_name = ovs_netdev_get_name,
Expand Down
3 changes: 0 additions & 3 deletions datapath/vport.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,6 @@ void ovs_vport_receive(struct vport *vport, struct sk_buff *skb)
stats->rx_bytes += skb->len;
u64_stats_update_end(&stats->sync);

if (!(vport->ops->flags & VPORT_F_FLOW))
OVS_CB(skb)->flow = NULL;

if (!(vport->ops->flags & VPORT_F_TUN_ID))
OVS_CB(skb)->tun_key = NULL;

Expand Down
3 changes: 1 addition & 2 deletions datapath/vport.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ struct vport {
};

#define VPORT_F_REQUIRED (1 << 0) /* If init fails, module loading fails. */
#define VPORT_F_FLOW (1 << 1) /* Sets OVS_CB(skb)->flow. */
#define VPORT_F_TUN_ID (1 << 2) /* Sets OVS_CB(skb)->tun_id. */
#define VPORT_F_TUN_ID (1 << 1) /* Sets OVS_CB(skb)->tun_id. */

/**
* struct vport_parms - parameters for creating a new vport
Expand Down

0 comments on commit 52a23d9

Please sign in to comment.