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>
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)