Skip to content

Conversation

@PolynomialDivision
Copy link
Member

@PolynomialDivision PolynomialDivision commented Jan 15, 2021

Send a notification via the ubus bus if we experience any changes in neighbors, 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.

@PolynomialDivision PolynomialDivision changed the title [WIP] babeld: send events via ubus babeld: send events via ubus Jan 15, 2021
@PolynomialDivision
Copy link
Member Author

I try upstreaming the change in babeld:

jech/babeld#72

@PolynomialDivision
Copy link
Member Author

PolynomialDivision commented Jan 15, 2021

@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>
@PolynomialDivision
Copy link
Member Author

I wrote some small daemon that shows how to connect to the ubus interface and process the data:
https://github.com/PolynomialDivision/babeld-ids

More logic will follow soon.

@PolynomialDivision
Copy link
Member Author

@kerneis

Copy link
Contributor

@kerneis kerneis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me with a few minor comments.


blob_buf_init(&b, 0);
babeld_add_route_buf(route, &b);
sprintf(method, "route.%s", local_kind(kind));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use snprintf(method, sizeof(method), ...), I'm paranoid about buffer overflow. Idem below.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True story. :)


void ubus_notify_route(struct babel_route *route, int kind) {
struct blob_buf b = {0};
char method[13]; // max is route.change
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

char method[sizeof("route.change")]; // possible methods are route.change, route.add, route.flush

Idem below

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just use a largish value and don't bother (50, 100)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will just go for 50. ;)

@PolynomialDivision
Copy link
Member Author

PolynomialDivision commented Jan 31, 2021

Probably I will rewrite "a lot of stuff" again, if this is merged upstream:
jech/babeld#57

@kerneis kerneis merged commit 519c1ff into openwrt:master Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants