Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma
[linux-2.6-microblaze.git] / drivers / infiniband / core / user_mad.c
index 02b7947..671f07b 100644 (file)
@@ -129,6 +129,9 @@ struct ib_umad_packet {
        struct ib_user_mad mad;
 };
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/ib_umad.h>
+
 static const dev_t base_umad_dev = MKDEV(IB_UMAD_MAJOR, IB_UMAD_MINOR_BASE);
 static const dev_t base_issm_dev = MKDEV(IB_UMAD_MAJOR, IB_UMAD_MINOR_BASE) +
                                   IB_UMAD_NUM_FIXED_MINOR;
@@ -334,6 +337,9 @@ static ssize_t copy_recv_mad(struct ib_umad_file *file, char __user *buf,
                                return -EFAULT;
                }
        }
+
+       trace_ib_umad_read_recv(file, &packet->mad.hdr, &recv_buf->mad->mad_hdr);
+
        return hdr_size(file) + packet->length;
 }
 
@@ -353,6 +359,9 @@ static ssize_t copy_send_mad(struct ib_umad_file *file, char __user *buf,
        if (copy_to_user(buf, packet->mad.data, packet->length))
                return -EFAULT;
 
+       trace_ib_umad_read_send(file, &packet->mad.hdr,
+                               (struct ib_mad_hdr *)&packet->mad.data);
+
        return size;
 }
 
@@ -508,6 +517,9 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
 
        mutex_lock(&file->mutex);
 
+       trace_ib_umad_write(file, &packet->mad.hdr,
+                           (struct ib_mad_hdr *)&packet->mad.data);
+
        agent = __get_agent(file, packet->mad.hdr.id);
        if (!agent) {
                ret = -EINVAL;
@@ -968,6 +980,11 @@ static int ib_umad_open(struct inode *inode, struct file *filp)
                goto out;
        }
 
+       if (!rdma_dev_access_netns(port->ib_dev, current->nsproxy->net_ns)) {
+               ret = -EPERM;
+               goto out;
+       }
+
        file = kzalloc(sizeof(*file), GFP_KERNEL);
        if (!file) {
                ret = -ENOMEM;
@@ -985,7 +1002,7 @@ static int ib_umad_open(struct inode *inode, struct file *filp)
 
        list_add_tail(&file->port_list, &port->file_list);
 
-       nonseekable_open(inode, filp);
+       stream_open(inode, filp);
 out:
        mutex_unlock(&port->file_mutex);
        return ret;
@@ -1061,6 +1078,11 @@ static int ib_umad_sm_open(struct inode *inode, struct file *filp)
                }
        }
 
+       if (!rdma_dev_access_netns(port->ib_dev, current->nsproxy->net_ns)) {
+               ret = -EPERM;
+               goto err_up_sem;
+       }
+
        ret = ib_modify_port(port->ib_dev, port->port_num, 0, &props);
        if (ret)
                goto err_up_sem;