Skip to content

Commit

Permalink
datapath: Remove redundant key ref from upcall_info.
Browse files Browse the repository at this point in the history
struct dp_upcall_info has pointer to pkt_key which is already
available in OVS_CB.  This also simplifies upcall handling
for gso packet.

Signed-off-by: Pravin B Shelar <[email protected]>
Acked-by: Andy Zhou <[email protected]>
  • Loading branch information
Pravin B Shelar committed Jul 30, 2014
1 parent 0077a78 commit 9b277b3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 23 deletions.
3 changes: 0 additions & 3 deletions datapath/actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,7 @@ 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)->pkt_key;
upcall.userdata = NULL;
upcall.portid = 0;

Expand Down
34 changes: 17 additions & 17 deletions datapath/datapath.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ void ovs_dp_process_packet_with_key(struct sk_buff *skb,
u32 n_mask_hit;

stats = this_cpu_ptr(dp->stats_percpu);
OVS_CB(skb)->pkt_key = pkt_key;

/* Look up flow. */
flow = ovs_flow_tbl_lookup_stats(&dp->table, pkt_key, skb_get_hash(skb),
Expand All @@ -270,7 +271,6 @@ void ovs_dp_process_packet_with_key(struct sk_buff *skb,
struct dp_upcall_info upcall;

upcall.cmd = OVS_PACKET_CMD_MISS;
upcall.key = pkt_key;
upcall.userdata = NULL;
upcall.portid = ovs_vport_find_upcall_portid(p, skb);
ovs_dp_upcall(dp, skb, &upcall);
Expand All @@ -279,7 +279,6 @@ void ovs_dp_process_packet_with_key(struct sk_buff *skb,
goto out;
}

OVS_CB(skb)->pkt_key = pkt_key;
OVS_CB(skb)->flow = flow;

ovs_flow_stats_update(OVS_CB(skb)->flow, pkt_key->tp.flags, skb);
Expand Down Expand Up @@ -316,6 +315,8 @@ int ovs_dp_upcall(struct datapath *dp, struct sk_buff *skb,
struct dp_stats_percpu *stats;
int err;

BUG_ON(!OVS_CB(skb)->pkt_key);

if (upcall_info->portid == 0) {
err = -ENOTCONN;
goto err;
Expand Down Expand Up @@ -344,7 +345,6 @@ static int queue_gso_packets(struct datapath *dp, struct sk_buff *skb,
const struct dp_upcall_info *upcall_info)
{
unsigned short gso_type = skb_shinfo(skb)->gso_type;
struct dp_upcall_info later_info;
struct sw_flow_key later_key;
struct sk_buff *segs, *nskb;
int err;
Expand All @@ -353,25 +353,25 @@ static int queue_gso_packets(struct datapath *dp, struct sk_buff *skb,
if (IS_ERR(segs))
return PTR_ERR(segs);

if (gso_type & SKB_GSO_UDP) {
/* The initial flow key extracted by ovs_flow_extract()
* in this case is for a first fragment, so we need to
* properly mark later fragments.
*/
later_key = *OVS_CB(skb)->pkt_key;
later_key.ip.frag = OVS_FRAG_TYPE_LATER;
}

/* Queue all of the segments. */
skb = segs;
do {
if (gso_type & SKB_GSO_UDP && skb != segs)
OVS_CB(skb)->pkt_key = &later_key;

err = queue_userspace_packet(dp, skb, upcall_info);
if (err)
break;

if (skb == segs && gso_type & SKB_GSO_UDP) {
/* The initial flow key extracted by ovs_flow_extract()
* in this case is for a first fragment, so we need to
* properly mark later fragments.
*/
later_key = *upcall_info->key;
later_key.ip.frag = OVS_FRAG_TYPE_LATER;

later_info = *upcall_info;
later_info.key = &later_key;
upcall_info = &later_info;
}
} while ((skb = skb->next));

/* Free all of the segments. */
Expand Down Expand Up @@ -437,6 +437,7 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
struct ovs_header *upcall;
struct sk_buff *nskb = NULL;
struct sk_buff *user_skb; /* to be queued to userspace */
struct sw_flow_key *pkt_key = OVS_CB(skb)->pkt_key;
struct nlattr *nla;
struct genl_info info = {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)
Expand Down Expand Up @@ -497,8 +498,7 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
upcall->dp_ifindex = dp_ifindex;

nla = nla_nest_start(user_skb, OVS_PACKET_ATTR_KEY);
err = ovs_nla_put_flow(dp, upcall_info->key,
upcall_info->key, user_skb);
err = ovs_nla_put_flow(dp, pkt_key, pkt_key, user_skb);
BUG_ON(err);
nla_nest_end(user_skb, nla);

Expand Down
4 changes: 1 addition & 3 deletions datapath/datapath.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,16 @@ struct ovs_skb_cb {
/**
* struct dp_upcall - metadata to include with a packet to send to userspace
* @cmd: One of %OVS_PACKET_CMD_*.
* @key: Becomes %OVS_PACKET_ATTR_KEY. Must be nonnull.
* @userdata: If nonnull, its variable-length value is passed to userspace as
* %OVS_PACKET_ATTR_USERDATA.
* @portid: Netlink PID to which packet should be sent. If @portid is 0 then no
* packet is sent and the packet is accounted in the datapath's @n_lost
* counter.
*/
struct dp_upcall_info {
u8 cmd;
const struct sw_flow_key *key;
const struct nlattr *userdata;
u32 portid;
u8 cmd;
};

/**
Expand Down

0 comments on commit 9b277b3

Please sign in to comment.