aboutsummaryrefslogtreecommitdiffstats
path: root/net/openvswitch
diff options
context:
space:
mode:
authorAndy Zhou <azhou@nicira.com>2014-09-08 03:35:02 -0400
committerPravin B Shelar <pshelar@nicira.com>2014-11-06 02:52:34 -0500
commit738967b8bf57e582db1a23ce773c36fefd4b7d37 (patch)
treeb8a6a56e9eaa280fc10371002bb6d8fef790ab04 /net/openvswitch
parent426cda5cc177301f9c196f3a9b6a1287051ba599 (diff)
openvswitch: refactor do_output() to move 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> Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Diffstat (limited to 'net/openvswitch')
-rw-r--r--net/openvswitch/actions.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 930b1b6e4cef..9fd33c0bf173 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -551,21 +551,14 @@ static int set_sctp(struct sk_buff *skb,
551 return 0; 551 return 0;
552} 552}
553 553
554static int do_output(struct datapath *dp, struct sk_buff *skb, int out_port) 554static void do_output(struct datapath *dp, struct sk_buff *skb, int out_port)
555{ 555{
556 struct vport *vport; 556 struct vport *vport = ovs_vport_rcu(dp, out_port);
557 557
558 if (unlikely(!skb)) 558 if (likely(vport))
559 return -ENOMEM; 559 ovs_vport_send(vport, skb);
560 560 else
561 vport = ovs_vport_rcu(dp, out_port);
562 if (unlikely(!vport)) {
563 kfree_skb(skb); 561 kfree_skb(skb);
564 return -ENODEV;
565 }
566
567 ovs_vport_send(vport, skb);
568 return 0;
569} 562}
570 563
571static int output_userspace(struct datapath *dp, struct sk_buff *skb, 564static 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,
768 a = nla_next(a, &rem)) { 761 a = nla_next(a, &rem)) {
769 int err = 0; 762 int err = 0;
770 763
771 if (prev_port != -1) { 764 if (unlikely(prev_port != -1)) {
772 do_output(dp, skb_clone(skb, GFP_ATOMIC), prev_port); 765 struct sk_buff *out_skb = skb_clone(skb, GFP_ATOMIC);
766
767 if (out_skb)
768 do_output(dp, out_skb, prev_port);
769
773 prev_port = -1; 770 prev_port = -1;
774 } 771 }
775 772