[systemd-devel] question about BUS_MATCH_ARG_PATH

2015-06-10 Thread eshark77
Hi, All,
 According to the DBus protocol, 
http://dbus.freedesktop.org/doc/dbus-specification.html 
An example argument path match is arg0path='/aa/bb/'. This would match 
messages with first arguments of '/', '/aa/', '/aa/bb/', '/aa/bb/cc/' and 
'/aa/bb/cc'. It would not match messages with first arguments of '/aa/b', '/aa' 
or even '/aa/bb'.
  
Then  I did a simple  test using the  attached  test-bus-kernel-bloom.c , 
and I found that  if  I used arg0path='/p1/p2/' , the callback function 
couldn't run when I sent emit signal with  '/' , '/p1/' , '/p1/p2/p3'.


   I traced into the codes , and modified bloom_add_prefixes() , then I can 
watch the signals with '/p1/p2/p3' , and '/p1/p2/' , but still cannot watch the 
signals with '/' or '/p1/'.


  Any recommendations are appreciated.   


 Thanks!




Best Regards,
Li Cheng

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] siphash24 gives unmatched bloom_mask and bloom_filter?

2015-06-09 Thread eshark77
Hi, David,

I think I've found the reason for my problem. That is , with 
arg0path=/p1/p2/p3,

The sent signal should be sent with arg0=/p1/p2/p3/, but not arg0=/p1/p2/p3.




Then Another question is, with arg0path=/p1/p2, the signal sent with 
arg0=/p1/p2/p3

should be received and the callback be executed.

But following the execution path: proces_message()== process_match() 
==bus_match_run()

== value_node_test() == path_complex_pattern()== complex_pattern_check('/', 
pattern, value)

== if (*a != *b) return (separator  (*a == 0 || *b == 0)) || (*a == 0  *b 
== c  b[1] == 0) || (*b == 0  *a == c  a[1] == 0);

This will return false, which caused the callback cannot be executed.

Should this comply with the DBus Spec?

Thank you!

David Herrmann Mon, 08 Jun 2015 09:44:25 -0700

Hi

On Mon, Jun 8, 2015 at 3:26 PM,  eshar...@163.com wrote:
 Hi, David
I just modified the  src/libsystemd/sd-bus/test-bus-match.c.
 And you could add the following two lines in the bloom_add_data() in
 bus-bloom.c
  for (i = 0; i  size/sizeof(uint64_t); i++)
 log_info(bloom: filter[%d] = 0x%llx,i, filter[i]);
Can you please try with systemd-220? The diff against 220 is 83 lines
and it doesn't even compile. If there is a bloom-bug, it should be
possible to show this with a much shorter example. I'm having a hard
time understanding what you changed there, sorry.

Thanks
David___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] siphash24 gives unmatched bloom_mask and bloom_filter?

2015-06-08 Thread eshark77
Hi, David
   I just modified the  src/libsystemd/sd-bus/test-bus-match.c. 
And you could add the following two lines in the bloom_add_data() in bus-bloom.c
 for (i = 0; i  size/sizeof(uint64_t); i++)
log_info(bloom: filter[%d] = 0x%llx,i, filter[i]);


  Hi, All,
  I use libsystemd.so for the kdbus protocol layer, and  I met a
 question that I added a signal matching rule by sd_bus_add_match() , then I
 sent signal by sd_bus_send().
 But I couldn't receive this signal  because its bloom_filter  caculated by
 siphash24()  NOT match the bloom_mask which was also caculated by
 siphash24().

  For example ,  when adding matching rule for 
 type='signal',interface='service.a.interface',path='/service/a',member='com_0yunos_0spms_0uninstall',arg0path='/p1/p2/p3'
  by sd_bus_add_match(),
 Can you provide a real C-code example so we can reproduce this?



Thank you very much!
Li Cheng

/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/

/***
  This file is part of systemd.

  Copyright 2013 Lennart Poettering

  systemd is free software; you can redistribute it and/or modify it
  under the terms of the GNU Lesser General Public License as published by
  the Free Software Foundation; either version 2.1 of the License, or
  (at your option) any later version.

  systemd is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public License
  along with systemd; If not, see http://www.gnu.org/licenses/.
***/

#include log.h
#include macro.h

#include bus-match.h
#include bus-message.h
#include bus-util.h
#include bus-slot.h

static bool mask[32];

