datapath: Simplify vport_send() error handling.
[cascardo/ovs.git] / datapath / vport.c
index bda643e..e3f495e 100644 (file)
@@ -40,7 +40,8 @@ static void ovs_vport_record_error(struct vport *,
                                   enum vport_err_type err_type);
 
 /* List of statically compiled vport implementations.  Don't forget to also
- * add yours to the list at the bottom of vport.h. */
+ * add yours to the list at the bottom of vport.h.
+ */
 static const struct vport_ops *vport_ops_list[] = {
        &ovs_netdev_vport_ops,
        &ovs_internal_vport_ops,
@@ -166,7 +167,7 @@ struct vport *ovs_vport_alloc(int priv_size, const struct vport_ops *ops,
  */
 void ovs_vport_free(struct vport *vport)
 {
-       kfree((struct vport_portids __force *)vport->upcall_portids);
+       kfree(rcu_dereference_raw(vport->upcall_portids));
        free_percpu(vport->percpu_stats);
        kfree(vport);
 }
@@ -417,12 +418,12 @@ int ovs_vport_get_upcall_portids(const struct vport *vport,
  *
  * Returns the portid of the target socket.  Must be called with rcu_read_lock.
  */
-u32 ovs_vport_find_upcall_portid(const struct vport *p, struct sk_buff *skb)
+u32 ovs_vport_find_upcall_portid(const struct vport *vport, struct sk_buff *skb)
 {
        struct vport_portids *ids;
        u32 hash;
 
-       ids = rcu_dereference(p->upcall_portids);
+       ids = rcu_dereference(vport->upcall_portids);
 
        if (ids->n_ids == 1 && ids->ids[0] == 0)
                return 0;
@@ -491,9 +492,9 @@ int ovs_vport_send(struct vport *vport, struct sk_buff *skb)
                u64_stats_update_end(&stats->syncp);
        } else if (sent < 0) {
                ovs_vport_record_error(vport, VPORT_E_TX_ERROR);
-               kfree_skb(skb);
-       } else
+       } else {
                ovs_vport_record_error(vport, VPORT_E_TX_DROPPED);
+       }
 
        return sent;
 }