datapath: Cleanup actions.c:do_output().
authorJesse Gross <jesse@nicira.com>
Tue, 20 Sep 2011 23:44:46 +0000 (16:44 -0700)
committerJesse Gross <jesse@nicira.com>
Wed, 21 Sep 2011 17:24:09 +0000 (10:24 -0700)
The code for outputting a packet can be simplified a little and
also modernized.  There is no functional change.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
datapath/actions.c

index deaa4dc9200506774f7905f2b16a24268d43b32f..32e44c040ff930ab94340efd617bb1f87f5d225b 100644 (file)
@@ -227,22 +227,21 @@ static int set_tp_port(struct sk_buff *skb, const struct nlattr *a)
        return 0;
 }
 
-static void do_output(struct datapath *dp, struct sk_buff *skb, int out_port)
+static int do_output(struct datapath *dp, struct sk_buff *skb, int out_port)
 {
-       struct vport *p;
+       struct vport *vport;
 
-       if (!skb)
-               goto error;
-
-       p = rcu_dereference(dp->ports[out_port]);
-       if (!p)
-               goto error;
+       if (unlikely(!skb))
+               return -ENOMEM;
 
-       vport_send(p, skb);
-       return;
+       vport = rcu_dereference(dp->ports[out_port]);
+       if (unlikely(!vport)) {
+               kfree_skb(skb);
+               return -ENODEV;
+       }
 
-error:
-       kfree_skb(skb);
+       vport_send(vport, skb);
+       return 0;
 }
 
 static int output_userspace(struct datapath *dp, struct sk_buff *skb, u64 arg)