diff options
author | Daniel Mack <daniel@zonque.org> | 2014-10-08 11:29:49 +0200 |
---|---|---|
committer | Daniel Mack <daniel@zonque.org> | 2014-10-08 16:40:40 +0200 |
commit | 1585f5129a5f53f909a0560d16901184483c9139 (patch) | |
tree | f8edfcdfed0708fd056b9d2fd7edc69cf059411b | |
parent | 76db77792371380fbe6698d042ee5054e72bc4af (diff) | |
download | kdbus-bus-1585f5129a5f53f909a0560d16901184483c9139.tar.gz kdbus-bus-1585f5129a5f53f909a0560d16901184483c9139.tar.bz2 kdbus-bus-1585f5129a5f53f909a0560d16901184483c9139.zip |
kdbus.h: add features bitmask to cmd_make and cmd_hello (ABI BREAK)
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>
-rw-r--r-- | handle.c | 21 | ||||
-rw-r--r-- | kdbus.h | 4 | ||||
-rw-r--r-- | kdbus.txt | 18 | ||||
-rw-r--r-- | test/test-connection.c | 8 |
4 files changed, 36 insertions, 15 deletions
@@ -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; } @@ -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))); diff --git a/kdbus.txt b/kdbus.txt index 3753ebbaa78..74082c4e43b 100644 --- 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. }; diff --git a/test/test-connection.c b/test/test-connection.c index bc397d9b6df..7d94e2fe754 100644 --- a/test/test-connection.c +++ b/test/test-connection.c @@ -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); |