Commit Graph

7 Commits

Author SHA1 Message Date
Nick Hainke 2cf253b3df babeld: remove unnecessray blob_buf_init calls
For some reason the buffer is initialized twice before filling it.
This does not break anything but is useless. Reduce the initialization
to only one.

Signed-off-by: Nick Hainke <vincent@systemli.org>
2021-10-16 10:48:38 +02:00
Nick Hainke 6d463ca97c babeld: free blob-buffers that are on stack
As Felix mentioned:
If a buffer was already allocated, blob_buf_init reuses it. You can
keep reusing it as many times as you want. You only need to call
blob_buf_free if you explicitly want to free the buffer memory
(e.g. on exit, or if the blob_buf is on stack).

http://lists.openwrt.org/pipermail/openwrt-devel/2021-October/036722.html

This PR frees the blob-buffers that are on the stack.

Signed-off-by: Nick Hainke <vincent@systemli.org>
2021-10-16 09:29:07 +02:00
Nick Hainke dc22d38f91 babeld: update to 1.10
25 April 2021: babeld-1.10
  * Removed the disambiguation code: source-specific routing is no longer
    supported for IPv4, and for IPv6 only on Linux 3.11 or later.
  * Fixed an issue handling of retractions with no next hop, which caused
    interoperability problems with BIRD.  Thanks to Fabian Bläse.
  * If skip-kernel-setup is set, we no longer disable the rp_filter, which
    makes babeld work in containers.  Thanks to Martin Weinelt.

Remove upstreamed part of ubus patch:
-  local: make local_kind function accessible

Signed-off-by: Nick Hainke <vincent@systemli.org>
2021-06-02 21:24:13 +02:00
Polynomdivision 86991248ac
babeld: adopt to upstream header-style (#640)
babeld: adopt to upstream header-style

Instead of including the headerfiles that define the structs, we add
forward definitions to our headerfile.

Fixes warning:

ubus.h:67:32: warning: 'struct xroute' declared inside parameter list will not be visible outside of this definition or declaration
 void ubus_notify_xroute(struct xroute *xroute, int kind);
                                ^~~~~~
Signed-off-by: Nick Hainke <vincent@systemli.org>
2021-02-09 22:51:39 +01:00
Polynomdivision 72408a9cf8
babeld: fix compiler warnings (#639)
babeld: fix compiler warnings

Fixes:
- "route_list_entry" points to "struct babel_route"
- "format_thousands" returns a string pointer
- "UBUS_METHOD_NOARG" wants a function returning an integer

Signed-off-by: Nick Hainke <vincent@systemli.org>
2021-02-01 20:40:17 +01:00
Polynomdivision 519c1ff731
babeld: send events via ubus (#633)
* babeld: send events via ubus

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>
2021-02-01 15:26:44 +01:00
Nick Hainke ea4a3f28dc babeld: add ubus bindings
A better integration of babeld with OpenWrt is to connect the daemon to
the IPC. So far, we can only communicate via a websocket. With ubus we
can send and receive commands in json format.

The commit adds a ubus interface to babeld with following functions:
- get_info
- get_neighbours
- get_xroutes
- get_routes

All output is divided into IPv4 and IPv6.

Ubus has to be enabled by setting "config general"
  option 'ubus_bindings' 'true'

Example:

root@OpenWrt:~# ubus call babeld get_info
{
	"babeld-version": "babeld-1.9.2",
	"my-id": "32:xx:xx:xx:xx:xx:xx:xx",
	"host": "OpenWrt"
}

root@OpenWrt:~# ubus call babeld get_neighbours
{
	"IPv4": {

	},
	"IPv6": {
		"fe80::xx:xx:xx:xxx": {
			"dev": "br-lan",
			"hello-reach": 65408,
			"uhello-reach": 0,
			"rxcost": 96,
			"txcost": 96,
			"rtt": 4338271,
			"channel": -2,
			"if_up": true
		}
	}
}

root@OpenWrt:~# ubus call babeld get_xroutes
{
	"IPv4": {
		"10.0.0.3/32": {
			"src-prefix": "0.0.0.0/0",
			"metric": 0
		},
		"10.0.0.0/24": {
			"src-prefix": "0.0.0.0/0",
			"metric": 0
		}
	},
	"IPv6": {
		"fdfa:xx:xx::1/128": {
			"src-prefix": "::/0",
			"metric": 0
		}
	}
}

root@OpenWrt:~# ubus call babeld get_routes
{
	"IPv4": {
		"10.2.0.1/32": {
			"src-prefix": "0.0.0.0/0",
			"route_metric": 96,
			"route_smoothed_metric": 96,
			"refmetric": 0,
			"id": "62:xx:xx:xx:xx:xx:xx:xx",
			"seqno": 41381,
			"channels": "",
			"age": 17,
			"via": "fe80::xx:xxxx:xxxx:xxxx",
			"nexthop": " nexthop ",
			"installed": true,
			"feasible": true
		},
	"IPv6": {

	}
}

Additional IPC functionality will follow.

Further, we changed the version to $version-ubus-mod.

Signed-off-by: Nick Hainke <vincent@systemli.org>
2021-01-15 01:13:26 +01:00