From f15c86394230974d0535c0f5913cc959f3d920f3 Mon Sep 17 00:00:00 2001 From: Jesse Gross Date: Tue, 20 Sep 2011 16:44:46 -0700 Subject: [PATCH] datapath: Cleanup actions.c:do_output(). The code for outputting a packet can be simplified a little and also modernized. There is no functional change. Signed-off-by: Jesse Gross Acked-by: Ben Pfaff --- datapath/actions.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/datapath/actions.c b/datapath/actions.c index deaa4dc9..32e44c04 100644 --- a/datapath/actions.c +++ b/datapath/actions.c @@ -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) -- 2.30.2