diff options
-rw-r--r-- | connection.c | 25 | ||||
-rw-r--r-- | connection.h | 1 | ||||
-rw-r--r-- | match.c | 21 | ||||
-rw-r--r-- | metadata.c | 2 | ||||
-rw-r--r-- | metadata.h | 5 |
5 files changed, 28 insertions, 26 deletions
diff --git a/connection.c b/connection.c index b51e9232c85..0a9410b82ee 100644 --- a/connection.c +++ b/connection.c @@ -1543,3 +1543,28 @@ exit_unref: kdbus_conn_unref(conn); return ret; } + + +/** + * kdbus_conn_has_name() - check if a connection owns a name + * @conn: Connection + * @name: Well-know name to check for + * + * Returns true if the name is currently owned by the connection. + */ +bool kdbus_conn_has_name(struct kdbus_conn *conn, const char *name) +{ + struct kdbus_name_entry *e; + bool match = false; + + mutex_lock(&conn->lock); + list_for_each_entry(e, &conn->names_list, conn_entry) { + if (strcmp(e->name, name) == 0) { + match = true; + break; + } + } + mutex_unlock(&conn->lock); + + return match; +} diff --git a/connection.h b/connection.h index 6543fd50e08..37b4220e2be 100644 --- a/connection.h +++ b/connection.h @@ -92,4 +92,5 @@ int kdbus_conn_kmsg_list_send(struct kdbus_ep *ep, struct list_head *kmsg_list); int kdbus_conn_move_messages(struct kdbus_conn *conn_dst, struct kdbus_conn *conn_src); +bool kdbus_conn_has_name(struct kdbus_conn *conn, const char *name); #endif @@ -147,22 +147,7 @@ int kdbus_match_db_new(struct kdbus_match_db **db) return 0; } -static inline -bool kdbus_match_name(const char *haystack, - size_t haystack_size, - const char *needle) -{ - size_t i; - - for (i = 0; i < haystack_size; i += strlen(haystack) + 1) - if (strcmp(haystack + i, needle) == 0) - return true; - - return false; -} - -static inline -bool kdbus_match_bloom(const u64 *filter, const u64 *mask, +static bool kdbus_match_bloom(const u64 *filter, const u64 *mask, const struct kdbus_conn *conn) { unsigned int i; @@ -242,9 +227,7 @@ static bool kdbus_match_rules(const struct kdbus_match_entry *entry, break; case KDBUS_ITEM_NAME: - if (!kdbus_match_name(kmsg->meta.src_names, - kmsg->meta.src_names_len, - r->name)) + if (!kdbus_conn_has_name(conn_src, r->name)) return false; break; diff --git a/metadata.c b/metadata.c index 69d47904649..dd54a858a4c 100644 --- a/metadata.c +++ b/metadata.c @@ -163,7 +163,6 @@ static int kdbus_meta_append_src_names(struct kdbus_meta *meta, return 0; mutex_lock(&conn->lock); - list_for_each_entry(e, &conn->names_list, conn_entry) { struct kdbus_item *item; size_t len; @@ -183,7 +182,6 @@ static int kdbus_meta_append_src_names(struct kdbus_meta *meta, item->name.flags = e->flags; memcpy(item->name.name, e->name, len); } - mutex_unlock(&conn->lock); return ret; diff --git a/metadata.h b/metadata.h index beed7fadaeb..5c111b5d42f 100644 --- a/metadata.h +++ b/metadata.h @@ -20,8 +20,6 @@ * @data: Allocated buffer * @size: Number of bytes used * @allocated_size: Size of buffer - * @src_names: List of \0-separated well-known names - * @src_names_len: Length of list * * Used to collect and store connection metadata in a pre-compiled * buffer containing struct kdbus_item. @@ -32,9 +30,6 @@ struct kdbus_meta { struct kdbus_item *data; size_t size; size_t allocated_size; - - const char *src_names; - size_t src_names_len; }; struct kdbus_conn; |