chiark / gitweb /
bus: rework bloom filter logic to operate with variable bloom filter
[elogind.git] / src / libsystemd / sd-bus / bus-control.c
index 55482394264c2a70a3e8071199f6bafdf29dd033..846307d6647d1f23d94804efba66b5f067103d96 100644 (file)
@@ -926,7 +926,7 @@ int bus_add_match_internal_kernel(
 
         struct kdbus_cmd_match *m;
         struct kdbus_item *item;
-        uint64_t bloom[BLOOM_SIZE/8];
+        uint64_t *bloom;
         size_t sz;
         const char *sender = NULL;
         size_t sender_length = 0;
@@ -939,7 +939,7 @@ int bus_add_match_internal_kernel(
 
         assert(bus);
 
-        zero(bloom);
+        bloom = alloca0(bus->bloom_size);
 
         sz = ALIGN8(offsetof(struct kdbus_cmd_match, items));
 
@@ -969,7 +969,7 @@ int bus_add_match_internal_kernel(
                         if (c->value_u8 != SD_BUS_MESSAGE_SIGNAL)
                                 matches_name_change = false;
 
-                        bloom_add_pair(bloom, "message-type", bus_message_type_to_string(c->value_u8));
+                        bloom_add_pair(bloom, bus->bloom_size, bus->bloom_n_hash, "message-type", bus_message_type_to_string(c->value_u8));
                         using_bloom = true;
                         break;
 
@@ -977,7 +977,7 @@ int bus_add_match_internal_kernel(
                         if (!streq(c->value_str, "org.freedesktop.DBus"))
                                 matches_name_change = false;
 
-                        bloom_add_pair(bloom, "interface", c->value_str);
+                        bloom_add_pair(bloom, bus->bloom_size, bus->bloom_n_hash, "interface", c->value_str);
                         using_bloom = true;
                         break;
 
@@ -985,7 +985,7 @@ int bus_add_match_internal_kernel(
                         if (!streq(c->value_str, "NameOwnerChanged"))
                                 matches_name_change = false;
 
-                        bloom_add_pair(bloom, "member", c->value_str);
+                        bloom_add_pair(bloom, bus->bloom_size, bus->bloom_n_hash, "member", c->value_str);
                         using_bloom = true;
                         break;
 
@@ -993,13 +993,13 @@ int bus_add_match_internal_kernel(
                         if (!streq(c->value_str, "/org/freedesktop/DBus"))
                                 matches_name_change = false;
 
-                        bloom_add_pair(bloom, "path", c->value_str);
+                        bloom_add_pair(bloom, bus->bloom_size, bus->bloom_n_hash, "path", c->value_str);
                         using_bloom = true;
                         break;
 
                 case BUS_MATCH_PATH_NAMESPACE:
                         if (!streq(c->value_str, "/")) {
-                                bloom_add_pair(bloom, "path-slash-prefix", c->value_str);
+                                bloom_add_pair(bloom, bus->bloom_size, bus->bloom_n_hash, "path-slash-prefix", c->value_str);
                                 using_bloom = true;
                         }
                         break;
@@ -1011,7 +1011,7 @@ int bus_add_match_internal_kernel(
                                 name_change_arg[c->type - BUS_MATCH_ARG] = c->value_str;
 
                         snprintf(buf, sizeof(buf), "arg%u", c->type - BUS_MATCH_ARG);
-                        bloom_add_pair(bloom, buf, c->value_str);
+                        bloom_add_pair(bloom, bus->bloom_size, bus->bloom_n_hash, buf, c->value_str);
                         using_bloom = true;
                         break;
                 }
@@ -1020,7 +1020,7 @@ int bus_add_match_internal_kernel(
                         char buf[sizeof("arg")-1 + 2 + sizeof("-slash-prefix")];
 
                         snprintf(buf, sizeof(buf), "arg%u-slash-prefix", c->type - BUS_MATCH_ARG_PATH);
-                        bloom_add_pair(bloom, buf, c->value_str);
+                        bloom_add_pair(bloom, bus->bloom_size, bus->bloom_n_hash, buf, c->value_str);
                         using_bloom = true;
                         break;
                 }
@@ -1029,7 +1029,7 @@ int bus_add_match_internal_kernel(
                         char buf[sizeof("arg")-1 + 2 + sizeof("-dot-prefix")];
 
                         snprintf(buf, sizeof(buf), "arg%u-dot-prefix", c->type - BUS_MATCH_ARG_NAMESPACE);
-                        bloom_add_pair(bloom, buf, c->value_str);
+                        bloom_add_pair(bloom, bus->bloom_size, bus->bloom_n_hash, buf, c->value_str);
                         using_bloom = true;
                         break;
                 }
@@ -1052,7 +1052,7 @@ int bus_add_match_internal_kernel(
         }
 
         if (using_bloom)
-                sz += ALIGN8(offsetof(struct kdbus_item, data64) + BLOOM_SIZE);
+                sz += ALIGN8(offsetof(struct kdbus_item, data64) + bus->bloom_size);
 
         m = alloca0(sz);
         m->size = sz;
@@ -1069,9 +1069,9 @@ int bus_add_match_internal_kernel(
         }
 
         if (using_bloom) {
-                item->size = offsetof(struct kdbus_item, data64) + BLOOM_SIZE;
-                item->type = KDBUS_ITEM_BLOOM;
-                memcpy(item->data64, bloom, BLOOM_SIZE);
+                item->size = offsetof(struct kdbus_item, data64) + bus->bloom_size;
+                item->type = KDBUS_ITEM_BLOOM_MASK;
+                memcpy(item->data64, bloom, bus->bloom_size);
                 item = KDBUS_ITEM_NEXT(item);
         }
 
@@ -1214,7 +1214,7 @@ _public_ int sd_bus_get_owner_machine_id(sd_bus *bus, const char *name, sd_id128
         if (r < 0)
                 return r;
 
-        r = sd_bus_message_set_no_auto_start(m, true);
+        r = sd_bus_message_set_auto_start(m, false);
         if (r < 0)
                 return r;