Controlling host routes via ubus / netifd

Michael Jones mike at meshplusplus.com
Wed Aug 12 19:15:09 EDT 2020


Hi List.

I am trying to control the routes on my OpenWRT system
programmatically, and would like to know if this is possible to do via
ubus and netifd.

I've located the ubus target "ubus call network add_host_route
'{"interface":"wan", "target":"1.0.0.0"}'" However, it does not seem
to actually do anything when called other than return "interface":
"wan".

I see that the ubus function for this is in netifd's ubus.c,
netifd_add_host_route(), which then calls
interface_ip_add_target_route() in interface-ip.c. This function
checks the indicated target for all zeros, and if all zeros are given
sets the route as a default route.

My main objective with this is that I want to be able to tell netifd
to make a particular interface (e.g. wan, wwan, so on) the default
route with a ubus command.

Is there an existing ubus endpoint that can do this?



More information about the openwrt-devel mailing list