Additional configuration is passed down to the kernel in the "config"
array of an odp_port when a vport is created. This information is not
returned when a vport is queried, though. This information is useful
for debugging, since it may be used to distinguish ports based on
additional data, such as the peer in tunnels. In a forthcoming patch, it
will be essential to distinguish between plain GRE and GRE over IPsec.
Signed-off-by: Justin Pettit <jpettit@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
rcu_read_lock();
strncpy(op.devname, vport_get_name(p), sizeof op.devname);
strncpy(op.type, vport_get_type(p), sizeof op.type);
rcu_read_lock();
strncpy(op.devname, vport_get_name(p), sizeof op.devname);
strncpy(op.type, vport_get_type(p), sizeof op.type);
+ vport_get_config(p, op.config);
rcu_read_unlock();
op.port = p->port_no;
rcu_read_unlock();
op.port = p->port_no;
return rcu_dereference_rtnl(tnl_vport->mutable)->eth_addr;
}
return rcu_dereference_rtnl(tnl_vport->mutable)->eth_addr;
}
+void tnl_get_config(const struct vport *vport, void *config)
+{
+ const struct tnl_vport *tnl_vport = tnl_vport_priv(vport);
+ struct tnl_port_config *port_config;
+
+ port_config = &rcu_dereference_rtnl(tnl_vport->mutable)->port_config;
+ memcpy(config, port_config, sizeof(*port_config));
+}
+
int tnl_get_mtu(const struct vport *vport)
{
const struct tnl_vport *tnl_vport = tnl_vport_priv(vport);
int tnl_get_mtu(const struct vport *vport)
{
const struct tnl_vport *tnl_vport = tnl_vport_priv(vport);
int tnl_set_addr(struct vport *vport, const unsigned char *addr);
const char *tnl_get_name(const struct vport *vport);
const unsigned char *tnl_get_addr(const struct vport *vport);
int tnl_set_addr(struct vport *vport, const unsigned char *addr);
const char *tnl_get_name(const struct vport *vport);
const unsigned char *tnl_get_addr(const struct vport *vport);
+void tnl_get_config(const struct vport *vport, void *config);
int tnl_get_mtu(const struct vport *vport);
int tnl_send(struct vport *vport, struct sk_buff *skb);
void tnl_rcv(struct vport *vport, struct sk_buff *skb);
int tnl_get_mtu(const struct vport *vport);
int tnl_send(struct vport *vport, struct sk_buff *skb);
void tnl_rcv(struct vport *vport, struct sk_buff *skb);
.set_addr = tnl_set_addr,
.get_name = tnl_get_name,
.get_addr = tnl_get_addr,
.set_addr = tnl_set_addr,
.get_name = tnl_get_name,
.get_addr = tnl_get_addr,
+ .get_config = tnl_get_config,
.get_dev_flags = vport_gen_get_dev_flags,
.is_running = vport_gen_is_running,
.get_operstate = vport_gen_get_operstate,
.get_dev_flags = vport_gen_get_dev_flags,
.is_running = vport_gen_is_running,
.get_operstate = vport_gen_get_operstate,
.set_addr = tnl_set_addr,
.get_name = tnl_get_name,
.get_addr = tnl_get_addr,
.set_addr = tnl_set_addr,
.get_name = tnl_get_name,
.get_addr = tnl_get_addr,
+ .get_config = tnl_get_config,
.get_dev_flags = vport_gen_get_dev_flags,
.is_running = vport_gen_is_running,
.get_operstate = vport_gen_get_operstate,
.get_dev_flags = vport_gen_get_dev_flags,
.is_running = vport_gen_is_running,
.get_operstate = vport_gen_get_operstate,
int netdev_set_addr(struct vport *, const unsigned char *addr);
const char *netdev_get_name(const struct vport *);
const unsigned char *netdev_get_addr(const struct vport *);
int netdev_set_addr(struct vport *, const unsigned char *addr);
const char *netdev_get_name(const struct vport *);
const unsigned char *netdev_get_addr(const struct vport *);
+const char *netdev_get_config(const struct vport *);
struct kobject *netdev_get_kobj(const struct vport *);
int netdev_get_stats(const struct vport *, struct rtnl_link_stats64 *);
unsigned netdev_get_dev_flags(const struct vport *);
struct kobject *netdev_get_kobj(const struct vport *);
int netdev_get_stats(const struct vport *, struct rtnl_link_stats64 *);
unsigned netdev_get_dev_flags(const struct vport *);
struct device_config {
struct rcu_head rcu;
struct device_config {
struct rcu_head rcu;
+ char peer_name[IFNAMSIZ];
unsigned char eth_addr[ETH_ALEN];
unsigned int mtu;
};
unsigned char eth_addr[ETH_ALEN];
unsigned int mtu;
};
char name[IFNAMSIZ];
/* Protected by RTNL lock. */
char name[IFNAMSIZ];
/* Protected by RTNL lock. */
- char peer_name[IFNAMSIZ];
struct hlist_node hash_node;
struct vport __rcu *peer;
struct hlist_node hash_node;
struct vport __rcu *peer;
-static int set_config(struct vport *vport, const void *config)
+static int set_config(struct vport *vport, const void *config,
+ struct device_config *devconf)
{
struct patch_vport *patch_vport = patch_vport_priv(vport);
char peer_name[IFNAMSIZ];
{
struct patch_vport *patch_vport = patch_vport_priv(vport);
char peer_name[IFNAMSIZ];
if (!strcmp(patch_vport->name, peer_name))
return -EINVAL;
if (!strcmp(patch_vport->name, peer_name))
return -EINVAL;
- strcpy(patch_vport->peer_name, peer_name);
+ strcpy(devconf->peer_name, peer_name);
{
struct vport *vport;
struct patch_vport *patch_vport;
{
struct vport *vport;
struct patch_vport *patch_vport;
int err;
vport = vport_alloc(sizeof(struct patch_vport), &patch_vport_ops, parms);
int err;
vport = vport_alloc(sizeof(struct patch_vport), &patch_vport_ops, parms);
strcpy(patch_vport->name, parms->name);
strcpy(patch_vport->name, parms->name);
- err = set_config(vport, parms->config);
- if (err)
- goto error_free_vport;
-
patch_vport->devconf = kmalloc(sizeof(struct device_config), GFP_KERNEL);
if (!patch_vport->devconf) {
err = -ENOMEM;
goto error_free_vport;
}
patch_vport->devconf = kmalloc(sizeof(struct device_config), GFP_KERNEL);
if (!patch_vport->devconf) {
err = -ENOMEM;
goto error_free_vport;
}
+ err = set_config(vport, parms->config, patch_vport->devconf);
+ if (err)
+ goto error_free_devconf;
+
vport_gen_rand_ether_addr(patch_vport->devconf->eth_addr);
/* Make the default MTU fairly large so that it doesn't become the
* bottleneck on systems using jumbo frames. */
patch_vport->devconf->mtu = 65535;
vport_gen_rand_ether_addr(patch_vport->devconf->eth_addr);
/* Make the default MTU fairly large so that it doesn't become the
* bottleneck on systems using jumbo frames. */
patch_vport->devconf->mtu = 65535;
- hlist_add_head(&patch_vport->hash_node, hash_bucket(patch_vport->peer_name));
+ peer_name = patch_vport->devconf->peer_name;
+ hlist_add_head(&patch_vport->hash_node, hash_bucket(peer_name));
- rcu_assign_pointer(patch_vport->peer, vport_locate(patch_vport->peer_name));
+ rcu_assign_pointer(patch_vport->peer, vport_locate(peer_name));
update_peers(patch_vport->name, vport);
return vport;
update_peers(patch_vport->name, vport);
return vport;
+error_free_devconf:
+ kfree(patch_vport->devconf);
error_free_vport:
vport_free(vport);
error:
error_free_vport:
vport_free(vport);
error:
static int patch_modify(struct vport *vport, struct odp_port *port)
{
static int patch_modify(struct vport *vport, struct odp_port *port)
{
- int err = set_config(vport, port->config);
- if (!err) {
- struct patch_vport *patch_vport = patch_vport_priv(vport);
+ struct patch_vport *patch_vport = patch_vport_priv(vport);
+ struct device_config *devconf;
+ int err;
- hlist_del(&patch_vport->hash_node);
- rcu_assign_pointer(patch_vport->peer, vport_locate(patch_vport->peer_name));
- hlist_add_head(&patch_vport->hash_node, hash_bucket(patch_vport->peer_name));
+ devconf = kmemdup(patch_vport->devconf, sizeof(struct device_config), GFP_KERNEL);
+ if (!devconf) {
+ err = -ENOMEM;
+ goto error;
+
+ err = set_config(vport, port->config, devconf);
+ if (err)
+ goto error_free;
+
+ assign_config_rcu(vport, devconf);
+
+ hlist_del(&patch_vport->hash_node);
+
+ rcu_assign_pointer(patch_vport->peer, vport_locate(devconf->peer_name));
+ hlist_add_head(&patch_vport->hash_node, hash_bucket(devconf->peer_name));
+
+ return 0;
+
+error_free:
+ kfree(devconf);
+error:
struct patch_vport *peer_vport;
struct hlist_node *node;
struct patch_vport *peer_vport;
struct hlist_node *node;
- hlist_for_each_entry(peer_vport, node, bucket, hash_node)
- if (!strcmp(peer_vport->peer_name, name))
+ hlist_for_each_entry(peer_vport, node, bucket, hash_node) {
+ const char *peer_name;
+
+ peer_name = rtnl_dereference(peer_vport->devconf)->peer_name;
+ if (!strcmp(peer_name, name))
rcu_assign_pointer(peer_vport->peer, vport);
rcu_assign_pointer(peer_vport->peer, vport);
}
static int patch_set_mtu(struct vport *vport, int mtu)
}
static int patch_set_mtu(struct vport *vport, int mtu)
return rcu_dereference_rtnl(patch_vport->devconf)->eth_addr;
}
return rcu_dereference_rtnl(patch_vport->devconf)->eth_addr;
}
+static void patch_get_config(const struct vport *vport, void *config)
+{
+ const struct patch_vport *patch_vport = patch_vport_priv(vport);
+ const char *peer_name;
+
+ peer_name = rcu_dereference_rtnl(patch_vport->devconf)->peer_name;
+ strlcpy(config, peer_name, VPORT_CONFIG_SIZE);
+}
+
static int patch_get_mtu(const struct vport *vport)
{
const struct patch_vport *patch_vport = patch_vport_priv(vport);
static int patch_get_mtu(const struct vport *vport)
{
const struct patch_vport *patch_vport = patch_vport_priv(vport);
.set_addr = patch_set_addr,
.get_name = patch_get_name,
.get_addr = patch_get_addr,
.set_addr = patch_set_addr,
.get_name = patch_get_name,
.get_addr = patch_get_addr,
+ .get_config = patch_get_config,
.get_dev_flags = vport_gen_get_dev_flags,
.is_running = vport_gen_is_running,
.get_operstate = vport_gen_get_operstate,
.get_dev_flags = vport_gen_get_dev_flags,
.is_running = vport_gen_is_running,
.get_operstate = vport_gen_get_operstate,
return vport->ops->get_mtu(vport);
}
return vport->ops->get_mtu(vport);
}
+/**
+ * vport_get_config - retrieve device configuration
+ *
+ * @vport: vport from which to retrieve the configuration.
+ * @config: buffer to store config, which must be at least the length
+ * of VPORT_CONFIG_SIZE.
+ *
+ * Retrieves the configuration of the given device. Either RTNL lock or
+ * rcu_read_lock must be held.
+ */
+void vport_get_config(const struct vport *vport, void *config)
+{
+ if (vport->ops->get_config)
+ vport->ops->get_config(vport, config);
+}
+
/**
* vport_receive - pass up received packet to the datapath for processing
*
/**
* vport_receive - pass up received packet to the datapath for processing
*
int vport_get_iflink(const struct vport *);
int vport_get_mtu(const struct vport *);
int vport_get_iflink(const struct vport *);
int vport_get_mtu(const struct vport *);
+void vport_get_config(const struct vport *, void *);
int vport_send(struct vport *, struct sk_buff *);
int vport_send(struct vport *, struct sk_buff *);
* May be null if not supported.
* @get_name: Get the device's name.
* @get_addr: Get the device's MAC address.
* May be null if not supported.
* @get_name: Get the device's name.
* @get_addr: Get the device's MAC address.
+ * @get_config: Get the device's configuration.
* @get_kobj: Get the kobj associated with the device (may return null).
* @get_stats: Fill in the transmit/receive stats. May be null if stats are
* not supported or if generic stats are in use. If defined and
* @get_kobj: Get the kobj associated with the device (may return null).
* @get_stats: Fill in the transmit/receive stats. May be null if stats are
* not supported or if generic stats are in use. If defined and
/* Called with rcu_read_lock or RTNL lock. */
const char *(*get_name)(const struct vport *);
const unsigned char *(*get_addr)(const struct vport *);
/* Called with rcu_read_lock or RTNL lock. */
const char *(*get_name)(const struct vport *);
const unsigned char *(*get_addr)(const struct vport *);
+ void (*get_config)(const struct vport *, void *);
struct kobject *(*get_kobj)(const struct vport *);
int (*get_stats)(const struct vport *, struct rtnl_link_stats64 *);
struct kobject *(*get_kobj)(const struct vport *);
int (*get_stats)(const struct vport *, struct rtnl_link_stats64 *);