- struct odp_vport_ether vport_ether;
- struct vport *vport;
- int err = 0;
-
- if (copy_from_user(&vport_ether, uvport_ether, sizeof(struct odp_vport_ether)))
- return -EFAULT;
-
- vport_ether.devname[IFNAMSIZ - 1] = '\0';
-
- vport_lock();
-
- vport = vport_locate(vport_ether.devname);
- if (!vport) {
- err = -ENODEV;
- goto out;
- }
-
- rcu_read_lock();
- memcpy(vport_ether.ether_addr, vport_get_addr(vport), ETH_ALEN);
- rcu_read_unlock();
-
-out:
- vport_unlock();
-
- if (!err)
- if (copy_to_user(uvport_ether, &vport_ether, sizeof(struct odp_vport_ether)))
- err = -EFAULT;
-
- return err;
-}
-
-/**
- * vport_user_ether_set - set device Ethernet address (for userspace callers)
- *
- * @uvport_ether: Ethernet address request parameters.
- *
- * Sets the Ethernet address of the given device. Some devices may not support
- * setting the Ethernet address, in which case the result will always be
- * -EOPNOTSUPP. This function is for userspace callers and assumes no locks
- * are held.
- */
-int vport_user_ether_set(struct odp_vport_ether __user *uvport_ether)
-{
- struct odp_vport_ether vport_ether;
- struct vport *vport;
- int err;
-
- if (copy_from_user(&vport_ether, uvport_ether, sizeof(struct odp_vport_ether)))
- return -EFAULT;
-
- vport_ether.devname[IFNAMSIZ - 1] = '\0';
-
- rtnl_lock();
- vport_lock();
-
- vport = vport_locate(vport_ether.devname);
- if (!vport) {
- err = -ENODEV;
- goto out;
- }
-
- err = vport_set_addr(vport, vport_ether.ether_addr);
-
-out:
- vport_unlock();
- rtnl_unlock();
- return err;
-}
-
-/**
- * vport_user_mtu_get - retrieve device MTU (for userspace callers)
- *
- * @uvport_mtu: MTU request parameters.
- *
- * Retrieves the MTU of the given device. This function is for userspace
- * callers and assumes no locks are held.
- */
-int vport_user_mtu_get(struct odp_vport_mtu __user *uvport_mtu)
-{
- struct odp_vport_mtu vport_mtu;
- struct vport *vport;
- int err = 0;
-
- if (copy_from_user(&vport_mtu, uvport_mtu, sizeof(struct odp_vport_mtu)))
- return -EFAULT;
-
- vport_mtu.devname[IFNAMSIZ - 1] = '\0';
-
- vport_lock();
-
- vport = vport_locate(vport_mtu.devname);
- if (!vport) {
- err = -ENODEV;
- goto out;
- }
-
- vport_mtu.mtu = vport_get_mtu(vport);
-
-out:
- vport_unlock();
-
- if (!err)
- if (copy_to_user(uvport_mtu, &vport_mtu, sizeof(struct odp_vport_mtu)))
- err = -EFAULT;
-
- return err;
-}
-
-/**
- * vport_user_mtu_set - set device MTU (for userspace callers)
- *
- * @uvport_mtu: MTU request parameters.
- *
- * Sets the MTU of the given device. Some devices may not support setting the
- * MTU, in which case the result will always be -EOPNOTSUPP. This function is
- * for userspace callers and assumes no locks are held.
- */
-int vport_user_mtu_set(struct odp_vport_mtu __user *uvport_mtu)
-{
- struct odp_vport_mtu vport_mtu;
- struct vport *vport;
- int err;
-
- if (copy_from_user(&vport_mtu, uvport_mtu, sizeof(struct odp_vport_mtu)))
- return -EFAULT;
-
- vport_mtu.devname[IFNAMSIZ - 1] = '\0';
-
- rtnl_lock();
- vport_lock();
-
- vport = vport_locate(vport_mtu.devname);
- if (!vport) {
- err = -ENODEV;
- goto out;
- }
-
- err = vport_set_mtu(vport, vport_mtu.mtu);
-
-out:
- vport_unlock();
- rtnl_unlock();
- return err;
-}
-
-static struct hlist_head *hash_bucket(const char *name)
-{
- unsigned int hash = full_name_hash(name, strlen(name));