babeld: send events via ubus#633
babeld: send events via ubus#633kerneis merged 3 commits intoopenwrt:masterfrom PolynomialDivision:babeld-notify-ubus
Conversation
|
I try upstreaming the change in babeld: |
|
@kerneis This is what I mean with sending notifications on the bus. Now I just receive the part I need. Polling would require babeld to create each time probably thousands of messages. With updates I can just check the updates. For example, I can check if a certain prefix is announced, by just looking add the "route.add" methods. Maybe it would be interesting to create objects or to make more options allowing a more fine grade decision what to send over the ubus bus. |
Send a notification via the ubus bus if we experience any changes in
neighbours, routes or xroutes.
The format looks like this:
{route,xroute,neighbour}.add: Object was added
{route,xroute,neighbour}.change: Object was changed
{route,xroute,neighbour}.flush: Object was flushed
If ubus_bindings is turned off, it will minimally effect performance,
since only an if-statement has to be evaluated.
If no subscriber is available, it will minimally change the performance,
since only an if-statmenet that checks for subscribers has to be
evaluated.
Signed-off-by: Nick Hainke <vincent@systemli.org>
|
I wrote some small daemon that shows how to connect to the ubus interface and process the data: More logic will follow soon. |
kerneis
left a comment
There was a problem hiding this comment.
Looks good to me with a few minor comments.
babeld/src/ubus.c
Outdated
|
|
||
| blob_buf_init(&b, 0); | ||
| babeld_add_route_buf(route, &b); | ||
| sprintf(method, "route.%s", local_kind(kind)); |
There was a problem hiding this comment.
Please use snprintf(method, sizeof(method), ...), I'm paranoid about buffer overflow. Idem below.
There was a problem hiding this comment.
True story. :)
babeld/src/ubus.c
Outdated
|
|
||
| void ubus_notify_route(struct babel_route *route, int kind) { | ||
| struct blob_buf b = {0}; | ||
| char method[13]; // max is route.change |
There was a problem hiding this comment.
char method[sizeof("route.change")]; // possible methods are route.change, route.add, route.flush
Idem below
There was a problem hiding this comment.
Or just use a largish value and don't bother (50, 100)?
There was a problem hiding this comment.
I will just go for 50. ;)
|
Probably I will rewrite "a lot of stuff" again, if this is merged upstream: |
Send a notification via the ubus bus if we experience any changes in neighbors, routes or xroutes.
The format looks like this:
If ubus_bindings is turned off, it will minimally effect performance, since only an if-statement has to be evaluated. If no subscriber is available, it will minimally change the performance, since only an if-statmenet that checks for subscribers has to be evaluated.