2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-21 14:49:41 +00:00

datapath: refactor do_output() to move skb_clone NULL check out of fast path

skb_clone() NULL check is implemented in do_output(), as past of the
common (fast) path. Refactoring so that NULL check is done in the
slow path, immediately after skb_clone() is called.

Besides optimization, this change also improves code readability by
making the skb_clone() NULL check consistent within OVS datapath
module.

Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
This commit is contained in:
Andy Zhou
2014-07-10 00:50:26 -07:00
parent 15cd5a8e1d
commit fe90efd9d6

View File

@@ -486,21 +486,14 @@ static int set_sctp(struct sk_buff *skb,
return 0; return 0;
} }
static int do_output(struct datapath *dp, struct sk_buff *skb, int out_port) static void do_output(struct datapath *dp, struct sk_buff *skb, int out_port)
{ {
struct vport *vport; struct vport *vport = ovs_vport_rcu(dp, out_port);
if (unlikely(!skb)) if (likely(vport))
return -ENOMEM; ovs_vport_send(vport, skb);
else
vport = ovs_vport_rcu(dp, out_port);
if (unlikely(!vport)) {
kfree_skb(skb); kfree_skb(skb);
return -ENODEV;
}
ovs_vport_send(vport, skb);
return 0;
} }
static int output_userspace(struct datapath *dp, struct sk_buff *skb, static int output_userspace(struct datapath *dp, struct sk_buff *skb,
@@ -693,8 +686,12 @@ static int do_execute_actions(struct datapath *dp, struct sk_buff *skb,
a = nla_next(a, &rem)) { a = nla_next(a, &rem)) {
int err = 0; int err = 0;
if (prev_port != -1) { if (unlikely(prev_port != -1)) {
do_output(dp, skb_clone(skb, GFP_ATOMIC), prev_port); struct sk_buff *out_skb = skb_clone(skb, GFP_ATOMIC);
if (out_skb)
do_output(dp, out_skb, prev_port);
prev_port = -1; prev_port = -1;
} }