vport = vport_locate(odp_port->devname);
if (!vport) {
- vport_lock();
+ struct vport_parms parms;
- if (odp_port->flags & ODP_PORT_INTERNAL)
- vport = vport_add(odp_port->devname, "internal", NULL);
- else
- vport = vport_add(odp_port->devname, "netdev", NULL);
+ parms.name = odp_port->devname;
+ parms.type = odp_port->flags & ODP_PORT_INTERNAL ? "internal" : "netdev";
+ parms.config = NULL;
+ vport_lock();
+ vport = vport_add(&parms);
vport_unlock();
if (IS_ERR(vport))
return 0;
}
-struct vport *tnl_create(const char *name, const void __user *config,
+struct vport *tnl_create(const struct vport_parms *parms,
const struct vport_ops *vport_ops,
const struct tnl_ops *tnl_ops)
{
tnl_vport = tnl_vport_priv(vport);
- strcpy(tnl_vport->name, name);
+ strcpy(tnl_vport->name, parms->name);
tnl_vport->tnl_ops = tnl_ops;
tnl_vport->mutable = kzalloc(sizeof(struct tnl_mutable_config), GFP_KERNEL);
get_random_bytes(&initial_frag_id, sizeof(int));
atomic_set(&tnl_vport->frag_id, initial_frag_id);
- err = set_config(config, tnl_ops, NULL, tnl_vport->mutable);
+ err = set_config(parms->config, tnl_ops, NULL, tnl_vport->mutable);
if (err)
goto error_free_mutable;
#endif
};
-struct vport *tnl_create(const char *name, const void __user *config,
- const struct vport_ops *,
+struct vport *tnl_create(const struct vport_parms *, const struct vport_ops *,
const struct tnl_ops *);
int tnl_modify(struct vport *, const void __user *config);
int tnl_destroy(struct vport *);
.update_header = capwap_update_header,
};
-static struct vport *capwap_create(const char *name, const void __user *config)
+static struct vport *capwap_create(const struct vport_parms *parms)
{
- return tnl_create(name, config, &capwap_vport_ops, &capwap_tnl_ops);
+ return tnl_create(parms, &capwap_vport_ops, &capwap_tnl_ops);
}
/* Random value. Irrelevant as long as it's not 0 since we set the handler. */
.update_header = gre_update_header,
};
-static struct vport *gre_create(const char *name, const void __user *config)
+static struct vport *gre_create(const struct vport_parms *parms)
{
- return tnl_create(name, config, &gre_vport_ops, &gre_tnl_ops);
+ return tnl_create(parms, &gre_vport_ops, &gre_tnl_ops);
}
static const struct net_protocol gre_protocol_handlers = {
vport_gen_rand_ether_addr(netdev->dev_addr);
}
-static struct vport *internal_dev_create(const char *name,
- const void __user *config)
+static struct vport *internal_dev_create(const struct vport_parms *parms)
{
struct vport *vport;
struct netdev_vport *netdev_vport;
netdev_vport = netdev_vport_priv(vport);
- netdev_vport->dev = alloc_netdev(sizeof(struct internal_dev), name, do_setup);
+ netdev_vport->dev = alloc_netdev(sizeof(struct internal_dev), parms->name, do_setup);
if (!netdev_vport->dev) {
err = -ENOMEM;
goto error_free_vport;
}
#endif
-static struct vport *netdev_create(const char *name, const void __user *config)
+static struct vport *netdev_create(const struct vport_parms *parms)
{
struct vport *vport;
struct netdev_vport *netdev_vport;
netdev_vport = netdev_vport_priv(vport);
- netdev_vport->dev = dev_get_by_name(&init_net, name);
+ netdev_vport->dev = dev_get_by_name(&init_net, parms->name);
if (!netdev_vport->dev) {
err = -ENODEV;
goto error_free_vport;
return 0;
}
-static struct vport *patch_create(const char *name, const void __user *config)
+static struct vport *patch_create(const struct vport_parms *parms)
{
struct vport *vport;
struct patch_vport *patch_vport;
patch_vport = patch_vport_priv(vport);
- strcpy(patch_vport->name, name);
+ strcpy(patch_vport->name, parms->name);
- err = set_config(vport, config);
+ err = set_config(vport, parms->config);
if (err)
goto error_free_vport;
static int do_vport_add(struct odp_vport_add *vport_config)
{
+ struct vport_parms parms;
struct vport *vport;
int err = 0;
goto out;
}
+ parms.name = vport_config->devname;
+ parms.type = vport_config->port_type;
+ parms.config = vport_config->config;
+
vport_lock();
- vport = vport_add(vport_config->devname, vport_config->port_type,
- vport_config->config);
+ vport = vport_add(&parms);
vport_unlock();
if (IS_ERR(vport))
/**
* vport_add - add vport device (for kernel callers)
*
- * @name: Name of new device.
- * @type: Type of new device (to be matched against types in registered vport
- * ops).
- * @config: Device type specific configuration. Userspace pointer.
+ * @parms: Information about new vport.
*
* Creates a new vport with the specified configuration (which is dependent
* on device type). Both RTNL and vport locks must be held.
*/
-struct vport *vport_add(const char *name, const char *type, const void __user *config)
+struct vport *vport_add(const struct vport_parms *parms)
{
struct vport *vport;
int err = 0;
ASSERT_VPORT();
for (i = 0; i < n_vport_types; i++) {
- if (!strcmp(vport_ops_list[i]->type, type)) {
- vport = vport_ops_list[i]->create(name, config);
+ if (!strcmp(vport_ops_list[i]->type, parms->type)) {
+ vport = vport_ops_list[i]->create(parms);
if (IS_ERR(vport)) {
err = PTR_ERR(vport);
goto out;
#include "odp-compat.h"
struct vport;
+struct vport_parms;
struct dp_port;
/* The following definitions are for users of the vport subsytem: */
int vport_init(void);
void vport_exit(void);
-struct vport *vport_add(const char *name, const char *type, const void __user *config);
+struct vport *vport_add(const struct vport_parms *);
int vport_mod(struct vport *, const void __user *config);
int vport_del(struct vport *);
#define VPORT_F_FLOW (1 << 2) /* Sets OVS_CB(skb)->flow. */
#define VPORT_F_TUN_ID (1 << 3) /* Sets OVS_CB(skb)->tun_id. */
+/**
+ * struct vport_parms - parameters for creating a new vport
+ *
+ * @name: New vport's name.
+ * @type: New vport's type.
+ * @config: New vport's configuration, as %NULL or a userspace pointer to an
+ * arbitrary type-specific structure.
+ */
+struct vport_parms {
+ const char *name;
+ const char *type;
+ const void __user *config;
+};
+
/**
* struct vport_ops - definition of a type of virtual port
*
* failure of this function will cause the module to not load. If the flag is
* not set and initialzation fails then no vports of this type can be created.
* @exit: Called at module unload.
- * @create: Create a new vport called 'name' with vport type specific
- * configuration 'config' (which must be copied from userspace before use). On
- * success must allocate a new vport using vport_alloc().
+ * @create: Create a new vport configured as specified. On success returns
+ * a new vport allocated with vport_alloc(), otherwise an ERR_PTR() value.
* @modify: Modify the configuration of an existing vport. May be null if
* modification is not supported.
* @destroy: Destroy and free a vport using vport_free(). Prior to destruction
void (*exit)(void);
/* Called with RTNL lock. */
- struct vport *(*create)(const char *name, const void __user *config);
+ struct vport *(*create)(const struct vport_parms *);
int (*modify)(struct vport *, const void __user *config);
int (*destroy)(struct vport *);