openvswitch: Remove pkt_key from OVS_CB
[firefly-linux-kernel-4.4.55.git] / net / openvswitch / datapath.c
index 7228ec3faf19cdc02a685caa04ccbf04ddf8005a..458096da138a3252e2132922d33ac058cfdc0e29 100644 (file)
@@ -265,17 +265,19 @@ void ovs_dp_process_received_packet(struct vport *p, struct sk_buff *skb)
                upcall.key = &key;
                upcall.userdata = NULL;
                upcall.portid = ovs_vport_find_upcall_portid(p, skb);
-               ovs_dp_upcall(dp, skb, &upcall);
-               consume_skb(skb);
+               error = ovs_dp_upcall(dp, skb, &upcall);
+               if (unlikely(error))
+                       kfree_skb(skb);
+               else
+                       consume_skb(skb);
                stats_counter = &stats->n_missed;
                goto out;
        }
 
        OVS_CB(skb)->flow = flow;
-       OVS_CB(skb)->pkt_key = &key;
 
        ovs_flow_stats_update(OVS_CB(skb)->flow, key.tp.flags, skb);
-       ovs_execute_actions(dp, skb);
+       ovs_execute_actions(dp, skb, &key);
        stats_counter = &stats->n_hit;
 
 out:
@@ -404,7 +406,7 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
 {
        struct ovs_header *upcall;
        struct sk_buff *nskb = NULL;
-       struct sk_buff *user_skb; /* to be queued to userspace */
+       struct sk_buff *user_skb = NULL; /* to be queued to userspace */
        struct nlattr *nla;
        struct genl_info info = {
                .dst_sk = ovs_dp_get_net(dp)->genl_sock,
@@ -494,9 +496,11 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
        ((struct nlmsghdr *) user_skb->data)->nlmsg_len = user_skb->len;
 
        err = genlmsg_unicast(ovs_dp_get_net(dp), user_skb, upcall_info->portid);
+       user_skb = NULL;
 out:
        if (err)
                skb_tx_error(skb);
+       kfree_skb(user_skb);
        kfree_skb(nskb);
        return err;
 }
@@ -563,7 +567,6 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info)
                goto err_flow_free;
 
        OVS_CB(packet)->flow = flow;
-       OVS_CB(packet)->pkt_key = &flow->key;
        packet->priority = flow->key.phy.priority;
        packet->mark = flow->key.phy.skb_mark;
 
@@ -574,7 +577,7 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info)
                goto err_unlock;
 
        local_bh_disable();
-       err = ovs_execute_actions(dp, packet);
+       err = ovs_execute_actions(dp, packet, &flow->key);
        local_bh_enable();
        rcu_read_unlock();