mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
openvswitch: Remove redundant key ref from upcall_info.
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 <pshelar@nicira.com> Acked-by: Andy Zhou <azhou@nicira.com>
This commit is contained in:
parent
fff06c36a2
commit
e8eedb85bd
3 changed files with 32 additions and 28 deletions
|
@ -624,7 +624,6 @@ static int output_userspace(struct datapath *dp, struct sk_buff *skb,
|
||||||
int rem;
|
int rem;
|
||||||
|
|
||||||
upcall.cmd = OVS_PACKET_CMD_ACTION;
|
upcall.cmd = OVS_PACKET_CMD_ACTION;
|
||||||
upcall.key = key;
|
|
||||||
upcall.userdata = NULL;
|
upcall.userdata = NULL;
|
||||||
upcall.portid = 0;
|
upcall.portid = 0;
|
||||||
upcall.egress_tun_info = NULL;
|
upcall.egress_tun_info = NULL;
|
||||||
|
@ -659,7 +658,7 @@ static int output_userspace(struct datapath *dp, struct sk_buff *skb,
|
||||||
} /* End of switch. */
|
} /* End of switch. */
|
||||||
}
|
}
|
||||||
|
|
||||||
return ovs_dp_upcall(dp, skb, &upcall);
|
return ovs_dp_upcall(dp, skb, key, &upcall);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sample(struct datapath *dp, struct sk_buff *skb,
|
static int sample(struct datapath *dp, struct sk_buff *skb,
|
||||||
|
|
|
@ -136,8 +136,10 @@ EXPORT_SYMBOL_GPL(lockdep_ovsl_is_held);
|
||||||
|
|
||||||
static struct vport *new_vport(const struct vport_parms *);
|
static struct vport *new_vport(const struct vport_parms *);
|
||||||
static int queue_gso_packets(struct datapath *dp, struct sk_buff *,
|
static int queue_gso_packets(struct datapath *dp, struct sk_buff *,
|
||||||
|
const struct sw_flow_key *,
|
||||||
const struct dp_upcall_info *);
|
const struct dp_upcall_info *);
|
||||||
static int queue_userspace_packet(struct datapath *dp, struct sk_buff *,
|
static int queue_userspace_packet(struct datapath *dp, struct sk_buff *,
|
||||||
|
const struct sw_flow_key *,
|
||||||
const struct dp_upcall_info *);
|
const struct dp_upcall_info *);
|
||||||
|
|
||||||
/* Must be called with rcu_read_lock. */
|
/* Must be called with rcu_read_lock. */
|
||||||
|
@ -271,11 +273,10 @@ void ovs_dp_process_packet(struct sk_buff *skb, struct sw_flow_key *key)
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
upcall.cmd = OVS_PACKET_CMD_MISS;
|
upcall.cmd = OVS_PACKET_CMD_MISS;
|
||||||
upcall.key = key;
|
|
||||||
upcall.userdata = NULL;
|
upcall.userdata = NULL;
|
||||||
upcall.portid = ovs_vport_find_upcall_portid(p, skb);
|
upcall.portid = ovs_vport_find_upcall_portid(p, skb);
|
||||||
upcall.egress_tun_info = NULL;
|
upcall.egress_tun_info = NULL;
|
||||||
error = ovs_dp_upcall(dp, skb, &upcall);
|
error = ovs_dp_upcall(dp, skb, key, &upcall);
|
||||||
if (unlikely(error))
|
if (unlikely(error))
|
||||||
kfree_skb(skb);
|
kfree_skb(skb);
|
||||||
else
|
else
|
||||||
|
@ -299,6 +300,7 @@ out:
|
||||||
}
|
}
|
||||||
|
|
||||||
int ovs_dp_upcall(struct datapath *dp, struct sk_buff *skb,
|
int ovs_dp_upcall(struct datapath *dp, struct sk_buff *skb,
|
||||||
|
const struct sw_flow_key *key,
|
||||||
const struct dp_upcall_info *upcall_info)
|
const struct dp_upcall_info *upcall_info)
|
||||||
{
|
{
|
||||||
struct dp_stats_percpu *stats;
|
struct dp_stats_percpu *stats;
|
||||||
|
@ -310,9 +312,9 @@ int ovs_dp_upcall(struct datapath *dp, struct sk_buff *skb,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!skb_is_gso(skb))
|
if (!skb_is_gso(skb))
|
||||||
err = queue_userspace_packet(dp, skb, upcall_info);
|
err = queue_userspace_packet(dp, skb, key, upcall_info);
|
||||||
else
|
else
|
||||||
err = queue_gso_packets(dp, skb, upcall_info);
|
err = queue_gso_packets(dp, skb, key, upcall_info);
|
||||||
if (err)
|
if (err)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
@ -329,39 +331,43 @@ err:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int queue_gso_packets(struct datapath *dp, struct sk_buff *skb,
|
static int queue_gso_packets(struct datapath *dp, struct sk_buff *skb,
|
||||||
|
const struct sw_flow_key *key,
|
||||||
const struct dp_upcall_info *upcall_info)
|
const struct dp_upcall_info *upcall_info)
|
||||||
{
|
{
|
||||||
unsigned short gso_type = skb_shinfo(skb)->gso_type;
|
unsigned short gso_type = skb_shinfo(skb)->gso_type;
|
||||||
struct dp_upcall_info later_info;
|
|
||||||
struct sw_flow_key later_key;
|
struct sw_flow_key later_key;
|
||||||
struct sk_buff *segs, *nskb;
|
struct sk_buff *segs, *nskb;
|
||||||
|
struct ovs_skb_cb ovs_cb;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
ovs_cb = *OVS_CB(skb);
|
||||||
segs = __skb_gso_segment(skb, NETIF_F_SG, false);
|
segs = __skb_gso_segment(skb, NETIF_F_SG, false);
|
||||||
|
*OVS_CB(skb) = ovs_cb;
|
||||||
if (IS_ERR(segs))
|
if (IS_ERR(segs))
|
||||||
return PTR_ERR(segs);
|
return PTR_ERR(segs);
|
||||||
if (segs == NULL)
|
if (segs == NULL)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (gso_type & SKB_GSO_UDP) {
|
||||||
|
/* The initial flow key extracted by ovs_flow_key_extract()
|
||||||
|
* in this case is for a first fragment, so we need to
|
||||||
|
* properly mark later fragments.
|
||||||
|
*/
|
||||||
|
later_key = *key;
|
||||||
|
later_key.ip.frag = OVS_FRAG_TYPE_LATER;
|
||||||
|
}
|
||||||
|
|
||||||
/* Queue all of the segments. */
|
/* Queue all of the segments. */
|
||||||
skb = segs;
|
skb = segs;
|
||||||
do {
|
do {
|
||||||
err = queue_userspace_packet(dp, skb, upcall_info);
|
*OVS_CB(skb) = ovs_cb;
|
||||||
|
if (gso_type & SKB_GSO_UDP && skb != segs)
|
||||||
|
key = &later_key;
|
||||||
|
|
||||||
|
err = queue_userspace_packet(dp, skb, key, upcall_info);
|
||||||
if (err)
|
if (err)
|
||||||
break;
|
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));
|
} while ((skb = skb->next));
|
||||||
|
|
||||||
/* Free all of the segments. */
|
/* Free all of the segments. */
|
||||||
|
@ -395,6 +401,7 @@ static size_t upcall_msg_size(const struct dp_upcall_info *upcall_info,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
|
static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
|
||||||
|
const struct sw_flow_key *key,
|
||||||
const struct dp_upcall_info *upcall_info)
|
const struct dp_upcall_info *upcall_info)
|
||||||
{
|
{
|
||||||
struct ovs_header *upcall;
|
struct ovs_header *upcall;
|
||||||
|
@ -457,7 +464,7 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
|
||||||
upcall->dp_ifindex = dp_ifindex;
|
upcall->dp_ifindex = dp_ifindex;
|
||||||
|
|
||||||
nla = nla_nest_start(user_skb, OVS_PACKET_ATTR_KEY);
|
nla = nla_nest_start(user_skb, OVS_PACKET_ATTR_KEY);
|
||||||
err = ovs_nla_put_flow(upcall_info->key, upcall_info->key, user_skb);
|
err = ovs_nla_put_flow(key, key, user_skb);
|
||||||
BUG_ON(err);
|
BUG_ON(err);
|
||||||
nla_nest_end(user_skb, nla);
|
nla_nest_end(user_skb, nla);
|
||||||
|
|
||||||
|
|
|
@ -108,20 +108,18 @@ struct ovs_skb_cb {
|
||||||
/**
|
/**
|
||||||
* struct dp_upcall - metadata to include with a packet to send to userspace
|
* struct dp_upcall - metadata to include with a packet to send to userspace
|
||||||
* @cmd: One of %OVS_PACKET_CMD_*.
|
* @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
|
* @userdata: If nonnull, its variable-length value is passed to userspace as
|
||||||
* %OVS_PACKET_ATTR_USERDATA.
|
* %OVS_PACKET_ATTR_USERDATA.
|
||||||
* @pid: Netlink PID to which packet should be sent. If @pid is 0 then no
|
* @portid: Netlink portid to which packet should be sent. If @portid is 0
|
||||||
* packet is sent and the packet is accounted in the datapath's @n_lost
|
* then no packet is sent and the packet is accounted in the datapath's @n_lost
|
||||||
* counter.
|
* counter.
|
||||||
* @egress_tun_info: If nonnull, becomes %OVS_PACKET_ATTR_EGRESS_TUN_KEY.
|
* @egress_tun_info: If nonnull, becomes %OVS_PACKET_ATTR_EGRESS_TUN_KEY.
|
||||||
*/
|
*/
|
||||||
struct dp_upcall_info {
|
struct dp_upcall_info {
|
||||||
u8 cmd;
|
const struct ovs_tunnel_info *egress_tun_info;
|
||||||
const struct sw_flow_key *key;
|
|
||||||
const struct nlattr *userdata;
|
const struct nlattr *userdata;
|
||||||
u32 portid;
|
u32 portid;
|
||||||
const struct ovs_tunnel_info *egress_tun_info;
|
u8 cmd;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -187,7 +185,7 @@ extern struct genl_family dp_vport_genl_family;
|
||||||
void ovs_dp_process_packet(struct sk_buff *skb, struct sw_flow_key *key);
|
void ovs_dp_process_packet(struct sk_buff *skb, struct sw_flow_key *key);
|
||||||
void ovs_dp_detach_port(struct vport *);
|
void ovs_dp_detach_port(struct vport *);
|
||||||
int ovs_dp_upcall(struct datapath *, struct sk_buff *,
|
int ovs_dp_upcall(struct datapath *, struct sk_buff *,
|
||||||
const struct dp_upcall_info *);
|
const struct sw_flow_key *, const struct dp_upcall_info *);
|
||||||
|
|
||||||
const char *ovs_dp_name(const struct datapath *dp);
|
const char *ovs_dp_name(const struct datapath *dp);
|
||||||
struct sk_buff *ovs_vport_cmd_build_info(struct vport *, u32 pid, u32 seq,
|
struct sk_buff *ovs_vport_cmd_build_info(struct vport *, u32 pid, u32 seq,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue