[ovs-dev] [PATCH 1/6] datapath: Return vport configuration when queried.

Justin Pettit jpettit at nicira.com
Wed Dec 22 08:04:29 UTC 2010


Signed-off-by: Justin Pettit <jpettit at nicira.com>
---
 datapath/datapath.c     |    1 +
 datapath/tunnel.c       |    9 +++++++++
 datapath/tunnel.h       |    1 +
 datapath/vport-capwap.c |    1 +
 datapath/vport-gre.c    |    1 +
 datapath/vport-netdev.h |    1 +
 datapath/vport-patch.c  |    7 +++++++
 datapath/vport.c        |   17 +++++++++++++++++
 datapath/vport.h        |    3 +++
 9 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/datapath/datapath.c b/datapath/datapath.c
index b95c8f2..f919887 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -1263,6 +1263,7 @@ static int put_port(const struct vport *p, struct odp_port __user *uop)
 	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;
diff --git a/datapath/tunnel.c b/datapath/tunnel.c
index eac3fa3..0c9ebbd 100644
--- a/datapath/tunnel.c
+++ b/datapath/tunnel.c
@@ -1524,6 +1524,15 @@ const unsigned char *tnl_get_addr(const struct vport *vport)
 	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 *tpc;
+	
+	tpc = &rcu_dereference_rtnl(tnl_vport->mutable)->port_config;
+	memcpy(config, tpc, sizeof *tpc);
+}
+
 int tnl_get_mtu(const struct vport *vport)
 {
 	const struct tnl_vport *tnl_vport = tnl_vport_priv(vport);
diff --git a/datapath/tunnel.h b/datapath/tunnel.h
index aa859f6..29f5922 100644
--- a/datapath/tunnel.h
+++ b/datapath/tunnel.h
@@ -192,6 +192,7 @@ int tnl_set_mtu(struct vport *vport, int mtu);
 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);
diff --git a/datapath/vport-capwap.c b/datapath/vport-capwap.c
index e17d85f..fc2ea8e 100644
--- a/datapath/vport-capwap.c
+++ b/datapath/vport-capwap.c
@@ -656,6 +656,7 @@ const struct vport_ops capwap_vport_ops = {
 	.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,
diff --git a/datapath/vport-gre.c b/datapath/vport-gre.c
index 191fd06..cddfa59 100644
--- a/datapath/vport-gre.c
+++ b/datapath/vport-gre.c
@@ -398,6 +398,7 @@ const struct vport_ops gre_vport_ops = {
 	.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,
diff --git a/datapath/vport-netdev.h b/datapath/vport-netdev.h
index 542ddfd..88a5f90 100644
--- a/datapath/vport-netdev.h
+++ b/datapath/vport-netdev.h
@@ -29,6 +29,7 @@ int netdev_set_mtu(struct vport *, int mtu);
 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 *);
diff --git a/datapath/vport-patch.c b/datapath/vport-patch.c
index 4fdbcf5..032c0ac 100644
--- a/datapath/vport-patch.c
+++ b/datapath/vport-patch.c
@@ -232,6 +232,12 @@ static const unsigned char *patch_get_addr(const struct vport *vport)
 	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);
+	strlcpy(config, patch_vport->peer_name, VPORT_CONFIG_SIZE);
+}
+
 static int patch_get_mtu(const struct vport *vport)
 {
 	const struct patch_vport *patch_vport = patch_vport_priv(vport);
@@ -267,6 +273,7 @@ const struct vport_ops patch_vport_ops = {
 	.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,
diff --git a/datapath/vport.c b/datapath/vport.c
index e699f8c..7006427 100644
--- a/datapath/vport.c
+++ b/datapath/vport.c
@@ -978,6 +978,23 @@ int vport_get_mtu(const struct vport *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 for the entire duration that the
+ * configuration is in use.
+ */
+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: vport that received the packet
diff --git a/datapath/vport.h b/datapath/vport.h
index fb3a3e3..6ba7f2f 100644
--- a/datapath/vport.h
+++ b/datapath/vport.h
@@ -63,6 +63,7 @@ int vport_get_ifindex(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 *);
 
@@ -169,6 +170,7 @@ struct vport_parms {
  * 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
@@ -205,6 +207,7 @@ struct vport_ops {
 	/* 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 *);
 
-- 
1.7.1





More information about the dev mailing list