aboutsummaryrefslogtreecommitdiff
path: root/datapath/vport.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2010-05-13 15:25:27 -0700
committerBen Pfaff <blp@nicira.com>2010-05-13 15:29:51 -0700
commit3fbd517acfd8dba2cd75fa234b0eb3337d202d33 (patch)
tree97319cfbf75de5b1df2632441d37ffefc63591ff /datapath/vport.c
parent776f10ce0f008e95b457f8c6b69b9748d8d1fdbd (diff)
datapath: Add 32-bit compatibility ioctls.
When a 32-bit userspace program runs on a 64-bit kernel, data structures that contain members whose sizes or alignments change from 32- to 64-bit must be translated when they are passed to ioctls. This commit adds such support for openvswitch_mod. We should really reconsider some parts of the Open vSwitch ioctl interface to avoid needing as much translation as we do. Lightly tested with 32-bit userspace on sparc64.
Diffstat (limited to 'datapath/vport.c')
-rw-r--r--datapath/vport.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/datapath/vport.c b/datapath/vport.c
index 5656672c..6b7381e9 100644
--- a/datapath/vport.c
+++ b/datapath/vport.c
@@ -14,6 +14,7 @@
#include <linux/mutex.h>
#include <linux/percpu.h>
#include <linux/rtnetlink.h>
+#include <linux/compat.h>
#include "vport.h"
@@ -228,6 +229,24 @@ vport_add(const struct odp_vport_add __user *uvport_config)
return do_vport_add(&vport_config);
}
+#ifdef CONFIG_COMPAT
+int
+compat_vport_add(struct compat_odp_vport_add *ucompat)
+{
+ struct compat_odp_vport_add compat;
+ struct odp_vport_add vport_config;
+
+ if (copy_from_user(&compat, ucompat, sizeof(struct compat_odp_vport_add)))
+ return -EFAULT;
+
+ memcpy(vport_config.port_type, compat.port_type, VPORT_TYPE_SIZE);
+ memcpy(vport_config.devname, compat.devname, IFNAMSIZ);
+ vport_config.config = compat_ptr(compat.config);
+
+ return do_vport_add(&vport_config);
+}
+#endif
+
/**
* vport_mod - modify existing vport device (for userspace callers)
*
@@ -273,6 +292,23 @@ vport_mod(const struct odp_vport_mod __user *uvport_config)
return do_vport_mod(&vport_config);
}
+#ifdef CONFIG_COMPAT
+int
+compat_vport_mod(struct compat_odp_vport_mod *ucompat)
+{
+ struct compat_odp_vport_mod compat;
+ struct odp_vport_mod vport_config;
+
+ if (copy_from_user(&compat, ucompat, sizeof(struct compat_odp_vport_mod)))
+ return -EFAULT;
+
+ memcpy(vport_config.devname, compat.devname, IFNAMSIZ);
+ vport_config.config = compat_ptr(compat.config);
+
+ return do_vport_mod(&vport_config);
+}
+#endif
+
/**
* vport_del - delete existing vport device (for userspace callers)
*