]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
openvswitch: refactor do_output() to move NULL check out of fast path
authorAndy Zhou <azhou@nicira.com>
Mon, 8 Sep 2014 07:35:02 +0000 (00:35 -0700)
committerPravin B Shelar <pshelar@nicira.com>
Thu, 6 Nov 2014 07:52:34 +0000 (23:52 -0800)
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>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
net/openvswitch/actions.c

index 930b1b6e4cef26a1569ba284e3d6818a8ff63069..9fd33c0bf173ef18626c9c15d5d99834a70fb6fe 100644 (file)
@@ -551,21 +551,14 @@ static int set_sctp(struct sk_buff *skb,
        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))
-               return -ENOMEM;
-
-       vport = ovs_vport_rcu(dp, out_port);
-       if (unlikely(!vport)) {
+       if (likely(vport))
+               ovs_vport_send(vport, skb);
+       else
                kfree_skb(skb);
-               return -ENODEV;
-       }
-
-       ovs_vport_send(vport, skb);
-       return 0;
 }
 
 static int output_userspace(struct datapath *dp, struct sk_buff *skb,
@@ -768,8 +761,12 @@ static int do_execute_actions(struct datapath *dp, struct sk_buff *skb,
             a = nla_next(a, &rem)) {
                int err = 0;
 
-               if (prev_port != -1) {
-                       do_output(dp, skb_clone(skb, GFP_ATOMIC), prev_port);
+               if (unlikely(prev_port != -1)) {
+                       struct sk_buff *out_skb = skb_clone(skb, GFP_ATOMIC);
+
+                       if (out_skb)
+                               do_output(dp, out_skb, prev_port);
+
                        prev_port = -1;
                }