Hi Developers,

A quick question - how does ubus know a network connection is actually up?
I have a tunnel interface, which is available at boot time (so always
available basically) and then a userland daemon that manages it - assigns
IP address to the interface, authentication, etc

I¹ve written a /lib/netifd/proto/mytun.sh file, with

proto_mytun_init_config() {
        # Have tried without these, doesn’t seem to make a difference
        available=1
        no_device=0
}


proto_mytun_setup() {
local config="$1"
local iface="$2"

/etc/init.d/mytun start

# Attempt to tell everyone it¹s up - doesn¹t seem to work
uci_toggle_state network "$1" up 1
uci_toggle_state network "$1" connect_time $(sed -ne 's![^0-9].*$!!p'
/proc/uptime)


}

proto_mytun_teardown() {
local interface="$1"
/etc/init.d/mytun stop

proto_kill_command "$interface"
}

add_proto mytun

        
With the above, LuCI seems to know the state (shows up/down correctly in
the GUI) and ifup/ifdown seem to work consistently, but ubus does not think
it is up, and the Online for: counter never changes:


root@OpenWRT:~# ubus call network.interface.mytun status
{
        "up": false,
        "pending": false,
        "available": true,
        "autostart": false,
        "proto": "mytun",
        "device": "mytdev",
        "data": {
                
        }
}

root@OpenWRT:~# ifup mytun

root@OpenWRT:~# ubus call network.interface.mytun status
{
        "up": false,
        "pending": true,
        "available": true,
        "autostart": true,
        "proto": "mytun",
        "device": "miydev",
        "data": {
                
        }
}

devstatus on mytun returns as expected:
{
        "external": true,
        "present": true,
        "type": "Network device",
        "up": true,
        "link": true,
        "mtu": 1340,
        "macaddr": "0:0:0:0:0:0",
        "txqueuelen": 0,
        "statistics": {
// trimmed for length
        }
}

Can someone point me in the right direction?


Thanks,

Ken

_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to