From: Kay Sievers Date: Fri, 17 Oct 2014 08:00:35 +0000 (+0200) Subject: Revert KDBUS_HELLO_ACCEPT_MEMFD support (ABI break) X-Git-Tag: upstream/0.20141102.012929utc~87 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6da98d27bf4878456403e814e068d87474bf2719;p=platform%2Fcore%2Fsystem%2Fkdbus-bus.git Revert KDBUS_HELLO_ACCEPT_MEMFD support (ABI break) Memfds are a basic exchange mechanism not supposed to be optional per connection. A per-bus flag, instead of a per-connection one, would probably be acceptable, but its usefulness is questionable at this point. Broadcasts can contain memfds and we would silently messages for such connections, which is not the expected behavior. Receivers just need to make sure to be able to receive messages with memfd payload, otherwise they are just not fully supporting the common kdbus interface. Contracts of not supporting memfds on private buses are fine, but the general purpose communication will always require memfds to be supported by all clients. --- diff --git a/connection.c b/connection.c index bbc87b1..e4464cf 100644 --- a/connection.c +++ b/connection.c @@ -507,7 +507,7 @@ static int kdbus_conn_entry_insert(struct kdbus_conn *conn, } if ((kmsg->fds && !(conn->flags & KDBUS_HELLO_ACCEPT_FD)) || - (kmsg->memfds_count && !(conn->flags & KDBUS_HELLO_ACCEPT_MEMFD))) { + (kmsg->memfds_count && !(conn->flags & KDBUS_HELLO_ACCEPT_FD))) { ret = -ECOMM; goto exit_unlock; } @@ -1415,10 +1415,9 @@ int kdbus_conn_new(struct kdbus_ep *ep, BUG_ON(*c); /* Reject unknown flags */ - if (hello->conn_flags & ~(KDBUS_HELLO_ACCEPT_FD | - KDBUS_HELLO_ACCEPT_MEMFD | - KDBUS_HELLO_ACTIVATOR | - KDBUS_HELLO_POLICY_HOLDER | + if (hello->conn_flags & ~(KDBUS_HELLO_ACCEPT_FD | + KDBUS_HELLO_ACTIVATOR | + KDBUS_HELLO_POLICY_HOLDER | KDBUS_HELLO_MONITOR)) return -EOPNOTSUPP; diff --git a/kdbus.h b/kdbus.h index 1ea4329..79a17f3 100644 --- a/kdbus.h +++ b/kdbus.h @@ -500,8 +500,6 @@ enum kdbus_policy_type { * enum kdbus_hello_flags - flags for struct kdbus_cmd_hello * @KDBUS_HELLO_ACCEPT_FD: The connection allows the reception of * any passed file descriptors - * @KDBUS_HELLO_ACCEPT_MEMFD: The connection allows the reception of - * any passed memfd file descriptors * @KDBUS_HELLO_ACTIVATOR: Special-purpose connection which registers * a well-know name for a process to be started * when traffic arrives @@ -516,10 +514,9 @@ enum kdbus_policy_type { */ enum kdbus_hello_flags { KDBUS_HELLO_ACCEPT_FD = 1ULL << 0, - KDBUS_HELLO_ACCEPT_MEMFD = 1ULL << 1, - KDBUS_HELLO_ACTIVATOR = 1ULL << 2, - KDBUS_HELLO_POLICY_HOLDER = 1ULL << 3, - KDBUS_HELLO_MONITOR = 1ULL << 4, + KDBUS_HELLO_ACTIVATOR = 1ULL << 1, + KDBUS_HELLO_POLICY_HOLDER = 1ULL << 2, + KDBUS_HELLO_MONITOR = 1ULL << 3, }; /** diff --git a/kdbus.txt b/kdbus.txt index 6e8b090..3a219be 100644 --- a/kdbus.txt +++ b/kdbus.txt @@ -442,11 +442,6 @@ struct kdbus_cmd_hello { as message payload. If it's not set, any attempt of doing so will result in -ECOMM on the sender's side. - KDBUS_HELLO_ACCEPT_MEMFD - When this flag is set, the connection can be sent memfd file - descriptors as message payload. If it's not set, any attempt of - doing so will result in -ECOMM on the sender's side. - KDBUS_HELLO_ACTIVATOR Make this connection an activator (see below). With this bit set, an item of type KDBUS_ITEM_NAME has to be attached which describes @@ -876,10 +871,9 @@ pool. The message is stored as struct kdbus_msg at this offset, and can be interpreted with the semantics described above. Also, if the connection allowed for file descriptor to be passed -(KDBUS_HELLO_ACCEPT_FD or KDBUS_HELLO_ACCEPT_MEMFD), and if the message -contained any, they will be installed into the receiving process after the -KDBUS_CMD_MSG_RECV ioctl returns. The receiving task is obliged to close all -of them appropriately. +(KDBUS_HELLO_ACCEPT_FD), and if the message contained any, they will be +installed into the receiving process after the KDBUS_CMD_MSG_RECV ioctl +returns. The receiving task is obliged to close all of them appropriately. The caller is obliged to call KDBUS_CMD_FREE with the returned offset when the memory is no longer needed. diff --git a/test/kdbus-util.c b/test/kdbus-util.c index 90e9e47..52b4c47 100644 --- a/test/kdbus-util.c +++ b/test/kdbus-util.c @@ -139,8 +139,7 @@ kdbus_hello(const char *path, uint64_t flags, return NULL; } - h.hello.conn_flags = flags | KDBUS_HELLO_ACCEPT_FD | - KDBUS_HELLO_ACCEPT_MEMFD; + h.hello.conn_flags = flags | KDBUS_HELLO_ACCEPT_FD; h.hello.attach_flags = _KDBUS_ATTACH_ALL; h.conn_name.type = KDBUS_ITEM_CONN_NAME; strcpy(h.conn_name.str, "this-is-my-name"); diff --git a/test/test-connection.c b/test/test-connection.c index 7d51b4d..bc397d9 100644 --- a/test/test-connection.c +++ b/test/test-connection.c @@ -104,7 +104,7 @@ int kdbus_test_hello(struct kdbus_test_env *env) if (fd < 0) return TEST_ERR; - hello.conn_flags = KDBUS_HELLO_ACCEPT_FD | KDBUS_HELLO_ACCEPT_MEMFD; + hello.conn_flags = KDBUS_HELLO_ACCEPT_FD; hello.attach_flags = _KDBUS_ATTACH_ALL; hello.size = sizeof(struct kdbus_cmd_hello); hello.pool_size = POOL_SIZE; @@ -125,6 +125,8 @@ int kdbus_test_hello(struct kdbus_test_env *env) ret = ioctl(fd, KDBUS_CMD_HELLO, &hello); ASSERT_RETURN(ret == -1 && errno == EOPNOTSUPP); + hello.conn_flags = KDBUS_HELLO_ACCEPT_FD; + /* check for faulty pool sizes */ hello.pool_size = 0; ret = ioctl(fd, KDBUS_CMD_HELLO, &hello); @@ -134,9 +136,9 @@ int kdbus_test_hello(struct kdbus_test_env *env) ret = ioctl(fd, KDBUS_CMD_HELLO, &hello); ASSERT_RETURN(ret == -1 && errno == EFAULT); - /* success test */ hello.pool_size = POOL_SIZE; - hello.conn_flags = KDBUS_HELLO_ACCEPT_FD | KDBUS_HELLO_ACCEPT_MEMFD; + + /* success test */ ret = ioctl(fd, KDBUS_CMD_HELLO, &hello); ASSERT_RETURN(ret == 0); @@ -302,7 +304,7 @@ int kdbus_test_writable_pool(struct kdbus_test_env *env) ASSERT_RETURN(fd >= 0); memset(&hello, 0, sizeof(hello)); - hello.conn_flags = KDBUS_HELLO_ACCEPT_FD | KDBUS_HELLO_ACCEPT_MEMFD; + hello.conn_flags = KDBUS_HELLO_ACCEPT_FD; hello.attach_flags = _KDBUS_ATTACH_ALL; hello.size = sizeof(struct kdbus_cmd_hello); hello.pool_size = POOL_SIZE; diff --git a/tools/kdbus-monitor.c b/tools/kdbus-monitor.c index ef7381e..4bb61b7 100644 --- a/tools/kdbus-monitor.c +++ b/tools/kdbus-monitor.c @@ -81,8 +81,7 @@ static struct conn *kdbus_hello(const char *path, uint64_t flags) return NULL; } - h.hello.conn_flags = flags | KDBUS_HELLO_ACCEPT_FD | - KDBUS_HELLO_ACCEPT_MEMFD; + h.hello.conn_flags = flags | KDBUS_HELLO_ACCEPT_FD; h.hello.attach_flags = _KDBUS_ATTACH_ALL; h.type = KDBUS_ITEM_CONN_NAME; strncpy(h.comm, "monitor", sizeof(h.comm) - 1);