static int filter(sd_bus *b, sd_bus_message *m, void *userdata, sd_bus_error 
*ret_error) {
log_info(Ran %u, PTR_TO_UINT(userdata));
assert_se(PTR_TO_UINT(userdata)  ELEMENTSOF(mask));
mask[PTR_TO_UINT(userdata)] = true;
return 0;
}

static bool mask_contains(unsigned a[], unsigned n) {
unsigned i, j;

for (i = 0; i  ELEMENTSOF(mask); i++) {
bool found = false;

for (j = 0; j  n; j++)
if (a[j] == i) {
found = true;
break;
}

if (found != mask[i])
return false;
}

return true;
}

static int match_add(sd_bus_slot *slots, struct bus_match_node *root, const 
char *match, int value) {
struct bus_match_component *components = NULL;
unsigned n_components = 0;
sd_bus_slot *s;
int r;

s = slots + value;
zero(*s);

r = bus_match_parse(match, components, n_components);
if (r  0)
return r;

s-userdata = INT_TO_PTR(value);
s-match_callback.callback = filter;

r = bus_match_add(root, components, n_components, s-match_callback);
bus_match_parse_free(components, n_components);

return r;
}

int main(int argc, char *argv[]) {
struct bus_match_node root = {
.type = BUS_MATCH_ROOT,
};

_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_bus_close_unref_ sd_bus *bus = NULL;
enum bus_match_node_type i;
sd_bus_slot *slots[19];
int r;

r = sd_bus_open_system(bus);
if (r  0)
return EXIT_TEST_SKIP;

//assert_se(match_add(slots, root, 
type='signal',interface='service.a.interface',path='/service/a',member='com_0yunos_0spms_0uninstall',arg0path='/p1/p2/p3',,
 1) = 0);
assert_se(sd_bus_add_match(bus, slots[1], 
type='signal',interface='service.a.interface',path='/service/a',member='com_0yunos_0spms_0uninstall',arg0path='/p1/p2/p3',,
 filter, NULL) = 0);

bus_match_dump(bus-match_callbacks, 0);

assert_se(sd_bus_message_new_signal(bus, m, /service/a, 
service.a.interface, com_0yunos_0spms_0uninstall) = 0);
  //  assert_se(sd_bus_message_append(m, s, /p1/p2/p3) = 0);
assert_se(sd_bus_message_append_basic(m, SD_BUS_TYPE_STRING, 
/p1/p2/p3) = 0);
//assert_se(bus_message_seal(m, 1, 0) = 0);
assert_se(sd_bus_send(bus, m, NULL) = 0);


bus_match_free(root);

return 0;
}
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] siphash24 gives unmatched bloom_mask and bloom_filter?

2015-06-04 Thread eshark77
Hi, All,
 I use libsystemd.so for the kdbus protocol layer, and  I met a  question 
that I added a signal matching rule by sd_bus_add_match() , then I sent signal 
by sd_bus_send().
But I couldn't receive this signal  because its bloom_filter  caculated by 
siphash24()  NOT match the bloom_mask which was also caculated by siphash24().


 For example ,  when adding matching rule for  
type='signal',interface='service.a.interface',path='/service/a',member='com_0yunos_0spms_0uninstall',arg0path='/p1/p2/p3'
  by sd_bus_add_match(),
I got the following bloom_mask:
bloom: mask[0] = 0x4c0880d4   


bloom: mask[1] = 0x880410402010


bloom: mask[2] = 0x4610
  
bloom: mask[3] = 0x80408
 
bloom: mask[4] = 0x12000101000
   
bloom: mask[5] = 0x804822002000
  
bloom: mask[6] = 0x400040200110
  
bloom: mask[7] = 0x10

But when I sent the exact same signal by sd_bus_send(),  I got the following 
bloom_filter:
bloom: filter[0] = 0x6e0801020086


bloom: filter[1] = 0x880411408410
   
bloom: filter[2] = 0x2000400c40400710
   
bloom: filter[3] = 0x20800040528

bloom: filter[4] = 0x120010080002000

bloom: filter[5] = 0x8058000122406000
   
bloom: filter[6] = 0xc22000104111
   
bloom: filter[7] = 0x800300a12080
   
Obviously,  filter[0]  maks[0] != mask[0],  which  caused that I couldn't 
receive the signal. 


I also tested with 
type='signal',interface='service.a.interface',path='/service/a',member='com_0yunos_0spms_0uninstall'
  , which works OK.


Could anyone gives me some suggestion?
Thanks a lot!___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel