kdbus.h: add features bitmask to cmd_make and cmd_hello (ABI BREAK)
authorDaniel Mack <daniel@zonque.org>
Wed, 8 Oct 2014 09:29:49 +0000 (11:29 +0200)
committerDaniel Mack <daniel@zonque.org>
Wed, 8 Oct 2014 14:40:40 +0000 (16:40 +0200)
Add a new field called 'features' to struct kdbus_cmd_make and
kdbus_cmd_hello. In these bitmasks, userspace can request features from
the kernel, and the kernel can itself request features from userspace.

For now, we check that this field is set to 0, and bail with
 -EOPNOTSUPP otherwise.

Signed-off-by: Daniel Mack <daniel@zonque.org>
handle.c
kdbus.h
kdbus.txt
test/test-connection.c

index a32033b4d16acd5312de648c045eab8399f34fe9..d08b5dda433879ebc410e3e2c798b6f0c8ec158c 100644 (file)
--- a/handle.c
+++ b/handle.c
@@ -197,15 +197,6 @@ static int kdbus_handle_release(struct inode *inode, struct file *file)
        return 0;
 }
 
-static bool kdbus_check_flags(u64 kernel_flags)
-{
-       /*
-        * The higher 32bit are considered 'incompatible flags'.
-        * Refuse them all for now.
-        */
-       return upper_32_bits(kernel_flags) == 0;
-}
-
 static int kdbus_copy_from_user(void *dest,
                                void __user *user_ptr,
                                size_t size)
@@ -318,7 +309,8 @@ static long kdbus_handle_ioctl_control(struct file *file, unsigned int cmd,
                if (ret < 0)
                        break;
 
-               if (!kdbus_check_flags(make->flags)) {
+               /* Reject all feature requests for now */
+               if (make->features != 0) {
                        ret = -EOPNOTSUPP;
                        break;
                }
@@ -375,7 +367,8 @@ static long kdbus_handle_ioctl_control(struct file *file, unsigned int cmd,
                if (ret < 0)
                        break;
 
-               if (!kdbus_check_flags(make->flags)) {
+               /* Reject all feature requests for now */
+               if (make->features != 0) {
                        ret = -EOPNOTSUPP;
                        break;
                }
@@ -451,7 +444,8 @@ static long kdbus_handle_ioctl_ep(struct file *file, unsigned int cmd,
                if (ret < 0)
                        break;
 
-               if (!kdbus_check_flags(make->flags)) {
+               /* Reject all feature requests for now */
+               if (make->features != 0) {
                        ret = -EOPNOTSUPP;
                        break;
                }
@@ -519,7 +513,8 @@ static long kdbus_handle_ioctl_ep(struct file *file, unsigned int cmd,
                if (ret < 0)
                        break;
 
-               if (!kdbus_check_flags(hello->conn_flags)) {
+               /* Reject all feature requests for now */
+               if (hello->features != 0) {
                        ret = -EOPNOTSUPP;
                        break;
                }
diff --git a/kdbus.h b/kdbus.h
index 8994b5673dfafd1230c0c62f67ef95ff2ad5bab5..b227c513eb7cfe63531be65844786183747c9b8d 100644 (file)
--- a/kdbus.h
+++ b/kdbus.h
@@ -554,6 +554,7 @@ enum kdbus_attach_flags {
 /**
  * struct kdbus_cmd_hello - struct to say hello to kdbus
  * @size:              The total size of the structure
+ * @features:          Feature negotiation bitmask
  * @conn_flags:                Connection flags (KDBUS_HELLO_*).
  * @attach_flags:      Mask of metadata to attach to each message sent
  *                     (KDBUS_ATTACH_*)
@@ -573,6 +574,7 @@ enum kdbus_attach_flags {
  */
 struct kdbus_cmd_hello {
        __u64 size;
+       __u64 features;
        __u64 conn_flags;
        __u64 attach_flags;
        __u64 bus_flags;
@@ -596,6 +598,7 @@ enum kdbus_make_flags {
 /**
  * struct kdbus_cmd_make - struct to make a bus, an endpoint or a domain
  * @size:              The total size of the struct
+ * @features:          Feature negotiation bitmask
  * @flags:             Properties for the bus/ep/domain to create
  * @items:             Items describing details
  *
@@ -604,6 +607,7 @@ enum kdbus_make_flags {
  */
 struct kdbus_cmd_make {
        __u64 size;
+       __u64 features;
        __u64 flags;
        struct kdbus_item items[0];
 } __attribute__((aligned(8)));
index 3753ebbaa78a873eafc349b666fcce4e72dab337..74082c4e43bd42678f1667a5eebffda897358e67 100644 (file)
--- a/kdbus.txt
+++ b/kdbus.txt
@@ -308,6 +308,14 @@ struct kdbus_cmd_make {
   __u64 size;
     The overall size of the struct, including its items.
 
+  __u64 features;
+    Feature negotiation bitmask. In this field, userspace specifies a set
+    of features it requires from the kernel driver. When the ioctl returns,
+    the kernel has set this field to a value describing the features it
+    requires from the userspace. This field is intended for future forward-
+    compatibility and has to be set to 0. Userspace should check the value
+    after the ioctl returned and treat non-null values as error.
+
   __u64 flags;
     The flags for creation.
 
@@ -419,6 +427,14 @@ struct kdbus_cmd_hello {
   __u64 size;
     The overall size of the struct, including all attached items.
 
+  __u64 features;
+    Feature negotiation bitmask. In this field, userspace specifies a set
+    of features it requires from the kernel driver. When the ioctl returns,
+    the kernel has set this field to a value describing the features it
+    requires from the userspace. This field is intended for future forward-
+    compatibility and has to be set to 0. Userspace should check the value
+    after the ioctl returned and treat non-null values as error.
+
   __u64 conn_flags;
     Flags to apply to this connection:
 
@@ -586,7 +602,7 @@ struct kdbus_cmd_update {
     KDBUS_ITEM_NAME
     KDBUS_ITEM_POLICY_ACCESS
       Policy holder connections may supply a new set of policy information
-      with these items. For other connection types, -ENOTSUPP is returned.
+      with these items. For other connection types, -EOPNOTSUPP is returned.
 };
 
 
index bc397d9b6df3be526b8c165341df8261f578507e..7d94e2fe754ac70036ff4b4373b34446ca3aa67d 100644 (file)
@@ -120,7 +120,13 @@ int kdbus_test_hello(struct kdbus_test_env *env)
 
        hello.size = sizeof(struct kdbus_cmd_hello);
 
-       /* check faulty flags */
+       /* check faulty features */
+       hello.features = 1;
+       ret = ioctl(fd, KDBUS_CMD_HELLO, &hello);
+       ASSERT_RETURN(ret == -1 && errno == EOPNOTSUPP);
+       hello.features = 0;
+
+       /* check faulty features */
        hello.conn_flags = 1ULL << 32;
        ret = ioctl(fd, KDBUS_CMD_HELLO, &hello);
        ASSERT_RETURN(ret == -1 && errno == EOPNOTSUPP);