mirror of
https://github.com/openwrt/routing.git
synced 2025-12-21 17:04:33 +04:00
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>
104 lines
3.9 KiB
Plaintext
104 lines
3.9 KiB
Plaintext
package babeld
|
|
|
|
# Detailed documentation: https://openwrt.org/docs/guide-user/services/babeld
|
|
|
|
# Babeld reads options from the following files (the last one takes precedence
|
|
# if an option is defined in several places):
|
|
# - the file defined by the option conf_file (default: /etc/babeld.conf),
|
|
# - *.conf files in the directory defined by conf_dir (default: /tmp/babel.d/),
|
|
# - this UCI configuration file.
|
|
|
|
# See "man babeld" for all available options ("Global options").
|
|
# Important: remember to use '_' instead of '-' in option names.
|
|
config general
|
|
# option 'random_id' 'true'
|
|
# option 'debug' '1'
|
|
# option 'local_port' '33123'
|
|
# option 'log_file' '/var/log/babeld.log'
|
|
## Enable ipv6-subtrees by default since OpenWrt should ship with a
|
|
## recent enough kernel for it to work.
|
|
option 'ipv6_subtrees' 'true'
|
|
# list 'import_table' '42'
|
|
# list 'import_table' '100'
|
|
## Alternative configuration file and directory.
|
|
## See comment at the top of this file for more details.
|
|
# option 'conf_file' '/etc/babeld.conf'
|
|
# option 'conf_dir' '/tmp/babel.d/'
|
|
# option 'ubus_bindings' 'false'
|
|
|
|
config interface
|
|
## Remove this line to enable babeld on this interface
|
|
option 'ignore' 'true'
|
|
## You can use aliases (like lan, wlan) or real names (like eth0.0).
|
|
## If you use an alias, it must be already defined when babeld starts.
|
|
## Otherwise, the name is taken literally and the interface can be
|
|
## brought up later (useful for tunnels for instance).
|
|
option 'ifname' 'wlan'
|
|
## You can set options, see babeld man page ("Interface configuration")
|
|
# option 'rxcost' '256'
|
|
# option 'hello_interval' '1'
|
|
|
|
config interface
|
|
option 'ignore' 'true'
|
|
## Physical interface name
|
|
option 'ifname' 'tun-example'
|
|
## Specify the type of interface: tunnels use the RTT-based metric.
|
|
option 'type' 'tunnel'
|
|
## Other options that can be overriden.
|
|
# option 'max_rtt_penalty' '96'
|
|
|
|
# A config interface without "option ifname" will set default options
|
|
# for all interfaces. Interface-specific configuration always overrides
|
|
# default configuration.
|
|
config interface
|
|
# option 'enable_timestamps' 'true'
|
|
# option 'update_interval' '30'
|
|
|
|
|
|
# A filter consists of a type ('in', 'out', 'redistribute' or 'install'),
|
|
# a set of selectors ('ip', 'eq', etc.) and a set of actions to perform
|
|
# ('allow', 'deny', 'metric xxx', 'src-prefix xxx', 'table xxx', 'pref-src xxx').
|
|
# See babeld man page ("Filtering rules") for more details.
|
|
|
|
# Below is a sample filter that redistributes the default route if its
|
|
# protocol number is "boot", e.g. when it is installed by dhcp (see
|
|
# /etc/iproute2/rt_protos). This filter is disabled thanks to the 'ignore'
|
|
# setting.
|
|
config filter
|
|
option 'ignore' 'true'
|
|
# Type of filter
|
|
option 'type' 'redistribute'
|
|
# Selectors: ip, eq, le, ge, src_ip, src_eq, src_le, src_ge, neigh, id,
|
|
# proto, local, if.
|
|
option 'ip' '0.0.0.0/0'
|
|
option 'eq' '0'
|
|
option 'proto' '3'
|
|
# Action, which can be any of: allow, deny, metric <NUMBER>, src-prefix <PREFIX>,
|
|
# table <ID>, pref-src <IP>.
|
|
# The action defaults to "allow" if not specified. Here, we specify a higher
|
|
# redistribution metric than the default (0).
|
|
option 'action' 'metric 128'
|
|
|
|
# Another example filter: don't redistribute local addresses in a certain IP prefix.
|
|
# By default, babeld redistributes *all* local addresses.
|
|
config filter
|
|
option 'ignore' 'true'
|
|
option 'type' 'redistribute'
|
|
# Only apply to routes/addresses within this prefix.
|
|
option 'ip' '198.51.100.0/24'
|
|
# Notice that the 'local' selector is a boolean.
|
|
option 'local' 'true'
|
|
# Don't redistribute.
|
|
option 'action' 'deny'
|
|
|
|
# Example install filter, to change or filter routes before they are inserted
|
|
# into the kernel.
|
|
config filter
|
|
option 'ignore' 'true'
|
|
option 'type' 'install'
|
|
# Optional: only apply to routes within 2001:db8:cafe::/48
|
|
option 'ip' '2001:db8:cafe::/48'
|
|
# We specify the kernel routing table and the preferred source address to use for these routes.
|
|
# "Allow" is implicit.
|
|
option 'action' 'table 200 pref-src 2001:db8:ba:be1::42'
|